]> pd.if.org Git - pdclib/blob - Jamrules
Cosmetic comment fixes.
[pdclib] / Jamrules
1 PDCLIB ?= pdclib ;
2
3 ECHO "PDCLIB_TOP: " $(PDCLIB_TOP) ;
4
5 if ! $(PDCLIB_HAVE_PLATFORM) && ! $(PDCLIB_PLATFORM) {
6     if $(NT) {
7         PDCLIB_PLATFORM = "win32" ;
8     } else if $(UNIX) {
9         PDCLIB_PLATFORM = "posix" ;
10     } else {
11         ECHO PDCLIB_PLATFORM not set and platform not automatically detected ;
12         ECHO Set PDCLIB_PLATFORM to the platform to be built for ;
13         EXIT ;
14     }
15     PDCLIB_HAVE_PLATFORM = 1 ;
16 }
17
18 if $(PDCLIB_TOOLCHAIN) = "" {
19   local __ccparts = [ SPLIT $(CC) : "-" ] ;
20   if $(JAM_TOOLSET) = "MINGW" || "gcc" in $(__ccparts) 
21       || "clang" in $(__ccparts) {
22     # GCC / GCC-alike
23     PDCLIB_TOOLCHAIN = "gcc" ;
24   } else if $(JAM_TOOLSET) != "" {
25     PDCLIB_TOOLCHAIN = $(JAM_TOOLSET) ;
26   } else {
27     ECHO PDCLIB_TOOLCHAIN is unset and I can't glean what toolset is being ;
28     ECHO used from your environment. Please set it.  ;
29     EXIT ;
30   }
31 }
32
33 if $(PDCLIB_TOOLCHAIN) = "gcc" {
34     PDCLIB_WARNINGS ?= 
35       -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow 
36       -Wpointer-arith -Wwrite-strings -Wmissing-declarations -Wno-long-long 
37       -Wuninitialized -Wno-deprecated-declarations -Wredundant-decls -Winline
38       -Wcast-align -Wno-format
39       ;
40     PDCLIB_CCWARNINGS ?= 
41       -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes ;
42     PDCLIB_CCFLAGS  = 
43       -ffreestanding 
44       #-nostdinc 
45       -std=c11 
46       -g 
47       -ffunction-sections
48       -fdata-sections
49       -D_PDCLIB_BUILD
50       $(PDCLIB_WARNINGS) ;
51     PDCLIB_C++FLAGS =
52       -ffreestanding
53       #-nostdinc
54       -std=c++11
55       -g
56       -ffunction-sections
57       -fdata-sections
58       -D_PDCLIB_BUILD
59       $(PDCLIB_WARNINGS) ;
60
61     if $(OS) = "MACOSX" {
62         # ld64 does automatic repeated searches of archives
63         # and doesn't accept --start-group/--end-group
64
65         #actions Link bind NEEDLIBS
66         #{
67         #    $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
68         #}
69     } else {
70         PDCLIB_TEST_LINKFLAGS += -Wl,--gc-sections ;
71         actions Link bind NEEDLIBS
72         {
73             $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) -Wl,--start-group $(NEEDLIBS) $(LINKLIBS) -Wl,--end-group
74         }
75     }
76 } else if $(PDCLIB_TOOLCHAIN) = "WATCOM" {
77   ECHO "Watcom!" ;
78   CCFLAGS  = /zq /DWIN32 /zls ;
79   C++FLAGS = /zq /DWIN32 /zls ;
80   STDHDRS  = $(WATCOM)\\h\\nt ;
81   PDCLIB_CCFLAGS = "-za99 -zl -s" ;
82 } else {
83   ECHO The value of PDCLIB_TOOLCHAIN is not recognized  ;
84   ECHO Currently set to $(PDCLIB_TOOLCHAIN)  ;
85   EXIT ;
86 }
87
88 if $(PDCLIB_PLATFORM) {
89     include [ FDirName $(PDCLIB_TOP) platform $(PDCLIB_PLATFORM) Config.jam ] ;
90 }
91
92 rule PDCLibHeaders {
93     SubDirHdrs $(PDCLIB_TOP) includes ;
94     SubDirHdrs $(PDCLIB_TOP) internals ;
95     SubDirHdrs $(PDCLIB_TOP) testing ;
96     for opt in $(PDCLIB_OPTIONS) {
97         SubDirHdrs $(PDCLIB_TOP) opt $(opt) ;
98     }
99     PDCLibTargetHeaders ;
100 }
101
102 rule PDCLibConfig {
103     SubDirCcFlags $(PDCLIB_CCFLAGS) ;
104     SubDirC++Flags $(PDCLIB_C++FLAGS) ;
105     PDCLibHeaders ;
106     PDCLibTargetConfig ;
107 }
108
109 # MinGW needs appropriate prodding to cretae executables
110 if $(TOOLSET) = MINGW {
111     PDCLIB_TEST_LINKFLAGS    += -mconsole ;
112     PDCLIB_REGTEST_LINKFLAGS += -mconsole ;
113 }
114
115 # Tests
116 ALWAYS regtest test ;
117
118 rule Test {
119     DEPENDS $(<) : $(>) ;
120     ALWAYS $(<) ;
121     DEPENDS test : $(<) ;
122 }
123
124 rule RegTest {
125     DEPENDS $(<) : $(>) ;
126     ALWAYS $(<) ;
127     DEPENDS regtest : $(<) ;
128 }
129
130 actions Test {
131     $(>)
132 }
133
134 actions RegTest {
135     $(>)
136 }
137
138 # list all files in a directory, except ., ..
139 # [ ListDir base : dirname ]
140 rule ListDir {
141   # start with empty list
142   local _result =  ;
143
144   # for each file in the directory
145   local _dirlist = [ GLOB [ FDirName $(1) $(2) ] : * ] ;
146   for _subdir in $(_dirlist) {
147
148     # if it is not . or ..
149     switch $(_subdir) {
150     case *\\. :  _dummy = "" ; # is there some no-op statement?
151     case *\\.. : _dummy = "" ; # is there some no-op statement?
152     case * :
153       # add it to the list
154       _result += $(_subdir:D=$(2)) ;
155     }
156   }
157
158   # return resulting list
159   return $(_result) ;
160 }
161
162 # same as glob, but recurses into subdirs
163 rule RecursiveGlob {
164   # initially use the files in the current directory
165   local _dir  = $(2) ;
166   local _path = [ FDirName $(1) $(2) ] ;
167   local _result = [ GLOB $(_path) : $(3) ] ;
168   _result = $(_result:D=$(_dir)) ;
169
170   # list all subdirectories (and files, but it doesn't hurt)
171   local _subdirlist = [ ListDir $(1) : $(2) ] ;
172
173   # for each subdir/file
174   for _subdir in $(_subdirlist) {
175     # recurse into it
176     _result += [ RecursiveGlob $(1) : $(_subdir) : $(3) ] ;
177   }
178
179   # return the resulting list
180   return $(_result) ;
181 }
182
183 # Fix to work on targets in subdirs
184 rule MakeLocate
185 {
186     # Note we grist the directory name with 'dir',
187     # so that directory path components and other
188     # targets don't conflict.
189
190     if $(>)
191     {
192         local _rev = [ FReverse $(>) ] ;
193         if $(_rev[1]) = "." {
194           _rev = $(_rev[2-]) ;
195         } 
196         local _dir = [ FDirName [ FReverse $(_rev) ] $(<[0]:D) ] ;
197
198         LOCATE on $(<) = [ FDirName $(>) ] ;
199         Depends $(<) : $(_dir:G=dir) ;
200         MkDir $(_dir:G=dir) ;
201     }
202 }