Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/jam/src/build.jam @ 29

Last change on this file since 29 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 23.6 KB
Line 
1#~ Copyright 2002-2005 Rene Rivera.
2#~ Distributed under the Boost Software License, Version 1.0.
3#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
4
5# Platform related specifics.
6if $(NT) { rule .path { return "$(<:J=\\)" ; } }
7else if $(OS2) { rule .path { return "$(<:J=\\)" ; } }
8else if $(VMS) { rule .path { return "[.$(<:J=/)]" ; } }
9else if $(MAC) { rule .path { return ":$(<:J=\:)" ; } }
10else { rule .path { return "$(<:J=/)" ; } }
11if $(VMS) { . = "_" ; }
12else { . = "." ; }
13
14# Info about what we are building.
15_VERSION_ = 3 1 14 ;
16NAME = boost-jam ;
17VERSION = $(_VERSION_:J=$(.)) ;
18RELEASE = 1 ;
19LICENSE = LICENSE_1_0 ;
20
21# Generate development debug binaries?
22if --debug in $(ARGV)
23{
24    debug = true ;
25}
26
27# Attempt to generate and/or build the grammar?
28if --grammar in $(ARGV)
29{
30    grammar = true ;
31}
32
33# Do we need to add a default build type argument?
34if ! ( --release in $(ARGV) ) &&
35   ! ( --debug in $(ARGV) )
36{
37    ARGV += --release ;
38}
39
40# Enable, and configure, Python hooks.
41with-python = ;
42python-location = [ MATCH --with-python=(.*) : $(ARGV) ] ;
43if $(python-location)
44{
45    with-python = true ;
46}
47if $(with-python)
48{
49    if $(NT)
50    {
51        --python-include = [ .path $(python-location) include ] ;
52        --python-lib = ;
53        for local v in 25 24 23 22
54        {
55            --python-lib ?=
56                [ GLOB [ .path $(python-location) libs ] : "python$(v).lib" ]
57                [ GLOB $(python-location) $(Path) $(PATH) $(path) : "python$(v).dll" ]
58                ;
59            if ! $(--python-lib[2])
60            {
61                --python-lib = ;
62            }
63        }
64    }
65    else if $(OS) = MACOSX
66    {
67        --python-include = [ .path $(python-location) Headers ] ;
68        --python-lib = $(python-location) Python ;
69    }
70    else
71    {
72        --python-include = ;
73        --python-lib = ;
74        for local v in 2.5 2.4 2.3 2.2
75        {
76            local inc = [ GLOB [ .path $(python-location) include ] : python$(v) ] ;
77            local lib = [ GLOB [ .path $(python-location) lib ] : libpython$(v)* ] ;
78            if $(inc) && $(lib)
79            {
80                --python-include ?= $(inc) ;
81                --python-lib ?= $(lib[1]:D) python$(v) ;
82            }
83        }
84    }
85}
86
87# An explicit root for the toolset? (trim spaces)
88toolset-root = [ MATCH --toolset-root=(.*) : $(ARGV) ] ;
89{
90    local t = [ MATCH "[ ]*(.*)" : $(toolset-root:J=" ") ] ;
91    toolset-root = ;
92    while $(t)
93    {
94        t = [ MATCH "([^ ]+)([ ]*)(.*)" : $(t) ] ;
95        toolset-root += $(t[1]) ;
96        if $(t[3]) { toolset-root += $(t[2]) ; }
97        t = $(t[3]) ;
98    }
99    toolset-root = $(toolset-root:J="") ;
100}
101
102# Configure the implemented toolsets. These are minimal
103# commands and options to compile the full Jam. When
104# adding new toolsets make sure to add them to the
105# "known" list also.
106rule toolset ( name command .type ? : opt.out + : opt.define * : flags * : linklibs * )
107{
108    .type ?= "" ;
109    tool.$(name)$(.type).cc ?= $(command) ;
110    tool.$(name)$(.type).opt.out ?= $(opt.out) ;
111    tool.$(name)$(.type).opt.define ?= $(opt.define) ;
112    tool.$(name)$(.type).flags ?= $(flags) ;
113    tool.$(name)$(.type).linklibs ?= $(linklibs) ;
114    if ! $(name) in $(toolsets) { toolsets += $(name) ; }
115}
116rule opt ( type : yes-opt * : no-opt * ) { if $(type) in $(ARGV) { return $(yes-opt) ; } else { return $(no-opt) ; } }
117## HP-UX aCC compiler
118toolset acc cc : "-o " : -D
119    : -Ae
120    [ opt --release : -s -O3 ]
121    [ opt --debug : -g -pg ]
122    -I$(--python-include)
123    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
124## Borland C++ 5.5.x
125toolset borland bcc32 : -e -n : /D
126    : -WC -w- -q "-I$(toolset-root)Include" "-L$(toolset-root)Lib"
127    [ opt --release : -O2 -vi -w-inl ]
128    [ opt --debug : -v -Od -vi- ]
129    -I$(--python-include)
130    : $(--python-lib[1]) ;
131## Generic Unix cc
132if ! $(CC) { CC = cc ; }
133toolset cc $(CC) : "-o " : -D
134    : $(CFLAGS)
135    [ opt --release : -s -O ]
136    [ opt --debug : -g ]
137    -I$(--python-include)
138    : $(LIBS) -L$(--python-lib[1]) -l$(--python-lib[2]) ;
139## Comeau C/C++ 4.x
140toolset como como : "-o " : -D
141    : --c
142    [ opt --release : --inlining ]
143    [ opt --debug : --no_inlining ]
144    -I$(--python-include)
145    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
146## MacOSX Darwin, using GCC 2.9.x, 3.x
147toolset darwin cc :  "-o " : -D
148    :
149    [ opt --release : -Wl,-x -O3 -finline-functions ]
150    [ opt --debug : -g -O0 -fno-inline -pg ]
151    -I$(--python-include)
152    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
153## GCC 2.x, 3.x, 4.x
154toolset gcc gcc : "-o " : -D
155    : -pedantic
156    [ opt --release : [ opt --symbols : -g : -s ] -O3 ]
157    [ opt --debug : -g -O0 -fno-inline ]
158    -I$(--python-include) -Wno-long-long
159    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
160## GCC 2.x, 3.x on CYGWIN but without cygwin1.dll
161toolset gcc-nocygwin gcc : "-o " : -D
162    : -s -O3 -mno-cygwin
163    [ opt --release : -finline-functions ]
164    [ opt --debug : -s -O3 -fno-inline -pg ]
165    -I$(--python-include)
166    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
167## Intel C/C++ for Linux
168toolset intel-linux icc : "-o " : -D
169    :
170    [ opt --release : -Xlinker -s -O3 ]
171    [ opt --debug : -g -O0 -p ]
172    -I$(--python-include)
173    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
174## Intel C/C++ for Win32
175toolset intel-win32 icl : /Fe : -D
176    : /nologo
177    [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ]
178    [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ]
179    -I$(--python-include)
180    : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ;
181## KCC ?
182toolset kcc KCC : "-o " : -D
183    :
184    [ opt --release : -s +K2 ]
185    [ opt --debug : -g +K0 ]
186    -I$(--python-include)
187    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
188## Borland Kylix
189toolset kylix bc++ : -o : -D
190    : -tC -q
191    [ opt --release : -O2 -vi -w-inl ]
192    [ opt --debug : -v -Od -vi- ]
193    -I$(--python-include)
194    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
195## Metrowerks CodeWarrior 8.x
196{
197    # Even though CW can compile all files at once, it crashes if it tries in the bjam case.
198    local mwcc = ; if $(NT) { mwcc = mwcc ; } else { mwcc = mwc$(OSPLAT:L) ; }
199    mwcc ?= mwcc ;
200    toolset metrowerks $(mwcc) : "-o " : -D
201        : -c -lang c -subsystem console -cwd include
202        [ opt --release : -runtime ss -opt full -inline all ]
203        [ opt --debug : -runtime ssd -opt none -inline off ]
204        -I$(--python-include) ;
205    toolset metrowerks $(mwcc) .link : "-o " :
206        : -subsystem console -lkernel32.lib -ladvapi32.lib -luser32.lib
207        [ opt --release : -runtime ss ]
208        [ opt --debug : -runtime ssd ]
209        : $(--python-lib[1]) ;
210}
211## MINGW GCC
212toolset mingw gcc : "-o " : -D
213    :
214    [ opt --release : -s -O3 -finline-functions ]
215    [ opt --debug : -g -O0 -fno-inline -pg ]
216    -I$(--python-include)
217    : $(--python-lib[2]) ;
218## MIPS Pro
219toolset mipspro cc : "-o " : -D
220    :
221    [ opt --release : -s -O3 -g0 -INLINE:none ]
222    [ opt --debug : -g -O0 -INLINE ]
223    -I$(--python-include)
224    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
225## Microsoft Visual Studio C++ 6.x
226toolset msvc cl : /Fe : -D
227    : /nologo
228    [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ]
229    [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ]
230    -I$(--python-include)
231    : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ;
232## QNX 6.x GCC 3.x/2.95.3
233toolset qcc qcc : "-o " : -D
234    : -Wc,-pedantic
235    [ opt --release : [ opt --symbols : -g ] -O3 -Wc,-finline-functions ]
236    [ opt --debug : -g -O0 -Wc,-fno-inline ]
237    -I$(--python-include)
238    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
239## Sun Workshop 6 C++
240toolset sunpro cc : "-o " : -D
241    :
242    [ opt --release : -s -fast -xO4 ]
243    [ opt --debug : -g ]
244    -xarch=generic
245    -I$(--python-include)
246    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
247## Compaq Alpha CXX
248toolset tru64cxx cc : "-o " : -D
249    :
250    [ opt --release : -s -O5 -inline speed ]
251    [ opt --debug : -g -O0 -pg ]
252    -I$(--python-include)
253    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
254## IBM VisualAge C++
255toolset vacpp xlc : "-o " : -D
256    :
257    [ opt --release : -s -O3 -qstrict -qinline ]
258    [ opt --debug : -g -qNOOPTimize -qnoinline -pg ]
259    -I$(--python-include)
260    : -L$(--python-lib[1]) -l$(--python-lib[2]) ;
261## Microsoft Visual C++ .NET 7.x
262toolset vc7 cl : /Fe : -D
263    : /nologo
264    [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ]
265    [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ]
266    -I$(--python-include)
267    : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ;
268## Microsoft Visual C++ 2005
269toolset vc8 cl : /Fe : -D
270    : /nologo
271    [ opt --release : /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ]
272    [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ]
273    -I$(--python-include)
274    : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ;
275## VMS/OpenVMS DEC C
276toolset vmsdecc cc : /OBJECT= : "/DEFINES=(" "," ")"
277    : /STANDARD=VAXC /PREFIX_LIBRARY_ENTRIES=ALL_ENTRIES
278    [ opt --release : /OPTIMIZE /NODEBUG ]
279    [ opt --debug : /NOOPTIMIZE /DEBUG ]
280    ;
281toolset vmsdecc link .link : /EXECUTABLE= :
282    : /NOMAP
283    [ opt --release : /NODEBUG ]
284    [ opt --debug : /DEBUG ]
285    ;
286
287# First set the build commands and options according to the
288# preset toolset.
289toolset = [ MATCH --toolset=(.*) : $(ARGV) ] ;
290if ! $(toolset)
291{
292    # For some reason, the following test does not catch
293    # empty toolset.
294    ECHO "###" ;
295    ECHO "###" No toolset specified. Please use --toolset option. ;
296    ECHO "###" ;
297    ECHO "###" Known toolsets are: $(toolsets:J=", ") ;
298    EXIT "###" ;   
299}
300if ! $(toolset) in $(toolsets)
301{
302    ECHO "###" ;
303    ECHO "###" Unknown toolset: $(toolset) ;
304    ECHO "###" ;
305    ECHO "###" Known toolsets are: $(toolsets:J=", ") ;
306    EXIT "###" ;
307}
308--cc = $(tool.$(toolset).cc) ;
309if $(tool.$(toolset).opt.out[2])
310{
311    --bin = $(tool.$(toolset).opt.out[1]) ;
312    --dir = $(tool.$(toolset).opt.out[2]) ;
313}
314else
315{
316    --out = $(tool.$(toolset).opt.out) ;
317}
318--def = $(tool.$(toolset).opt.define) ;
319--flags = $(tool.$(toolset).flags) ;
320--defs = $(tool.$(toolset).defines) ;
321--libs = $(tool.$(toolset).linklibs) ;
322if $(tool.$(toolset).link.cc)
323{
324    --link = $(tool.$(toolset).link.cc) ;
325    if $(tool.$(toolset).link.opt.out[2])
326    {
327        --link-bin = $(tool.$(toolset).link.opt.out[1]) ;
328        --link-dir = $(tool.$(toolset).link.opt.out[2]) ;
329    }
330    else
331    {
332        --link-out = $(tool.$(toolset).link.opt.out) ;
333    }
334    --link-def = $(tool.$(toolset).link.opt.define) ;
335    --link-flags = $(tool.$(toolset).link.flags) ;
336    --link-defs = $(tool.$(toolset).link.defines) ;
337    --link-libs = $(tool.$(toolset).link.linklibs) ;
338}
339
340# Put executables in platform-specific subdirectory.
341locate-target = $(LOCATE_TARGET) ;
342if $(VMS)
343{
344    locate-target ?= bin$(.)vms ;
345    platform = vms ;
346}
347else if $(MAC)
348{
349    locate-target ?= bin$(.)$(OS:L)$(OSPLAT:L) ;
350    platform = $(OS:L)$(OSPLAT:L) ;
351}
352else if $(OSPLAT)
353{
354    locate-target ?= bin$(.)$(OS:L)$(OSPLAT:L) ;
355    platform = $(OS:L)$(OSPLAT:L) ;
356}
357else
358{
359    locate-target ?= bin$(.)$(OS:L) ;
360    platform = $(OS:L) ;
361}
362if $(debug)
363{
364    locate-target = [ .path $(locate-target)$(.)debug ] ;
365}
366else
367{
368    locate-target = [ .path $(locate-target) ] ;
369}
370
371if --show-locate-target in $(ARGV)
372{
373  ECHO $(locate-target) ;
374}
375
376# We have some different files for UNIX, VMS, and NT.
377jam.source =
378    command.c compile.c debug.c expand.c glob.c
379    hash.c hcache.c headers.c hdrmacro.c
380    jam.c jambase.c jamgram.c
381    lists.c make.c make1.c newstr.c
382    option.c parse.c regexp.c rules.c
383    scan.c search.c subst.c w32_getreg.c
384    timestamp.c variable.c modules.c strings.c filesys.c
385    builtins.c pwd.c class.c native.c modules/set.c
386    modules/path.c modules/regex.c modules/property-set.c
387    modules/sequence.c modules/order.c
388    ;
389if $(NT)
390{
391    jam.source += execnt.c filent.c pathunix.c ;
392}
393else if $(OS2)
394{
395    jam.source += execunix.c fileos2.c pathunix.c ;
396}
397else if $(VMS)
398{
399    jam.source += execvms.c filevms.c pathvms.c ;
400}
401else if $(MAC)
402{
403    jam.source += execmac.c filemac.c pathmac.c ;
404}
405else
406{
407    jam.source += execunix.c fileunix.c pathunix.c ;
408}
409
410# Debug assertions, or not.
411if ! $(debug) || --noassert in $(ARGV)
412{
413    --defs += NDEBUG ;
414}
415
416# Enable some optional features.
417--defs += OPT_HEADER_CACHE_EXT ;
418--defs += OPT_GRAPH_DEBUG_EXT ;
419--defs += OPT_SEMAPHORE ;
420--defs += OPT_AT_FILES ;
421
422# Bug fixes
423--defs += OPT_FIX_TARGET_VARIABLES_EXT ;
424#~ --defs += OPT_NO_EXTERNAL_VARIABLE_SPLIT ;
425
426# Improvements
427--defs += OPT_IMPROVED_PATIENCE_EXT ;
428
429if ( $(OS) = NT || $(NT) ) && ! NT in $(--defs)
430{
431    --defs += NT ;
432}
433if $(VMS)
434{
435    --defs += VMS ;
436}
437--defs += YYSTACKSIZE=5000 ;
438
439if $(with-python)
440{
441    --defs += HAVE_PYTHON ;
442}
443
444
445
446# The basic symbolic targets...
447NOTFILE all clean dist ;
448ALWAYS clean ;
449
450# Utility rules and actions...
451rule .clean
452{
453    [DELETE] clean : $(<) ;
454}
455if $(NT) { actions piecemeal together existing [DELETE] {
456    del /F /Q $(>)
457} }
458if $(UNIX) { actions piecemeal together existing [DELETE] {
459    rm -f $(>)
460} }
461if $(VMS) { actions piecemeal together existing [DELETE] {
462    DELETE $(>[--2]:J=";*, ") $(>[-1]);*
463} }
464if $(NT) {
465    --chmod+w = "attrib -r " ;
466}
467if $(UNIX) {
468    --chmod+w = "chmod +w " ;
469}
470if $(VMS) {
471    --chmod+w = "SET FILE/PROT=(S:RWED) " ;
472}
473
474rule .mkdir
475{
476    NOUPDATE $(<) ;
477    if $(<:P) { DEPENDS $(<) : $(<:P) ; .mkdir $(<:P) ; }
478    if ! $(md<$(<)>) { [MKDIR] $(<) ; md<$(<)> = - ; }
479}
480if $(NT) { actions [MKDIR] {
481    md $(<)
482} }
483if $(UNIX) { actions [MKDIR] {
484    mkdir $(<)
485} }
486if $(VMS) { actions [MKDIR] {
487    CREATE/DIR $(<J=", ")
488} }
489
490rule .exe
491{
492    local exe = $(<) ;
493    if $(NT) || ( $(UNIX) && $(OS) = CYGWIN ) || $(VMS) { exe = $(exe:S=.exe) ; }
494    LOCATE on $(exe) = $(locate-target) ;
495    DEPENDS all : $(exe) ;
496    .mkdir $(locate-target) ;
497    if $(--link)
498    {
499        local objs = ;
500        for local s in $(>)
501        {
502            # Translate any subdir elements into a simple file name.
503            local o = [ MATCH "([^/]+)[/]?(.+)" : $(s) ] ;
504            o = $(o:J=_) ;
505            o = $(o:S=.o) ;
506            objs += $(o) ;
507            LOCATE on $(o) = $(locate-target) ;
508            DEPENDS $(exe) : $(o) ;
509            DEPENDS $(o) : $(s) ;
510            DEPENDS $(o) : $(locate-target) ;
511            [COMPILE] $(o) : $(s) ;
512            .clean $(o) ;
513        }
514        DEPENDS $(exe) : $(objs) ;
515        DEPENDS $(exe) : $(locate-target) ;
516        [COMPILE.LINK] $(exe) : $(objs) ;
517        .clean $(exe) ;
518    }
519    else
520    {
521        DEPENDS $(exe) : $(>) ;
522        DEPENDS $(exe) : $(locate-target) ;
523        [COMPILE] $(exe) : $(>) ;
524        .clean $(exe) ;
525    }
526    return $(exe) ;
527}
528if ! $(--def[2]) { actions [COMPILE] {
529    "$(--cc)" $(--bin)$(<:D=) $(--dir)$(<:D) $(--out)$(<) $(--def)$(--defs) $(--flags) "$(--libs)" $(>)
530} }
531else { actions [COMPILE] {
532    "$(--cc)" $(--bin)$(<:D=) $(--dir)$(<:D) $(--out)$(<) $(--def[1])$(--defs:J=$(--def[2]))$(--def[3]) $(--flags) "$(--libs)" $(>)
533} }
534if $(VMS) { actions [COMPILE.LINK] {
535    "$(--link)" $(--link-bin)$(<:D=) $(--link-dir)$(<:D) $(--link-out)$(<) $(--link-def)$(--link-defs) $(--link-flags) "$(--link-libs)" $(>J=", ")
536} }
537else { actions [COMPILE.LINK] {
538    "$(--link)" $(--link-bin)$(<:D=) $(--link-dir)$(<:D) $(--link-out)$(<) $(--link-def)$(--link-defs) $(--link-flags) "$(--link-libs)" $(>)
539} }
540
541rule .link
542{
543    DEPENDS all : $(<) ;
544    DEPENDS $(<) : $(>) ;
545    [LINK] $(<) : $(>) ;
546    .clean $(<) ;
547}
548if $(NT) { actions [LINK] {
549    copy $(>) $(<)
550} }
551if $(UNIX) { actions [LINK] {
552    ln -fs $(>) $(<)
553} }
554if $(VMS) { actions [LINK] {
555    COPY/REPLACE $(>) $(<)
556} }
557
558rule .move
559{
560    DEPENDS $(<) : $(>) ;
561    [MOVE] $(<) : $(>) ;
562}
563if $(NT) { actions [MOVE] {
564    del /f $(<)
565    rename $(>) $(<)
566} }
567if $(UNIX) { actions [MOVE] {
568    mv -f $(>) $(<)
569} }
570if $(VMS) { actions [MOVE] {
571    RENAME $(>) $(<)
572} }
573
574# Generate the grammar tokens table, and the real yacc grammar.
575rule .yyacc
576{
577    local exe = [ .exe yyacc : yyacc.c ] ;
578    NOUPDATE $(exe) ;
579    DEPENDS $(<) : $(exe) $(>) ;
580    LEAVES $(<) ;
581    yyacc.exe on $(<) = $(exe:R=$(locate-target)) ;
582    [YYACC] $(<) : $(>) ;
583}
584actions [YYACC] {
585    $(--chmod+w)$(<[1])
586    $(--chmod+w)$(<[2])
587    "$(yyacc.exe)" $(<) $(>)
588}
589if $(grammar)
590{
591    .yyacc jamgram.y jamgramtab.h : jamgram.yy ;
592}
593else if $(debug)
594{
595    .exe yyacc : yyacc.c ;
596}
597
598# How to build the grammar.
599if $(NT)
600{
601    SUFEXE = .exe ;
602    # try some other likely spellings...
603    PATH ?= $(Path) ;
604    PATH ?= $(path) ;
605}
606SUFEXE ?= "" ;
607
608yacc ?= [ GLOB $(PATH) : yacc$(SUFEXE) ] ;
609yacc ?= [ GLOB $(PATH) : bison$(SUFEXE) ] ;
610yacc ?= [ GLOB "$(ProgramFiles:J= )\\GnuWin32\\bin" "C:\\Program Files\\GnuWin32\\bin" : bison$(SUFEXE) ] ;
611yacc = $(yacc[1]) ;
612switch $(yacc:D=:S=)
613{
614    case bison : yacc += -d --yacc ;
615    case yacc  : yacc += -d ;
616}
617if $(debug) && $(yacc)
618{
619    yacc += -t -v ;
620}
621yacc += $(YACCFLAGS) ;
622
623rule .yacc
624{
625    DEPENDS $(<) : $(>) ;
626    LEAVES $(<) ;
627    [YACC] $(<) : $(>) ;
628}
629if $(NT) { actions [YACC] {
630    "$(yacc)" $(>)
631    if not errorlevel 1 (
632        del /f $(<[1])
633        rename y.tab$(<[1]:S) $(<[1])
634        del /f $(<[2])
635        rename y.tab$(<[2]:S) $(<[2])
636    ) else set _error_ =
637} }
638if $(UNIX) { actions [YACC] {
639    if ` "$(yacc)" $(>) ` ; then
640        mv -f y.tab$(<[1]:S) $(<[1])
641        mv -f y.tab$(<[2]:S) $(<[2])
642    else
643        exit 1
644    fi
645} }
646if $(VMS) { actions [YACC] {
647    IF "$(yacc)" $(>)
648    THEN
649        RENAME y_tab$(<[1]:S) $(<[1])
650        RENAME y_tab$(<[2]:S) $(<[2])
651    ENDIF
652} }
653if $(grammar) && ! $(yacc)
654{
655    EXIT "Could not find the 'yacc' tool, and therefore can not build the grammar." ;
656}
657if $(grammar) && $(yacc)
658{
659    .yacc jamgram.c jamgram.h : jamgram.y ;
660}
661
662# How to build the compiled in jambase.
663rule .mkjambase
664{
665    local exe = [ .exe mkjambase : mkjambase.c ] ;
666    DEPENDS $(<) : $(exe) $(>) ;
667    LEAVES $(<) ;
668    mkjambase.exe on $(<) = $(exe:R=$(locate-target)) ;
669    [MKJAMBASE] $(<) : $(>) ;
670}
671actions [MKJAMBASE] {
672    $(--chmod+w)$(<)
673    $(mkjambase.exe) $(<) $(>)
674}
675if $(debug)
676{
677    .mkjambase jambase.c : Jambase ;
678}
679
680# How to build Jam.
681rule .jam
682{
683    $(>).exe = [ .exe $(>) : $(jam.source) ] ;
684    DEPENDS all : $($(>).exe) ;
685   
686    if $(debug)
687    {
688        $(<).exe = $(<:S=$($(>).exe:S)) ;
689        LOCATE on $($(<).exe) = $(locate-target) ;
690        .link $($(<).exe) : $($(>).exe) ;
691        DEPENDS all : $($(<).exe) ;
692    }
693}
694.jam jam : bjam ;
695
696# Scan sources for header dependencies.
697#       WARNING: Yes those are *REAL TABS* below. DO NOT CHANGE,
698#       under any circumstances, to spaces!! And the tabs
699#       indenting this are so that if someone is in the mood to
700#       replace tabs they hit this comment, and hopefully notice
701#       their error.
702rule .scan
703{
704    HDRRULE on $(<:D=) = .hdr.scan ;
705    HDRSCAN on $(<:D=) = "^[    ]*#[    ]*include[      ]*([<\"][^\">]*[\">]).*$" ;
706}
707rule .hdr.scan
708{
709    local hdrs = [ GLOB . : $(>:D=) ] ;
710    INCLUDES $(<:D=) : $(hdrs:D=) ;
711    HDRRULE on $(>:D=) = .hdr.scan ;
712    HDRSCAN on $(>:D=) = "^[    ]*#[    ]*include[      ]*([<\"][^\">]*[\">]).*$" ;
713}
714.scan [ GLOB . : *.c ] ;
715
716# Distribution making from here on out. Assumes that
717# the docs are already built as html at ../doc/html. If
718# they aren't, then the docs are not included in the dist
719# archive.
720dist.license =
721    [ GLOB . : $(LICENSE).txt ]
722    ;
723dist.license = $(dist.license:D=)
724    [ GLOB [ .path .. .. .. ] : $(LICENSE).txt ]
725    [ GLOB [ .path .. boost ] : $(LICENSE).txt ] ;
726dist.docs =
727    [ GLOB . : *.png *.css *.html ]
728    ;
729dist.docs = $(dist.docs:D=)
730    [ GLOB [ .path images ] : *.png ]
731    [ GLOB [ .path jam ] : *.html ]
732    ;
733dist.source =
734    [ GLOB . : *.c *.h ]
735    ;
736dist.source = $(dist.source:D=)
737    $(dist.license[1])
738    $(dist.docs)
739    build.jam build.bat build.sh build_vms.com
740    Jambase
741    jamgram.y jamgram.yy
742    [ .path debian changelog ]
743    [ .path debian control ]
744    [ .path debian copyright ]
745    [ .path debian jam.man.sgml ]
746    [ .path debian rules ]
747    [ .path modules set.c ]
748    [ .path modules path.c ]
749    [ .path modules regex.c ]
750    [ .path modules property-set.c ]
751    [ .path modules sequence.c ]
752    [ .path modules order.c ]
753    boost-jam.spec
754    ;
755dist.bin =
756    bjam
757    ;
758dist.bin =
759    $(dist.license[1])
760    $(dist.bin:S=$(bjam.exe:S))
761    ;
762
763if $(NT)
764{
765    zip ?= [ GLOB "$(ProgramFiles:J= )\\7-ZIP" "C:\\Program Files\\7-ZIP" : "7z.exe" ] ;
766    zip ?= [ GLOB "$(ProgramFiles:J= )\\7-ZIP" "C:\\Program Files\\7-ZIP" : "7zn.exe" ] ;
767    zip ?= [ GLOB $(PATH) : zip.exe ] ;
768    zip ?= zip ;
769    zip = $(zip[1]) ;
770    switch $(zip:D=:S=)
771    {
772        case 7z* : zip += a -r -tzip -mx=9 ;
773        case zip  : zip += -9r ;
774    }
775    actions piecemeal [PACK] {
776    "$(zip)" "$(<)" "$(>)"
777    }
778    actions piecemeal [ZIP] {
779    "$(zip)" "$(<)" "$(>)"
780    }
781    actions piecemeal [COPY] {
782    copy /Y "$(>)" "$(<)" >NUL:
783    }
784}
785if $(UNIX)
786{
787    actions [PACK] {
788    tar zcf "$(<)" "$(>)"
789    }
790    actions [ZIP] {
791    gzip -c9 "$(>)" > "$(<)"
792    }
793    actions [COPY] {
794    cp -Rpf "$(>)" "$(<)"
795    }
796}
797
798# The single binary, compressed.
799rule .binary
800{
801    local zip = ;
802    if $(NT) { zip = $($(<).exe:S=.zip) ; }
803    if $(UNIX) { zip = $($(<).exe:S=.tgz) ; }
804    zip = $(zip:S=)-$(VERSION)-$(RELEASE)-$(platform)$(zip:S) ;
805    DEPENDS $(zip) : $($(<).exe) ;
806    DEPENDS dist : $(zip) ;
807    #~ LOCATE on $(zip) = $(locate-target) ;
808    if $(NT) { [ZIP] $(zip) : $($(<).exe) ; }
809    if $(UNIX) { [PACK] $(zip) : $($(<).exe) ; }
810    .clean $(zip) ;
811}
812
813# Package some file.
814rule .package ( dst-dir : src-files + )
815{
816    local dst-files ;
817    for local src-path in $(src-files)
818    {
819        local src-subdir = $(src-path:D) ;
820        local src-file = $(src-path) ;
821        while $(src-subdir:D) { src-subdir = $(src-subdir:D) ; }
822        if $(src-subdir) = ".."
823        {
824            src-file = $(src-file:D=) ;
825        }
826        dst-files += $(src-file:R=$(dst-dir)) ;
827    }
828   
829    local pack = ;
830    if $(NT) { pack = $(dst-dir).zip ; }
831    if $(UNIX) { pack = $(dst-dir).tgz ; }
832   
833    DEPENDS dist : $(pack) ;
834    DEPENDS $(pack) : $(dst-files) ;
835   
836    local dst-files-queue = $(dst-files) ;
837    for local src-path in $(src-files)
838    {
839        local dst-file = $(dst-files-queue[1]) ;
840        dst-files-queue = $(dst-files-queue[2-]) ;
841        DEPENDS $(dst-file) : $(src-path) $(dst-file:D) ;
842        .mkdir $(dst-file:D) ;
843       
844        [COPY] $(dst-file) : $(src-path) ;
845        .clean $(dst-file) ;
846    }
847   
848    [PACK] $(pack) : $(dst-files) ;
849    .clean $(pack) ;
850}
851
852# RPM distro file.
853rpm-tool = [ GLOB $(PATH) : "rpmbuild" ] ;
854rpm-tool ?= [ GLOB $(PATH) : "rpm" ] ;
855rpm-tool = $(rpm-tool[1]) ;
856rule .rpm ( name : source )
857{
858    local rpm-arch = ;
859    switch $(OSPLAT)
860    {
861        case X86       : rpm-arch ?= i386 ;
862        case PPC       : rpm-arch ?= ppc ;
863        case AXP       : rpm-arch ?= alpha ;
864        # no guaranty for these:
865        case IA64      : rpm-arch ?= ia64 ;
866        case ARM       : rpm-arch ?= arm ;
867        case SPARC     : rpm-arch ?= sparc ;
868        case *         : rpm-arch ?= other ;
869    }
870    local target = $(name)-rpm ;
871    NOTFILE $(target) ;
872    DEPENDS dist : $(target) ;
873    DEPENDS $(target) : $(name).$(rpm-arch).rpm $(name).src.rpm ;
874    DEPENDS $(name).$(rpm-arch).rpm : $(source) ;
875    DEPENDS $(name).src.rpm : $(name).$(rpm-arch).rpm ;
876    docs on $(target) = $(dist.docs:J=" ") ;
877    arch on $(target) = $(rpm-arch) ;
878    if $(rpm-arch) = ppc { target-opt on $(target) = --target= ; }
879    else { target-opt on $(target) = "--target " ; }
880    [RPM] $(target) : $(source) ;
881    .clean $(name).$(rpm-arch).rpm $(name).src.rpm ;
882}
883actions [RPM] {
884    set -e
885    export BOOST_JAM_TOOLSET="$(toolset)"
886    $(rpm-tool) -ta $(target-opt)$(arch) $(>) | tee rpm.out
887    cp `grep -e '^Wrote:' rpm.out | sed 's/^Wrote: //'` .
888    rm -f rpm.out
889}
890
891# The distribution targets. Don't bother with the targets if
892# distribution build not requested.
893if dist in $(ARGV)
894{
895    #~ .binary bjam ;
896    .package $(NAME)-$(VERSION) : $(dist.source) ;
897    .package $(NAME)-$(VERSION)-$(RELEASE)-$(platform) : $(dist.bin) ;
898    if $(rpm-tool)
899    {
900        .rpm $(NAME)-$(VERSION)-$(RELEASE) : $(NAME)-$(VERSION).tgz ;
901    }
902}
Note: See TracBrowser for help on using the repository browser.