Debian Codegraph @

etc/howto.cook

raw
1 /*
2 * fstrcmp - fuzzy string compare library
3 * Copyright (C) 2009, 2012 Peter Miller
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 *
19 * It is assumed that the following variables are assigned on the command line:
20 *
21 * project The name of the Aegis project.
22 * change The number of the Aegis change.
23 * version The version of this change
24 * search_path The search path from the development directory back into
25 * the baseline, colon separated.
26 */
27
28 #include "functions"
29
30 default_target: all
31 set default;
32
33 /*
34 * always remove targets before recreating them
35 */
36 set unlink;
37
38 /*
39 * always create directories for targets if they don't yet exist.
40 */
41 set mkdir;
42
43 /*
44 * Make sure time mod-time of targets is consistent with the ingredients.
45 * (During integration builds, adjust beack agressively.)
46 */
47 set time-adjust;
48 if [match_mask %1D%2 [version]] then
49 set time-adjust-back;
50
51 /*
52 * Use file fingerprints to supplement file-modified times.
53 */
54 set fingerprint;
55
56 /* -------------------------------------------------------------------------
57 *
58 * determine the short version:
59 * no change or delta number
60 */
61 version_short = [fromto %1.C%2 %1 [subst D C [version]]];
62
63 version_shorter = [split "." [version_short]] _ _;
64 version_shorter =
65 [unsplit "." [word 1 [version_shorter]]
66 [word 2 [version_shorter]]];
67 project_short = [fromto %.[version_short] % [project]];
68 /* project_minus = [project_short]-[version_short]; */
69 project_minus = [project_short]-[version];
70
71 /* -------------------------------------------------------------------------
72 * Section: Search path
73 *
74 * The aegis search path (colon separated) is turned into a cook
75 * search_list (separate words).
76 */
77
78 search_list = .;
79 search_tmp = [tail [split ':' [search_path]]];
80 search_name = bl;
81 loop
82 {
83 search_dir = [head [search_tmp]];
84 if [not [search_dir]] then
85 loopstop;
86 search_tmp = [tail [search_tmp]];
87
88 if [not [exists [search_name]]] then
89 ln -s [search_dir] [search_name]
90 set clearstat;
91 search_list = [search_list] [search_name];
92 search_name = [search_name]bl;
93 }
94
95 /* -------------------------------------------------------------------------
96 * Section: Utilities
97 *
98 * The include files in the lib/ directory define the interface between
99 * the lib/ contents and the programs.
100 */
101
102 CPPFLAGS = [addprefix "-I" [search_list]];
103 CC = gcc;
104 CFLAGS = -Werror -Wall -Wextra
105 -Wformat\=2
106 -Wswitch-default
107 -Wswitch-enum
108 -Wdeclaration-after-statement
109 -Wshadow
110 -Wpointer-arith
111 -Wwrite-strings
112 -Wstrict-prototypes
113 -Wold-style-definition
114 -Wmissing-prototypes
115 -Wmissing-declarations
116 -Wnested-externs
117 -g
118 ;
119 LDFLAGS = -Wl,--as-needed;
120 LIBS = ;
121
122 /* -------------------------------------------------------------------------
123 * Section: Compile Flags
124 *
125 * If you need to add specific options for a particular .c file,
126 * use the full name of the file, with a _CFLAGS suffix.
127 * (See the C recipe, below, for how this is referenced.)
128 */
129 /* lib/version.c_CFLAGS = "-D'VERSION=\""[version]"\"'"; */
130
131 /*
132 * If you need to add specific options for a particular .c file,
133 * use the full name of the file, with a _CFLAGS suffix.
134 * (See the C recipe, below, for how this is referenced.)
135 */
136 /* lib/name2_CFLAGS = -DEXTRA_STUFF; */
137
138 /* -------------------------------------------------------------------------
139 * Section: Primary Source Files
140 *
141 * Ask Aegis for the manifest of primary source files.
142 * It is almost *never* a good idea to alter this section in any way.
143 * If you are not an experiences Aegis user, do not edit this section.
144 */
145
146 project_files = [collect aegis -l pf -p [project] -c [change] -terse];
147 change_files = [shell aegis -l cf -p [project] -c [change] -terse];
148 source_files = [sort [project_files] [change_files]];
149
150 /* -------------------------------------------------------------------------
151 * Section: Libraries
152 *
153 * For each library, construct the object list for that library.
154 *
155 * The relevant portion of the directory structure looks like this
156 *
157 * lib/
158 * libfstrcmp.la
159 * source.file1.c
160 * source.file2.c
161 * ...
162 */
163
164 lib/libfstrcmp_obj =
165 [patsubst %0%.c %0%.lo [filter lib/%0%.c [source_files]]]
166 [patsubst %0%.y %0%.yacc.lo [filter lib/%0%.y [source_files]]]
167 [patsubst %0%.l %0%.lex.lo [filter lib/%0%.l [source_files]]]
168 ;
169
170 lib/libfstrcmp.la : [lib/libfstrcmp_obj]
171 set unlink
172 {
173 /*
174 * We include the "hidden" libtool output files because we need to
175 * fingerprint somethign that actually changes, and the .la file is
176 * pretty much static.
177 */
178 local version-info =
179 [collect aesub "'${project_specific aemakegen:version-info}'" ];
180 libtool --mode\=link
181 [CC] [CPPFLAGS] [CFLAGS]
182 -o lib/libfstrcmp.la
183 [resolve [lib/libfstrcmp_obj]]
184 [LIBS]
185 -version-info [version-info]
186
187 /*
188 * If you don't specify -rpath it doesn't make the shared
189 * library, even though the Debian people Really Don't Like
190 * Rpath. We really really want the .so so we can check out
191 * version-info using the aede-policy soname.
192 */
193 -rpath /usr/local/bin
194 ;
195 }
196
197 /* -------------------------------------------------------------------------
198 * Section: Programs
199 *
200 * For each program, construct the object list for that program.
201 * Because Make only had macros, not a full 3GL, you have to enumerate
202 * each one explicitly.
203 *
204 * The relevant portion of the directory structure looks like this
205 *
206 * progA/
207 * source.file.c ...
208 * progB/
209 * source.file.c ...
210 * bin/
211 * progA
212 * progB
213 *
214 * The list of programs is determinted automatically from the sourec files,
215 * and the list of objects for each one.
216 */
217
218 programs =
219 [stringset /* remove duplicates */
220 [patsubst %/main.c % [filter %/main.c [source_files]]]
221 ];
222
223 loop prog = [programs]
224 {
225 bin/[prog]_obj =
226 [patsubst %0%.c %0%.o [filter [prog]/%0%.c [source_files]]]
227 [patsubst %0%.y %0%.yacc.o [filter [prog]/%0%.y [source_files]]]
228 [patsubst %0%.l %0%.lex.o [filter [prog]/%0%.l [source_files]]]
229 ;
230 bin/[prog]_libs = lib/libfstrcmp.la;
231 }
232
233 /*
234 * We can use a single pattern recipe to make all of the programs.
235 */
236
237 bin/% bin/.libs/%: [[target]_obj] [defined-or-null [target]_libs]
238 /* [fromto %%0%%.la %%0.libs/%%.so [defined-or-null [target]_libs]] */
239 set gate-first shallow /* tests need them */
240 if [defined [target]_obj]
241 {
242 rm -f bin/.libs/lt-%;
243 libtool --mode\=link
244 [CC] -o [target]
245 [LDFLAGS]
246 [resolve [[target]_obj] [defined-or-null [target]_libs]]
247 ;
248
249 /*
250 * libtool creates bin/% as a script, which, when executed, does the
251 * actual link. But this link puts its results in bin/.libs, and
252 * that directory will not be writable for executables sourced from
253 * the baseline. So we goose it into linking now, which would seem
254 * to defeat the purpose.
255 */
256 [target] -V;
257 }
258
259 /* --------------------------------------------------------------------------
260 * Section: What to make
261 *
262 * The ``all'' targets are each of the commands.
263 */
264
265 all = [addprefix "bin/" [programs]];
266 all: [all];
267
268 integration-build-targets = web-site/[project_minus].ae;
269 integration-build-targets: [integration-build-targets];
270
271 if [match_mask %1D%2 [version]] then
272 all += integration-build-targets;
273
274 /* --------------------------------------------------------------------------
275 * Section: Compiling C Source Files
276 */
277
278 #if 0
279 %0%.o: %0%.c
280 {
281 rm -f %0.libs/%.o %0.libs/%.lo;
282 libtool --mode\=compile
283 [CC] [CFLAGS]
284 [defined-or-null %0%.c_CFLAGS]
285 [defined-or-null [dir %0%.c]_CFLAGS]
286 [CPPFLAGS]
287 -c [resolve %0%.c]
288 -o [target];
289 }
290 #endif
291
292 cascade %0%.lo = %0%.o %0.libs/%.lo;
293
294 %0%.lo %0%.o %0.libs/%.o: %0%.c
295 {
296 rm -f %0%.lo %0.libs/%.o %0.libs/%.lo;
297 libtool --mode\=compile
298 [CC] [CFLAGS]
299 [defined-or-null %0%.c_CFLAGS]
300 [defined-or-null [dir %0%.c]_CFLAGS]
301 [CPPFLAGS]
302 -c [resolve %0%.c]
303 -o [target];
304 md5sum %0%.o %0.libs/%.o | sed "'s|^|# |'" >> [target];
305 }
306
307 /* force this one to be shallow */
308 if [not [exists lib/version.lo]] then
309 lib/version.lo: .;
310
311 /* --------------------------------------------------------------------------
312 * Section: Maintaining C Include Dependencies
313 *
314 * How to manage C include dependencies, straight out of the Cook manual.
315 */
316
317 /*
318 * There is a special list of files you must use, in preference to the
319 * standard C files. This ensures appropriate operating system insulation
320 * is always in place.
321 */
322 c_incl_excludes =
323 [fromto lib/ac/%0%.h -ex\=%0%.h
324 [match_mask lib/ac/%0%.h [source_files]]
325 ]
326 ;
327
328 %0%.c.d: %0%.c
329 set no-cascade
330 {
331 /*
332 * Generated files may use excluded headers, because we
333 * have no control over the quality of generated code.
334 */
335 local ex = ;
336 if [not [match %%.yacc %]] then
337 {
338 if [not [filter lib/ac/%%0%% %0%.c]] then
339 ex = [c_incl_excludes];
340 }
341
342 c_incl -nc -ns -eia -nrec
343 -nsri /* essential for Aegis development */
344 [filter -I%%0%% [CPPFLAGS]]
345 -prefix "'cascade %0%.c ='"
346 -suffix "';'"
347 [resolve %0%.c]
348 [addprefix -rlp\= [search_list]]
349 [ex]
350 -o [target];
351 }
352
353 #include-cooked-nowarn [addsuffix ".d" [filter %0%.c [source_files]]]
354
355 %0%.h.d: %0%.h: lib/config.h
356 set no-cascade
357 {
358 /*
359 * Generated files may use excluded headers, because we
360 * have no control over the quality of generated code.
361 */
362 local ex = ;
363 if [not [match %%.yacc %]] then
364 {
365 if [not [filter lib/ac/%%0%% %0%.c]] then
366 ex = [c_incl_excludes];
367 }
368 if [in %0%.h lib/fstrcmp.h] then
369 {
370 ex = [stringset [ex] - "-ex=stddef.h" ];
371 }
372
373 c_incl -nc -ns -eia -nrec
374 -nsri /* essential for Aegis development */
375 [filter -I%%0%% [CPPFLAGS]]
376 -prefix "'cascade %0%.h ='"
377 -suffix "';'"
378 [resolve %0%.h]
379 [addprefix -rlp\= [search_list]]
380 [ex]
381 -o [target];
382 }
383
384 #include-cooked-nowarn [addsuffix ".d" [filter %0%.h [source_files]]]
385
386 /*
387 * If the relationship between a target and a derived ingredient
388 * appears only in a derived cookbook, it is likely that a clean build
389 * (solely from primary source files) will fail. It is recommended that
390 * relationships such as this be placed in a primary source cookbook.
391 */
392
393 cascade lib/ac/errno.h = lib/config.h;
394 cascade lib/ac/stddef.h = lib/config.h;
395 cascade lib/ac/stdio.h = lib/config.h;
396 cascade lib/ac/stdlib.h = lib/config.h;
397 cascade lib/ac/string.h = lib/config.h;
398 cascade lib/ac/fcntl.h = lib/config.h;
399
400 /* --------------------------------------------------------------------------
401 * Section: Using Yacc Source Files
402 *
403 * How to have yacc read .y files and generate .yacc.c and .yacc.h files.
404 * This section allows you to have more than one yacc file in a program
405 * (or library) by editing the generated ``yy'' identifiers into something
406 * more unique.
407 */
408
409 /* yacc = yacc; */
410 yacc = bison -y;
411 yacc_flags = ;
412
413 /* LIBS += -ly; */
414
415 %0%.yacc.c %0%.yacc.h: %0%.y
416 single-thread y.tab.c y.tab.h
417 {
418 local name = [substitute / _ %0%_];
419 [yacc] -d [yacc_flags] [resolve %0%.y];
420 sed -e "'s|[yY][yY]|"[name]"|g'" y.tab.c > %0%.yacc.c;
421 sed -e "'s|[yY][yY]|"[name]"|g'" y.tab.h > %0%.yacc.h;
422 rm y.tab.c y.tab.h;
423 }
424
425 yacc_d_files =
426 [patsubst %0%.y %0%.yacc.c.d [filter %0%.y [source_files]]]
427 [patsubst %0%.y %0%.yacc.h.d [filter %0%.y [source_files]]]
428 ;;
429 #include-cooked-nowarn [yacc_d_files]
430
431 /* --------------------------------------------------------------------------
432 * Section: Change Set
433 */
434
435 web-site/[project_minus].ae: [source_files]
436 {
437 aedist --send --entire-source -p [project] -c [change] -ndh -naa
438 -o [target];
439 }
440
441 /* --------------------------------------------------------------------------
442 * Section: scripts
443 *
444 * see etc/autoconf.cook for how the scripts are cooked
445 */
446
447 scripts = [fromto script/%.sh.in % [match_mask script/%.sh.in [source_files]]];
448
449 all += [addprefix bin/ [scripts]];
450
451
452 /* ---------------------------------------------------------------------- */
453 #include-cooked etc/autoconf.cook
454 #include-cooked etc/doxygen.cook
455 #include-cooked etc/makefile.cook
456 #include-cooked etc/tags.cook
457 #include-cooked etc/metrics.cook
458 #include-cooked etc/documentation.cook
459 #include-cooked etc/i18n.cook
460 #include-cooked web-src/module.cook