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