]> pd.if.org Git - pdclib/blob - Jamrules
* Test cleanups: surround the code for all functions by #ifndef REGTEST
[pdclib] / Jamrules
1 PDCLIB ?= pdclib ;\r
2 \r
3 ECHO "PDCLIB_TOP: " $(PDCLIB_TOP) ;\r
4 \r
5 if ! $(PDCLIB_HAVE_PLATFORM) && ! $(PDCLIB_PLATFORM) {\r
6     if $(NT) {\r
7         PDCLIB_PLATFORM = "win32" ;\r
8     } else if $(UNIX) {\r
9         PDCLIB_PLATFORM = "posix" ;\r
10     } else {\r
11         ECHO "PDCLIB_PLATFORM not set and platform not automatically detected" ;\r
12         ECHO "Set PDCLIB_PLATFORM to the platform to be built for" ;\r
13         EXIT ;\r
14     }\r
15     PDCLIB_HAVE_PLATFORM = 1 ;\r
16 }\r
17 \r
18 #if $(CC) = "gcc" {\r
19 # TODO: Better toolchain handling\r
20 \r
21     # No -Wcast-align      : spurious warnings when using char* to do pointer \r
22     #                        arithmetic\r
23     # No -Winline          : when compiling with e.g. -Os causes spurious \r
24     #                        warnings that call is unlikely/code size would grow\r
25     # No -Wredundant-decls : some functions must be multiply defined\r
26     PDCLIB_WARNINGS ?= \r
27       -Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow \r
28       -Wpointer-arith -Wwrite-strings -Wmissing-declarations -Wno-long-long \r
29       -Wuninitialized \r
30       ;\r
31     PDCLIB_CCWARNINGS ?= \r
32       -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes ;\r
33     PDCLIB_CCFLAGS  = \r
34       -ffreestanding \r
35       #-nostdinc \r
36       -std=c11 \r
37       -g \r
38       -D_PDCLIB_BUILD\r
39       $(PDCLIB_WARNINGS) ;\r
40     PDCLIB_C++FLAGS =\r
41       -ffreestanding\r
42       #-nostdinc\r
43       -std=c++11\r
44       -g\r
45       -D_PDCLIB_BUILD\r
46       $(PDCLIB_WARNINGS) ;\r
47 \r
48     actions Link bind NEEDLIBS\r
49     {\r
50         $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) -Wl,--start-group $(NEEDLIBS) $(LINKLIBS) -Wl,--end-group\r
51     }\r
52 #}\r
53 \r
54 if $(PDCLIB_PLATFORM) {\r
55     include [ FDirName $(PDCLIB_TOP) platform $(PDCLIB_PLATFORM) Config.jam ] ;\r
56 }\r
57 \r
58 rule PDCLibHeaders {\r
59     SubDirHdrs $(PDCLIB_TOP) includes ;\r
60     SubDirHdrs $(PDCLIB_TOP) internals ;\r
61     SubDirHdrs $(PDCLIB_TOP) testing ;\r
62     for opt in $(PDCLIB_OPTIONS) {\r
63         SubDirHdrs $(PDCLIB_TOP) opt $(opt) ;\r
64     }\r
65     PDCLibTargetHeaders ;\r
66 }\r
67 \r
68 rule PDCLibConfig {\r
69     SubDirCcFlags $(PDCLIB_CCFLAGS) ;\r
70     SubDirC++Flags $(PDCLIB_C++FLAGS) ;\r
71     PDCLibHeaders ;\r
72     PDCLibTargetConfig ;\r
73 }\r
74 \r
75 # MinGW needs appropriate prodding to cretae executables\r
76 if $(TOOLSET) = MINGW {\r
77     PDCLIB_TEST_LINKFLAGS    += -mconsole ;\r
78     PDCLIB_REGTEST_LINKFLAGS += -mconsole ;\r
79 }\r
80 \r
81 # Tests\r
82 ALWAYS regtest test ;\r
83 \r
84 rule Test {\r
85     DEPENDS $(<) : $(>) ;\r
86     ALWAYS $(<) ;\r
87     DEPENDS test : $(<) ;\r
88 }\r
89 \r
90 rule RegTest {\r
91     DEPENDS $(<) : $(>) ;\r
92     ALWAYS $(<) ;\r
93     DEPENDS regtest : $(<) ;\r
94 }\r
95 \r
96 actions Test {\r
97     $(>)\r
98 }\r
99 \r
100 actions RegTest {\r
101     $(>)\r
102 }\r
103 \r
104 # list all files in a directory, except ., ..\r
105 # [ ListDir base : dirname ]\r
106 rule ListDir {\r
107   # start with empty list\r
108   local _result =  ;\r
109 \r
110   # for each file in the directory\r
111   local _dirlist = [ GLOB [ FDirName $(1) $(2) ] : * ] ;\r
112   for _subdir in $(_dirlist) {\r
113 \r
114     # if it is not . or ..\r
115     switch $(_subdir) {\r
116     case *\\. :  _dummy = "" ; # is there some no-op statement?\r
117     case *\\.. : _dummy = "" ; # is there some no-op statement?\r
118     case * :\r
119       # add it to the list\r
120       _result += $(_subdir:D=$(2)) ;\r
121     }\r
122   }\r
123 \r
124   # return resulting list\r
125   return $(_result) ;\r
126 }\r
127 \r
128 # same as glob, but recurses into subdirs\r
129 rule RecursiveGlob {\r
130   # initially use the files in the current directory\r
131   local _dir  = $(2) ;\r
132   local _path = [ FDirName $(1) $(2) ] ;\r
133   local _result = [ GLOB $(_path) : $(3) ] ;\r
134   _result = $(_result:D=$(_dir)) ;\r
135 \r
136   # list all subdirectories (and files, but it doesn't hurt)\r
137   local _subdirlist = [ ListDir $(1) : $(2) ] ;\r
138 \r
139   # for each subdir/file\r
140   for _subdir in $(_subdirlist) {\r
141     # recurse into it\r
142     _result += [ RecursiveGlob $(1) : $(_subdir) : $(3) ] ;\r
143   }\r
144 \r
145   # return the resulting list\r
146   return $(_result) ;\r
147 }\r
148 \r
149 # Fix to work on targets in subdirs\r
150 rule MakeLocate\r
151 {\r
152     # Note we grist the directory name with 'dir',\r
153     # so that directory path components and other\r
154     # targets don't conflict.\r
155 \r
156     if $(>)\r
157     {\r
158         local _rev = [ FReverse $(>) ] ;\r
159         if $(_rev[1]) = "." {\r
160           _rev = $(_rev[2-]) ;\r
161         } \r
162         local _dir = [ FDirName [ FReverse $(_rev) ] $(<[0]:D) ] ;\r
163 \r
164         LOCATE on $(<) = [ FDirName $(>) ] ;\r
165         Depends $(<) : $(_dir:G=dir) ;\r
166         MkDir $(_dir:G=dir) ;\r
167     }\r
168 }