#
# There are a number of modifications made to Jam which you can either
# accept or reject as you wish.
#
# 
# To turn on one of these features, either alter the default below or
# set it on the Jam command line, like:
#     jam -sHeaderCache=1
#
# CWM, 2001.

AllOptions          ?= "" ;

DynamicCommandSize  ?= True ;
ImprovedWarnings    ?= True ;
SerialOutput        ?= True ;
SlashModifiers      ?= True ;
HeaderCache         ?= True ;
OptionalHeaders     ?= True ;
GraphDebugDump      ?= True ;
DebugFateChanges    ?= True ;
LargeBuildOutput    ?= True ;
TimeStamps          ?= True ;
DebugOutputMods     ?= True ;
NocareNodes         ?= True ;
PercentDone         ?= True ;
ExportJobNum        ?= True ;
JobSlotExpansion    ?= True ;
PrintTotalTime      ?= True ;
W32GetReg           ?= True ;
Semaphore           ?= True ;
IntrFix             ?= True ;
EnvFix              ?= True ;


# ----------------------------------------------------------------------
# A rule that checks a variable, if its set, it adds the define to the
# list of defines

OPT_DEFINES = ;

rule config
{
    if $($(<)) || $(AllOptions)
    {
        OPT_DEFINES += $(2) ;
        ECHO "Config:" $(<) is on ;

        $(<) = True ;   # Turn on if all options is on
    }
    else {
        ECHO "Config:" $(<) is off ;
    }
}

if $(AllOptions)
{
    ECHO "Config:" AllOptions is on ;
}
else {
    ECHO "Config:" AllOptions is off ;
}


# ----------------------------------------------------------------------
# A note on the names of the defines.  
# 
# An optional part of Jam is initially an extension.
#
# If an extension is accepted into to the mainline, its define is either
# removed completely and the code simply placed into the mainline in a 
# non-conditional manner, or the EXT extension is dropped and it remains
# conditional.  
#
# For example, if the header cache code is accepted into the mainline but
# as a continuing option to the build, the define would be OPT_HEADER_CACHE, 
# not OPT_HEADER_CACHE_EXT.
#
# Or something like that.  Just an idea.


# When creating the actions command buffer, dynamically grow the buffer 
# to as large as needed.  Even though some shells are not able to accept
# very large buffers - some OSs support amazingly large commands.  Multi
# mega-byte commands are ok on Solaris, HPUX, Linux, etc
# 
# Craig McPheeters, 2001.
config DynamicCommandSize : OPT_DYNAMIC_COMMAND_SIZE_EXT ;


# Try to associate a filename and line number with errors and warnings
# 
# Craig McPheeters, 2001.
config ImprovedWarnings : OPT_IMPROVED_WARNINGS_EXT ;


# Actions write their output into temporary files.  When an action
# completes, the files contents are displayed along with the associated
# jam action line.  This serializes the output from Jam - however it 
# introduces a latency in that you don't see what Jam is doing as it
# works on an action, you only see the results afterwards
# 
# Craig McPheeters, 2001.
config SerialOutput : OPT_SERIAL_OUTPUT_EXT ;


# Add support for the variable expansion modifiers:
#    $(foo:/)  - which converts all \ characters to /, and
#    $(foo:\)  - which converts all / characters to \
# These are useful mainly on NT to get the pathname syntax you want
# 
# Craig McPheeters, 2001.
config SlashModifiers : OPT_SLASH_MODIFIERS_EXT ;


# The header cache is used to cache the results from the scan of each
# file to find headers.  Pretty much as it sounds.
#
# When Jam is started, the header cache is read into a hash table.  Then
# as each file is about to be scanned for headers, it is looked up in 
# the cache, and if its there and the files timestamp agrees with the 
# cache then the cache's results are used.  This is really useful for large
# builds.
# 
# Craig McPheeters, 2001.
config HeaderCache : OPT_HEADER_CACHE_EXT ;


# This option allows you to ignore header dependencies when building with
# Jam.  If you are working with a large system, and you have modified a 
# low level header, you may want to delay the full build Jam would do 
# when it sees the dependencies that are out of date.  By building with
# this option, you can specify a command line argument to have include 
# file dependencies ignored for a build: jam -p
# 
# Craig McPheeters, 2001.
config OptionalHeaders : OPT_HEADER_OPTION_EXT ;


# This option enables two new debugging levels.  The first, debug level
# 10 outputs a more readable form of the dependency graph.  This may be
# useful for people trying to understand a problem with the dependency
# graph
#
# The second new debug level is debug level 11.  This shows more
# information about the fate of each target, as it is processed in make0().
# The debug level 10 extension shows you the final state of the targets.
# There are times when this is insufficient to know why a target is being
# updated.  Debug level 11 gives a little information on why a targets fate
# is changed from stable, to newer, update, missing, etc.
# 
# Craig McPheeters, 2001.
config GraphDebugDump : OPT_GRAPH_DEBUG_EXT ;


# This option controls a variety of minor mods to the output of Jam which
# I found more suitable when working with large systems.  YMMV.
# 
# Craig McPheeters, 2001.
config LargeBuildOutput : OPT_LARGE_BUILD_EXT ;


# This option places time stamps on various output messages in jam.  I
# found this useful to guage the performance of long builds to find 
# where most of the time was spent, to compare build performance between
# machines, or to compare the effect on a build of any changes you are
# making.
# 
# Craig McPheeters, 2001.
config TimeStamps : OPT_TIME_STAMP_OUTPUT_EXT ;


# Various minor mods to the debug level 4, execcmds() level.
# 
# Craig McPheeters, 2001.
config DebugOutputMods : OPT_OUTPUT_MOD_EXT ;


# This option allows you to mark an intermediate node as being 
# NOCARE.  If an action related to the building of this node fails,
# any dependencies on this NOCARE node continue anyway.  This is useful
# when partial results from the build are useful.
# 
# Craig McPheeters, 2001.
config NocareNodes : OPT_NOCARE_NODES_EXT ;


# This displays the percentage of the build which is done, as each
# rule is printed out
# 
# Craig McPheeters, 2001.
config PercentDone : OPT_PERCENT_DONE_EXT ;


# Create Jam variables which shows how many jobs have been requested,
# if the build is using more than one job, and a list of the job
# numbers.  These variables can be used in a variety of ways.
# 
# Craig McPheeters, 2001.
config ExportJobNum : OPT_EXPORT_JOBNUM_EXT ;


# When building some objects, there may be conflicts between shared files
# being accessed by more than one jam job.  For example, when processing
# yacc .y files, there are intermediate files created.  If more than one
# action processes yacc files at the same time, these temporary files may
# collide.  Most Unix shells allow you to easily incorporate a process id
# into a filename, via the $$ expansion.  NT's cmd.exe doesn't allow this.
# This extension allows a portable method for creating temporary file
# names, among other uses.  Jam has a variable number of slots it can run a
# command from, depending on the value of the '-j' argument.  This
# extension replaces a '!!' sequence in the action block with a two digit
# representation of the jam slot the action is running in.  There is a 
# maximum of 64 jobs enforced by jam, two digits is sufficient to represent
# the job slot.  
#
# The other way for jam to communicate the job slot being used by an acion
# is via the '!' character in the JAMSHELL for the action.  This extension
# may potentially interfere with some given syntax in an action block, if
# the !! character sequence is used in a different way.  This hasn't been
# a problem for me, and I prefer the ease of getting the job slot via this
# extension.  YMMV.
#
# Craig McPheeters, 2001.  
config JobSlotExpansion : OPT_JOB_SLOT_EXT ;


# This extension is from Matt Armstrong.  For the original, see: 
#     //guest/matt_armstrong/jam/patched_version/... 
#
# If the total time jam runs is greater than 10 seconds, the time is
# printed when jam exits.  This helps people back up claims that the
# build is too slow and they need a faster machine.  ;-)
#
# Matt Armstrong, 2001.
config PrintTotalTime : OPT_PRINT_TOTAL_TIME_EXT ;


# This extension is from Matt Armstrong.  For the original, see: 
#     //guest/matt_armstrong/jam/patched_version/... 
#
# Available only under WinNT (Win2k as well).  Gets a value from the
# registry, like so:
#
#   value = [ W32_GETREG list ] ;
#
# This is primarily so Jam can find the location of the Visual C++
# installation from the registry, which makes it a bit easier to get
# a build environment up and running.  Otherwise, they would have to
# set the MSVCDIR environment variable, either at Visual C++ install
# time or by running the vcvars32.bat file that comes with Visual C++.
#
# Matt Armstrong, 2001.
config W32GetReg : OPT_BUILTIN_W32_GETREG_EXT ;


# When building, there are rare occassions when you just can't allow
# multiple jobs to operate on the same object, or with the same file
# at the same time.  This is most often best expressed by setting up the
# proper dependencies.  There are occassions where the dependencies are not
# able to express the relationships however.
#
# An example of this is on NT, related to PDB debug files used with
# pre-compiled headers.  Each set of files which are compiled with the same
# pre-compiled header must use the same .pdb file as was used for the
# pre-compiled header.  Only one compile job that references the .pdb file
# must be active at one time, as the compiler needs to open the file in
# exclusive write mode.  Its not a dependency on the file existing, its a
# dependency that only one job access the file at one time, its a timing
# rather than a dependency problem.  
# 
# Rather than doing a build with only one job active, using this extension
# it is possible to identify portions of the graph which must be serialized
# with respect to some file.  This is done by creating a node which acts as
# a semaphore, and assigning that node to the variable JAM_SEMAPHORE either
# globally or on a set of targets.  Only one job is able to be active at
# one time for each semaphore node you create.
#
# This facility could also be used to ensure only one occurence of a certain
# action type be launched at once.  For example, if the link of some shared
# objects consumes a lot of memory, you can set a semaphore on the links and
# only one link at a time will be run.
#
# Note, that a dependency node used as a semaphore should not be part of
# the graph, nothing should depend on them.  A semaphore node does not get 
# normal dependency propogation.
#
# Craig McPheeters, April 2002.
config Semaphore : OPT_SEMAPHORE ;

# To test the semaphore extension, uncomment the following line
# JAM_SEMAPHORE = .semaphore. ;


# Get interruptions to halt jam earlier.  Jam used to only check the interrupt
# flag when traversing the graph.  It now checks the flag when getting ready to
# launching new commands as well
#
# Craig McPheeters, April 2002.
config IntrFix : OPT_INTERRUPT_FIX ;

# When importing the environment, if the variable has trailing spaces the old
# code would incorrectly create a list with null elements.  This fix tests that
# the size of each list element when creating from the environment is non-null.
#
# Craig McPheeters, June 2002.
config EnvFix : OPT_ENVIRONMENT_FIX ;


# ----------------------------------------------------------------------
# Propogate the defines into the compiler flags

if $(UNIX)
{
    CCFLAGS += -D$(OPT_DEFINES) ;
}
else if $(NT)
{
    CCFLAGS += /D$(OPT_DEFINES) ;
}
else {
    ECHO The build options are not supported on this platform. ;
}