]> pd.if.org Git - pdclib/blob - Jamrules
PDCLIB-3 Add iswctype(3)
[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     # 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       -D_PDCLIB_BUILD
52       $(PDCLIB_WARNINGS) ;
53     PDCLIB_C++FLAGS =
54       -ffreestanding
55       #-nostdinc
56       -std=c++11
57       -g
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         actions Link bind NEEDLIBS
71         {
72             $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) -Wl,--start-group $(NEEDLIBS) $(LINKLIBS) -Wl,--end-group
73         }
74     }
75 } else if $(PDCLIB_TOOLCHAIN) = "WATCOM" {
76   ECHO "Watcom!" ;
77   CCFLAGS  = /zq /DWIN32 /zls ;
78   C++FLAGS = /zq /DWIN32 /zls ;
79   STDHDRS  = $(WATCOM)\\h\\nt ;
80   PDCLIB_CCFLAGS = "-za99 -zl -s" ;
81 } else {
82   ECHO The value of PDCLIB_TOOLCHAIN is not recognized  ;
83   ECHO Currently set to $(PDCLIB_TOOLCHAIN)  ;
84   EXIT ;
85 }
86
87 if $(PDCLIB_PLATFORM) {
88     include [ FDirName $(PDCLIB_TOP) platform $(PDCLIB_PLATFORM) Config.jam ] ;
89 }
90
91 rule PDCLibHeaders {
92     SubDirHdrs $(PDCLIB_TOP) includes ;
93     SubDirHdrs $(PDCLIB_TOP) internals ;
94     SubDirHdrs $(PDCLIB_TOP) testing ;
95     for opt in $(PDCLIB_OPTIONS) {
96         SubDirHdrs $(PDCLIB_TOP) opt $(opt) ;
97     }
98     PDCLibTargetHeaders ;
99 }
100
101 rule PDCLibConfig {
102     SubDirCcFlags $(PDCLIB_CCFLAGS) ;
103     SubDirC++Flags $(PDCLIB_C++FLAGS) ;
104     PDCLibHeaders ;
105     PDCLibTargetConfig ;
106 }
107
108 # MinGW needs appropriate prodding to cretae executables
109 if $(TOOLSET) = MINGW {
110     PDCLIB_TEST_LINKFLAGS    += -mconsole ;
111     PDCLIB_REGTEST_LINKFLAGS += -mconsole ;
112 }
113
114 # Tests
115 ALWAYS regtest test ;
116
117 rule Test {
118     DEPENDS $(<) : $(>) ;
119     ALWAYS $(<) ;
120     DEPENDS test : $(<) ;
121 }
122
123 rule RegTest {
124     DEPENDS $(<) : $(>) ;
125     ALWAYS $(<) ;
126     DEPENDS regtest : $(<) ;
127 }
128
129 actions Test {
130     $(>)
131 }
132
133 actions RegTest {
134     $(>)
135 }
136
137 # list all files in a directory, except ., ..
138 # [ ListDir base : dirname ]
139 rule ListDir {
140   # start with empty list
141   local _result =  ;
142
143   # for each file in the directory
144   local _dirlist = [ GLOB [ FDirName $(1) $(2) ] : * ] ;
145   for _subdir in $(_dirlist) {
146
147     # if it is not . or ..
148     switch $(_subdir) {
149     case *\\. :  _dummy = "" ; # is there some no-op statement?
150     case *\\.. : _dummy = "" ; # is there some no-op statement?
151     case * :
152       # add it to the list
153       _result += $(_subdir:D=$(2)) ;
154     }
155   }
156
157   # return resulting list
158   return $(_result) ;
159 }
160
161 # same as glob, but recurses into subdirs
162 rule RecursiveGlob {
163   # initially use the files in the current directory
164   local _dir  = $(2) ;
165   local _path = [ FDirName $(1) $(2) ] ;
166   local _result = [ GLOB $(_path) : $(3) ] ;
167   _result = $(_result:D=$(_dir)) ;
168
169   # list all subdirectories (and files, but it doesn't hurt)
170   local _subdirlist = [ ListDir $(1) : $(2) ] ;
171
172   # for each subdir/file
173   for _subdir in $(_subdirlist) {
174     # recurse into it
175     _result += [ RecursiveGlob $(1) : $(_subdir) : $(3) ] ;
176   }
177
178   # return the resulting list
179   return $(_result) ;
180 }
181
182 # Fix to work on targets in subdirs
183 rule MakeLocate
184 {
185     # Note we grist the directory name with 'dir',
186     # so that directory path components and other
187     # targets don't conflict.
188
189     if $(>)
190     {
191         local _rev = [ FReverse $(>) ] ;
192         if $(_rev[1]) = "." {
193           _rev = $(_rev[2-]) ;
194         } 
195         local _dir = [ FDirName [ FReverse $(_rev) ] $(<[0]:D) ] ;
196
197         LOCATE on $(<) = [ FDirName $(>) ] ;
198         Depends $(<) : $(_dir:G=dir) ;
199         MkDir $(_dir:G=dir) ;
200     }
201 }