5ee1aa94638ca9252f1725842cf6182c60fc8a1b
[supertux.git] / mk / jam / unix.jam
1 #============================================================================
2 # Jam configuration and actions for Linux/Unix
3 #============================================================================
4 SHELL ?= "/bin/sh" ;
5
6 #----------------------------------------------------------------------------
7 # platform specific rules
8
9 ##  ConstructApplicationTarget target : options
10 ##    Constructs the application atrget name (ie. foo.exe for foo)
11 rule ConstructApplicationTarget
12 {
13     return $(<) ;
14 }
15 rule ConstructLibraryTarget
16 {
17     if [ IsElem shared : $(2) ] {
18         return lib$(<).la ;
19     } else {
20         return lib$(<).a ;
21     }
22 }
23 rule ConstructPluginTarget
24 {
25     return $(<).so ;
26 }
27
28 # SystemLinkApplication target : objects : options
29 #  do system specific actions needed for linking the application and construct
30 #  correct clean targets.
31 rule SystemLinkApplication
32 {
33     # check options
34     CheckOptions linkerfile : $(3) : $(<) ;
35
36     local target = $($(<)_TARGET) ;
37   
38     Depends $(target) : $(>) ;
39
40     if [ IsElem linkerfile : $(3) ]
41     {
42         RemoveLinkerInputFile $(target) ;
43         local i ;
44         for i in $(>) { AppendLinkerInputFile $(target) : $(i) ; }
45         LinkApplicationFromFile $(target) : $(target) ;
46         RemoveLinkerInputFile $(target) ;
47     }
48     else
49     {
50         LinkApplication $(target) : $(>) ;
51     }
52
53     LIBS on $(target) = $(LIBS) ;
54     # setup clean rules
55     Clean clean : $(target) ;
56     Clean $(<)clean : $(target) ;
57 }
58
59 actions LinkApplication bind NEEDLIBS bind EXTRAOBJECTS
60 {
61     $(LINK) -o $(<) $(>) $(EXTRAOBJECTS) $(NEEDLIBS) $(LIBS)
62 }
63
64 actions quietly RemoveLinkerInputFile
65 {
66     $(RM) $(<).opt
67 }
68
69 actions quietly together piecemeal AppendLinkerInputFile
70 {
71     echo $(>) >> $(<).opt
72 }
73
74 actions LinkApplicationFromFile bind NEEDLIBS bind EXTRAOBJECTS
75 {
76     $(LINK) -o $(<) `cat $(>).opt` $(EXTRAOBJECTS) $(NEEDLIBS) $(LIBS)
77 #    $(LINK) -o $(<) -Xlinker @$(>).opt $(EXTRAOBJECTS) $(NEEDLIBS) $(LIBS)
78 }
79