add a dist target to jam
[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 rule Application
26 {
27     # check options
28     CheckOptions noinstall console independent : $(3) : $(<) ;
29
30     local target = [ ConstructApplicationTarget $(<) : $(3) ] ;
31     local sources = [ DoSourceGrist $(>) ] ;
32     local objects = [ CompileObjects $(sources) ] ;
33
34     $(<)_TYPE = application ;
35     $(<)_OBJECTS = $(objects) ;
36     $(<)_SOURCES = $(sources) ;
37     $(<)_TARGET = $(target) ;
38     $(<)_OPTIONS = $(3) ;
39     $(<)_INSTALLTARGET = ;
40
41     # create target clean rule
42     Always $(<)clean ;
43     NotFile $(<)clean ;
44     Clean $(<)clean : $(objects) ; # create target clean rule 
45         Depends clean : $(<)clean ;
46
47     # so 'jam foo' works when it's really foo.exe (Windows) or foo.app (MacOS/X)
48     if $(target) != $(<)
49     {
50         Depends $(<) : $(target) ;
51         NotFile $(<) ;
52     }
53
54     # make dependency on apps target
55     if ! [ IsElem independent : $(3) ]
56     {
57         Depends apps : $(<) ;
58     }
59
60     # construct Install target
61     if ! [ IsElem noinstall : $(3) ]
62     {
63         $(<)_INSTALLTARGET = [ 
64             DoInstall $(target) : $(bindir) : $(INSTALL_PROGRAM) : nopackage
65         ] ;
66         Depends install_bin : $($(<)_INSTALLTARGET) ;
67     }
68
69     # Link
70     MakeLocate $(target) : $(LOCATE_TARGETS) ;
71     SystemLinkApplication $(<) : $(objects) : $(3) ;
72
73     # Import default flags
74     CppFlags $(<) : $(CPPFLAGS) $(APPLICTION_CPPFLAGS) ;
75     CFlags $(<) : $(CFLAGS) $(APPLICATION_CFLAGS) ;
76     C++Flags $(<) : $(C++FLAGS) $(APPLICATION_C++FLAGS) ;
77     LFlags $(<) : $(LFLAGS) $(APPLICATION_LFLAGS) ;
78
79     # Sources are part of the package
80     if ! [ IsElem nopackage : $(3) ]
81     {
82         Package $(sources) ;
83     }
84 }
85
86 #----------------------------------------------------------------------------
87 # private part
88
89 # Construct pseudo target apps
90 Depends all : apps ;
91 NotFile apps ;
92