6b4df5404c83626bcb0364597ca28b96454a9efd
[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     local target = $($(<)_TARGET) ;
34   
35     Depends $(target) : $(>) ;
36
37     if [ IsElem linkerfile : $(3) ]
38     {
39         RemoveLinkerInputFile $(target) ;
40         local i ;
41         for i in $(>) { AppendLinkerInputFile $(target) : $(i) ; }
42         LinkApplicationFromFile $(target) : $(target) ;
43         RemoveLinkerInputFile $(target) ;
44     }
45     else
46     {
47         LinkApplication $(target) : $(>) ;
48     }
49
50     LIBS on $(target) = $(LIBS) ;
51     # setup clean rules
52     Clean clean : $(target) ;
53     Clean $(<)clean : $(target) ;
54 }
55
56 actions LinkApplication bind NEEDLIBS bind EXTRAOBJECTS
57 {
58     $(LINK) -o $(<) $(>) $(EXTRAOBJECTS) $(NEEDLIBS) $(LIBS)
59 }
60
61 actions quietly RemoveLinkerInputFile
62 {
63     $(RM) $(<).opt
64 }
65
66 actions quietly together piecemeal AppendLinkerInputFile
67 {
68     echo $(>) >> $(<).opt
69 }
70
71 actions LinkApplicationFromFile bind NEEDLIBS bind EXTRAOBJECTS
72 {
73     $(LINK) -o $(<) `cat $(>).opt` $(EXTRAOBJECTS) $(NEEDLIBS) $(LIBS)
74 #    $(LINK) -o $(<) -Xlinker @$(>).opt $(EXTRAOBJECTS) $(NEEDLIBS) $(LIBS)
75 }
76