added jam build system, please try it out - the advantage would be that it already...
[supertux.git] / mk / jam / compiler.jam
1 #============================================================================
2 # Rules for C and C++ files
3 #============================================================================
4
5 # convert autoconf style variablenames to jam style ones
6 CCFLAGS += $(CFLAGS) ;
7 C++FLAGS += $(CXXFLAGS) ;
8 LFLAGS += $(LIBS) ;
9
10 if $(CC)
11 {
12
13 rule CcRule
14 {
15     local object ;
16
17     if [ IsElem shared : $(2) ]
18     {
19         object = [ DoObjectGrist $(<:S=.lo) ] ;
20         CC on $(object) = "$(LIBTOOL) --mode=compile $(CC)" ;
21     } else {
22         object = [ DoObjectGrist $(<:S=.o) ] ;
23     }
24
25     Cc $(object) : $(<) ;
26     return $(object) ;
27 }
28 RegisterFileType CcRule : .c ;
29 RegisterHeaderRule HeaderRule : $(HDRPATTERN) : .c ;
30
31 rule Cc
32 {
33     Depends $(<) : $(>) ;
34 }
35
36 actions Cc
37 {
38     $(CC) -c -o $(<) $(CPPFLAGS) $(CFLAGS) $(>)
39 }
40 } # end if $(CC)
41
42 if $(CXX)
43 {
44
45 rule C++Rule
46 {
47     local object ;
48     
49     if [ IsElem shared : $(2) ] {
50         object = [ DoObjectGrist $(<:S=.lo) ] ;
51         CXX on $(object) = "$(LIBTOOL) --mode=compile $(CXX)" ;
52     } else {
53         object = [ DoObjectGrist $(<:S=.o) ] ;
54     }
55     C++ $(object) : $(<) ;
56     return $(object) ;
57 }
58 RegisterFileType C++Rule : .cpp .cc .c++ ; # we can't register .C here because
59                                            # of windows being case-insensitive.
60 RegisterHeaderRule HeaderRule : $(HDRPATTERN) : .cpp .cc .c++ ;
61
62 rule C++
63 {
64     Depends $(<) : $(>) ;
65 }
66
67 actions C++
68 {
69     $(CXX) -c -o $(<) $(CPPFLAGS) $(C++FLAGS) $(>)
70 }
71 } # end if $(CXX)
72
73 rule CreateIncludeFlags
74 {
75     return -I$(<) ;
76 }
77
78 rule CreateDefineFlags
79 {
80     return -D$(<) ;
81 }