📄 jambase
字号:
#
# /+\
# +\ Copyright 1993, 2000 Christopher Seiwald.
# \+/
#
# This file is part of Jam - see jam.c for Copyright information.
#
# This file is ALSO:
# Copyright 2001-2004 David Abrahams.
# Copyright 2002-2004 Rene Rivera.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
if $(NT)
{
SLASH ?= \\ ;
}
SLASH ?= / ;
# Glob for patterns in the directories starting from the given
# start directory, up to and including the root of the file-system.
# We stop globbing as soon as we find at least one match.
#
rule find-to-root ( dir : patterns + )
{
local globs = [ GLOB $(dir) : $(patterns) ] ;
while ! $(globs) && $(dir:P) != $(dir)
{
dir = $(dir:P) ;
globs = [ GLOB $(dir) : $(patterns) ] ;
}
return $(globs) ;
}
# This global will hold the location of the user's boost-build.jam file.
.boost-build-file = ;
# This global will hold the location of the build system bootstrap file.
.bootstrap-file = ;
# Remember the value of $(BOOST_BUILD_PATH) supplied to us by the user.
BOOST_BUILD_PATH.user-value = $(BOOST_BUILD_PATH) ;
# On Unix only, when BOOST_BUILD_PATH is not supplied by user, put
# sensible default value. This allowes Boost.Build to work without
# any environment variables, which is good in itself and also
# required by Debian Policy.
if ! $(BOOST_BUILD_PATH) && $(UNIX)
{
BOOST_BUILD_PATH = /usr/share/boost-build ;
}
rule _poke ( module-name ? : variables + : value * )
{
module $(<)
{
$(>) = $(3) ;
}
}
# This rule can be invoked from an optional user's boost-build.jam
# file to both indicate where to find the build system files, and to
# load them. The path indicated is relative to the location of the
# boost-build.jam file.
#
rule boost-build ( dir ? )
{
if $(.bootstrap-file)
{
EXIT "Error: Illegal attempt to re-bootstrap the build system by invoking" ;
ECHO ;
ECHO " 'boost-build" $(dir) ";'" ;
ECHO ;
EXIT "Please consult the documentation at 'http://www.boost.org'." ;
}
# Add the given directory to the path so we can find the build
# system. If dir is empty, has no effect.
#
BOOST_BUILD_PATH = $(dir:R=$(.boost-build-file:D)) $(BOOST_BUILD_PATH) ;
# We might have just modified the *global* value of BOOST_BUILD_PATH.
# The code that loads the rest of Boost.Build, in particular the
# site-config.jam and user-config.jam files uses os.environ, so we need to
# update the value there.
_poke .ENVIRON : BOOST_BUILD_PATH : $(BOOST_BUILD_PATH) ;
# Try to find the build system bootstrap file 'bootstrap.jam'.
#
local bootstrap-file =
[ GLOB $(BOOST_BUILD_PATH) : bootstrap.jam ] ;
.bootstrap-file = $(bootstrap-file[1]) ;
# There is no boost-build.jam we can find, exit with an error
#
if ! $(.bootstrap-file)
{
ECHO "Unable to load Boost.Build: could not find build system." ;
ECHO --------------------------------------------------------- ;
ECHO "$(.boost-build-file) attempted to load the build system by invoking" ;
ECHO ;
ECHO " 'boost-build" $(dir) ";'" ;
ECHO ;
ECHO "but we were unable to find \"bootstrap.jam\" in the specified directory" ;
ECHO "or in BOOST_BUILD_PATH (searching "$(BOOST_BUILD_PATH:J=", ")")." ;
ECHO ;
EXIT "Please consult the documentation at 'http://www.boost.org'." ;
}
if [ MATCH .*(--debug-configuration).* : $(ARGV) ]
{
ECHO "notice: loading Boost.Build from"
[ NORMALIZE_PATH $(.bootstrap-file:D) ] ;
}
# Load the build system, now that we know where to start from.
#
include $(.bootstrap-file) ;
}
if [ MATCH .*(bjam).* : $(ARGV[1]:BL) ]
|| $(BOOST_ROOT) # A temporary measure so Jam works with Boost.Build v1
{
# We attempt to load "boost-build.jam" by searching from the current invocation directory
# up to the root of the file-system.
#
# boost-build.jam is expected to invoke the "boost-build" rule to
# load the Boost.Build files.
local search-path = $(BOOST_BUILD_PATH) $(BOOST_ROOT) ;
local boost-build-files =
[ find-to-root [ PWD ] : boost-build.jam ]
# Another temporary measure so Jam works with Boost.Build v1
[ GLOB $(search-path) : boost-build.jam ] ;
.boost-build-file = $(boost-build-files[1]) ;
# There is no boost-build.jam we can find, exit with an error, and information.
#
if ! $(.boost-build-file)
{
ECHO "Unable to load Boost.Build: could not find \"boost-build.jam\"" ;
ECHO --------------------------------------------------------------- ;
if ! [ MATCH .*(bjam).* : $(ARGV[1]:BL) ]
{
ECHO "BOOST_ROOT must be set, either in the environment, or " ;
ECHO "on the command-line with -sBOOST_ROOT=..., to the root" ;
ECHO "of the boost installation." ;
ECHO ;
}
ECHO "Attempted search from" [ PWD ] "up to the root" ;
ECHO "and in these directories from BOOST_BUILD_PATH and BOOST_ROOT: "$(search-path:J=", ")"." ;
EXIT "Please consult the documentation at 'http://www.boost.org'." ;
}
if [ MATCH .*(--debug-configuration).* : $(ARGV) ]
{
ECHO "notice: found boost-build.jam at"
[ NORMALIZE_PATH $(.boost-build-file) ] ;
}
# Now load the boost-build.jam to get the build system loaded. This
# incidentaly loads the users jamfile and attempts to build targets.
#
# We also set it up so we can tell wether we are loading the new V2
# system or the the old V1 system.
#
include $(.boost-build-file) ;
# Check that, at minimum, the bootstrap file was found.
#
if ! $(.bootstrap-file)
{
ECHO "Unable to load Boost.Build" ;
ECHO -------------------------- ;
ECHO "\"$(.boost-build-file)\" was found by searching from" [ PWD ] "up to the root" ;
ECHO "and in these directories from BOOST_BUILD_PATH and BOOST_ROOT: "$(search-path:J=", ")"." ;
ECHO ;
ECHO "However, it failed to call the \"boost-build\" rule to indicate" ;
ECHO "the location of the build system." ;
ECHO ;
EXIT "Please consult the documentation at 'http://www.boost.org'." ;
}
}
else
{
#
# JAMBASE - jam 2.3 ruleset providing make(1)-like functionality
#
# Supports UNIX, NT, and VMS.
#
# 12/27/93 (seiwald) - purturb library sources with SOURCE_GRIST
# 04/18/94 (seiwald) - use '?=' when setting OS specific vars
# 04/21/94 (seiwald) - do RmTemps together
# 05/05/94 (seiwald) - all supported C compilers support -o: relegate
# RELOCATE as an option; set Ranlib to "" to disable it
# 06/01/94 (seiwald) - new 'actions existing' to do existing sources
# 08/25/94 (seiwald) - new ObjectCcFlags rule to append to per-target CCFLAGS
# 08/29/94 (seiwald) - new ObjectHdrs rule to append to per-target HDRS
# 09/19/94 (seiwald) - LinkLibraries and Undefs now append
# - Rule names downshifted.
# 10/06/94 (seiwald) - Dumb yyacc stuff moved into Jamfile.
# 10/14/94 (seiwald) - (Crude) support for .s, .C, .cc, .cpp, and .f files.
# 01/08/95 (seiwald) - Shell now handled with awk, not sed
# 01/09/95 (seiwald) - Install* now take dest directory as target
# 01/10/95 (seiwald) - All entries sorted.
# 01/10/95 (seiwald) - NT support moved in, with LauraW's help.
# 01/10/95 (seiwald) - VMS support moved in.
# 02/06/95 (seiwald) - ObjectC++Flags and SubDirC++Flags added.
# 02/07/95 (seiwald) - Iron out when HDRSEARCH uses "" or SEARCH_SOURCE.
# 02/08/95 (seiwald) - SubDir works on VMS.
# 02/14/95 (seiwald) - MkDir and entourage.
# 04/30/95 (seiwald) - Use install -c flag so that it copies, not moves.
# 07/10/95 (taylor) - Support for Microsoft C++.
# 11/21/96 (peterk) - Support for BeOS
# 07/19/99 (sickel) - Support for Mac OS X Server (and maybe client)
# 02/18/00 (belmonte)- Support for Cygwin.
# Special targets defined in this file:
#
# all - parent of first, shell, files, lib, exe
# first - first dependent of 'all', for potential initialization
# shell - parent of all Shell targets
# files - parent of all File targets
# lib - parent of all Library targets
# exe - parent of all Main targets
# dirs - parent of all MkDir targets
# clean - removes all Shell, File, Library, and Main targets
# uninstall - removes all Install targets
#
# Rules defined by this file:
#
# as obj.o : source.s ; .s -> .o
# Bulk dir : files ; populate directory with many files
# Cc obj.o : source.c ; .c -> .o
# C++ obj.o : source.cc ; .cc -> .o
# Clean clean : sources ; remove sources with 'jam clean'
# File dest : source ; copy file
# Fortran obj.o : source.f ; .f -> .o
# GenFile source.c : program args ; make custom file
# Hardlink target : source ; make link from source to target
# HdrRule source : headers ; handle #includes
# InstallInto dir : sources ; install any files
# InstallBin dir : sources ; install binaries
# InstallLib dir : sources ; install files
# InstallFile dir : sources ; install files
# InstallMan dir : sources ; install man pages
# InstallShell dir : sources ; install shell scripts
# Lex source.c : source.l ; .l -> .c
# Library lib : source ; archive library from compiled sources
# LibraryFromObjects lib : objects ; archive library from objects
# LinkLibraries images : libraries ; bag libraries onto Mains
# Main image : source ; link executable from compiled sources
# MainFromObjects image : objects ; link executable from objects
# MkDir dir ; make a directory, if not there
# Object object : source ; compile object from source
# ObjectCcFlags source : flags ; add compiler flags for object
# ObjectC++Flags source : flags ; add compiler flags for object
# ObjectHdrs source : dirs ; add include directories for object
# Objects sources ; compile sources
# RmTemps target : sources ; remove temp sources after target made
# Setuid images ; mark executables Setuid
# SubDir TOP d1 d2 ... ; start a subdirectory Jamfile
# SubDirCcFlags flags ; add compiler flags until next SubDir
# SubDirC++Flags flags ; add compiler flags until next SubDir
# SubDirHdrs dirs ; add include dirs until next SubDir
# SubInclude TOP d1 d2 ... ; include a subdirectory Jamfile
# Shell exe : source ; make a shell executable
# Undefines images : symbols ; save undef's for linking
# UserObject object : source ; handle unknown suffixes for Object
# Yacc source.c : source.y ; .y -> .c
#
# Utility rules that have no side effects (not supported):
#
# FAppendSuffix f1 f2 ... : $(SUF) ; return $(<) with suffixes
# FConcat value ... ; return contatenated values
# FDirName d1 d2 ... ; return path from root to dir
# FGrist d1 d2 ... ; return d1!d2!...
# FGristFiles value ; return $(value:G=$(SOURCE_GRIST))
# FGristSourceFiles value ; return $(value:G=$(SOURCE_GRIST))
# FRelPath d1 : d2 ; return rel path from d1 to d2
# FSubDir d1 d2 ... ; return path to root
#
# Brief review of the jam language:
#
# Statements:
# rule RULE - statements to process a rule
# actions RULE - system commands to carry out target update
#
# Modifiers on actions:
# together - multiple instances of same rule on target get executed
# once with their sources ($(>)) concatenated
# updated - refers to updated sources ($(>)) only
# ignore - ignore return status of command
# quietly - don't trace its execution unless verbose
# piecemeal - iterate command each time with a small subset of $(>)
# existing - refers to currently existing sources ($(>)) only
# bind vars - subject to binding before expanding in actions
#
# Special rules:
# ALWAYS - always build a target
# DEPENDS - builds the dependency graph
# ECHO - blurt out targets on stdout
# EXIT - blurt out targets and exit
# INCLUDES - marks sources as headers for target (a codependency)
# NOCARE - don't panic if the target can't be built
# NOUPDATE - create the target if needed but never update it
# NOTFILE - ignore the timestamp of the target (it's not a file)
# TEMPORARY - target need not be present if sources haven't changed
#
# Special variables set by jam:
# $(<) - targets of a rule (to the left of the :)
# $(>) - sources of a rule (to the right of the :)
# $(xxx) - true on xxx (UNIX, VMS, NT, OS2, MAC)
# $(OS) - name of OS - varies wildly
# $(JAMVERSION) - version number (2.3)
#
# Special variables used by jam:
# SEARCH - where to find something (used during binding and actions)
# LOCATE - where to plop something not found with SEARCH
# HDRRULE - rule to call to handle include files
# HDRSCAN - egrep regex to extract include files
#
# Special targets:
# all - default if none given on command line
#
# Initialize variables
#
#
# OS specific variable settings
#
if $(NT)
{
# the list of supported toolsets on Windows NT and Windows 95/98
#
local SUPPORTED_TOOLSETS = "BORLANDC" "VC7" "VISUALC" "VISUALC16" "INTELC" "WATCOM"
"MINGW" "LCC" ;
# this variable holds the current toolset
#
TOOLSET = "" ;
# if the JAM_TOOLSET environment variable is defined, check that it is
# one of our supported values
#
if $(JAM_TOOLSET)
{
local t ;
for t in $(SUPPORTED_TOOLSETS)
{
$(t) = $($(t):J=" ") ; # reconstitute paths with spaces in them
if $(t) = $(JAM_TOOLSET) { TOOLSET = $(t) ; }
}
if ! $(TOOLSET)
{
ECHO "The JAM_TOOLSET environment variable is defined but its value" ;
ECHO "is invalid, please use one of the following:" ;
ECHO ;
for t in $(SUPPORTED_TOOLSETS) { ECHO " " $(t) ; }
EXIT ;
}
}
# if TOOLSET is empty, we'll try to detect the toolset from other
# environment variables to remain backwards compatible with Jam 2.3
#
if ! $(TOOLSET)
{
if $(BCCROOT)
{
TOOLSET = BORLANDC ;
BORLANDC = $(BCCROOT:J=" ") ;
}
else if $(MSVC)
{
TOOLSET = VISUALC16 ;
VISUALC16 = $(MSVC:J=" ") ;
}
else if $(MSVCNT)
{
TOOLSET = VISUALC ;
VISUALC = $(MSVCNT:J=" ") ;
}
else if $(MSVCDir)
{
TOOLSET = VISUALC ;
VISUALC = $(MSVCDir:J=" ") ;
}
else if $(MINGW)
{
TOOLSET = MINGW ;
}
else
{
ECHO "Jam cannot be run because, either:" ;
ECHO " a. You didn't set BOOST_ROOT to indicate the root of your" ;
ECHO " Boost installation." ;
ECHO " b. You are trying to use stock Jam but didn't indicate which" ;
ECHO " compilation toolset to use. To do so, follow these simple" ;
ECHO " instructions:" ;
ECHO ;
ECHO " - define one of the following environment variable, with the" ;
ECHO " appropriate value according to this list:" ;
ECHO ;
ECHO " Variable Toolset Description" ;
ECHO ;
ECHO " BORLANDC Borland C++ BC++ install path" ;
ECHO " VISUALC Microsoft Visual C++ VC++ install path" ;
ECHO " VISUALC16 Microsoft Visual C++ 16 bit VC++ 16 bit install" ;
ECHO " INTELC Intel C/C++ IC++ install path" ;
ECHO " WATCOM Watcom C/C++ Watcom install path" ;
ECHO " MINGW MinGW (gcc) MinGW install path" ;
ECHO " LCC Win32-LCC LCC-Win32 install path" ;
ECHO ;
ECHO " - define the JAM_TOOLSET environment variable with the *name*" ;
ECHO " of the toolset variable you want to use." ;
ECHO ;
ECHO " e.g.: set VISUALC=C:\\Visual6" ;
ECHO " set JAM_TOOLSET=VISUALC" ;
EXIT ;
}
}
CP ?= copy ;
RM ?= del /f/q ;
SLASH ?= \\ ;
SUFLIB ?= .lib ;
SUFOBJ ?= .obj ;
SUFEXE ?= .exe ;
if $(TOOLSET) = BORLANDC
{
ECHO "Compiler is Borland C++" ;
AR ?= tlib /C /P64 ;
CC ?= bcc32 ;
CCFLAGS ?= -q -y -d -v -w-par -w-ccc -w-rch -w-pro -w-aus ;
C++ ?= bcc32 ;
C++FLAGS ?= -q -y -d -v -w-par -w-ccc -w-rch -w-pro -w-aus -P ;
LINK ?= $(CC) ;
LINKFLAGS ?= $(CCFLAGS) ;
STDLIBPATH ?= $(BORLANDC)\\lib ;
STDHDRS ?= $(BORLANDC)\\include ;
NOARSCAN ?= true ;
}
else if $(TOOLSET) = VISUALC16
{
ECHO "Compiler is Microsoft Visual C++ 16 bit" ;
AR ?= lib /nologo ;
CC ?= cl /nologo ;
CCFLAGS ?= /D \"WIN\" ;
C++ ?= $(CC) ;
C++FLAGS ?= $(CCFLAGS) ;
LINK ?= $(CC) ;
LINKFLAGS ?= $(CCFLAGS) ;
LINKLIBS ?=
\"$(VISUALC16)\\lib\\mlibce.lib\"
\"$(VISUALC16)\\lib\\oldnames.lib\"
;
LINKLIBS ?= ;
NOARSCAN ?= true ;
OPTIM ?= "" ;
STDHDRS ?= $(VISUALC16)\\include ;
UNDEFFLAG ?= "/u _" ;
}
else if $(TOOLSET) = VISUALC
{
ECHO "Compiler is Microsoft Visual C++" ;
AR ?= lib ;
AS ?= masm386 ;
CC ?= cl /nologo ;
CCFLAGS ?= "" ;
C++ ?= $(CC) ;
C++FLAGS ?= $(CCFLAGS) ;
LINK ?= link /nologo ;
LINKFLAGS ?= "" ;
LINKLIBS ?= \"$(VISUALC)\\lib\\advapi32.lib\"
# $(VISUALC)\\lib\\libc.lib
# $(VISUALC)\\lib\\oldnames.lib
\"$(VISUALC)\\lib\\gdi32.lib\"
\"$(VISUALC)\\lib\\user32.lib\"
\"$(VISUALC)\\lib\\kernel32.lib\" ;
OPTIM ?= "" ;
STDHDRS ?= $(VISUALC)\\include ;
UNDEFFLAG ?= "/u _" ;
}
else if $(TOOLSET) = VC7
{
ECHO "Compiler is Microsoft Visual C++ .NET" ;
AR ?= lib ;
AS ?= masm386 ;
CC ?= cl /nologo ;
CCFLAGS ?= "" ;
C++ ?= $(CC) ;
C++FLAGS ?= $(CCFLAGS) ;
LINK ?= link /nologo ;
LINKFLAGS ?= "" ;
LINKLIBS ?= \"$(VISUALC)\\PlatformSDK\\lib\\advapi32.lib\"
# $(VISUALC)\\lib\\libc.lib
# $(VISUALC)\\lib\\oldnames.lib
\"$(VISUALC)\\PlatformSDK\\lib\\gdi32.lib\"
\"$(VISUALC)\\PlatformSDK\\lib\\user32.lib\"
\"$(VISUALC)\\PlatformSDK\\lib\\kernel32.lib\" ;
OPTIM ?= "" ;
STDHDRS ?= \"$(VISUALC)\\include\"
\"$(VISUALC)\\PlatformSDK\\include\" ;
UNDEFFLAG ?= "/u _" ;
}
else if $(TOOLSET) = INTELC
{
ECHO "Compiler is Intel C/C++" ;
if ! $(VISUALC)
{
ECHO "As a special exception, when using the Intel C++ compiler, you need" ;
ECHO "to define the VISUALC environment variable to indicate the location" ;
ECHO "of your Visual C++ installation. Aborting.." ;
EXIT ;
}
AR ?= lib ;
AS ?= masm386 ;
CC ?= icl /nologo ;
CCFLAGS ?= "" ;
C++ ?= $(CC) ;
C++FLAGS ?= $(CCFLAGS) ;
LINK ?= link /nologo ;
LINKFLAGS ?= "" ;
LINKLIBS ?= $(VISUALC)\\lib\\advapi32.lib
# $(VISUALC)\\lib\\libc.lib
# $(VISUALC)\\lib\\oldnames.lib
$(VISUALC)\\lib\\kernel32.lib
;
OPTIM ?= "" ;
STDHDRS ?= $(INTELC)\include $(VISUALC)\\include ;
UNDEFFLAG ?= "/u _" ;
}
else if $(TOOLSET) = WATCOM
{
ECHO "Compiler is Watcom C/C++" ;
AR ?= wlib ;
CC ?= wcc386 ;
CCFLAGS ?= /zq /DWIN32 /I$(WATCOM)\\h ; # zq=quiet
C++ ?= wpp386 ;
C++FLAGS ?= $(CCFLAGS) ;
CP ?= copy ;
DOT ?= . ;
DOTDOT ?= .. ;
LINK ?= wcl386 ;
LINKFLAGS ?= /zq ; # zq=quiet
LINKLIBS ?= ;
MV ?= move ;
NOARSCAN ?= true ;
OPTIM ?= ;
RM ?= del /f ;
SLASH ?= \\ ;
STDHDRS ?= $(WATCOM)\\h $(WATCOM)\\h\\nt ;
SUFEXE ?= .exe ;
SUFLIB ?= .lib ;
SUFOBJ ?= .obj ;
UNDEFFLAG ?= "/u _" ;
}
else if $(TOOLSET) = MINGW
{
ECHO "Compiler is GCC with Mingw" ;
AR ?= ar -ru ;
CC ?= gcc ;
CCFLAGS ?= "" ;
C++ ?= $(CC) ;
C++FLAGS ?= $(CCFLAGS) ;
LINK ?= $(CC) ;
LINKFLAGS ?= "" ;
LINKLIBS ?= "" ;
OPTIM ?= ;
SUFOBJ = .o ;
SUFLIB = .a ;
SLASH = / ;
# NOARSCAN ?= true ;
}
else if $(TOOLSET) = LCC
{
ECHO "Compiler is Win32-LCC" ;
AR ?= lcclib ;
CC ?= lcc ;
CCFLAGS ?= "" ;
C++ ?= $(CC) ;
C++FLAGS ?= $(CCFLAGS) ;
LINK ?= lcclnk ;
LINKFLAGS ?= "" ;
LINKLIBS ?= "" ;
OPTIM ?= ;
NOARSCAN = true ;
}
else
{
#
# XXX: We need better comments here !!
#
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -