[go: up one dir, main page]

File: Howto.cook

package info (click to toggle)
srecord 1.39-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,624 kB
  • ctags: 1,822
  • sloc: cpp: 18,283; sh: 5,839; makefile: 1,701; awk: 201; vhdl: 15
file content (374 lines) | stat: -rw-r--r-- 9,655 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
/*
 *      srecord - manipulate eprom load files
 *      Copyright (C) 1998, 1999, 2001-2003, 2006-2008 Peter Miller
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 3 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program. If not, see
 *      <http://www.gnu.org/licenses/>.
 */

set mkdir;
set unlink;
set time-adjust;

awk = gawk;

/*
 * The first item in search list should be the absolute path of the
 * current directory.  Assume that it is.
 */
search_list = .;
search_tmp = [tail [split ':' [search_path]]];

/*
 * Try to shorten the search path in command lines, too.
 *
 * This takes a little getting used to....
 * 1. For development builds, the search path is dev dir, then branch bl,
 *    then ... project bl.  Thus, bl in a dev dir winds up pointing to
 *    the branch reporitory.
 * 2. For integration builds, aegis deliberately omits the branch
 *    baseline from the path, but include's the branch's parents and
 *    ancestors.  Thus, bl in an int dir winds up pointing to the
 *    branch's parent's reporitory.
 * The idea is that integration builds in a branch are like a
 * development build of the branch's dev dir.
 */
search_name = bl;
loop
{
    search_dir = [head [search_tmp]];
    if [not [search_dir]] then
        loopstop;
    search_tmp = [tail [search_tmp]];

    if [not [exists [search_name]]] then
        ln -s [search_dir] [search_name]
            set clearstat;
    search_list = [search_list] [search_name];
    search_name = [search_name]bl;
}

/*
 * determine the short version:
 * no change or delta number
 */
version_short = [fromto %1.C%2 %1 [subst D C [version]]];

version_shorter = [split "." [version_short]] _ _;
version_shorter = [unsplit "." [word 1 [version_shorter]]
    [word 2 [version_shorter]]];
project_short = [fromto %.[version_short] % [project]];
project_minus = [project_short]-[version_short];

change_source_files = ;
#include-cooked-nowarn etc/cook/change_files.[version]
etc/cook/change_files.[version]:
    set shallow nodefault
{
    echo "'change_source_files ='" > [target];
    aegis -l cf -p [project] -c [change] -terse >> [target];
    echo "';'" >> [target];
}
project_source_files = ;
#include-cooked-nowarn etc/cook/project_files.[version]
etc/cook/project_files.[version]:
    set shallow nodefault
{
    echo "'project_source_files ='" > [target];
    aegis -l pf -p [project] -c [change] -terse >> [target];
    echo "';'" >> [target];
}
source_files = [sort [project_source_files] [change_source_files]];

/*
 * Speed up graph building by stating the leaves explictly.
 * This also gives more useful error messages.
 */
if [count [project_source_files]] then
if [count [change_source_files]] then
{
    leaf_file_accept = [project_source_files] [change_source_files];
    leaf_pattern_accept = /%0%;
}

debug = /* -g */ ;      /* g++ takes forever if you say -g for complex
                        template usage */

all = ;

/* the right hand side is deferred until triggered */
all: [all];

/*
 * Howto use GNU Autoconf.
 */
#include-cooked etc/autoconf.cook


/*
 * The files which are linked to form the common library for the programs.
 */
lib/[project_short]_obj =
    [fromto %0%.cc [arch]/%0%.o [match_mask lib/%0%.cc [source_files]]] ;

/*
 * Generate lists of object files for programs
 */
program_list = [fromto %1/%2 %1 [match_mask %/main.cc [source_files]]];
loop program = [program_list]
{
    [program]_obj =
        [fromto %0%.cc [arch]/%0%.o
            [match_mask [program]/%0%.cc [source_files]]
        ];
    [program]_libs = [arch]/lib/lib[project_short].a ;
    all += [arch]/bin/[program] ;
}

if [match %1C%2 [version]] then
{
    baseline = bl;
}
else
{
    /*
     * this is essential so that aeipass does the right thing
     *
     * It also means that generated files (e.g. from objen) have consistent
     * mod-times after integration, sop everythign does not immediately
     * re-build.
     */
    set time-adjust-back;
    all = [all] integration-build-targets;
}


/*
 * Note: this must come *after* the etc/autoconf.cook include.
 */
if [not [defined c++]] then
    c++ = g++;
cc_include_flags =
    [prepost "-I" "" [search_list]]
    [prepost "-I" /[arch] [search_list]]
    ;
if [not [defined c++_flags]] then
    c++_flags = -O [debug];
c++_flags = [c++_flags] -Wall -Wextra -Werror;
if [not [defined ld_flags]] then
    ld_flags = [debug];


[arch]/%0%.o: %0%.c
{
    [cc] [cc_include_flags] [cc_flags] -c [resolve %0%.c] -o [target];
}


[arch]/%0%.o: %0%.cc
{
    [c++] [cc_include_flags] [c++_flags] -c [resolve %0%.cc] -o [target]
        set meter;
}


c_incl = c_incl;

%0%.c.d: %0%.c
        set no-cascade
{
    [c_incl] -nc -ns -nrec
        [cc_include_flags]
        [resolve %0%.c]
        -prefix "'cascade %0%.c ='"
        -suffix "';'"
        -nsri
        [prepost "-rlp=" "" [search_list]]
        -slp [arch] "'[arch]'"
        -o [target];
}

%0%.c,M:: %0%.c,Md;

%0%.c,Md: %0%.c : etc/Makefile.file.sh
{
    [c_incl] -nc -ns
        [cc_include_flags]
        [resolve %0%.c]
        -nsri
        [prepost "-rlp=" "" [search_list]]
        -slp [arch] "'[arch]'"
        -o [target];
}

%0%.h.d: %0%.h
    set no-cascade
{
    [c_incl] -nc -ns -nrec
        [cc_include_flags]
        [resolve %0%.h]
        -prefix "'cascade %0%.h ='"
        -suffix "';'"
        -nsri
        [prepost "-rlp=" "" [search_list]]
        -slp [arch] "'[arch]'"
        -o [target];
}

%0%.cc.d: %0%.cc
        set no-cascade
{
    [c_incl] -nc -ns -nrec
        [cc_include_flags]
        [resolve %0%.cc]
        -prefix "'cascade %0%.cc ='"
        -suffix "';'"
        -nsri
        [prepost "-rlp=" "" [search_list]]
        -slp [arch] "'[arch]'"
        -o [target];
}

%0%.cc,M:: %0%.cc,Md;

%0%.cc,Md: %0%.cc : etc/Makefile.file.sh
{
    [c_incl] -nc -ns
        [cc_include_flags]
        [resolve %0%.cc]
        -nsri
        [prepost "-rlp=" "" [search_list]]
        -slp [arch] "'[arch]'"
        -o [target];
}

cc_dep_files =
        [fromto %0%.c %0%.c.d [match_mask %1/%0%.c [source_files]]]
        [fromto %0%.h %0%.h.d [match_mask %1/%0%.h [source_files]]]
        [fromto %0%.cc %0%.cc.d [match_mask %1/%0%.cc [source_files]]]
        [fromto %0%.y %0%.gen.c.d [match_mask %1/%0%.y [source_files]]]
        ;

#include-cooked-nowarn [cc_dep_files]

[arch]/bin/%: : [%_obj] [%_libs]
    set gate-first
    if [defined %_obj]
{
    [c++] [ld_flags] -o [target] [resolve [%_obj] [%_libs]] -lm;
}

[arch]/%0lib%.a: : [%0%_obj]
{
    ar cq [target] [resolve [%0%_obj]];
    if [find_command ranlib] then
        ranlib [target];
}


[arch]/bin/%: script/%
{
    cp script/% [target];
    chmod a+rx [target];
}


[arch]/bin/%: [arch]/script/%
{
    cp [arch]/script/% [target];
    chmod a+rx [target];
}

all +=
    [fromto script/% [arch]/bin/%
        [fromto %1/%2.in %1/%2
            [match_mask script/% [source_files]]
        ]
    ];


/*
 * How to build the release sets.
 */
#include-cooked etc/archive.cook

/*
 * How to build the documentation.
 */
#include-cooked etc/documentation.cook

/*
 * Explicit include dependencies.
 */
#if [count [cc_dep_files]]
[cc_dep_files]: [arch]/lib/config.h;
#endif


/*
 * The version stamp is to be updated for every
 * integration and development build.
 * (The integrate_begin_command in the config file
 * deletes them for integration builds.)
 */

lib/patchlevel.h:
        set shallow
{
    copyright_years =
        [collect
            aegis -list version -p [project] -c [change]
            | [awk] "-F'[[\\\\]]'" "'/^copyright_years/{print $2}'"
        ];
    echo "'#define PATCHLEVEL \""[version]"\"'" > [target];
    echo "'#define COPYRIGHT_YEARS \""[copyright_years]"\"'" >> [target];
}

/*
 * Build the version include, but not too often.
 */
etc/version.so:
    set ['if' [or [not [defined baseline] ] [not [exists bl/etc/version.so
                ] ] ] 'then' shallow]
{
    copyright_years =
        [collect
            aegis -list version -p [project] -c [change]
            | [awk] "-F'[[\\\\]]'" "'/^copyright_years/{print $2}'"
        ];
    echo "'.ds V) "[version]"'" > [target];
    echo "'.ds v) "[version_short]"'" >> [target];
    aegis -list version -p [project] -c [change]
        | [awk] -F'\'"\'' "'/previous/{print $2}'"
        | [awk] -F. "'{print \".ds w) \"$1\".\"$2}'"
        >> [target];
    echo "'.ds Y) "[copyright_years]"'" >> [target];
}


/*
 * Catch 22: If the relationship between a target and a derived ingredient
 * appears only in a derived cookbook, it is likely that a clean build
 * (solely from primary source files) will fail.  It is recommended that
 * relationships such as this be placed in a primary source cookbook.
 */
cascade etc/BUILDING.man = etc/version.so ;
cascade etc/README.man = etc/version.so etc/new.so;
cascade etc/change_log.man = etc/version.so etc/new.so;
cascade etc/reference.man = etc/version.so ;
cascade etc/srecord.lsm = etc/version.so ;
cascade lib/versn_stamp.cc = lib/patchlevel.h ;
cascade man/man1/z_copyright.so = etc/version.so ;

#include [resolve etc/doxygen.cook etc/metrics.cook etc/tags.cook ]