code:
# Boost.Build support specific for the Boost C++ Libraries.
# Copyright Vladimir Prus 2002-2010.
# Copyright Dave Abrahams 2005-2006.
# Copyright Rene Rivera 2005-2007.
# Copyright Douglas Gregor 2005.
#
# Distributed under the Boost Software License, Version 1.0.
#    (See accompanying file LICENSE_1_0.txt or copy at
#          http://www.boost.org/LICENSE_1_0.txt)

import "class" : new ;
import common ;
import configure ;
import build-system ;
import generate ;
import modules ;
import option ;
import os ;
import package ;
import path ;
import project ;
import regex ;
import set ;
import targets ;
import feature ;
import property ;

##############################################################################
#
# 0. General setup. Parse options, check them.
#
##############################################################################

BOOST_ROOT = [ modules.binding $(__name__) ] ;
BOOST_ROOT = $(BOOST_ROOT:D) ;

rule set-version ( version )
{
    BOOST_VERSION = $(version) ;

    local version-tag = [ MATCH ^([^.]+)[.]([^.]+)[.]([^.]+) : $(BOOST_VERSION)
        ] ;
    if $(version-tag[3]) = 0
    {
        version-tag = $(version-tag[1-2]) ;
    }
    BOOST_VERSION_TAG = $(version-tag:J=_) ;
}

# Option to choose how many variants to build. The default is "minimal".
build-type = [ option.get build-type ] ;
build-type ?= minimal ;
if ! ( $(build-type) in complete minimal )
{
    EXIT The value of the --build-type option should be either 'complete' or
        'minimal' ;
}

# What kind of layout are we doing?
layout = [ option.get layout : "" ] ;
# On Windows, we used versioned layout by default in order to be compatible with
# autolink. On other systems, we use system layout which is what every other
# program uses. Note that the Windows check is static, and will not be affected
# by specific build properties used.
if ! $(layout)
{
    if [ os.name ] = NT
    {
        layout = versioned ;
    }
    else
    {
        layout = system ;
    }
}
layout-$(layout) = true ;

if $(layout) = system && $(build-type) = complete
{
    ECHO error: Cannot use --layout=system with --build-type complete. ;
    ECHO error: Please use either --layout=versioned or --layout=tagged ;
    ECHO error: if you wish to build multiple variants. ;
    if [ os.name ] != NT
    {
        ECHO error: Note that --layout=system is used by default on Unix
            starting with Boost 1.40. ;
    }
    EXIT ;
}

# Possible stage only location.
stage-locate = [ option.get stagedir ] ;
stage-locate ?= stage ;
BOOST_STAGE_LOCATE = $(stage-locate) ;

# Custom build ID.
build-id = [ option.get buildid ] ;
if $(build-id)
{
    BUILD_ID = [ regex.replace $(build-id) "[*\\/:.\"\' ]" _ ] ;
}

# Python build id (for Python libraries only).
python-id = [ option.get "python-buildid" ] ;
if $(python-id)
{
    PYTHON_ID = [ regex.replace $(python-id) [*\\/:.\"\'] _ ] ;
}

################################################################################
#
# 1. 'tag' function adding decorations suitable to the properties if versioned
# or tagged layout is requested. Called from Jamroot.
#
################################################################################

rule tag ( name : type ? : property-set )
{
    if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
    {
        local result ;
        if $(layout) = versioned
        {
            result = [ common.format-name
                <base> <toolset> <threading> <runtime> -$(BOOST_VERSION_TAG)
                -$(BUILD_ID)
                : $(name) : $(type) : $(property-set) ] ;
        }
        else if $(layout) = tagged
        {
            result = [ common.format-name
                <base> <threading> <runtime>
                -$(BUILD_ID)
                : $(name) : $(type) : $(property-set) ] ;
        }
        else if $(layout) = system
        {
            result = [ common.format-name
                <base>
                -$(BUILD_ID)
                : $(name) : $(type) : $(property-set) ] ;
        }
        else
        {
            EXIT error: invalid layout '$(layout:E=)' ;
        }

        # Optionally add version suffix. On NT, library with version suffix will
        # not be recognized by linkers. On CYGWIN, we get strage duplicate
        # symbol errors when library is generated with version suffix. On OSX,
        # version suffix is not needed -- the linker expects the
        # libFoo.1.2.3.dylib format. AIX linkers do not accept version suffixes
        # either. Pgi compilers can not accept a library with version suffix.
        if $(type) = SHARED_LIB &&
          ! [ $(property-set).get <target-os> ] in windows cygwin darwin aix &&
          ! [ $(property-set).get <toolset> ] in pgi
        {
            result = $(result).$(BOOST_VERSION)  ;
        }

        return $(result) ;
    }
}

# Specialized tag function to use for libraries linking to Python.
# Appends value of --python-buildid if provided.
rule python-tag ( name : type ? : property-set )
{
    local result = $(name) ;
    if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB && $(PYTHON_ID)
    {
        result = $(result)-$(PYTHON_ID) ;
    }

    # forward to the boost tagging rule
    return  [ tag $(result) : $(type) : $(property-set) ] ;
}

################################################################################
#
# 2. Declare targets that build and install all libraries. Specifically:
#
#    - 'stage-proper' that puts all libraries in stage/lib
#    - 'install-proper' that install libraries and headers to system location
#    - 'stage-unversioned' that creates links to libraries without boost version
#       in name
#    - 'install-unversioned' which creates unversioned linked to installed
#       libraries.
#
################################################################################

# Worker function suitable to the 'generate' metatarget. Creates a link to
# 'source', striping any version number information from the name.
rule make-unversioned-links ( project name ? : property-set : sources * )
{
    local filter ;
    if [ modules.peek : NT ]
    {
        filter = (.*[.]lib) ;
    }
    else
    {
        filter =
            (.*[.]so)[.0-9]*
            (.*[.]dylib)
            (.*[.]a) ;
    }

    local result ;
    for local s in $(sources)
    {
        local m = [ MATCH ^(.*)-[0-9_]+$(filter)$ : [ $(s).name ] ] ;
        if $(m)
        {
            local ea = [ $(s).action ] ;
            local ep = [ $(ea).properties ] ;
            local a = [ new non-scanning-action $(s) : symlink.ln : $(ep) ] ;
            result += [ new file-target $(m:J=) exact : [ $(s).type ] :
                $(project) : $(a) ] ;
        }
    }
    return $(result) ;
}

rule filtered-target ( name : message + : sources + : requirements * )
{
    message $(name)-message : warning: $(message) ;
    alias $(name) : $(sources) : $(requirements) ;
    alias $(name) : $(name)-message ;

    local p = [ project.current ] ;
    $(p).mark-target-as-explicit $(name) ;
    $(p).mark-target-as-explicit $(name)-message ;
}

rule declare_install_and_stage_proper_targets ( libraries * : headers * )
{
    local p = [ project.current ] ;
    for local l in $(libraries)
    {
        if $(l) = locale
        {
            filtered-target $(l)-for-install :
                Skipping Boost.Locale library with threading=single. :
                libs/$(l)/build : <threading>multi ;
        }
        else if $(l) = wave
        {
            filtered-target $(l)-for-install :
                Skipping Boost.Wave library with threading=single. :
                libs/$(l)/build : <threading>multi ;
        }
        else if $(l) = thread
        {
            filtered-target $(l)-for-install :
                Skipping Boost.Thread library with threading=single. :
                libs/$(l)/build : <threading>multi ;
        }
        else
        {
            alias $(l)-for-install : libs/$(l)/build ;
            $(p).mark-target-as-explicit $(l)-for-install ;
        }
    }
    local library-targets = $(libraries)-for-install ;

    install-requirements = <install-source-root>$(BOOST_ROOT)/boost ;

    if $(layout-versioned)
    {
        install-requirements +=
            <install-header-subdir>boost-$(BOOST_VERSION_TAG)/boost ;
    }
    else
    {
        install-requirements += <install-header-subdir>boost ;
    }

    if [ os.name ] = NT
    {
        install-requirements += <install-default-prefix>C:/Boost ;
    }
    else
    {
        install-requirements += <install-default-prefix>/usr/local ;
    }

    p = [ project.current ] ;

    # Complete install.
    package.install install-proper
        : $(install-requirements) <install-no-version-symlinks>on
        :
        : $(libraries)-for-install
        : $(headers)
        ;
    $(p).mark-target-as-explicit install-proper ;

    # Install just library.
    install stage-proper
        : $(libraries)-for-install
        : <location>$(stage-locate)/lib
          <install-dependencies>on <install-type>LIB
          <install-no-version-symlinks>on
        ;
    $(p).mark-target-as-explicit stage-proper ;

    # Commented out as it does not seem to work. Whoever wrote this originally,
    # left some typos in the code, but when that got corrected and the code got
    # enabled - it started reporting ambiguous/duplicate target Boost Build
    # errors. Anyone requiring unversioned staged libraries needs to correct
    # those errors before reenabling this code. For more detailed information
    # see the related Boost library development mailing list thread at
    # 'http://lists.boost.org/Archives/boost/2012/06/194312.php'.
    #                                                (06.07.2012.) (Jurko)
    #~ if $(layout-versioned) && ( [ modules.peek : NT ] || [ modules.peek : UNIX ] )
    #~ {
    #~     generate stage-unversioned : stage-proper :
    #~         <generating-rule>@boostcpp.make-unversioned-links ;
    #~     $(p).mark-target-as-explicit stage-unversioned ;
    #~
    #~     generate install-unversioned : install-proper :
    #~         <generating-rule>@boostcpp.make-unversioned-links ;
    #~     $(p).mark-target-as-explicit install-unversioned ;
    #~ }
    #~ else
    {
        # Create do-nothing aliases.
        alias stage-unversioned ;
        $(p).mark-target-as-explicit stage-unversioned ;
        alias install-unversioned ;
        $(p).mark-target-as-explicit install-unversioned ;
    }
}

################################################################################
#
#  3. Declare top-level targets 'stage' and 'install'. These examine the
#  --build-type option and, in case it is 'complete', build the 'install-proper'
#  and 'stage-proper' targets with a number of property sets.
#
################################################################################

class top-level-target : alias-target-class
{
    import modules ;

    rule __init__ ( name : project : sources * : requirements *
        : default-build * : usage-requirements * )
    {
        alias-target-class.__init__ $(name) : $(project) : $(sources) :
            $(requirements) : $(default-build) : $(usage-requirements) ;

        self.build-type = [ modules.peek boostcpp : build-type ] ;
        # On Linux, we build the release variant by default, since few users
        # will ever want to debug C++ Boost libraries, and there is no ABI
        # incompatibility between debug and release variants. We build shared
        # and static libraries since that is what most packages seem to provide
        # (.so in libfoo and .a in libfoo-dev).
        self.minimal-properties = [ property-set.create <variant>release
            <threading>multi <link>shared <link>static <runtime-link>shared ] ;
        # On Windows, new IDE projects use:
        #
        #   runtime-link=dynamic, threading=multi, variant=(debug|release)
        #
        # and in addition, C++ Boost's autolink defaults to static linking.
        self.minimal-properties-win = [ property-set.create <variant>debug
            <variant>release <threading>multi <link>static <runtime-link>shared
            ] ;

        self.complete-properties = [ property-set.create
            <variant>debug <variant>release
            <threading>single <threading>multi
            <link>shared <link>static
            <runtime-link>shared <runtime-link>static ] ;
    }

    rule generate ( property-set )
    {
        modules.poke : top-level-targets : [ modules.peek : top-level-targets ]
            $(self.name) ;
        if $(self.build-type) = minimal
        {
            local expanded ;

            local os = [ $(property-set).get <target-os> ] ;
            # Because we completely override the parent's 'generate' we need to
            # check for default feature values ourselves.
            if ! $(os)
            {
                os = [ feature.defaults <target-os> ] ;
                os = $(os:G=) ;
            }

            if $(os) = windows
            {
                expanded = [ targets.apply-default-build $(property-set)
                    : $(self.minimal-properties-win) ] ;
            }
            else
            {
                expanded = [ targets.apply-default-build $(property-set)
                    : $(self.minimal-properties) ] ;
            }
            return [ build-multiple $(expanded) ] ;
        }
        else if $(self.build-type) = complete
        {
            local expanded = [ targets.apply-default-build $(property-set)
                : $(self.complete-properties) ] ;

            # Filter inappopriate combinations.
            local filtered ;
            for local p in $(expanded)
            {
                # See comment in handle-static-runtime regarding this logic.
                if [ $(p).get <link> ] = shared
                    && [ $(p).get <runtime-link> ] = static
                    && [ $(p).get <toolset> ] != cw
                {
                    # Skip this.
                }
                else
                {
                    filtered += $(p) ;
                }
            }
            return [ build-multiple $(filtered) ] ;
        }
        else
        {
            import errors ;
            errors.error "Unknown build type" ;
        }
    }

    rule build-multiple ( property-sets * )
    {
        local usage-requirements = [ property-set.empty ] ;
        local result ;
        for local p in $(property-sets)
        {
            local r = [ alias-target-class.generate $(p) ] ;
            if $(r)
            {
                usage-requirements = [ $(usage-requirements).add $(r[1]) ] ;
                result += $(r[2-]) ;
            }
        }
        return $(usage-requirements) [ sequence.unique $(result) ] ;
    }
}

rule declare_top_level_targets ( libraries * : headers * )
{
    declare_install_and_stage_proper_targets $(libraries) : $(headers) ;

    targets.create-metatarget top-level-target : [ project.current ]
        : install
        : install-proper install-unversioned
        ;
    targets.create-metatarget top-level-target : [ project.current ]
        : stage
        : stage-proper stage-unversioned
        ;

    p = [ project.current ] ;
    $(p).mark-target-as-explicit install stage ;

    # This target is built by default, and will forward to 'stage' after
    # producing some explanations.
    targets.create-metatarget top-level-target : [ project.current ]
        : forward
        : explain stage
        ;
}

stage-abs = [ path.native [ path.root $(stage-locate)/lib [ path.pwd ] ] ] ;

################################################################################
#
# 4. Add hook to report configuration before the build, and confirmation with
# setup instructions after the build.
#
################################################################################

message explain : "\nBuilding the Boost C++ Libraries.\n\n" ;
local p = [ project.current ] ;
$(p).mark-target-as-explicit explain ;

rule pre-build ( )
{
    local tl = [ modules.peek : top-level-targets ] ;
    if stage in $(tl) || install in $(tl)
    {
        # FIXME: Remove 'if' when Boost regression tests start using trunk bjam.
        if PAD in [ RULENAMES ]
        {
            configure.print-component-configuration ;
        }
    }
}
IMPORT $(__name__) : pre-build : : $(__name__).pre-build ;
build-system.set-pre-build-hook $(__name__).pre-build ;

# FIXME: Revise stage_abs.
rule post-build ( ok ? )
{
    if forward in [ modules.peek : top-level-targets ]
    {
        if $(ok)
        {
            local include-path = [ path.native $(BOOST_ROOT) ] ;
            ECHO "

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

    $(include-path)

The following directory should be added to linker library paths:

    $(stage-abs)
" ;
        }
    }
}
IMPORT $(__name__) : post-build : : $(__name__).post-build ;
build-system.set-post-build-hook $(__name__).post-build ;

################################################################################
#
# 5. Top-level setup.
#
################################################################################

# Decides which libraries are to be installed by looking at --with-<library>
# --without-<library> arguments. Returns the list of directories under "libs"
# which must be built and installed.
#
rule libraries-to-install ( existing-libs * )
{
    local argv = [ modules.peek : ARGV ] ;
    local with-parameter = [ MATCH ^--with-(.*) : $(argv) ] ;
    local without-parameter = [ MATCH ^--without-(.*) : $(argv) ] ;

    if ! $(with-parameter) && ! $(without-parameter)
    {
        # Nothing is specified on command line. See if maybe project-config.jam
        # has some choices.
        local libs = [ modules.peek project-config : libraries ] ;
        with-parameter = [ MATCH ^--with-(.*) : $(libs) ] ;
        without-parameter = [ MATCH ^--without-(.*) : $(libs) ] ;
    }

    # Do some checks.
    if $(with-parameter) && $(without-parameter)
    {
        EXIT error: both --with-<library> and --without-<library> specified ;
    }

    local wrong = [ set.difference $(with-parameter) : $(existing-libs) ] ;
    if $(wrong)
    {
        EXIT error: wrong library name '$(wrong[1])' in the --with-<library>
            option. ;
    }
    local wrong = [ set.difference $(without-parameter) : $(existing-libs) ] ;
    if $(wrong)
    {
        EXIT error: wrong library name '$(wrong[1])' in the --without-<library>
            option. ;
    }

    if $(with-parameter)
    {
        return [ set.intersection $(existing-libs) : $(with-parameter) ] ;
    }
    else
    {
        return [ set.difference $(existing-libs) : $(without-parameter) ] ;
    }
}

rule declare-targets ( all-libraries * : headers * )
{
    configure.register-components $(all-libraries) ;

    # Select the libraries to install.
    libraries = [ libraries-to-install $(all-libraries) ] ;
    configure.components-building $(libraries) ;

    if [ option.get "show-libraries" : : true ]
    {
        ECHO The following libraries require building: ;
        for local l in $(libraries)
        {
            ECHO "    - $(l)" ;
        }
        EXIT ;
    }

    declare_top_level_targets $(libraries) : $(headers) ;
}

# Returns the properties identifying the toolset. We'll use them
# below to configure checks. These are essentially same as in
# configure.builds, except we don't use address-model and
# architecture - as we're trying to detect them here.
#
rule toolset-properties ( properties * )
{
    local toolset = [ property.select <toolset> : $(properties) ] ;
    local toolset-version-property = "<toolset-$(toolset:G=):version>" ;
    return [ property.select <target-os> <toolset> $(toolset-version-property) : $(properties) ] ;
}

feature.feature deduced-address-model : 32 64 : propagated optional composite hidden ;
feature.compose <deduced-address-model>32 : <address-model>32 ;
feature.compose <deduced-address-model>64 : <address-model>64 ;

rule deduce-address-model ( properties * )
{
    local result ;
    local filtered = [ toolset-properties $(properties) ] ;

    if [ configure.builds /boost/architecture//32 : $(filtered) : 32-bit ]
    {
        result = 32 ;
    }
    else if [ configure.builds /boost/architecture//64 : $(filtered) : 64-bit ]
    {
        result = 64 ;
    }

    if $(result)
    {
        # Normally, returning composite feature here is equivalent to forcing
        # consituent properties as well. But we only want to indicate toolset
        # deduced default, so also pick whatever address-model is explicitly
        # specified, if any.
        result = <deduced-address-model>$(result) [ property.select <address-model> : $(properties) ] ;
    }
    return $(result) ;
}

rule address-model ( )
{
    return <conditional>@boostcpp.deduce-address-model ;
}

local deducable-architectures = arm mips1 power sparc x86 combined ;
feature.feature deduced-architecture : $(deducable-architectures) : propagated optional composite hidden ;
for a in $(deducable-architectures)
{
    feature.compose <deduced-architecture>$(a) : <architecture>$(a) ;
}

rule deduce-architecture ( properties * )
{
    local result ;
    local filtered = [ toolset-properties $(properties) ] ;
    if [ configure.builds /boost/architecture//arm : $(filtered) : arm ]
    {
        result = arm ;
    }
    else if [ configure.builds /boost/architecture//mips1 : $(filtered) : mips1 ]
    {
        result = mips1 ;
    }
    else if [ configure.builds /boost/architecture//power : $(filtered) : power ]
    {
        result = power ;
    }
    else if [ configure.builds /boost/architecture//sparc : $(filtered) : sparc ]
    {
        result = sparc ;
    }
    else if [ configure.builds /boost/architecture//x86 : $(filtered) : x86 ]
    {
        result = x86 ;
    }
    else if [ configure.builds /boost/architecture//combined : $(filtered) : combined ]
    {
        result = combined ;
    }

    if $(result)
    {
        # See comment in deduce-address-model.
        result = <deduced-architecture>$(result) [ property.select <architecture> : $(properties) ] ;
    }
    return $(result) ;
}

rule architecture ( )
{
    return <conditional>@boostcpp.deduce-architecture ;
}


code:
@ECHO OFF

REM Copyright (C) 2009 Vladimir Prus
REM
REM Distributed under the Boost Software License, Version 1.0.
REM (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

ECHO Building Boost.Build engine
if exist ".\tools\build\src\engine\bin.ntx86\b2.exe" del tools\build\src\engine\bin.ntx86\b2.exe
if exist ".\tools\build\src\engine\bin.ntx86\bjam.exe" del tools\build\src\engine\bin.ntx86\bjam.exe
if exist ".\tools\build\src\engine\bin.ntx86_64\b2.exe" del tools\build\src\engine\bin.ntx86_64\b2.exe
if exist ".\tools\build\src\engine\bin.ntx86_64\bjam.exe" del tools\build\src\engine\bin.ntx86_64\bjam.exe
pushd tools\build\src\engine

call .\build.bat %* > ..\..\..\..\bootstrap.log
@ECHO OFF

popd

if exist ".\tools\build\src\engine\bin.ntx86\bjam.exe" (
   copy .\tools\build\src\engine\bin.ntx86\b2.exe . > nul
   copy .\tools\build\src\engine\bin.ntx86\bjam.exe . > nul
   goto :bjam_built)

if exist ".\tools\build\src\engine\bin.ntx86_64\bjam.exe" (
   copy .\tools\build\src\engine\bin.ntx86_64\b2.exe . > nul
   copy .\tools\build\src\engine\bin.ntx86_64\bjam.exe . > nul
   goto :bjam_built)

goto :bjam_failure

:bjam_built

REM Ideally, we should obtain the toolset that build.bat has
REM guessed. However, it uses setlocal at the start and does not
REM export BOOST_JAM_TOOLSET, and I don't know how to do that
REM properly. Default to msvc for now.
set toolset=msvc

ECHO import option ; > project-config.jam
ECHO. >> project-config.jam
ECHO using %toolset% ; >> project-config.jam
ECHO. >> project-config.jam
ECHO option.set keep-going : false ; >> project-config.jam
ECHO. >> project-config.jam

ECHO.
ECHO Bootstrapping is done. To build, run:
ECHO.
ECHO     .\b2
ECHO.
ECHO To adjust configuration, edit 'project-config.jam'.
ECHO Further information:
ECHO.
ECHO     - Command line help:
ECHO     .\b2 --help
ECHO.
ECHO     - Getting started guide:
ECHO     http://boost.org/more/getting_started/windows.html
ECHO.
ECHO     - Boost.Build documentation:
ECHO     http://www.boost.org/build/doc/html/index.html

goto :end

:bjam_failure

ECHO.
ECHO Failed to build Boost.Build engine.
ECHO Please consult bootstrap.log for further diagnostics.
ECHO.
ECHO You can try to obtain a prebuilt binary from
ECHO.
ECHO    http://sf.net/project/showfiles.php?group_id=7586^&package_id=72941
ECHO.
ECHO Also, you can file an issue at http://svn.boost.org
ECHO Please attach bootstrap.log in that case.

goto :end

:end

license: mit


code:
#!/bin/sh
# Copyright (C) 2005, 2006 Douglas Gregor.
# Copyright (C) 2006 The Trustees of Indiana University
#
# 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)

# boostinspect:notab - Tabs are required for the Makefile.

BJAM=""
TOOLSET=""
BJAM_CONFIG=""
BUILD=""
PREFIX=/usr/local
EPREFIX=
LIBDIR=
INCLUDEDIR=
LIBS=""
PYTHON=python
PYTHON_VERSION=
PYTHON_ROOT=
ICU_ROOT=

# Handle case where builtin shell version of echo command doesn't
# support -n.  Use the installed echo executable if there is one
# rather than builtin version to ensure -n is supported.
ECHO=`which echo`
if test "x$ECHO" = x; then
  ECHO=echo
fi

# Internal flags
flag_no_python=
flag_icu=
flag_show_libraries=

for option
do
    case $option in

    -help | --help | -h)
      want_help=yes ;;

    -prefix=* | --prefix=*)
      PREFIX=`expr "x$option" : "x-*prefix=\(.*\)"`
      ;;

    -exec-prefix=* | --exec-prefix=*)
      EPREFIX=`expr "x$option" : "x-*exec-prefix=\(.*\)"`
      ;;

    -libdir=* | --libdir=*)
      LIBDIR=`expr "x$option" : "x-*libdir=\(.*\)"`
      ;;

    -includedir=* | --includedir=*)
      INCLUDEDIR=`expr "x$option" : "x-*includedir=\(.*\)"`
      ;;

    -show-libraries | --show-libraries )
      flag_show_libraries=yes
      ;;

    -with-bjam=* | --with-bjam=* )
      BJAM=`expr "x$option" : "x-*with-bjam=\(.*\)"`
      ;;

    -with-icu | --with-icu )
      flag_icu=yes
      ;;

    -with-icu=* | --with-icu=* )
      flag_icu=yes
      ICU_ROOT=`expr "x$option" : "x-*with-icu=\(.*\)"`
      ;;

    -without-icu | --without-icu )
      flag_icu=no
      ;;

    -with-libraries=* | --with-libraries=* )
      library_list=`expr "x$option" : "x-*with-libraries=\(.*\)"`
      if test "$library_list" != "all"; then
          old_IFS=$IFS
          IFS=,
          for library in $library_list
          do
              LIBS="$LIBS --with-$library"

              if test $library = python; then
                  requested_python=yes
              fi
          done
          IFS=$old_IFS

          if test "x$requested_python" != xyes; then
              flag_no_python=yes
          fi
      fi
      ;;

    -without-libraries=* | --without-libraries=* )
      library_list=`expr "x$option" : "x-*without-libraries=\(.*\)"`
      old_IFS=$IFS
      IFS=,
      for library in $library_list
      do
          LIBS="$LIBS --without-$library"

          if test $library = python; then
              flag_no_python=yes
          fi
      done
      IFS=$old_IFS
      ;;

    -with-python=* | --with-python=* )
      PYTHON=`expr "x$option" : "x-*with-python=\(.*\)"`
      ;;

    -with-python-root=* | --with-python-root=* )
      PYTHON_ROOT=`expr "x$option" : "x-*with-python-root=\(.*\)"`
      ;;

    -with-python-version=* | --with-python-version=* )
      PYTHON_VERSION=`expr "x$option" : "x-*with-python-version=\(.*\)"`
      ;;

    -with-toolset=* | --with-toolset=* )
      TOOLSET=`expr "x$option" : "x-*with-toolset=\(.*\)"`
      ;;

    -*)
      { echo "error: unrecognized option: $option
Try \`$0 --help' for more information." >&2
      { (exit 1); exit 1; }; }
      ;;

    esac
done

if test "x$want_help" = xyes; then
  cat <<EOF
\`./bootstrap.sh' prepares Boost for building on a few kinds of systems.

Usage: $0 [OPTION]...

Defaults for the options are specified in brackets.

Configuration:
  -h, --help                display this help and exit
  --with-bjam=BJAM          use existing Boost.Jam executable (bjam)
                            [automatically built]
  --with-toolset=TOOLSET    use specific Boost.Build toolset
                            [automatically detected]
  --show-libraries          show the set of libraries that require build
                            and installation steps (i.e., those libraries
                            that can be used with --with-libraries or
                            --without-libraries), then exit
  --with-libraries=list     build only a particular set of libraries,
                            describing using either a comma-separated list of
                            library names or "all"
                            [all]
  --without-libraries=list  build all libraries except the ones listed []
  --with-icu                enable Unicode/ICU support in Regex
                            [automatically detected]
  --without-icu             disable Unicode/ICU support in Regex
  --with-icu=DIR            specify the root of the ICU library installation
                            and enable Unicode/ICU support in Regex
                            [automatically detected]
  --with-python=PYTHON      specify the Python executable [python]
  --with-python-root=DIR    specify the root of the Python installation
                            [automatically detected]
  --with-python-version=X.Y specify the Python version as X.Y
                            [automatically detected]

Installation directories:
  --prefix=PREFIX           install Boost into the given PREFIX
                            [/usr/local]
  --exec-prefix=EPREFIX     install Boost binaries into the given EPREFIX
                            [PREFIX]

More precise control over installation directories:
  --libdir=DIR              install libraries here [EPREFIX/lib]
  --includedir=DIR          install headers here [PREFIX/include]

EOF
fi
test -n "$want_help" && exit 0

# TBD: Determine where the script is located
my_dir="."

# Determine the toolset, if not already decided
if test "x$TOOLSET" = x; then
  guessed_toolset=`$my_dir/tools/build/src/engine/build.sh --guess-toolset`
  case $guessed_toolset in
    acc | darwin | gcc | como | mipspro | pathscale | pgi | qcc | vacpp )
    TOOLSET=$guessed_toolset
    ;;

    intel-* )
    TOOLSET=intel
    ;;

    mingw )
    TOOLSET=gcc
    ;;

    sun* )
    TOOLSET=sun
    ;;

    * )
    # Not supported by Boost.Build
    ;;
  esac
fi

rm -f config.log

# Build bjam
if test "x$BJAM" = x; then
  $ECHO -n "Building Boost.Build engine with toolset $TOOLSET... "
  pwd=`pwd`
  (cd "$my_dir/tools/build/src/engine" && ./build.sh "$TOOLSET") > bootstrap.log 2>&1
  if [ $? -ne 0 ]; then
      echo
      echo "Failed to build Boost.Build build engine"
      echo "Consult 'bootstrap.log' for more details"
      exit 1
  fi
  cd "$pwd"
  arch=`cd $my_dir/tools/build/src/engine && ./bootstrap/jam0 -d0 -f build.jam --toolset=$TOOLSET --toolset-root= --show-locate-target && cd ..`
  BJAM="$my_dir/tools/build/src/engine/$arch/b2"
  echo "tools/build/src/engine/$arch/b2"
  cp "$BJAM" .
  cp "$my_dir/tools/build/src/engine/$arch/bjam" .

fi

# TBD: Turn BJAM into an absolute path

# If there is a list of libraries
if test "x$flag_show_libraries" = xyes; then
  cat <<EOF

The following Boost libraries have portions that require a separate build
and installation step. Any library not listed here can be used by including
the headers only.

The Boost libraries requiring separate building and installation are:
EOF
  $BJAM -d0 --show-libraries | grep '^[[:space:]]*-'
  exit 0
fi

# Setup paths
if test "x$EPREFIX" = x; then
  EPREFIX="$PREFIX"
fi

if test "x$LIBDIR" = x; then
  LIBDIR="$EPREFIX/lib"
fi

if test "x$INCLUDEDIR" = x; then
  INCLUDEDIR="$PREFIX/include"
fi

# Find Python
if test "x$flag_no_python" = x; then
  result=`$PYTHON -c "exit" > /dev/null 2>&1`
  if [ "$?" -ne "0" ]; then
    flag_no_python=yes
  fi
fi

if test "x$flag_no_python" = x; then
    if test "x$PYTHON_VERSION" = x; then
        $ECHO -n "Detecting Python version... "
        PYTHON_VERSION=`$PYTHON -c "import sys; print (\"%d.%d\" % (sys.version_info[0], sys.version_info[1]))"`
        echo $PYTHON_VERSION
    fi

    if test "x$PYTHON_ROOT" = x; then
        $ECHO -n "Detecting Python root... "
        PYTHON_ROOT=`$PYTHON -c "import sys; print(sys.prefix)"`
        echo $PYTHON_ROOT
    fi
fi

# Configure ICU
$ECHO -n "Unicode/ICU support for Boost.Regex?... "
if test "x$flag_icu" != xno; then
  if test "x$ICU_ROOT" = x; then
    COMMON_ICU_PATHS="/usr /usr/local /sw"
    for p in $COMMON_ICU_PATHS; do
      if test -r $p/include/unicode/utypes.h; then
        ICU_ROOT=$p
      fi
    done

    if test "x$ICU_ROOT" = x; then
      echo "not found."
    else
      BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT"
      echo "$ICU_ROOT"
    fi
  else
    BJAM_CONFIG="$BJAM_CONFIG -sICU_PATH=$ICU_ROOT"
    echo "$ICU_ROOT"
  fi
else
  echo "disabled."
fi

# Backup the user's existing project-config.jam
JAM_CONFIG_OUT="project-config.jam"
if test -r "project-config.jam"; then
  counter=1

  while test -r "project-config.jam.$counter"; do
    counter=`expr $counter + 1`
  done

  echo "Backing up existing Boost.Build configuration in project-config.jam.$counter"
  mv "project-config.jam" "project-config.jam.$counter"
fi

# Generate user-config.jam
echo "Generating Boost.Build configuration in project-config.jam..."
cat > project-config.jam <<EOF
# Boost.Build Configuration
# Automatically generated by bootstrap.sh

import option ;
import feature ;

# Compiler configuration. This definition will be used unless
# you already have defined some toolsets in your user-config.jam
# file.
if ! $TOOLSET in [ feature.values <toolset> ]
{
    using $TOOLSET ;
}

project : default-build <toolset>$TOOLSET ;
EOF

#  - Python configuration
if test "x$flag_no_python" = x; then
  cat >> project-config.jam <<EOF

# Python configuration
import python ;
if ! [ python.configured ]
{
    using python : $PYTHON_VERSION : $PYTHON_ROOT ;
}
EOF
fi

if test "x$ICU_ROOT" != x; then
  cat >> project-config.jam << EOF

path-constant ICU_PATH : $ICU_ROOT ;

EOF
fi

cat >> project-config.jam << EOF

# List of --with-<library> and --without-<library>
# options. If left empty, all libraries will be built.
# Options specified on the command line completely
# override this variable.
libraries = $LIBS ;

# These settings are equivivalent to corresponding command-line
# options.
option.set prefix : $PREFIX ;
option.set exec-prefix : $EPREFIX ;
option.set libdir : $LIBDIR ;
option.set includedir : $INCLUDEDIR ;

# Stop on first error
option.set keep-going : false ;
EOF

cat << EOF

Bootstrapping is done. To build, run:

    ./b2

To adjust configuration, edit 'project-config.jam'.
Further information:

   - Command line help:
     ./b2 --help

   - Getting started guide:
     http://www.boost.org/more/getting_started/unix-variants.html

   - Boost.Build documentation:
     http://www.boost.org/build/doc/html/index.html

EOF


code:
@import url("doc/src/boostbook.css");
@import url("doc/src/docutils.css");
/* Copyright David Abrahams 2006. Distributed under the Boost
   Software License, Version 1.0. (See accompanying
   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 */

dl.docutils dt {
  font-weight: bold }

img.boost-logo {
  border: none;
  vertical-align: middle
}

pre.literal-block span.concept {
  font-style: italic;
}

.nav {
display: inline;
list-style-type: none;
}

.prevpage {
padding-top: -5px;
text-align: left;
float: left;
}

.nextpage {
padding-top: -20px;
text-align: right;
float: right;
}

div.small {
   font-size: smaller }

h2 a {
   font-size: 90%;
}
h3 a {
   font-size: 80%;
}
h4 a {
   font-size: 70%;
}
h5 a {
   font-size: 60%;
}

dl,table
{
   text-align: left;
   font-size: 10pt;
   line-height: 1.15;
}

/*=============================================================================
    Tables
=============================================================================*/

/* The only clue docutils gives us that tables are logically tables,
   and not, e.g., footnotes, is that they have border="1".  Therefore
   we're keying off of that.  We used to manually patch docutils to
   add a "table" class to all logical tables, but that proved much too
   fragile.
*/

    table[border="1"]
    {
        width: 92%;
        margin-left: 4%;
        margin-right: 4%;
    }

    table[border="1"]
    {
        padding: 4px;
    }

    /* Table Cells */
    table[border="1"] tr td
    {
        padding: 0.5em;
        text-align: left;
        font-size: 9pt;
    }

    table[border="1"] tr th
    {
        padding: 0.5em 0.5em 0.5em 0.5em;
        border: 1pt solid white;
        font-size: 80%;
    }

    @media screen
    {

    /* Tables */
        table[border="1"] tr td
        {
            border: 1px solid #DCDCDC;
        }

        table[border="1"] tr th
        {
            background-color: #F0F0F0;
            border: 1px solid #DCDCDC;
        }

        pre,
        .screen
        {
            border: 1px solid #DCDCDC;
        }

        td pre
        td .screen
        {
            border: 0px
        }

        .sidebar pre
        {
            border: 0px
        }

    }

    pre,
    .screen
    {
        font-size: 9pt;
        display: block;
        margin: 1pc 4% 0pc 4%;
        padding: 0.5pc 0.5pc 0.5pc 0.5pc;
    }

    /* Program listings in tables don't get borders */
    td pre,
    td .screen
    {
        margin: 0pc 0pc 0pc 0pc;
        padding:  0pc 0pc 0pc 0pc;
    }


code:
#ifndef COMMONS_H
#define COMMONS_H

#define NSMAX 6827
#define NTMAX 300
#define RX_SAMPLE_RATE 12000

#ifdef __cplusplus
#include <cstdbool>
extern "C" {
#else
#include <stdbool.h>
#endif

  /*
   * This structure is shared with Fortran code, it MUST be kept in
   * sync with lib/jt9com.f90
   */
extern struct dec_data {
  float ss[184*NSMAX];
  float savg[NSMAX];
  float sred[5760];
  short int d2[NTMAX*RX_SAMPLE_RATE];
  struct
  {
    int nutc;                   //UTC as integer, HHMM
    bool ndiskdat;              //true ==> data read from *.wav file
    int ntrperiod;              //TR period (seconds)
    int nQSOProgress;           /* QSO state machine state */
    int nfqso;                  //User-selected QSO freq (kHz)
    int nftx;                   /* Transmit audio offset where
                                   replies might be expected */
    bool newdat;                //true ==> new data, must do long FFT
    int npts8;                  //npts for c0() array
    int nfa;                    //Low decode limit (Hz)
    int nfSplit;                //JT65 | JT9 split frequency
    int nfb;                    //High decode limit (Hz)
    int ntol;                   //+/- decoding range around fQSO (Hz)
    int kin;
    int nzhsym;
    int nsubmode;
    bool nagain;
    int ndepth;
    bool lft8apon;
    bool lapcqonly;
    bool ljt65apon;
    int napwid;
    int ntxmode;
    int nmode;
    int minw;
    bool nclearave;
    int minSync;
    float emedelay;
    float dttol;
    int nlist;
    int listutc[10];
    int n2pass;
    int nranera;
    int naggressive;
    bool nrobust;
    int nexp_decode;
    char datetime[20];
    char mycall[12];
    char mygrid[6];
    char hiscall[12];
    char hisgrid[6];
  } params;
} dec_data;

extern struct {
  float syellow[NSMAX];
  float ref[3457];
  float filter[3457];
} spectra_;

extern struct {
  int   nclearave;
  int   nsum;
  float blue[4096];
  float red[4096];
} echocom_;

extern struct {
  float wave[606720];
  int   nslots;
  int   nfreq;
  int   i3bit[5];
  char  cmsg[5][40];
  char  mycall[12];
} foxcom_;

#ifdef __cplusplus
}
#endif

#endif // COMMONS_H