1#
2# /+\
3# +\    Copyright 1993, 2000 Christopher Seiwald.
4# \+/
5#
6# This file is part of Jam - see jam.c for Copyright information.
7#
8
9# This file is ALSO:
10# Copyright 2001-2004 David Abrahams.
11# Copyright 2002-2004 Rene Rivera.
12# Distributed under the Boost Software License, Version 1.0.
13# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
14
15if $(NT)
16{
17    SLASH ?= \\ ;
18}
19SLASH ?= / ;
20
21
22# Glob for patterns in the directories starting from the given start directory,
23# up to and including the root of the file-system. We stop globbing as soon as
24# we find at least one match.
25#
26rule find-to-root ( dir : patterns + )
27{
28    local globs = [ GLOB $(dir) : $(patterns) ] ;
29    while ! $(globs) && $(dir:P) != $(dir)
30    {
31        dir = $(dir:P) ;
32        globs = [ GLOB $(dir) : $(patterns) ] ;
33    }
34    return $(globs) ;
35}
36
37
38# This global will hold the location of the user's boost-build.jam file.
39.boost-build-file = ;
40
41# This global will hold the location of the build system bootstrap file.
42.bootstrap-file = ;
43
44# Remember the value of $(BOOST_BUILD_PATH) supplied to us by the user.
45BOOST_BUILD_PATH.user-value = $(BOOST_BUILD_PATH) ;
46
47# On Unix only, when BOOST_BUILD_PATH is not supplied by the user, set it to a
48# sensible default value. This allows Boost.Build to work without any
49# environment variables, which is good in itself and also required by the Debian
50# Policy.
51if ! $(BOOST_BUILD_PATH) && $(UNIX)
52{
53    BOOST_BUILD_PATH = /usr/share/boost-build ;
54}
55
56
57rule _poke ( module-name ? : variables + : value * )
58{
59    module $(<)
60    {
61        $(>) = $(3) ;
62    }
63}
64
65
66# This rule can be invoked from an optional user's boost-build.jam file to both
67# indicate where to find the build system files, and to load them. The path
68# indicated is relative to the location of the boost-build.jam file.
69#
70rule boost-build ( dir ? )
71{
72    if $(.bootstrap-file)
73    {
74        ECHO "Error: Illegal attempt to re-bootstrap the build system by invoking" ;
75        ECHO ;
76        ECHO "   'boost-build" $(dir) ";'" ;
77        ECHO ;
78        EXIT "Please consult the documentation at 'http://www.boost.org'." ;
79    }
80
81    # Add the given directory to the path so we can find the build system. If
82    # dir is empty, has no effect.
83    BOOST_BUILD_PATH = $(dir:R=$(.boost-build-file:D)) $(BOOST_BUILD_PATH) ;
84
85    # We might have just modified the *global* value of BOOST_BUILD_PATH. The
86    # code that loads the rest of Boost.Build, in particular the site-config.jam
87    # and user-config.jam configuration files uses os.environ, so we need to
88    # update the value there.
89    _poke .ENVIRON : BOOST_BUILD_PATH : $(BOOST_BUILD_PATH) ;
90
91    # Try to find the build system bootstrap file 'bootstrap.jam'.
92    local bootstrap-file = [ GLOB $(BOOST_BUILD_PATH) : bootstrap.jam ] ;
93    .bootstrap-file = $(bootstrap-file[1]) ;
94
95    # There is no bootstrap.jam we can find, exit with an error.
96    if ! $(.bootstrap-file)
97    {
98        ECHO "Unable to load Boost.Build: could not find build system." ;
99        ECHO --------------------------------------------------------- ;
100        ECHO "$(.boost-build-file) attempted to load the build system by invoking" ;
101        ECHO ;
102        ECHO "   'boost-build" $(dir) ";'" ;
103        ECHO ;
104        ECHO "but we were unable to find \"bootstrap.jam\" in the specified directory" ;
105        ECHO "or in BOOST_BUILD_PATH (searching "$(BOOST_BUILD_PATH:J=", ")")." ;
106        ECHO ;
107        EXIT "Please consult the documentation at 'http://www.boost.org'." ;
108    }
109
110    if [ MATCH .*(--debug-configuration).* : $(ARGV) ]
111    {
112        ECHO "notice: loading Boost.Build from"
113            [ NORMALIZE_PATH $(.bootstrap-file:D) ] ;
114    }
115
116    # Load the build system, now that we know where to start from.
117    include $(.bootstrap-file) ;
118}
119
120
121if [ MATCH .*(b2).* : $(ARGV[1]:BL) ]
122  || [ MATCH .*(bjam).* : $(ARGV[1]:BL) ]
123  || $(BOOST_ROOT)    # A temporary measure so Jam works with Boost.Build v1.
124{
125    # We attempt to load "boost-build.jam" by searching from the current
126    # invocation directory up to the root of the file-system.
127    #
128    # boost-build.jam is expected to invoke the "boost-build" rule to load the
129    # Boost.Build files.
130
131    local search-path = $(BOOST_BUILD_PATH) $(BOOST_ROOT) ;
132    local self = [ SELF_PATH ] ;
133    local boost-build-relative = ../../share/boost-build ;
134    local self-based-path = [ NORMALIZE_PATH $(boost-build-relative:R=$(self)) ] ;
135
136    local boost-build-files =
137        [ find-to-root [ PWD ] : boost-build.jam ]
138        [ GLOB $(self-based-path) : boost-build.jam ]
139        # Another temporary measure so Jam works with Boost.Build v1.
140        [ GLOB $(search-path) : boost-build.jam ] ;
141
142    .boost-build-file = $(boost-build-files[1]) ;
143
144    # There is no boost-build.jam we can find, exit with an error, and
145    # information.
146    if ! $(.boost-build-file)
147    {
148        ECHO "Unable to load Boost.Build: could not find \"boost-build.jam\"" ;
149        ECHO --------------------------------------------------------------- ;
150
151        if ! [ MATCH .*(bjam).* : $(ARGV[1]:BL) ]
152        {
153            ECHO "BOOST_ROOT must be set, either in the environment, or " ;
154            ECHO "on the command-line with -sBOOST_ROOT=..., to the root" ;
155            ECHO "of the boost installation." ;
156            ECHO ;
157        }
158
159        ECHO "Attempted search from" [ PWD ] "up to the root" ;
160        ECHO "at" $(self-based-path) ;
161        ECHO "and in these directories from BOOST_BUILD_PATH and BOOST_ROOT: "$(search-path:J=", ")"." ;
162        EXIT "Please consult the documentation at 'http://www.boost.org'." ;
163    }
164
165    if [ MATCH .*(--debug-configuration).* : $(ARGV) ]
166    {
167        ECHO "notice: found boost-build.jam at"
168            [ NORMALIZE_PATH $(.boost-build-file) ] ;
169    }
170
171    # Now load the boost-build.jam to get the build system loaded. This
172    # incidentaly loads the users jamfile and attempts to build targets.
173    #
174    # We also set it up so we can tell whether we are loading the new V2 system
175    # or the the old V1 system.
176    include $(.boost-build-file) ;
177
178    # Check that, at minimum, the bootstrap file was found.
179    if ! $(.bootstrap-file)
180    {
181        ECHO "Unable to load Boost.Build" ;
182        ECHO -------------------------- ;
183        ECHO "\"$(.boost-build-file)\" was found by searching from" [ PWD ] "up to the root" ;
184        ECHO "and in these directories from BOOST_BUILD_PATH and BOOST_ROOT: "$(search-path:J=", ")"." ;
185        ECHO ;
186        ECHO "However, it failed to call the \"boost-build\" rule to indicate" ;
187        ECHO "the location of the build system." ;
188        ECHO ;
189        EXIT "Please consult the documentation at 'http://www.boost.org'." ;
190    }
191}
192else
193{
194
195#
196# JAMBASE - jam 2.3 ruleset providing make(1)-like functionality
197#
198# Supports UNIX, NT, and VMS.
199#
200# 12/27/93 (seiwald) - purturb library sources with SOURCE_GRIST
201# 04/18/94 (seiwald) - use '?=' when setting OS specific vars
202# 04/21/94 (seiwald) - do RmTemps together
203# 05/05/94 (seiwald) - all supported C compilers support -o: relegate
204#              RELOCATE as an option; set Ranlib to "" to disable it
205# 06/01/94 (seiwald) - new 'actions existing' to do existing sources
206# 08/25/94 (seiwald) - new ObjectCcFlags rule to append to per-target CCFLAGS
207# 08/29/94 (seiwald) - new ObjectHdrs rule to append to per-target HDRS
208# 09/19/94 (seiwald) - LinkLibraries and Undefs now append
209#            - Rule names downshifted.
210# 10/06/94 (seiwald) - Dumb yyacc stuff moved into Jamfile.
211# 10/14/94 (seiwald) - (Crude) support for .s, .C, .cc, .cpp, and .f files.
212# 01/08/95 (seiwald) - Shell now handled with awk, not sed
213# 01/09/95 (seiwald) - Install* now take dest directory as target
214# 01/10/95 (seiwald) - All entries sorted.
215# 01/10/95 (seiwald) - NT support moved in, with LauraW's help.
216# 01/10/95 (seiwald) - VMS support moved in.
217# 02/06/95 (seiwald) - ObjectC++Flags and SubDirC++Flags added.
218# 02/07/95 (seiwald) - Iron out when HDRSEARCH uses "" or SEARCH_SOURCE.
219# 02/08/95 (seiwald) - SubDir works on VMS.
220# 02/14/95 (seiwald) - MkDir and entourage.
221# 04/30/95 (seiwald) - Use install -c flag so that it copies, not moves.
222# 07/10/95 (taylor) - Support for Microsoft C++.
223# 11/21/96 (peterk) - Support for BeOS
224# 07/19/99 (sickel) - Support for Mac OS X Server (and maybe client)
225# 02/18/00 (belmonte)- Support for Cygwin.
226
227# Special targets defined in this file:
228#
229# all       - parent of first, shell, files, lib, exe
230# first     - first dependency of 'all', for potential initialization
231# shell     - parent of all Shell targets
232# files     - parent of all File targets
233# lib       - parent of all Library targets
234# exe       - parent of all Main targets
235# dirs      - parent of all MkDir targets
236# clean     - removes all Shell, File, Library, and Main targets
237# uninstall - removes all Install targets
238#
239
240# Rules defined by this file:
241#
242# as obj.o : source.s ;         .s -> .o
243# Bulk dir : files ;            populate directory with many files
244# Cc obj.o : source.c ;         .c -> .o
245# C++ obj.o : source.cc ;       .cc -> .o
246# Clean clean : sources ;       remove sources with 'jam clean'
247# File dest : source ;          copy file
248# Fortran obj.o : source.f ;        .f -> .o
249# GenFile source.c : program args ; make custom file
250# Hardlink target : source ;        make link from source to target
251# HdrRule source : headers ;        handle #includes
252# InstallInto dir : sources ;       install any files
253# InstallBin dir : sources ;        install binaries
254# InstallLib dir : sources ;        install files
255# InstallFile dir : sources ;       install files
256# InstallMan dir : sources ;        install man pages
257# InstallShell dir : sources ;      install shell scripts
258# Lex source.c : source.l ;     .l -> .c
259# Library lib : source ;        archive library from compiled sources
260# LibraryFromObjects lib : objects ;    archive library from objects
261# LinkLibraries images : libraries ;    bag libraries onto Mains
262# Main image : source ;         link executable from compiled sources
263# MainFromObjects image : objects ; link executable from objects
264# MkDir dir ;               make a directory, if not there
265# Object object : source ;      compile object from source
266# ObjectCcFlags source : flags ;    add compiler flags for object
267# ObjectC++Flags source : flags ;   add compiler flags for object
268# ObjectHdrs source : dirs ;        add include directories for object
269# Objects sources ;         compile sources
270# RmTemps target : sources ;        remove temp sources after target made
271# Setuid images ;           mark executables Setuid
272# SubDir TOP d1 d2 ... ;        start a subdirectory Jamfile
273# SubDirCcFlags flags ;         add compiler flags until next SubDir
274# SubDirC++Flags flags ;        add compiler flags until next SubDir
275# SubDirHdrs dirs ;         add include dirs until next SubDir
276# SubInclude TOP d1 d2 ... ;        include a subdirectory Jamfile
277# Shell exe : source ;          make a shell executable
278# Undefines images : symbols ;      save undef's for linking
279# UserObject object : source ;      handle unknown suffixes for Object
280# Yacc source.c : source.y ;        .y -> .c
281#
282# Utility rules that have no side effects (not supported):
283#
284# FAppendSuffix f1 f2 ... : $(SUF) ;    return $(<) with suffixes
285# FConcat value ... ;               return contatenated values
286# FDirName d1 d2 ... ;          return path from root to dir
287# FGrist d1 d2 ... ;            return d1!d2!...
288# FGristFiles value ;           return $(value:G=$(SOURCE_GRIST))
289# FGristSourceFiles value ;     return $(value:G=$(SOURCE_GRIST))
290# FRelPath d1 : d2 ;            return rel path from d1 to d2
291# FSubDir d1 d2 ... ;           return path to root
292#
293
294
295# Brief review of the jam language:
296#
297# Statements:
298#   rule RULE - statements to process a rule
299#   actions RULE - system commands to carry out target update
300#
301# Modifiers on actions:
302#   together - multiple instances of same rule on target get executed
303#          once with their sources ($(>)) concatenated
304#   updated - refers to updated sources ($(>)) only
305#   ignore - ignore return status of command
306#   quietly - don't trace its execution unless verbose
307#   piecemeal - iterate command each time with a small subset of $(>)
308#   existing - refers to currently existing sources ($(>)) only
309#   bind vars - subject to binding before expanding in actions
310#
311# Special rules:
312#   ALWAYS - always build a target
313#   DEPENDS - builds the dependency graph
314#   ECHO - blurt out targets on stdout
315#   EXIT - blurt out targets and exit
316#   INCLUDES - marks sources as headers for target (a codependency)
317#   NOCARE - don't panic if the target can't be built
318#   NOUPDATE - create the target if needed but never update it
319#   NOTFILE - ignore the timestamp of the target (it's not a file)
320#   TEMPORARY - target need not be present if sources haven't changed
321#
322# Special variables set by jam:
323#   $(<) - targets of a rule (to the left of the :)
324#   $(>) - sources of a rule (to the right of the :)
325#   $(xxx) - true on xxx (UNIX, VMS, NT, OS2, MAC)
326#   $(OS) - name of OS - varies wildly
327#   $(JAMVERSION) - version number (2.3)
328#
329# Special variables used by jam:
330#   SEARCH - where to find something (used during binding and actions)
331#   LOCATE - where to plop something not found with SEARCH
332#   HDRRULE - rule to call to handle include files
333#   HDRSCAN - egrep regex to extract include files
334#
335# Special targets:
336#   all - default if none given on command line
337#
338
339# Initialize variables
340#
341
342#
343# OS specific variable settings
344#
345if $(NT)
346{
347    # the list of supported toolsets on Windows NT and Windows 95/98
348    #
349    local SUPPORTED_TOOLSETS = "BORLANDC" "VC7" "VISUALC" "VISUALC16" "INTELC" "WATCOM"
350                               "MINGW" "LCC" ;
351
352    # this variable holds the current toolset
353    #
354    TOOLSET = "" ;
355
356    # if the JAM_TOOLSET environment variable is defined, check that it is
357    # one of our supported values
358    #
359    if $(JAM_TOOLSET)
360    {
361      local t ;
362
363      for t in $(SUPPORTED_TOOLSETS)
364      {
365        $(t) = $($(t):J=" ") ; # reconstitute paths with spaces in them
366        if $(t) = $(JAM_TOOLSET) { TOOLSET = $(t) ; }
367      }
368
369      if ! $(TOOLSET)
370      {
371        ECHO  "The JAM_TOOLSET environment variable is defined but its value" ;
372        ECHO  "is invalid, please use one of the following:" ;
373        ECHO  ;
374
375        for t in $(SUPPORTED_TOOLSETS) { ECHO "  " $(t) ; }
376        EXIT ;
377      }
378    }
379
380    # if TOOLSET is empty, we'll try to detect the toolset from other
381    # environment variables to remain backwards compatible with Jam 2.3
382    #
383    if ! $(TOOLSET)
384    {
385      if $(BCCROOT)
386      {
387        TOOLSET  = BORLANDC ;
388        BORLANDC = $(BCCROOT:J=" ") ;
389      }
390      else if $(MSVC)
391      {
392        TOOLSET   = VISUALC16 ;
393        VISUALC16 = $(MSVC:J=" ") ;
394      }
395      else if $(MSVCNT)
396      {
397        TOOLSET = VISUALC ;
398        VISUALC = $(MSVCNT:J=" ") ;
399      }
400      else if $(MSVCDir)
401      {
402        TOOLSET = VISUALC ;
403        VISUALC = $(MSVCDir:J=" ") ;
404      }
405      else if $(MINGW)
406      {
407        TOOLSET = MINGW ;
408      }
409      else
410      {
411        ECHO  "Jam cannot be run because, either:" ;
412        ECHO  "   a. You didn't set BOOST_ROOT to indicate the root of your" ;
413        ECHO  "      Boost installation." ;
414        ECHO  "   b. You are trying to use stock Jam but didn't indicate which" ;
415        ECHO  "      compilation toolset to use. To do so, follow these simple" ;
416        ECHO  "      instructions:" ;
417        ECHO  ;
418        ECHO  "  - define one of the following environment variable, with the" ;
419        ECHO  "    appropriate value according to this list:" ;
420        ECHO  ;
421        ECHO  "   Variable    Toolset                      Description" ;
422        ECHO  ;
423        ECHO  "   BORLANDC    Borland C++                  BC++ install path" ;
424        ECHO  "   VISUALC     Microsoft Visual C++         VC++ install path" ;
425        ECHO  "   VISUALC16   Microsoft Visual C++ 16 bit  VC++ 16 bit install" ;
426        ECHO  "   INTELC      Intel C/C++                  IC++ install path" ;
427        ECHO  "   WATCOM      Watcom C/C++                 Watcom install path" ;
428        ECHO  "   MINGW       MinGW (gcc)                  MinGW install path" ;
429        ECHO  "   LCC         Win32-LCC                    LCC-Win32 install path" ;
430        ECHO  ;
431        ECHO  "  - define the JAM_TOOLSET environment variable with the *name*" ;
432        ECHO  "    of the toolset variable you want to use." ;
433        ECHO  ;
434        ECHO  "  e.g.:  set VISUALC=C:\\Visual6" ;
435        ECHO  "         set JAM_TOOLSET=VISUALC" ;
436        EXIT  ;
437      }
438    }
439
440    CP          ?= copy ;
441    RM          ?= del /f/q ;
442    SLASH       ?= \\ ;
443    SUFLIB      ?= .lib ;
444    SUFOBJ      ?= .obj ;
445    SUFEXE      ?= .exe ;
446
447    if $(TOOLSET) = BORLANDC
448    {
449    ECHO "Compiler is Borland C++" ;
450
451    AR          ?= tlib /C /P64 ;
452    CC          ?= bcc32 ;
453    CCFLAGS     ?= -q -y -d -v -w-par -w-ccc -w-rch -w-pro -w-aus ;
454    C++         ?= bcc32 ;
455    C++FLAGS    ?= -q -y -d -v -w-par -w-ccc -w-rch -w-pro -w-aus -P ;
456    LINK        ?= $(CC) ;
457    LINKFLAGS   ?= $(CCFLAGS) ;
458    STDLIBPATH  ?= $(BORLANDC)\\lib ;
459    STDHDRS     ?= $(BORLANDC)\\include ;
460    NOARSCAN    ?= true ;
461    }
462    else if $(TOOLSET) = VISUALC16
463    {
464    ECHO "Compiler is Microsoft Visual C++ 16 bit" ;
465
466    AR          ?= lib /nologo ;
467    CC          ?= cl /nologo ;
468    CCFLAGS     ?= /D \"WIN\" ;
469    C++         ?= $(CC) ;
470    C++FLAGS    ?= $(CCFLAGS) ;
471    LINK        ?= $(CC) ;
472    LINKFLAGS   ?= $(CCFLAGS) ;
473    LINKLIBS    ?=
474                \"$(VISUALC16)\\lib\\mlibce.lib\"
475                \"$(VISUALC16)\\lib\\oldnames.lib\"
476                ;
477    LINKLIBS    ?= ;
478    NOARSCAN    ?= true ;
479    OPTIM       ?= "" ;
480    STDHDRS     ?= $(VISUALC16)\\include ;
481    UNDEFFLAG   ?= "/u _" ;
482    }
483    else if $(TOOLSET) = VISUALC
484    {
485    ECHO "Compiler is Microsoft Visual C++" ;
486
487    AR          ?= lib ;
488    AS          ?= masm386 ;
489    CC          ?= cl /nologo ;
490    CCFLAGS     ?= "" ;
491    C++         ?= $(CC) ;
492    C++FLAGS    ?= $(CCFLAGS) ;
493    LINK        ?= link /nologo ;
494    LINKFLAGS   ?= "" ;
495    LINKLIBS    ?= \"$(VISUALC)\\lib\\advapi32.lib\"
496                   # $(VISUALC)\\lib\\libc.lib
497                   # $(VISUALC)\\lib\\oldnames.lib
498                   \"$(VISUALC)\\lib\\gdi32.lib\"
499                   \"$(VISUALC)\\lib\\user32.lib\"
500                   \"$(VISUALC)\\lib\\kernel32.lib\" ;
501    OPTIM       ?= "" ;
502    STDHDRS     ?= $(VISUALC)\\include ;
503    UNDEFFLAG   ?= "/u _" ;
504    }
505    else if $(TOOLSET) = VC7
506    {
507    ECHO "Compiler is Microsoft Visual C++ .NET" ;
508
509    AR          ?= lib ;
510    AS          ?= masm386 ;
511    CC          ?= cl /nologo ;
512    CCFLAGS     ?= "" ;
513    C++         ?= $(CC) ;
514    C++FLAGS    ?= $(CCFLAGS) ;
515    LINK        ?= link /nologo ;
516    LINKFLAGS   ?= "" ;
517    LINKLIBS    ?= \"$(VISUALC)\\PlatformSDK\\lib\\advapi32.lib\"
518                   # $(VISUALC)\\lib\\libc.lib
519                   # $(VISUALC)\\lib\\oldnames.lib
520                   \"$(VISUALC)\\PlatformSDK\\lib\\gdi32.lib\"
521                   \"$(VISUALC)\\PlatformSDK\\lib\\user32.lib\"
522                   \"$(VISUALC)\\PlatformSDK\\lib\\kernel32.lib\" ;
523    OPTIM       ?= "" ;
524    STDHDRS     ?= \"$(VISUALC)\\include\"
525									 \"$(VISUALC)\\PlatformSDK\\include\" ;
526    UNDEFFLAG   ?= "/u _" ;
527    }
528    else if $(TOOLSET) = INTELC
529    {
530    ECHO "Compiler is Intel C/C++" ;
531
532        if ! $(VISUALC)
533        {
534          ECHO "As a special exception, when using the Intel C++ compiler, you need" ;
535          ECHO "to define the VISUALC environment variable to indicate the location" ;
536          ECHO "of your Visual C++ installation. Aborting.." ;
537          EXIT ;
538        }
539
540    AR          ?= lib ;
541    AS          ?= masm386 ;
542    CC          ?= icl /nologo ;
543    CCFLAGS     ?= "" ;
544    C++         ?= $(CC) ;
545    C++FLAGS    ?= $(CCFLAGS) ;
546    LINK        ?= link /nologo ;
547    LINKFLAGS   ?= "" ;
548    LINKLIBS    ?= $(VISUALC)\\lib\\advapi32.lib
549                   # $(VISUALC)\\lib\\libc.lib
550                   # $(VISUALC)\\lib\\oldnames.lib
551                   $(VISUALC)\\lib\\kernel32.lib
552                   ;
553    OPTIM       ?= "" ;
554    STDHDRS     ?= $(INTELC)\include $(VISUALC)\\include ;
555    UNDEFFLAG   ?= "/u _" ;
556    }
557    else if $(TOOLSET) = WATCOM
558    {
559        ECHO "Compiler is Watcom C/C++" ;
560
561    AR          ?= wlib ;
562    CC          ?= wcc386 ;
563    CCFLAGS     ?= /zq /DWIN32 /I$(WATCOM)\\h ; # zq=quiet
564    C++         ?= wpp386 ;
565    C++FLAGS    ?= $(CCFLAGS) ;
566    CP          ?= copy ;
567    DOT         ?= . ;
568    DOTDOT      ?= .. ;
569    LINK        ?= wcl386 ;
570    LINKFLAGS   ?= /zq ; # zq=quiet
571    LINKLIBS    ?= ;
572    MV          ?= move ;
573    NOARSCAN    ?= true ;
574    OPTIM       ?= ;
575    RM          ?= del /f ;
576    SLASH       ?= \\ ;
577    STDHDRS     ?= $(WATCOM)\\h $(WATCOM)\\h\\nt ;
578    SUFEXE      ?= .exe ;
579    SUFLIB      ?= .lib ;
580    SUFOBJ      ?= .obj ;
581    UNDEFFLAG   ?= "/u _" ;
582    }
583    else if $(TOOLSET) = MINGW
584    {
585        ECHO "Compiler is GCC with Mingw" ;
586
587        AR              ?= ar -ru ;
588        CC              ?= gcc ;
589        CCFLAGS         ?= "" ;
590        C++             ?= $(CC) ;
591        C++FLAGS        ?= $(CCFLAGS) ;
592        LINK            ?= $(CC) ;
593        LINKFLAGS       ?= "" ;
594        LINKLIBS        ?= "" ;
595        OPTIM           ?= ;
596        SUFOBJ           = .o ;
597        SUFLIB           = .a ;
598        SLASH            = / ;
599#       NOARSCAN        ?= true ;
600    }
601    else if $(TOOLSET) = LCC
602    {
603        ECHO "Compiler is Win32-LCC" ;
604
605        AR              ?= lcclib ;
606        CC              ?= lcc ;
607        CCFLAGS         ?= "" ;
608        C++             ?= $(CC) ;
609        C++FLAGS        ?= $(CCFLAGS) ;
610        LINK            ?= lcclnk ;
611        LINKFLAGS       ?= "" ;
612        LINKLIBS        ?= "" ;
613        OPTIM           ?= ;
614        NOARSCAN         = true ;
615    }
616    else
617    {
618#
619# XXX: We need better comments here !!
620#
621    EXIT On NT, set BCCROOT, MSVCNT, MINGW or MSVC to the root of the
622        Borland or Microsoft directories. ;
623    }
624
625}
626else if $(OS2)
627{
628    # the list of supported toolsets on Windows NT and Windows 95/98
629    #
630    local SUPPORTED_TOOLSETS = "EMX" "WATCOM" ;
631
632    # this variable holds the current toolset
633    #
634    TOOLSET = "" ;
635
636    # if the JAM_TOOLSET environment variable is defined, check that it is
637    # one of our supported values
638    #
639    if $(JAM_TOOLSET)
640    {
641      local t ;
642
643      for t in $(SUPPORTED_TOOLSETS)
644      {
645        $(t) = $($(t):J=" ") ; # reconstitute paths with spaces in them
646        if $(t) = $(JAM_TOOLSET) { TOOLSET = $(t) ; }
647      }
648
649      if ! $(TOOLSET)
650      {
651        ECHO  "The JAM_TOOLSET environment variable is defined but its value" ;
652        ECHO  "is invalid, please use one of the following:" ;
653        ECHO  ;
654
655        for t in $(SUPPORTED_TOOLSETS) { ECHO "  " $(t) ; }
656        EXIT ;
657      }
658    }
659
660    # if TOOLSET is empty, we'll try to detect the toolset from other
661    # environment variables to remain backwards compatible with Jam 2.3
662    #
663    if ! $(TOOLSET)
664    {
665      if $(watcom)
666      {
667        WATCOM   = $(watcom:J=" ") ;
668        TOOLSET  = WATCOM ;
669      }
670      else
671      {
672        ECHO  "Jam cannot be run because you didn't indicate which compilation toolset" ;
673        ECHO  "to use. To do so, follow these simple instructions:" ;
674        ECHO  ;
675        ECHO  "  - define one of the following environment variable, with the" ;
676        ECHO  "    appropriate value according to this list:" ;
677        ECHO  ;
678        ECHO  "   Variable    Toolset                      Description" ;
679        ECHO  ;
680        ECHO  "   WATCOM      Watcom C/C++                 Watcom install path" ;
681        ECHO  "   EMX         EMX (gcc)                    EMX install path" ;
682        ECHO  "   VISUALAGE   IBM Visual Age C/C++         VisualAge install path" ;
683        ECHO  ;
684        ECHO  "  - define the JAM_TOOLSET environment variable with the *name*" ;
685        ECHO  "    of the toolset variable you want to use." ;
686        ECHO  ;
687        ECHO  "  e.g.:  set WATCOM=C:\WATCOM" ;
688        ECHO  "         set JAM_TOOLSET=WATCOM" ;
689        ECHO  ;
690        EXIT  ;
691      }
692    }
693
694    RM       = del /f ;
695    CP       = copy ;
696    MV      ?= move ;
697    DOT     ?= . ;
698    DOTDOT  ?= .. ;
699    SUFLIB  ?= .lib ;
700    SUFOBJ  ?= .obj ;
701    SUFEXE  ?= .exe ;
702
703    if $(TOOLSET) = WATCOM
704    {
705       AR           ?= wlib ;
706       BINDIR       ?= \\os2\\apps ;
707       CC           ?= wcc386 ;
708       CCFLAGS      ?= /zq /DOS2 /I$(WATCOM)\\h ; # zq=quiet
709       C++          ?= wpp386 ;
710       C++FLAGS     ?= $(CCFLAGS) ;
711       LINK         ?= wcl386 ;
712       LINKFLAGS    ?= /zq ; # zq=quiet
713       LINKLIBS     ?= ;
714       NOARSCAN     ?= true ;
715       OPTIM        ?= ;
716       SLASH        ?= \\ ;
717       STDHDRS      ?= $(WATCOM)\\h ;
718       UNDEFFLAG    ?= "/u _" ;
719    }
720    else if $(TOOLSET) = EMX
721    {
722      ECHO "Compiler is GCC-EMX" ;
723      AR            ?= ar -ru ;
724      CC            ?= gcc ;
725      CCFLAGS       ?= "" ;
726      C++           ?= $(CC) ;
727      C++FLAGS      ?= $(CCFLAGS) ;
728      LINK          ?= $(CC) ;
729      LINKFLAGS     ?= "" ;
730      LINKLIBS      ?= "" ;
731      OPTIM         ?= ;
732      SUFOBJ         = .o ;
733      SUFLIB         = .a ;
734      UNDEFFLAG     ?= "-U" ;
735      SLASH          = / ;
736#     NOARSCAN      ?= true ;
737    }
738    else
739    {
740      # should never happen
741      EXIT  "Sorry, but the $(JAM_TOOLSET) toolset isn't supported for now" ;
742    }
743}
744else if $(VMS)
745{
746    C++         ?= cxx ;
747    C++FLAGS    ?= ;
748    CC          ?= cc ;
749    CCFLAGS     ?= ;
750    CHMOD       ?= set file/prot= ;
751    CP          ?= copy/replace ;
752    CRELIB      ?= true ;
753    DOT         ?= [] ;
754    DOTDOT      ?= [-] ;
755    EXEMODE     ?= (w:e) ;
756    FILEMODE    ?= (w:r) ;
757    HDRS        ?= ;
758    LINK        ?= link ;
759    LINKFLAGS   ?= "" ;
760    LINKLIBS    ?= ;
761    MKDIR       ?= create/dir ;
762    MV          ?= rename ;
763    OPTIM       ?= "" ;
764    RM          ?= delete ;
765    RUNVMS      ?= mcr ;
766    SHELLMODE   ?= (w:er) ;
767    SLASH       ?= . ;
768    STDHDRS     ?= decc$library_include ;
769    SUFEXE      ?= .exe ;
770    SUFLIB      ?= .olb ;
771    SUFOBJ      ?= .obj ;
772
773    switch $(OS)
774    {
775    case OPENVMS : CCFLAGS  ?= /stand=vaxc ;
776    case VMS     : LINKLIBS ?= sys$library:vaxcrtl.olb/lib ;
777    }
778}
779else if $(MAC)
780{
781    local OPT ;
782
783    CW  ?= "{CW}" ;
784
785    MACHDRS ?=
786        "$(UMACHDRS):Universal:Interfaces:CIncludes"
787        "$(CW):MSL:MSL_C:MSL_Common:Include"
788        "$(CW):MSL:MSL_C:MSL_MacOS:Include" ;
789
790    MACLIBS ?=
791        "$(CW):MacOS Support:Universal:Libraries:StubLibraries:Interfacelib"
792        "$(CW):MacOS Support:Universal:Libraries:StubLibraries:Mathlib" ;
793
794    MPWLIBS ?=
795        "$(CW):MacOS Support:Libraries:Runtime:Runtime PPC:MSL MPWCRuntime.lib"
796        "$(CW):MSL:MSL_C:MSL_MacOS:Lib:PPC:MSL C.PPC MPW.Lib" ;
797
798    MPWNLLIBS ?=
799        "$(CW):MacOS Support:Libraries:Runtime:Runtime PPC:MSL MPWCRuntime.lib"
800        "$(CW):MSL:MSL_C:MSL_MacOS:Lib:PPC:MSL C.PPC MPW(NL).Lib" ;
801
802    SIOUXHDRS ?= ;
803
804    SIOUXLIBS ?=
805        "$(CW):MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.lib"
806        "$(CW):MSL:MSL_C:MSL_MacOS:Lib:PPC:MSL SIOUX.PPC.Lib"
807        "$(CW):MSL:MSL_C:MSL_MacOS:Lib:PPC:MSL C.PPC.Lib" ;
808
809    C++         ?= mwcppc ;
810    C++FLAGS    ?= -w off -nomapcr ;
811    CC          ?= mwcppc ;
812    CCFLAGS     ?= -w off -nomapcr ;
813    CP          ?= duplicate -y ;
814    DOT         ?= ":" ;
815    DOTDOT      ?= "::" ;
816    HDRS        ?= $(MACHDRS) $(MPWHDRS) ;
817    LINK        ?= mwlinkppc ;
818    LINKFLAGS   ?= -mpwtool -warn ;
819    LINKLIBS    ?= $(MACLIBS) $(MPWLIBS) ;
820    MKDIR       ?= newfolder ;
821    MV          ?= rename -y ;
822    NOARSCAN    ?= true ;
823    OPTIM       ?= ;
824    RM          ?= delete -y ;
825    SLASH       ?= ":" ;
826    STDHDRS     ?= ;
827    SUFLIB      ?= .lib ;
828    SUFOBJ      ?= .o ;
829}
830else if $(OS) = BEOS && $(METROWERKS)
831{
832    AR          ?= mwld -xml -o ;
833    BINDIR      ?= /boot/apps ;
834    CC          ?= mwcc ;
835    CCFLAGS     ?= -nosyspath ;
836    C++         ?= $(CC) ;
837    C++FLAGS    ?= -nosyspath ;
838    FORTRAN     ?= "" ;
839    LIBDIR      ?= /boot/develop/libraries ;
840    LINK        ?= mwld ;
841    LINKFLAGS   ?= "" ;
842    MANDIR      ?= /boot/documentation/"Shell Tools"/HTML ;
843    NOARSCAN    ?= true ;
844    STDHDRS     ?= /boot/develop/headers/posix ;
845}
846else if $(OS) = BEOS
847{
848    BINDIR      ?= /boot/apps ;
849    CC          ?= gcc ;
850    C++         ?= $(CC) ;
851    FORTRAN     ?= "" ;
852    LIBDIR      ?= /boot/develop/libraries ;
853    LINK        ?= gcc ;
854    LINKLIBS    ?= -lnet ;
855    NOARSCAN    ?= true ;
856    STDHDRS     ?= /boot/develop/headers/posix ;
857}
858else if $(OS) = HAIKU
859{
860    BINDIR      ?= /boot/system/non-packaged/bin ;
861    CC          ?= gcc ;
862    C++         ?= $(CC) ;
863    FORTRAN     ?= "" ;
864    LIBDIR      ?= /boot/system/non-packaged/lib ;
865    LINK        ?= gcc ;
866    LINKLIBS    ?= -lnetwork ;
867    NOARSCAN    ?= true ;
868    STDHDRS     ?= /boot/system/develop/headers/posix ;
869}
870else if $(UNIX)
871{
872    switch $(OS)
873    {
874    case AIX :
875    LINKLIBS    ?= -lbsd ;
876
877    case AMIGA :
878    CC          ?= gcc ;
879    YACC        ?= "bison -y" ;
880
881    case CYGWIN :
882    CC          ?= gcc ;
883    CCFLAGS     += -D__cygwin__ ;
884    LEX         ?= flex ;
885    RANLIB      ?= "" ;
886    SUFEXE      ?= .exe ;
887    YACC        ?= "bison -y" ;
888
889    case DGUX :
890    RANLIB      ?= "" ;
891    RELOCATE    ?= true ;
892
893    case HPUX :
894    YACC        = ;
895    CFLAGS      += -Ae ;
896    CCFLAGS     += -Ae ;
897    RANLIB      ?= "" ;
898
899    case INTERIX :
900    CC          ?= gcc ;
901    RANLIB      ?= "" ;
902
903    case IRIX :
904    RANLIB      ?= "" ;
905
906    case MPEIX :
907    CC          ?= gcc ;
908    C++         ?= gcc ;
909    CCFLAGS     += -D_POSIX_SOURCE ;
910    HDRS        += /usr/include ;
911    RANLIB      ?= "" ;
912    NOARSCAN    ?= true ;
913    NOARUPDATE  ?= true ;
914
915    case MVS :
916    RANLIB      ?= "" ;
917
918    case NEXT :
919    AR          ?= libtool -o ;
920    RANLIB      ?= "" ;
921
922    case MACOSX :
923    AR          ?= libtool -o ;
924    C++         ?= c++ ;
925    MANDIR      ?= /usr/local/share/man ;
926    RANLIB      ?= "" ;
927
928    case NCR :
929    RANLIB      ?= "" ;
930
931    case PTX :
932    RANLIB      ?= "" ;
933
934    case QNX :
935    AR          ?= wlib ;
936    CC          ?= cc ;
937    CCFLAGS     ?= -Q ; # quiet
938    C++         ?= $(CC) ;
939    C++FLAGS    ?= -Q ; # quiet
940    LINK        ?= $(CC) ;
941    LINKFLAGS   ?= -Q ; # quiet
942    NOARSCAN    ?= true ;
943    RANLIB      ?= "" ;
944
945    case SCO :
946    RANLIB      ?= "" ;
947    RELOCATE    ?= true ;
948
949    case SINIX :
950    RANLIB      ?= "" ;
951
952    case SOLARIS :
953    RANLIB      ?= "" ;
954    AR          ?= "/usr/ccs/bin/ar ru" ;
955
956    case UNICOS :
957    NOARSCAN    ?= true ;
958    OPTIM       ?= -O0 ;
959
960    case UNIXWARE :
961    RANLIB      ?= "" ;
962    RELOCATE    ?= true ;
963    }
964
965    # UNIX defaults
966
967    CCFLAGS     ?= ;
968    C++FLAGS    ?= $(CCFLAGS) ;
969    CHMOD       ?= chmod ;
970    CHGRP       ?= chgrp ;
971    CHOWN       ?= chown ;
972    LEX         ?= lex ;
973    LINKFLAGS   ?= $(CCFLAGS) ;
974    LINKLIBS    ?= ;
975    OPTIM       ?= -O ;
976    RANLIB      ?= ranlib ;
977    YACC        ?= yacc ;
978    YACCFILES   ?= y.tab ;
979    YACCFLAGS   ?= -d ;
980}
981
982#
983# General defaults; a lot like UNIX
984#
985
986    AR          ?= ar ru ;
987    AS          ?= as ;
988    ASFLAGS     ?= ;
989    AWK         ?= awk ;
990    BINDIR      ?= /usr/local/bin ;
991    C++         ?= cc ;
992    C++FLAGS    ?= ;
993    CC          ?= cc ;
994    CCFLAGS     ?= ;
995    CP          ?= cp -f ;
996    CRELIB      ?= ;
997    DOT         ?= . ;
998    DOTDOT      ?= .. ;
999    EXEMODE     ?= 711 ;
1000    FILEMODE    ?= 644 ;
1001    FORTRAN     ?= f77 ;
1002    FORTRANFLAGS ?= ;
1003    HDRS        ?= ;
1004    INSTALLGRIST ?= installed ;
1005    JAMFILE     ?= Jamfile ;
1006    JAMRULES    ?= Jamrules ;
1007    LEX         ?= ;
1008    LIBDIR      ?= /usr/local/lib ;
1009    LINK        ?= $(CC) ;
1010    LINKFLAGS   ?= ;
1011    LINKLIBS    ?= ;
1012    LN          ?= ln ;
1013    MANDIR      ?= /usr/local/man ;
1014    MKDIR       ?= mkdir ;
1015    MV          ?= mv -f ;
1016    OPTIM       ?= ;
1017    RCP         ?= rcp ;
1018    RM          ?= rm -f ;
1019    RSH         ?= rsh ;
1020    SED         ?= sed ;
1021    SHELLHEADER ?= "#!/bin/sh" ;
1022    SHELLMODE   ?= 755 ;
1023    SLASH       ?= / ;
1024    STDHDRS     ?= /usr/include ;
1025    SUFEXE      ?= "" ;
1026    SUFLIB      ?= .a ;
1027    SUFOBJ      ?= .o ;
1028    UNDEFFLAG   ?= "-u _" ;
1029    YACC        ?= ;
1030    YACCFILES   ?= ;
1031    YACCFLAGS   ?= ;
1032
1033    HDRPATTERN =
1034            "^[     ]*#[    ]*include[  ]*[<\"]([^\">]*)[\">].*$" ;
1035
1036    OSFULL = $(OS)$(OSVER)$(OSPLAT) $(OS)$(OSPLAT) $(OS)$(OSVER) $(OS) ;
1037
1038
1039#
1040# Base dependencies - first for "bootstrap" kinds of rules
1041#
1042
1043DEPENDS all : shell files lib exe obj ;
1044DEPENDS all shell files lib exe obj : first ;
1045NOTFILE all first shell files lib exe obj dirs clean uninstall ;
1046ALWAYS clean uninstall ;
1047
1048#
1049# Rules
1050#
1051
1052rule As
1053{
1054    DEPENDS $(<) : $(>) ;
1055    ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ;
1056}
1057
1058rule Bulk
1059{
1060    local i ;
1061
1062    for i in $(>)
1063    {
1064        File $(i:D=$(<)) : $(i) ;
1065    }
1066}
1067
1068rule Cc
1069{
1070    local _h ;
1071
1072    DEPENDS $(<) : $(>) ;
1073
1074    # Just to clarify here: this sets the per-target CCFLAGS to
1075    # be the current value of (global) CCFLAGS and SUBDIRCCFLAGS.
1076
1077    CCFLAGS on $(<) += $(CCFLAGS) $(SUBDIRCCFLAGS) ;
1078
1079    # If the compiler's -o flag doesn't work, relocate the .o
1080
1081    if $(RELOCATE)
1082    {
1083        CcMv $(<) : $(>) ;
1084    }
1085
1086    _h = $(SEARCH_SOURCE) $(HDRS) $(SUBDIRHDRS) ;
1087
1088    if $(VMS) && $(_h)
1089    {
1090        SLASHINC on $(<) = "/inc=(" $(_h[1]) ,$(_h[2-]) ")" ;
1091    }
1092    else if $(MAC) && $(_h)
1093    {
1094        local _i _j ;
1095        _j = $(_h[1]) ;
1096        for _i in $(_h[2-])
1097        {
1098            _j = $(_j),$(_i) ;
1099        }
1100        MACINC on $(<) = \"$(_j)\" ;
1101    }
1102}
1103
1104rule C++
1105{
1106    local _h ;
1107
1108    DEPENDS $(<) : $(>) ;
1109    C++FLAGS on $(<) += $(C++FLAGS) $(SUBDIRC++FLAGS) ;
1110
1111    if $(RELOCATE)
1112    {
1113        CcMv $(<) : $(>) ;
1114    }
1115
1116    _h = $(SEARCH_SOURCE) $(HDRS) $(SUBDIRHDRS) ;
1117
1118    if $(VMS) && $(_h)
1119    {
1120        SLASHINC on $(<) = "/inc=(" $(_h[1]) ,$(_h[2-]) ")" ;
1121    }
1122    else if $(MAC) && $(_h)
1123    {
1124        local _i _j ;
1125        _j = $(_h[1]) ;
1126        for _i in $(_h[2-])
1127        {
1128            _j = $(_j),$(_i) ;
1129        }
1130        MACINC on $(<) = \"$(_j)\" ;
1131    }
1132}
1133
1134rule Chmod
1135{
1136    if $(CHMOD) { Chmod1 $(<) ; }
1137}
1138
1139rule File
1140{
1141    DEPENDS files : $(<) ;
1142    DEPENDS $(<) : $(>) ;
1143    SEARCH on $(>) = $(SEARCH_SOURCE) ;
1144    MODE on $(<) = $(FILEMODE) ;
1145    Chmod $(<) ;
1146}
1147
1148rule Fortran
1149{
1150    DEPENDS $(<) : $(>) ;
1151}
1152
1153rule GenFile
1154{
1155    local _t = [ FGristSourceFiles $(<) ] ;
1156    local _s = [ FAppendSuffix $(>[1]) : $(SUFEXE) ] ;
1157    Depends $(_t) : $(_s) $(>[2-]) ;
1158    GenFile1 $(_t) : $(_s) $(>[2-]) ;
1159    Clean clean : $(_t) ;
1160}
1161
1162rule GenFile1
1163{
1164    MakeLocate $(<) : $(LOCATE_SOURCE) ;
1165    SEARCH on $(>) = $(SEARCH_SOURCE) ;
1166}
1167
1168rule HardLink
1169{
1170    DEPENDS files : $(<) ;
1171    DEPENDS $(<) : $(>) ;
1172    SEARCH on $(>) = $(SEARCH_SOURCE) ;
1173}
1174
1175rule HdrMacroFile
1176{
1177  # HdrMacroFile file ;
1178  #
1179  # this rule is used to indicate that a given file contains definitions
1180  # for filename macros (e.g. "#define  MYFILE_H <myfile.h>") that can
1181  # later be used in #include statements in the rest of the source
1182  #
1183  # theses files must be parsed before any make is tried..
1184  #
1185  HDRMACRO $(<) ;
1186}
1187
1188rule HdrRule
1189{
1190    # HdrRule source : headers ;
1191
1192    # N.B.  This rule is called during binding, potentially after
1193    # the fate of many targets has been determined, and must be
1194    # used with caution: don't add dependencies to unrelated
1195    # targets, and don't set variables on $(<).
1196
1197    # Tell Jam that anything depending on $(<) also depends on $(>),
1198    # set SEARCH so Jam can find the headers, but then say we don't
1199    # care if we can't actually find the headers (they may have been
1200    # within ifdefs),
1201
1202    local s ;
1203
1204    if $(HDRGRIST)
1205    {
1206        s = $(>:G=$(HDRGRIST)) ;
1207    } else {
1208        s = $(>) ;
1209    }
1210
1211    INCLUDES $(<) : $(s) ;
1212    SEARCH on $(s) = $(HDRSEARCH) ;
1213    NOCARE $(s) ;
1214
1215    # Propagate on $(<) to $(>)
1216
1217    HDRSEARCH on $(s) = $(HDRSEARCH) ;
1218    HDRSCAN on $(s) = $(HDRSCAN) ;
1219    HDRRULE on $(s) = $(HDRRULE) ;
1220    HDRGRIST on $(s) = $(HDRGRIST) ;
1221}
1222
1223rule InstallInto
1224{
1225    # InstallInto dir : sources ;
1226
1227    local i t ;
1228
1229    t = $(>:G=$(INSTALLGRIST)) ;
1230
1231    # Arrange for jam install
1232    # Arrange for jam uninstall
1233    # sources are in SEARCH_SOURCE
1234    # targets are in dir
1235
1236    Depends install : $(t) ;
1237    Clean uninstall : $(t) ;
1238    SEARCH on $(>) = $(SEARCH_SOURCE) ;
1239    MakeLocate $(t) : $(<) ;
1240
1241    # For each source, make gristed target name
1242    # and Install, Chmod, Chown, and Chgrp
1243
1244    for i in $(>)
1245    {
1246        local tt = $(i:G=$(INSTALLGRIST)) ;
1247
1248        Depends $(tt) : $(i) ;
1249        Install $(tt) : $(i) ;
1250        Chmod $(tt) ;
1251
1252        if $(OWNER) && $(CHOWN)
1253        {
1254        Chown $(tt) ;
1255        OWNER on $(tt) = $(OWNER) ;
1256        }
1257
1258        if $(GROUP) && $(CHGRP)
1259        {
1260        Chgrp $(tt) ;
1261        GROUP on $(tt) = $(GROUP) ;
1262        }
1263    }
1264}
1265
1266rule InstallBin
1267{
1268    local _t = [ FAppendSuffix $(>) : $(SUFEXE) ] ;
1269
1270    InstallInto $(<) : $(_t) ;
1271    MODE on $(_t:G=installed) = $(EXEMODE) ;
1272}
1273
1274rule InstallFile
1275{
1276    InstallInto $(<) : $(>) ;
1277    MODE on $(>:G=installed) = $(FILEMODE) ;
1278}
1279
1280rule InstallLib
1281{
1282    InstallInto $(<) : $(>) ;
1283    MODE on $(>:G=installed) = $(FILEMODE) ;
1284}
1285
1286rule InstallMan
1287{
1288    # Really this just strips the . from the suffix
1289
1290    local i s d ;
1291
1292    for i in $(>)
1293    {
1294        switch $(i:S)
1295        {
1296        case .1 : s = 1 ; case .2 : s = 2 ; case .3 : s = 3 ;
1297        case .4 : s = 4 ; case .5 : s = 5 ; case .6 : s = 6 ;
1298        case .7 : s = 7 ; case .8 : s = 8 ; case .l : s = l ;
1299        case .n : s = n ; case .man : s = 1 ;
1300        }
1301
1302        d = man$(s) ;
1303
1304        InstallInto $(d:R=$(<)) : $(i) ;
1305    }
1306
1307    MODE on $(>:G=installed) = $(FILEMODE) ;
1308}
1309
1310rule InstallShell
1311{
1312    InstallInto $(<) : $(>) ;
1313    MODE on $(>:G=installed) = $(SHELLMODE) ;
1314}
1315
1316rule Lex
1317{
1318    LexMv $(<) : $(>) ;
1319    DEPENDS $(<) : $(>) ;
1320    MakeLocate $(<) : $(LOCATE_SOURCE) ;
1321    Clean clean : $(<) ;
1322}
1323
1324rule Library
1325{
1326    LibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1327    Objects $(>) ;
1328}
1329
1330rule LibraryFromObjects
1331{
1332    local _i _l _s ;
1333
1334    # Add grist to file names
1335
1336    _s = [ FGristFiles $(>) ] ;
1337    _l = $(<:S=$(SUFLIB)) ;
1338
1339    # library depends on its member objects
1340
1341    if $(KEEPOBJS)
1342    {
1343        DEPENDS obj : $(_s) ;
1344    }
1345    else
1346    {
1347        DEPENDS lib : $(_l) ;
1348    }
1349
1350    # Set LOCATE for the library and its contents.  The bound
1351    # value shows up as $(NEEDLIBS) on the Link actions.
1352    # For compatibility, we only do this if the library doesn't
1353    # already have a path.
1354
1355    if ! $(_l:D)
1356    {
1357        MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_TARGET) ;
1358    }
1359
1360    if $(NOARSCAN)
1361    {
1362        # If we can't scan the library to timestamp its contents,
1363        # we have to just make the library depend directly on the
1364        # on-disk object files.
1365
1366        DEPENDS $(_l) : $(_s) ;
1367    }
1368    else
1369    {
1370        # If we can scan the library, we make the library depend
1371        # on its members and each member depend on the on-disk
1372        # object file.
1373
1374        DEPENDS $(_l) : $(_l)($(_s:BS)) ;
1375
1376        for _i in $(_s)
1377        {
1378        DEPENDS $(_l)($(_i:BS)) : $(_i) ;
1379        }
1380    }
1381
1382    Clean clean : $(_l) ;
1383
1384    if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }
1385
1386    Archive $(_l) : $(_s) ;
1387
1388    if $(RANLIB) { Ranlib $(_l) ; }
1389
1390    # If we can't scan the library, we have to leave the .o's around.
1391
1392    if ! ( $(NOARSCAN) || $(KEEPOBJS) ) { RmTemps $(_l) : $(_s) ; }
1393}
1394
1395rule Link
1396{
1397    MODE on $(<) = $(EXEMODE) ;
1398    Chmod $(<) ;
1399}
1400
1401rule LinkLibraries
1402{
1403    # make library dependencies of target
1404    # set NEEDLIBS variable used by 'actions Main'
1405
1406    local _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1407
1408    DEPENDS $(_t) : $(>:S=$(SUFLIB)) ;
1409    NEEDLIBS on $(_t) += $(>:S=$(SUFLIB)) ;
1410}
1411
1412rule Main
1413{
1414    MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;
1415    Objects $(>) ;
1416}
1417
1418rule MainFromObjects
1419{
1420    local _s _t ;
1421
1422    # Add grist to file names
1423    # Add suffix to exe
1424
1425    _s = [ FGristFiles $(>) ] ;
1426    _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;
1427
1428    if $(_t) != $(<)
1429    {
1430        DEPENDS $(<) : $(_t) ;
1431        NOTFILE $(<) ;
1432    }
1433
1434    # make compiled sources a dependency of target
1435
1436    DEPENDS exe : $(_t) ;
1437    DEPENDS $(_t) : $(_s) ;
1438    MakeLocate $(_t) : $(LOCATE_TARGET) ;
1439
1440    Clean clean : $(_t) ;
1441
1442    Link $(_t) : $(_s) ;
1443}
1444
1445rule MakeLocate
1446{
1447    if $(>)
1448    {
1449        LOCATE on $(<) = $(>) ;
1450        Depends $(<) : $(>[1]) ;
1451        MkDir $(>[1]) ;
1452    }
1453}
1454
1455rule MkDir
1456{
1457    # If dir exists, don't update it
1458    # Do this even for $(DOT).
1459
1460    NOUPDATE $(<) ;
1461
1462    if $(<) != $(DOT) && ! $($(<)-mkdir)
1463    {
1464        local s ;
1465
1466        # Cheesy gate to prevent multiple invocations on same dir
1467        # MkDir1 has the actions
1468        # Arrange for jam dirs
1469
1470        $(<)-mkdir = true ;
1471        MkDir1 $(<) ;
1472        Depends dirs : $(<) ;
1473
1474        # Recursively make parent directories.
1475        # $(<:P) = $(<)'s parent, & we recurse until root
1476
1477        s = $(<:P) ;
1478
1479        if $(NT)
1480        {
1481            switch $(s)
1482        {
1483        case *:   : s = ;
1484        case *:\\ : s = ;
1485        }
1486        }
1487
1488        if $(s) && $(s) != $(<)
1489        {
1490        Depends $(<) : $(s) ;
1491        MkDir $(s) ;
1492        }
1493        else if $(s)
1494        {
1495            NOTFILE $(s) ;
1496        }
1497
1498    }
1499}
1500
1501rule Object
1502{
1503    local h ;
1504
1505    # locate object and search for source, if wanted
1506
1507    Clean clean : $(<) ;
1508
1509    MakeLocate $(<) : $(LOCATE_TARGET) ;
1510    SEARCH on $(>) = $(SEARCH_SOURCE) ;
1511
1512    # Save HDRS for -I$(HDRS) on compile.
1513    # We shouldn't need -I$(SEARCH_SOURCE) as cc can find headers
1514    # in the .c file's directory, but generated .c files (from
1515    # yacc, lex, etc) are located in $(LOCATE_TARGET), possibly
1516    # different from $(SEARCH_SOURCE).
1517
1518    HDRS on $(<) = $(SEARCH_SOURCE) $(HDRS) $(SUBDIRHDRS) ;
1519
1520    # handle #includes for source: Jam scans for headers with
1521    # the regexp pattern $(HDRSCAN) and then invokes $(HDRRULE)
1522    # with the scanned file as the target and the found headers
1523    # as the sources.  HDRSEARCH is the value of SEARCH used for
1524    # the found header files.  Finally, if jam must deal with
1525    # header files of the same name in different directories,
1526    # they can be distinguished with HDRGRIST.
1527
1528    # $(h) is where cc first looks for #include "foo.h" files.
1529    # If the source file is in a distant directory, look there.
1530    # Else, look in "" (the current directory).
1531
1532    if $(SEARCH_SOURCE)
1533    {
1534        h = $(SEARCH_SOURCE) ;
1535    }
1536    else
1537    {
1538        h = "" ;
1539    }
1540
1541    HDRRULE on $(>) = HdrRule ;
1542    HDRSCAN on $(>) = $(HDRPATTERN) ;
1543    HDRSEARCH on $(>) = $(HDRS) $(SUBDIRHDRS) $(h) $(STDHDRS) ;
1544    HDRGRIST on $(>) = $(HDRGRIST) ;
1545
1546    # if source is not .c, generate .c with specific rule
1547
1548    switch $(>:S)
1549    {
1550        case .asm : As $(<) : $(>) ;
1551        case .c :   Cc $(<) : $(>) ;
1552        case .C :   C++ $(<) : $(>) ;
1553        case .cc :  C++ $(<) : $(>) ;
1554        case .cpp : C++ $(<) : $(>) ;
1555        case .f :   Fortran $(<) : $(>) ;
1556        case .l :   Cc $(<) : $(<:S=.c) ;
1557                    Lex $(<:S=.c) : $(>) ;
1558        case .s :   As $(<) : $(>) ;
1559        case .y :   Cc $(<) : $(<:S=.c) ;
1560                    Yacc $(<:S=.c) : $(>) ;
1561        case * :    UserObject $(<) : $(>) ;
1562    }
1563}
1564
1565
1566rule ObjectCcFlags
1567{
1568    CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
1569}
1570
1571rule ObjectC++Flags
1572{
1573    C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
1574}
1575
1576rule ObjectHdrs
1577{
1578    HDRS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;
1579}
1580
1581rule Objects
1582{
1583    local _i ;
1584
1585    for _i in [ FGristFiles $(<) ]
1586    {
1587        Object $(_i:S=$(SUFOBJ)) : $(_i) ;
1588        DEPENDS obj : $(_i:S=$(SUFOBJ)) ;
1589    }
1590}
1591
1592rule RmTemps
1593{
1594    TEMPORARY $(>) ;
1595}
1596
1597rule Setuid
1598{
1599    MODE on [ FAppendSuffix $(<) : $(SUFEXE) ] = 4711 ;
1600}
1601
1602rule Shell
1603{
1604    DEPENDS shell : $(<) ;
1605    DEPENDS $(<) : $(>) ;
1606    SEARCH on $(>) = $(SEARCH_SOURCE) ;
1607    MODE on $(<) = $(SHELLMODE) ;
1608    Clean clean : $(<) ;
1609    Chmod $(<) ;
1610}
1611
1612rule SubDir
1613{
1614    local _r _s ;
1615
1616    #
1617    # SubDir TOP d1 [ ... ]
1618    #
1619    # This introduces a Jamfile that is part of a project tree
1620    # rooted at $(TOP).  It (only once) includes the project-specific
1621    # rules file $(TOP)/Jamrules and then sets search & locate stuff.
1622    #
1623    # If the variable $(TOPRULES) is set (where TOP is the first arg
1624    # to SubDir), that file is included instead of $(TOP)/Jamrules.
1625    #
1626    # d1 ... are the directory elements that lead to this directory
1627    # from $(TOP).  We construct the system dependent path from these
1628    # directory elements in order to set search & locate stuff.
1629    #
1630
1631    if ! $($(<[1]))
1632    {
1633        if ! $(<[1])
1634        {
1635            EXIT SubDir syntax error ;
1636        }
1637
1638        $(<[1]) = [ FSubDir $(<[2-]) ] ;
1639    }
1640
1641    #
1642    # If $(TOP)/Jamrules hasn't been included, do so.
1643    #
1644
1645    if ! $($(<[1])-included)
1646    {
1647        # Gated entry.
1648
1649        $(<[1])-included = TRUE ;
1650
1651        # File is $(TOPRULES) or $(TOP)/Jamrules.
1652
1653        _r = $($(<[1])RULES) ;
1654
1655        if ! $(_r)
1656        {
1657        _r = $(JAMRULES:R=$($(<[1]))) ;
1658        }
1659
1660        # Include it.
1661
1662        include $(_r) ;
1663    }
1664
1665    # Get path to current directory from root using SubDir.
1666    # Save dir tokens for other potential uses.
1667
1668    _s = [ FDirName $(<[2-]) ] ;
1669    SUBDIR = $(_s:R=$($(<[1]))) ;
1670        SUBDIR_TOKENS = $(<[2-]) ;
1671
1672    # Now set up SEARCH_SOURCE, LOCATE_TARGET, SOURCE_GRIST
1673    # These can be reset if needed.  For example, if the source
1674    # directory should not hold object files, LOCATE_TARGET can
1675    # subsequently be redefined.
1676
1677    SEARCH_SOURCE = $(SUBDIR) ;
1678    LOCATE_SOURCE = $(ALL_LOCATE_TARGET) $(SUBDIR) ;
1679    LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(SUBDIR) ;
1680    SOURCE_GRIST = [ FGrist $(<[2-]) ] ;
1681
1682    # Reset per-directory ccflags, hdrs
1683
1684    SUBDIRCCFLAGS = ;
1685    SUBDIRC++FLAGS = ;
1686    SUBDIRHDRS = ;
1687}
1688
1689rule SubDirCcFlags
1690{
1691    SUBDIRCCFLAGS += $(<) ;
1692}
1693
1694rule SubDirC++Flags
1695{
1696    SUBDIRC++FLAGS += $(<) ;
1697}
1698
1699rule SubDirHdrs
1700{
1701    SUBDIRHDRS += $(<) ;
1702}
1703
1704rule SubInclude
1705{
1706    local _s ;
1707
1708    # That's
1709    #   SubInclude TOP d1 [ d2 [ d3 [ d4 ] ] ]
1710    #
1711    # to include a subdirectory's Jamfile.
1712
1713    if ! $($(<[1]))
1714    {
1715        EXIT Top level of source tree has not been set with $(<[1]) ;
1716    }
1717
1718    _s = [ FDirName $(<[2-]) ] ;
1719
1720    include $(JAMFILE:D=$(_s):R=$($(<[1]))) ;
1721}
1722
1723rule Undefines
1724{
1725    UNDEFS on [ FAppendSuffix $(<) : $(SUFEXE) ] += $(UNDEFFLAG)$(>) ;
1726}
1727
1728rule UserObject
1729{
1730    EXIT "Unknown suffix on" $(>) "- see UserObject rule in Jamfile(5)." ;
1731}
1732
1733rule Yacc
1734{
1735    local _h ;
1736
1737    _h = $(<:BS=.h) ;
1738
1739    # Some places don't have a yacc.
1740
1741    MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ;
1742
1743    if $(YACC)
1744    {
1745        DEPENDS $(<) $(_h) : $(>) ;
1746        Yacc1 $(<) $(_h) : $(>) ;
1747        YaccMv $(<) $(_h) : $(>) ;
1748        Clean clean : $(<) $(_h) ;
1749    }
1750
1751    # Make sure someone includes $(_h) else it will be a deadly independent
1752    # target.
1753    INCLUDES $(<) : $(_h) ;
1754}
1755
1756#
1757# Utility rules; no side effects on these.
1758#
1759
1760rule FGrist
1761{
1762    # Turn individual elements in $(<) into grist.
1763
1764    local _g _i ;
1765
1766    _g = $(<[1]) ;
1767
1768    for _i in $(<[2-])
1769    {
1770        _g = $(_g)!$(_i) ;
1771    }
1772
1773    return $(_g) ;
1774}
1775
1776rule FGristFiles
1777{
1778    if ! $(SOURCE_GRIST)
1779    {
1780        return $(<) ;
1781    }
1782    else
1783    {
1784        return $(<:G=$(SOURCE_GRIST)) ;
1785    }
1786}
1787
1788rule FGristSourceFiles
1789{
1790    # Produce source file name name with grist in it,
1791    # if SOURCE_GRIST is set.
1792
1793    # Leave header files alone, because they have a global
1794    # visibility.
1795
1796    if ! $(SOURCE_GRIST)
1797    {
1798        return $(<) ;
1799    }
1800    else
1801    {
1802        local _i _o ;
1803
1804        for _i in $(<)
1805        {
1806        switch $(_i)
1807        {
1808        case *.h :  _o += $(_i) ;
1809        case * :    _o += $(_i:G=$(SOURCE_GRIST)) ;
1810        }
1811        }
1812
1813        return $(_o) ;
1814    }
1815}
1816
1817rule FConcat
1818{
1819    # Puts the variables together, removing spaces.
1820
1821    local _t _r ;
1822
1823    $(_r) = $(<[1]) ;
1824
1825    for _t in $(<[2-])
1826    {
1827        $(_r) = $(_r)$(_t) ;
1828    }
1829
1830    return $(_r) ;
1831}
1832
1833rule FSubDir
1834{
1835    local _i _d ;
1836
1837    # If $(>) is the path to the current directory, compute the
1838    # path (using ../../ etc) back to that root directory.
1839    # Sets result in $(<)
1840
1841    if ! $(<[1])
1842    {
1843        _d = $(DOT) ;
1844    }
1845    else
1846    {
1847        _d = $(DOTDOT) ;
1848
1849        for _i in $(<[2-])
1850        {
1851        _d = $(_d:R=$(DOTDOT)) ;
1852        }
1853    }
1854
1855    return $(_d) ;
1856}
1857
1858rule FDirName
1859{
1860    local _s _i ;
1861
1862    # Turn individual elements in $(<) into a usable path.
1863
1864    if ! $(<)
1865    {
1866        _s = $(DOT) ;
1867    }
1868    else if $(VMS)
1869    {
1870        # This handles the following cases:
1871        #   a -> [.a]
1872        #   a b c -> [.a.b.c]
1873        #   x: -> x:
1874        #   x: a -> x:[a]
1875        #   x:[a] b -> x:[a.b]
1876
1877        switch $(<[1])
1878        {
1879        case *:* : _s = $(<[1]) ;
1880        case \\[*\\] : _s = $(<[1]) ;
1881        case * : _s = [.$(<[1])] ;
1882        }
1883
1884        for _i in [.$(<[2-])]
1885        {
1886        _s = $(_i:R=$(_s)) ;
1887        }
1888    }
1889    else if $(MAC)
1890    {
1891        _s = $(DOT) ;
1892
1893        for _i in $(<)
1894        {
1895            _s = $(_i:R=$(_s)) ;
1896        }
1897    }
1898    else
1899    {
1900        _s = $(<[1]) ;
1901
1902        for _i in $(<[2-])
1903        {
1904        _s = $(_i:R=$(_s)) ;
1905        }
1906    }
1907
1908    return $(_s) ;
1909}
1910
1911
1912rule _makeCommon
1913{
1914    # strip common initial elements
1915
1916    if $($(<)[1]) && $($(<)[1]) = $($(>)[1])
1917    {
1918        $(<) = $($(<)[2-]) ;
1919        $(>) = $($(>)[2-]) ;
1920        _makeCommon $(<) : $(>) ;
1921    }
1922}
1923
1924
1925rule FRelPath
1926{
1927    local _l _r ;
1928
1929    # first strip off common parts
1930
1931    _l = $(<) ;
1932    _r = $(>) ;
1933
1934    _makeCommon _l : _r ;
1935
1936    # now make path to root and path down
1937
1938    _l = [ FSubDir $(_l) ] ;
1939    _r = [ FDirName $(_r) ] ;
1940
1941    # Concatenate and save
1942
1943    # XXX This should be better
1944
1945    if $(_r) = $(DOT) {
1946        return $(_l) ;
1947    } else {
1948        return $(_r:R=$(_l)) ;
1949    }
1950}
1951
1952rule FAppendSuffix
1953{
1954       # E.g., "FAppendSuffix yacc lex foo.bat : $(SUFEXE) ;"
1955       # returns (yacc,lex,foo.bat) on Unix and
1956       # (yacc.exe,lex.exe,foo.bat) on NT.
1957
1958    if $(>)
1959    {
1960        local _i _o ;
1961
1962        for _i in $(<)
1963        {
1964        if $(_i:S)
1965        {
1966            _o += $(_i) ;
1967        }
1968        else
1969        {
1970            _o += $(_i:S=$(>)) ;
1971        }
1972        }
1973        return $(_o) ;
1974    }
1975    else
1976    {
1977        return $(<) ;
1978    }
1979}
1980
1981rule unmakeDir
1982{
1983    if $(>[1]:D) && $(>[1]:D) != $(>[1]) && $(>[1]:D) != \\\\
1984    {
1985        unmakeDir $(<) : $(>[1]:D) $(>[1]:BS) $(>[2-]) ;
1986    }
1987    else
1988    {
1989        $(<) = $(>) ;
1990    }
1991}
1992
1993
1994rule FConvertToSlashes
1995{
1996  local _d, _s, _i ;
1997
1998  unmakeDir _d : $(<) ;
1999
2000  _s = $(_d[1]) ;
2001  for _i in $(_d[2-])
2002  {
2003    _s = $(_s)/$(_i) ;
2004  }
2005  return $(_s) ;
2006}
2007
2008
2009#
2010# Actions
2011#
2012
2013#
2014# First the defaults
2015#
2016
2017actions updated together piecemeal Archive
2018{
2019    $(AR) $(<) $(>)
2020}
2021
2022actions As
2023{
2024    $(AS) $(ASFLAGS) -I$(HDRS) -o $(<) $(>)
2025}
2026
2027actions C++
2028{
2029    $(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) -o $(<) $(>)
2030}
2031
2032actions Cc
2033{
2034    $(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) -o $(<) $(>)
2035}
2036
2037actions Chgrp
2038{
2039    $(CHGRP) $(GROUP) $(<)
2040}
2041
2042actions Chmod1
2043{
2044    $(CHMOD) $(MODE) $(<)
2045}
2046
2047actions Chown
2048{
2049    $(CHOWN) $(OWNER) $(<)
2050}
2051
2052actions piecemeal together existing Clean
2053{
2054    $(RM) $(>)
2055}
2056
2057actions File
2058{
2059    $(CP) $(>) $(<)
2060}
2061
2062actions GenFile1
2063{
2064    $(>[1]) $(<) $(>[2-])
2065}
2066
2067actions Fortran
2068{
2069    $(FORTRAN) $(FORTRANFLAGS) -o $(<) $(>)
2070}
2071
2072actions HardLink
2073{
2074    $(RM) $(<) && $(LN) $(>) $(<)
2075}
2076
2077actions Install
2078{
2079    $(CP) $(>) $(<)
2080}
2081
2082actions Lex
2083{
2084    $(LEX) $(>)
2085}
2086
2087actions LexMv
2088{
2089    $(MV) lex.yy.c $(<)
2090}
2091
2092actions Link bind NEEDLIBS
2093{
2094    $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2095}
2096
2097actions MkDir1
2098{
2099    $(MKDIR) $(<)
2100}
2101
2102actions together Ranlib
2103{
2104    $(RANLIB) $(<)
2105}
2106
2107actions quietly updated piecemeal together RmTemps
2108{
2109    $(RM) $(>)
2110}
2111
2112actions Shell
2113{
2114    $(AWK) '
2115        NR == 1 { print "$(SHELLHEADER)" }
2116        NR == 1 && /^[#:]/ { next }
2117        /^##/ { next }
2118        { print }
2119    ' < $(>) > $(<)
2120}
2121
2122actions Yacc1
2123{
2124    $(YACC) $(YACCFLAGS) $(>)
2125}
2126
2127actions YaccMv
2128{
2129    $(MV) $(YACCFILES).c $(<[1])
2130    $(MV) $(YACCFILES).h $(<[2])
2131}
2132
2133#
2134# RELOCATE - for compilers with broken -o flags
2135#
2136
2137if $(RELOCATE)
2138{
2139    actions C++
2140    {
2141    $(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) $(>)
2142    }
2143
2144    actions Cc
2145    {
2146    $(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) $(>)
2147    }
2148
2149    actions ignore CcMv
2150    {
2151    [ $(<) != $(>:BS=$(SUFOBJ)) ] && $(MV) $(>:BS=$(SUFOBJ)) $(<)
2152    }
2153}
2154
2155#
2156# NOARUPDATE - can't update an archive
2157#
2158
2159if $(NOARUPDATE)
2160{
2161    actions Archive
2162    {
2163    $(AR) $(<) $(>)
2164    }
2165}
2166
2167#
2168# NT specific actions
2169#
2170
2171if $(NT)
2172{
2173  if $(TOOLSET) = VISUALC || $(TOOLSET) = VC7 || $(TOOLSET) = INTELC
2174  {
2175    actions updated together piecemeal Archive
2176    {
2177    if exist $(<) set _$(<:B)_=$(<)
2178    $(AR) /out:$(<) %_$(<:B)_% $(>)
2179    }
2180
2181    actions As
2182    {
2183    $(AS) /Ml /p /v /w2 $(>) $(<) ,nul,nul;
2184    }
2185
2186    actions Cc
2187    {
2188    $(CC) /c $(CCFLAGS) $(OPTIM) /Fo$(<) /I$(HDRS) /I$(STDHDRS) $(>)
2189    }
2190
2191    actions C++
2192    {
2193    $(C++) /c $(C++FLAGS) $(OPTIM) /Fo$(<) /I$(HDRS) /I$(STDHDRS) /Tp$(>)
2194    }
2195
2196    actions Link bind NEEDLIBS
2197    {
2198    $(LINK) $(LINKFLAGS) /out:$(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2199    }
2200  }
2201  else if $(TOOLSET) = VISUALC16
2202  {
2203    actions updated together piecemeal Archive
2204    {
2205    $(AR) $(<) -+$(>)
2206    }
2207
2208    actions Cc
2209    {
2210    $(CC) /c $(CCFLAGS) $(OPTIM) /Fo$(<) /I$(HDRS) $(>)
2211    }
2212
2213    actions C++
2214    {
2215    $(C++) /c $(C++FLAGS) $(OPTIM) /Fo$(<) /I$(HDRS) /Tp$(>)
2216    }
2217
2218    actions Link bind NEEDLIBS
2219    {
2220    $(LINK) $(LINKFLAGS) /out:$(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2221    }
2222  }
2223  else if $(TOOLSET) = BORLANDC
2224  {
2225    actions updated together piecemeal Archive
2226    {
2227    $(AR) $(<) -+$(>)
2228    }
2229
2230    actions Link bind NEEDLIBS
2231    {
2232    $(LINK) -e$(<) $(LINKFLAGS) $(UNDEFS) -L$(LINKLIBS) $(NEEDLIBS) $(>)
2233    }
2234
2235    actions C++
2236    {
2237    $(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)
2238    }
2239
2240    actions Cc
2241    {
2242    $(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)
2243    }
2244
2245  }
2246  else if $(TOOLSET) = MINGW
2247  {
2248    actions together piecemeal Archive
2249    {
2250      $(AR) $(<) $(>:T)
2251    }
2252
2253    actions Cc
2254    {
2255    $(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)
2256    }
2257
2258    actions C++
2259    {
2260    $(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)
2261    }
2262  }
2263  else if $(TOOLSET) = WATCOM
2264  {
2265    actions together piecemeal Archive
2266    {
2267    $(AR) $(<) +-$(>)
2268    }
2269
2270    actions Cc
2271    {
2272    $(CC) $(CCFLAGS) $(OPTIM) /Fo=$(<) /I$(HDRS) $(>)
2273    }
2274
2275    actions C++
2276    {
2277    $(C++) $(C++FLAGS) $(OPTIM) /Fo=$(<) /I$(HDRS) $(>)
2278    }
2279
2280    actions Link bind NEEDLIBS
2281    {
2282    $(LINK) $(LINKFLAGS) /Fe=$(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2283    }
2284
2285    actions Shell
2286    {
2287    $(CP) $(>) $(<)
2288    }
2289  }
2290  else if $(TOOLSET) = LCC
2291  {
2292    actions together piecemeal Archive
2293    {
2294    $(AR) /out:$(<) $(>)
2295    }
2296
2297    actions Cc
2298    {
2299    $(CC) $(CCFLAGS) $(OPTIM) -Fo$(<) -I$(HDRS) $(>)
2300    }
2301
2302    actions Link bind NEEDLIBS
2303    {
2304    $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2305    }
2306
2307    actions Shell
2308    {
2309    $(CP) $(>) $(<)
2310    }
2311  }
2312}
2313
2314#
2315# OS2 specific actions
2316#
2317
2318else if $(OS2)
2319{
2320  if $(TOOLSET) = WATCOM
2321  {
2322    actions together piecemeal Archive
2323    {
2324    $(AR) $(<) +-$(>)
2325    }
2326
2327    actions Cc
2328    {
2329    $(CC) $(CCFLAGS) $(OPTIM) /Fo=$(<) /I$(HDRS) $(>)
2330    }
2331
2332    actions C++
2333    {
2334    $(C++) $(C++FLAGS) $(OPTIM) /Fo=$(<) /I$(HDRS) $(>)
2335    }
2336
2337    actions Link bind NEEDLIBS
2338    {
2339    $(LINK) $(LINKFLAGS) /Fe=$(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
2340    }
2341
2342    actions Shell
2343    {
2344    $(CP) $(>) $(<)
2345    }
2346  }
2347  else if $(TOOLSET) = EMX
2348  {
2349    actions together piecemeal Archive
2350    {
2351      $(AR) $(<) $(>:T)
2352    }
2353
2354    actions Cc
2355    {
2356    $(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)
2357    }
2358
2359    actions C++
2360    {
2361    $(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)
2362    }
2363  }
2364}
2365
2366#
2367# VMS specific actions
2368#
2369
2370else if $(VMS)
2371{
2372    actions updated together piecemeal Archive
2373    {
2374    lib/replace $(<) $(>[1]) ,$(>[2-])
2375    }
2376
2377    actions Cc
2378    {
2379    $(CC)/obj=$(<) $(CCFLAGS) $(OPTIM) $(SLASHINC) $(>)
2380    }
2381
2382    actions C++
2383    {
2384    $(C++)/obj=$(<) $(C++FLAGS) $(OPTIM) $(SLASHINC) $(>)
2385    }
2386
2387    actions piecemeal together existing Clean
2388    {
2389    $(RM) $(>[1]);* ,$(>[2-]);*
2390    }
2391
2392    actions together quietly CreLib
2393    {
2394    if f$search("$(<)") .eqs. "" then lib/create $(<)
2395    }
2396
2397    actions GenFile1
2398    {
2399    mcr $(>[1]) $(<) $(>[2-])
2400    }
2401
2402    actions Link bind NEEDLIBS
2403    {
2404    $(LINK)/exe=$(<) $(LINKFLAGS) $(>[1]) ,$(>[2-]) ,$(NEEDLIBS)/lib ,$(LINKLIBS)
2405    }
2406
2407    actions quietly updated piecemeal together RmTemps
2408    {
2409    $(RM) $(>[1]);* ,$(>[2-]);*
2410    }
2411
2412    actions Shell
2413    {
2414    $(CP) $(>) $(<)
2415    }
2416}
2417
2418#
2419# Mac specifc actions
2420#
2421
2422else if $(MAC)
2423{
2424    actions together Archive
2425    {
2426    $(LINK) -library -o $(<) $(>)
2427    }
2428
2429    actions Cc
2430    {
2431    set -e MWCincludes $(MACINC)
2432    $(CC) -o $(<) $(CCFLAGS) $(OPTIM) $(>)
2433    }
2434
2435    actions C++
2436    {
2437    set -e MWCincludes $(MACINC)
2438    $(CC) -o $(<) $(C++FLAGS) $(OPTIM) $(>)
2439    }
2440
2441    actions Link bind NEEDLIBS
2442    {
2443    $(LINK) -o $(<) $(LINKFLAGS) $(>) $(NEEDLIBS) "$(LINKLIBS)"
2444    }
2445}
2446
2447#
2448# Backwards compatibility with jam 1, where rules were uppercased.
2449#
2450
2451rule BULK { Bulk $(<) : $(>) ; }
2452rule FILE { File $(<) : $(>) ; }
2453rule HDRRULE { HdrRule $(<) : $(>) ; }
2454rule INSTALL { Install $(<) : $(>) ; }
2455rule LIBRARY { Library $(<) : $(>) ; }
2456rule LIBS { LinkLibraries $(<) : $(>) ; }
2457rule LINK { Link $(<) : $(>) ; }
2458rule MAIN { Main $(<) : $(>) ; }
2459rule SETUID { Setuid $(<) ; }
2460rule SHELL { Shell $(<) : $(>) ; }
2461rule UNDEFINES { Undefines $(<) : $(>) ; }
2462
2463# Old INSTALL* didn't take dest directory.
2464
2465rule INSTALLBIN { InstallBin $(BINDIR) : $(<) ; }
2466rule INSTALLLIB { InstallLib $(LIBDIR) : $(<) ; }
2467rule INSTALLMAN { InstallMan $(MANDIR) : $(<) ; }
2468
2469# Compatibility with jam 2.2.
2470
2471rule addDirName { $(<) += [ FDirName $(>) ] ; }
2472rule makeDirName { $(<) = [ FDirName $(>) ] ; }
2473rule makeGristedName { $(<) = [ FGristSourceFiles $(>) ] ; }
2474rule makeRelPath { $(<[1]) = [ FRelPath $(<[2-]) : $(>) ] ; }
2475rule makeSuffixed { $(<[1]) = [ FAppendSuffix $(>) : $(<[2]) ] ; }
2476
2477#
2478# Now include the user's Jamfile.
2479#
2480
2481{
2482    if $(JAMFILE) { include $(JAMFILE) ; }
2483}
2484
2485}
2486