[go: up one dir, main page]

File: howto.cook

package info (click to toggle)
srecord 1.58-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 5,144 kB
  • sloc: cpp: 26,774; sh: 7,053; makefile: 2,889; awk: 187; vhdl: 15
file content (424 lines) | stat: -rw-r--r-- 11,740 bytes parent folder | download | duplicates (2)
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
/*
 *      srecord - manipulate eprom load files
 *      Copyright (C) 1998, 1999, 2001-2003, 2006-2010 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/>.
 */

#include "functions"

set mkdir;
set unlink;
set time-adjust;

awk = gawk;

/*
 * See how verbose we have decided to be.
 */
if [not [defined verbose]] then
    verbose = 0;
libtool-quiet = ;
if [not [verbose]] then
{
    set silent;
    libtool-quiet = --quiet;
    set no-star;
}
else
{
    set no-silent;
    libtool-quiet = ;
    set star;
}

/*
 * 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.
 */
[arch]/[project_short]/lib[project_short].la_obj =
    [fromto %0%.cc [arch]/%0%.lo [match_mask srecord/%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]
{
    [arch]/bin/[program]_obj =
        [fromto %0%.cc [arch]/%0%.lo
            [match_mask [program]/%0%.cc [source_files]]
        ];
    [arch]/bin/[program]_libs = [arch]/[project_short]/lib[project_short].la ;
    all += [arch]/bin/[program] ;
}

integration-build-targets = ;
integration-build-targets: [integration-build-targets];

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 += 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];
if [not [defined libs]] then
    libs = ;

cascade %0%.lo = %0%.o %0.libs/%.lo;

[arch]/%0%.lo [arch]/%0%.o [arch]/%0.libs/%.o: %0%.cc [arch]/srecord/config.h
{
    if [not [verbose]] then
        function print CXX %0%.cc;

    rm -f [arch]/%0%.lo [arch]/%0.libs/%.o [arch]/%0.libs/%.lo;
    libtool [libtool-quiet] --mode\=compile
    [c++] [c++_flags]
        [defined-or-null %0%.cc_c++_flags]
        [defined-or-null [dir %0%.cc]_c++_flags]
        [cc_include_flags]
        -c [resolve %0%.cc]
        -o [target];
    md5sum [arch]/%0%.o [arch]/%0.libs/%.o | sed "'s|^|# |'" >> [target];
}


c_incl = c_incl;

%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];
}

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/% [arch]/bin/.libs/%: [[target]_obj] [defined-or-null [target]_libs]
        [fromto %%0%%.la %%0.libs/%%.a  [defined-or-null [target]_libs]]
        [fromto %%0%%.la %%0.libs/%%.so [defined-or-null [target]_libs]]
    set gate-first shallow /* tests need them */
    if [defined [target]_obj]
{
    if [not [verbose]] then
        function print LINK [target];

    rm -f bin/.libs/lt-%;
    libtool [libtool-quiet] --mode\=link
    [c++] -o [target]
        [cc_include_flags]
        [ld_flags]
        [resolve [[target]_obj] [defined-or-null [target]_libs]]
        [libs]
        ;

    /*
     * Libtool makes intermediate shell scripts.
     * Make sure the fingerprint changes when it rebuilds,
     * otherwise some tests get confused.
     */
    date "'+# %%c'" >> [target]
        set silent;

    /*
     * libtool creates bin/% as a script, which, when executed, does the
     * actual link.  But this link puts its results in bin/.libs, and
     * that directory will not be writable for executables sourced from
     * the baseline.  So we goose it into linking now, which would seem
     * to defeat the purpose.
     */
    [target] --version > /dev/null;
}

[arch]/%/lib%.la [arch]/%/.libs/lib%.a [arch]/%/.libs/lib%.so:
        [[target]_obj]
    set unlink
{
    if [not [verbose]] then
        function print LINK [target];

    /*
     * We include the "hidden" libtool output files because we need to
     * fingerprint something that actually changes, and the .la file is
     * pretty much static.
     */
    local version-info =
        [collect aesub "'${project_specific aemakegen:version-info}'" ];
    libtool [libtool-quiet] --mode\=link
    [c++] [c++_flags]
        -o [target]
        [resolve [[target]_obj]]
        [libs]
        -version-info [version-info]

        /*
         * If you don't specify -rpath it doesn't make the shared library, even
         * though the Debian people Really Don't Like Rpath.  We really really
         * want the .so so we can check out version-info using the aede-policy
         * soname.
         */
        -rpath /usr/local/bin
        ;
}

[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]/srecord/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.)
 */

srecord/patchlevel.h:
    set shallow
{
    if [not [verbose]] then
        function print GEN [target];

    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]
{
    if [not [verbose]] then
        function print GEN [target];

    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 srecord/versn_stamp.cc = srecord/patchlevel.h ;
cascade man/man1/z_copyright.so = etc/version.so ;

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