added jam build system, please try it out - the advantage would be that it already...
[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 = [ DoInstall $(target) : $(bindir) : $(INSTALL_PROGRAM) ] ;
64     Depends install_bin : $($(<)_INSTALLTARGET) ;
65   }
66
67   # Link
68   MakeLocate $(target) : $(LOCATE_TARGETS) ;
69   SystemLinkApplication $(<) : $(objects) : $(3) ;
70
71   # Import default flags
72   CppFlags $(<) : $(CPPFLAGS) $(APPLICTION_CPPFLAGS) ;
73   CFlags $(<) : $(CFLAGS) $(APPLICATION_CFLAGS) ;
74   C++Flags $(<) : $(C++FLAGS) $(APPLICATION_C++FLAGS) ;
75   LFlags $(<) : $(LFLAGS) $(APPLICATION_LFLAGS) ;
76 }
77
78 #----------------------------------------------------------------------------
79 # private part
80
81 # Construct pseudo target apps
82 Depends all : apps ;
83 NotFile apps ;
84