e307bc9bdd61baaeec57c2fa075aeb097316c52c
[supertux.git] / mk / jam / application.jam
1 #============================================================================
2 # Rules for compiling applications
3 #============================================================================
4
5 ##  Application appname : sources [ : options ]
6 ##    Build an application out of sourcefiles. All sourcefiles will be passed
7 ##    to the Objects rule which tries to compile them into object-files. You
8 ##    can create rules for your own filetypes with the UserObject rule. Header
9 ##    files will just be ignored. They are only used for MSVC projectfile
10 ##    generation.
11 ##    Possible options are "noinstall" if you don't want a default install
12 ##    target to be created and "console" if you're building a console
13 ##    application (an application without any graphical output which is
14 ##    intended to be used on commandline)
15 ##    Some notes: You should not add the .exe extension to the appname - jam
16 ##    will do that on win32.
17 ##    If you have sourcefiles in subdirectories, then you'll need to use the
18 ##    SearchSubdir rule. Never specify sourcefiles with paths, only specify
19 ##    the filenames.
20 ##    Options:
21 ##      console: Create a console application
22 ##      noinstall: Don't setup a default installation target.
23 ##      independent: The target will not be made a dependency of the apps and
24 ##                   all target.
25 ##      linkerfile: Store a list of objects in a file and link using that
26 ##      file.  Use this to get around Jam's 10240 character argument limit.
27 rule Application
28 {
29     # check options
30     CheckOptions noinstall console independent linkerfile : $(3) : $(<) ;
31
32     local target = [ ConstructApplicationTarget $(<) : $(3) ] ;
33     local sources = [ SearchSource $(>) ] ;
34     local objects = [ CompileObjects $(sources) ] ;
35
36     $(<)_TYPE = application ;
37     $(<)_OBJECTS = $(objects) ;
38     $(<)_SOURCES = $(sources) ;
39     $(<)_TARGET = $(target) ;
40     $(<)_OPTIONS = $(3) ;
41     $(<)_INSTALLTARGET = ;
42
43     # create target clean rule
44     Always $(<)clean ;
45     NotFile $(<)clean ;
46     Clean $(<)clean : $(objects) ; # create target clean rule 
47         Depends clean : $(<)clean ;
48
49     # so 'jam foo' works when it's really foo.exe (Windows) or foo.app (MacOS/X)
50     if $(target) != $(<)
51     {
52         Depends $(<) : $(target) ;
53         NotFile $(<) ;
54     }
55
56     # make dependency on apps target
57     if ! [ IsElem independent : $(3) ]
58     {
59         Depends apps : $(<) ;
60     }
61
62     # construct Install target
63     if ! [ IsElem noinstall : $(3) ]
64     {
65         $(<)_INSTALLTARGET = [ 
66             DoInstall $(target) : $(bindir) : $(INSTALL_PROGRAM) : nopackage
67         ] ;
68         Depends install_bin : $($(<)_INSTALLTARGET) ;
69     }
70
71     # Link
72     MakeLocate $(target) : $(LOCATE_TARGETS) ;
73     SystemLinkApplication $(<) : $(objects) : $(3) ;
74
75     # Import default flags
76     CppFlags $(<) : $(APPLICTION_CPPFLAGS) ;
77     CFlags $(<) : $(APPLICATION_CFLAGS) ;
78     C++Flags $(<) : $(APPLICATION_CXXFLAGS) ;
79     LFlags $(<) : $(APPLICATION_LIBS) ;
80
81     # Sources are part of the package
82     if ! [ IsElem nopackage : $(3) ]
83     {
84         Package $(sources) ;
85     }
86
87     return $(target) ;
88 }
89
90 #----------------------------------------------------------------------------
91 # private part
92
93 # Construct pseudo target apps
94 Depends all : apps ;
95 NotFile apps ;
96