#! /bin/bash
#
# Copyright 2017 - 2019 James E. King III
# 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)
#
# Bash script to run in travis to perform codecov.io integration
#

# assumes cwd is the top level directory of the boost project
# assumes an environment variable $SELF is the boost project name

set -ex

. ci/enforce.sh

if [ -z "$GCOV" ]; then
    if [ "${B2_TOOLSET%%-*}" == "gcc" ]; then
        ver="${B2_TOOLSET#*-}"
        GCOV=gcov-${ver}
    else
        GCOV=gcov-7 # default
    fi
fi

# lcov after 1.14 needs this
# sudo apt install --no-install-recommends -y libperlio-gzip-perl libjson-perl

# install the latest lcov we know works
# some older .travis.yml files install the tip which may be unstable
rm -rf /tmp/lcov
pushd /tmp
git clone -b v1.14 https://github.com/linux-test-project/lcov.git
export PATH=/tmp/lcov/bin:$PATH
which lcov
lcov --version
popd

B2_VARIANT=variant=debug
ci/travis/build.sh cxxflags=--coverage linkflags=--coverage
#cxxflags=-fprofile-arcs cxxflags=-ftest-coverage linkflags=-fprofile-arcs linkflags=-ftest-coverage

# switch back to the original source code directory
cd $TRAVIS_BUILD_DIR

# coverage files are in ../../b2 from this location
lcov --gcov-tool=$GCOV --rc lcov_branch_coverage=0 --base-directory "$BOOST_ROOT/libs/$SELF" --directory "$BOOST_ROOT" --capture --output-file all.info

# all.info contains all the coverage info for all projects - limit to ours
# first we extract the interesting headers for our project then we use that list to extract the right things
for f in `for f in include/boost/*; do echo $f; done | cut -f2- -d/`; do echo "*/$f*"; done > /tmp/interesting
echo headers that matter:
cat /tmp/interesting
xargs -L 999999 -a /tmp/interesting lcov --gcov-tool=$GCOV --rc lcov_branch_coverage=1 --extract all.info {} "*/libs/$SELF/src/*" --output-file coverage.info

# dump a summary on the console - helps us identify problems in pathing
lcov --gcov-tool=$GCOV --rc lcov_branch_coverage=1 --list coverage.info

#
# upload to codecov.io
#
curl -s https://codecov.io/bash > .codecov
chmod +x .codecov
./.codecov -f coverage.info -X gcov -x "$GCOV"


#!/bin/sh

which lcov 1>/dev/null 2>&1
if [ $? != 0 ]
then
    echo "You need to have lcov installed in order to generate the test coverage report"
    exit 1
fi

bjam toolset=gcc-4.9.2 clean
bjam toolset=gcc-4.9.2 runtime-param-test

# Generate html report
lcov --base-directory . --directory ../../../bin.v2/libs/test/test/runtime-param-test.test/gcc-4.9.2/debug/utils-ts -c -o runtime-param-test.info
lcov --remove runtime-param-test.info "/usr*" -o runtime-param-test.info # remove output for external libraries
lcov --remove runtime-param-test.info  "boost" "/boost/c*" "/boost/d*"  "/boost/e*"  "/boost/f*"  "/boost/l*" "/boost/m*" "/boost/s*" -o runtime-param-test.info # remove output for other boost libs
rm -rf ./coverage
genhtml -o ./coverage -t "runtime-param-test coverage" --num-spaces 4 runtime-param-test.info

#Clean up
rm *.info


#! /bin/bash
#
# Copyright 2017 James E. King, III
# 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)
#
# Bash script to run in travis to perform a Coverity Scan build
#

#
# Environment Variables
#
# COVERITY_SCAN_NOTIFICATION_EMAIL  - email address to notify
# COVERITY_SCAN_TOKEN               - the Coverity Scan token (should be secure)
# SELF                              - the boost libs directory name

set -ex

pushd /tmp
rm -rf coverity_tool.tgz cov-analysis*
wget -nv https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_SCAN_TOKEN&project=boostorg/$SELF" -O coverity_tool.tgz
tar xzf coverity_tool.tgz
COVBIN=$(echo $(pwd)/cov-analysis*/bin)
export PATH=$COVBIN:$PATH
popd

cd libs/$SELF/test
../../../b2 toolset=gcc clean
rm -rf cov-int/
cov-build --dir cov-int ../../../b2 toolset=gcc -q -j3
tar cJf cov-int.tar.xz cov-int/
curl --form token="$COVERITY_SCAN_TOKEN" \
     --form email="$COVERITY_SCAN_NOTIFICATION_EMAIL" \
     --form file=@cov-int.tar.xz \
     --form version="$(git describe --tags)" \
     --form description="boostorg/$SELF" \
     https://scan.coverity.com/builds?project="boostorg/$SELF"


#!/bin/sh
#   Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
#
#   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)

# User configuration
# (MAINTANERS: please, keep in synch with setup_boostbook.py)
DOCBOOK_XSL_VERSION=1.75.2
DOCBOOK_DTD_VERSION=4.2
FOP_VERSION=0.94
FOP_JDK_VERSION=1.4
# FOP_MIRROR=http://mirrors.ibiblio.org/pub/mirrors/apache/xmlgraphics/fop/binaries
FOP_MIRROR=http://archive.apache.org/dist/xmlgraphics/fop/binaries/
SOURCEFORGE_DOWNLOAD=http://sourceforge.net/projects/docbook/files/
HTTP_GET_CMD="curl -O -L"

# No user configuration below this point-------------------------------------

# Get the DocBook XSLT Stylesheets
DOCBOOK_XSL_TARBALL=docbook-xsl-$DOCBOOK_XSL_VERSION.tar.gz
DOCBOOK_XSL_URL=$SOURCEFORGE_DOWNLOAD/docbook-xsl/$DOCBOOK_XSL_VERSION/$DOCBOOK_XSL_TARBALL
if test -f $DOCBOOK_XSL_TARBALL; then
  echo "Using existing DocBook XSLT Stylesheets (version $DOCBOOK_XSL_VERSION)."
else
  echo "Downloading DocBook XSLT Stylesheets version $DOCBOOK_XSL_VERSION..."
  $HTTP_GET_CMD $DOCBOOK_XSL_URL
fi

DOCBOOK_XSL_DIR="$PWD/docbook-xsl-$DOCBOOK_XSL_VERSION"
if test ! -d docbook-xsl-$DOCBOOK_XSL_VERSION; then
  echo -n "Expanding DocBook XSLT Stylesheets into $DOCBOOK_XSL_DIR..."
  gunzip -cd $DOCBOOK_XSL_TARBALL | tar xf -
  echo "done."
fi

# Get the DocBook DTD
DOCBOOK_DTD_ZIP=docbook-xml-$DOCBOOK_DTD_VERSION.zip
DOCBOOK_DTD_URL=http://www.oasis-open.org/docbook/xml/$DOCBOOK_DTD_VERSION/$DOCBOOK_DTD_ZIP
if test -f $DOCBOOK_DTD_ZIP; then
  echo "Using existing DocBook XML DTD (version $DOCBOOK_DTD_VERSION)."
else
  echo "Downloading DocBook XML DTD version $DOCBOOK_DTD_VERSION..."
  $HTTP_GET_CMD $DOCBOOK_DTD_URL
fi

DOCBOOK_DTD_DIR="$PWD/docbook-dtd-$DOCBOOK_DTD_VERSION"
if test ! -d docbook-dtd-$DOCBOOK_DTD_VERSION; then
  echo -n "Expanding DocBook XML DTD into $DOCBOOK_DTD_DIR... "
  unzip -q $DOCBOOK_DTD_ZIP -d $DOCBOOK_DTD_DIR
  echo "done."
fi

# Find xsltproc, doxygen, and java
OLD_IFS=$IFS
IFS=:
for dir in $PATH; do
  if test -f $dir/xsltproc && test -x $dir/xsltproc; then
    XSLTPROC="$dir/xsltproc"
  fi
  if test -f $dir/doxygen && test -x $dir/doxygen; then
    DOXYGEN="$dir/doxygen"
  fi
  if test -f $dir/java && test -x $dir/java; then
    JAVA="$dir/java"
  fi
done
IFS=$OLD_IFS

# Make sure we have xsltproc
if test ! -f "$XSLTPROC" && test ! -x "$XSLTPROC"; then
  echo "Searching for xsltproc... NOT FOUND.";
  echo "ERROR: Unable to find xsltproc executable."
  echo "If you have already installed xsltproc, please set the environment"
  echo "variable XSLTPROC to the xsltproc executable. If you do not have"
  echo "xsltproc, you may download it from http://xmlsoft.org/XSLT/."
  exit 0;
else
  echo "Searching for xsltproc... $XSLTPROC.";
fi

# Just notify the user if we haven't found doxygen.
if test ! -f "$DOXYGEN" && test ! -x "$DOXYGEN"; then
  echo "Searching for Doxygen... not found.";
  echo "Warning: unable to find Doxygen executable. You will not be able to"
  echo "  use Doxygen to generate BoostBook documentation. If you have Doxygen,"
  echo "  please set the DOXYGEN environment variable to the path of the doxygen"
  echo "  executable."
  HAVE_DOXYGEN="no"
else
  echo "Searching for Doxygen... $DOXYGEN.";
  HAVE_DOXYGEN="yes"
fi

# Just notify the user if we haven't found Java. Otherwise, go get FOP.
if test ! -f "$JAVA" && test ! -x "$JAVA"; then
  echo "Searching for Java... not found.";
  echo "Warning: unable to find Java executable. You will not be able to"
  echo "  generate PDF documentation. If you have Java, please set the JAVA"
  echo "  environment variable to the path of the java executable."
  HAVE_FOP="no"
else
  echo "Searching for Java... $JAVA.";
  FOP_TARBALL="fop-$FOP_VERSION-bin-jdk$FOP_JDK_VERSION.tar.gz"
  FOP_URL="$FOP_MIRROR/$FOP_TARBALL"
  FOP_DIR="$PWD/fop-$FOP_VERSION"
  FOP="$FOP_DIR/fop"
  if test -f $FOP_TARBALL; then
    echo "Using existing FOP distribution (version $FOP_VERSION)."
  else
    echo "Downloading FOP distribution version $FOP_VERSION..."
    $HTTP_GET_CMD $FOP_URL
  fi

  if test ! -d $FOP_DIR; then
    echo -n "Expanding FOP distribution into $FOP_DIR... ";
    gunzip -cd $FOP_TARBALL | tar xf -
    echo "done.";
  fi
  HAVE_FOP="yes"
fi

# Find the input jamfile to configure
JAM_CONFIG_OUT="$HOME/user-config.jam"
if test -r "$HOME/user-config.jam"; then
  JAM_CONFIG_IN="user-config-backup.jam"
  cp $JAM_CONFIG_OUT user-config-backup.jam
  JAM_CONFIG_IN_TEMP="yes"
  echo -n "Updating Boost.Jam configuration in $JAM_CONFIG_OUT... "

elif test -r "$BOOST_ROOT/tools/build/user-config.jam"; then
  JAM_CONFIG_IN="$BOOST_ROOT/tools/build/user-config.jam";
  JAM_CONFIG_IN_TEMP="no"
  echo -n "Writing Boost.Jam configuration to $JAM_CONFIG_OUT... "
else
  echo "ERROR: Please set the BOOST_ROOT environment variable to refer to your"
  echo "Boost installation or copy user-config.jam into your home directory."
  exit 0
fi

cat > setup_boostbook.awk <<EOF
BEGIN { using_boostbook = 0; eaten=0 }

/^\s*using boostbook/ {
  using_boostbook = 1;
  print "using boostbook";
  print "  : $DOCBOOK_XSL_DIR";
  print "  : $DOCBOOK_DTD_DIR";
  eaten=1
}

using_boostbook==1 && /;/ { using_boostbook = 2 }
using_boostbook==1 { eaten=1 }

/^\s*using xsltproc.*$/ { eaten=1 }
/^\s*using doxygen.*$/ { eaten=1 }
/^\s*using fop.*$/ { eaten=1 }

/^.*$/             { if (eaten == 0) print; eaten=0 }

END {
  if (using_boostbook==0) {
    print "using boostbook";
    print "  : $DOCBOOK_XSL_DIR";
    print "  : $DOCBOOK_DTD_DIR";
    print "  ;"
  }
  print "using xsltproc : $XSLTPROC ;"
  if ("$HAVE_DOXYGEN" == "yes") print "using doxygen : $DOXYGEN ;";
  if ("$HAVE_FOP" == "yes") print "using fop : $FOP : : $JAVA ;";
}
EOF

awk -f setup_boostbook.awk $JAM_CONFIG_IN > $JAM_CONFIG_OUT
rm -f setup_boostbook.awk
echo "done."

echo "Done! Execute \"b2\" in a documentation directory to generate"
echo "documentation with BoostBook. If you have not already, you will need"
echo "to compile Boost.Jam."


#!/bin/bash
# see the README file for usage etc.
#
# ------------------------------------------------------------------
#  This file is part of bzip2/libbzip2, a program and library for
#  lossless, block-sorting data compression.
#
#  bzip2/libbzip2 version 1.0.8 of 13 July 2019
#  Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
#
#  Please read the WARNING, DISCLAIMER and PATENTS sections in the
#  README file.
#
#  This program is released under the terms of the license contained
#  in the file LICENSE.
# ----------------------------------------------------------------

usage() {
  echo '';
  echo 'Usage: xmlproc.sh -[option] <filename.xml>';
  echo 'Specify a target from:';
  echo '-v      verify xml file conforms to dtd';
  echo '-html   output in html format (single file)';
  echo '-ps     output in postscript format';
  echo '-pdf    output in pdf format';
  exit;
}

if test $# -ne 2; then
  usage
fi
# assign the variable for the output type
action=$1; shift
# assign the output filename
xmlfile=$1; shift
# and check user input it correct
if !(test -f $xmlfile); then
  echo "No such file: $xmlfile";
  exit;
fi
# some other stuff we will use
OUT=output
xsl_fo=bz-fo.xsl
xsl_html=bz-html.xsl

basename=$xmlfile
basename=${basename//'.xml'/''}

fofile="${basename}.fo"
htmlfile="${basename}.html"
pdffile="${basename}.pdf"
psfile="${basename}.ps"
xmlfmtfile="${basename}.fmt"

# first process the xmlfile with CDATA tags
./format.pl $xmlfile $xmlfmtfile
# so the shell knows where the catalogs live
export XML_CATALOG_FILES=/etc/xml/catalog

# post-processing tidy up
cleanup() {
  echo "Cleaning up: $@"
  while [ $# != 0 ]
  do
    arg=$1; shift;
    echo "  deleting $arg";
    rm $arg
  done
}

case $action in
  -v)
   flags='--noout --xinclude --noblanks --postvalid'
   dtd='--dtdvalid http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd'
   xmllint $flags $dtd $xmlfmtfile 2> $OUT
   egrep 'error' $OUT
   rm $OUT
  ;;

  -html)
   echo "Creating $htmlfile ..."
   xsltproc --nonet --xinclude  -o $htmlfile $xsl_html $xmlfmtfile
   cleanup $xmlfmtfile
  ;;

  -pdf)
   echo "Creating $pdffile ..."
   xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile
   pdfxmltex $fofile >$OUT </dev/null
   pdfxmltex $fofile >$OUT </dev/null
   pdfxmltex $fofile >$OUT </dev/null
   cleanup $OUT $xmlfmtfile *.aux *.fo *.log *.out
  ;;

  -ps)
   echo "Creating $psfile ..."
   xsltproc --nonet --xinclude -o $fofile $xsl_fo $xmlfmtfile
   pdfxmltex $fofile >$OUT </dev/null
   pdfxmltex $fofile >$OUT </dev/null
   pdfxmltex $fofile >$OUT </dev/null
   pdftops $pdffile $psfile
   cleanup $OUT $xmlfmtfile $pdffile *.aux *.fo *.log *.out
#  passivetex is broken, so we can't go this route yet.
#   xmltex $fofile >$OUT </dev/null
#   xmltex $fofile >$OUT </dev/null
#   xmltex $fofile >$OUT </dev/null
#   dvips -R -q -o bzip-manual.ps *.dvi
  ;;

  *)
  usage
  ;;
esac


#!/bin/sh
#
#       ZLIB compilation script for the OS/400.
#
#
#       This is a shell script since make is not a standard component of OS/400.

################################################################################
#
#                       Tunable configuration parameters.
#
################################################################################

TARGETLIB='ZLIB'                # Target OS/400 program library
STATBNDDIR='ZLIB_A'             # Static binding directory.
DYNBNDDIR='ZLIB'                # Dynamic binding directory.
SRVPGM="ZLIB"                   # Service program.
IFSDIR='/zlib'                  # IFS support base directory.
TGTCCSID='500'                  # Target CCSID of objects
DEBUG='*NONE'                   # Debug level
OPTIMIZE='40'                   # Optimisation level
OUTPUT='*NONE'                  # Compilation output option.
TGTRLS='V6R1M0'                 # Target OS release

export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM IFSDIR
export TGTCCSID DEBUG OPTIMIZE OUTPUT TGTRLS

################################################################################
#
#                       OS/400 specific definitions.
#
################################################################################

LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"

################################################################################
#
#                               Procedures.
#
################################################################################

#       action_needed dest [src]
#
#       dest is an object to build
#       if specified, src is an object on which dest depends.
#
#       exit 0 (succeeds) if some action has to be taken, else 1.

action_needed()

{
        [ ! -e "${1}" ] && return 0
        [ "${2}" ] || return 1
        [ "${1}" -ot "${2}" ] && return 0
        return 1
}

#       make_module module_name source_name [additional_definitions]
#
#       Compile source name into module if needed.
#       As side effect, append the module name to variable MODULES.
#       Set LINK to "YES" if the module has been compiled.

make_module()

{
    MODULES="${MODULES} ${1}"
    MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
    CSRC="`basename \"${2}\"`"

    if action_needed "${MODIFSNAME}" "${2}"
    then    :
    elif [ ! "`sed -e \"/<source name=\\\"${CSRC}\\\">/,/<\\\\/source>/!d\" \
      -e '/<depend /!d'                                                 \
      -e 's/.* name=\"\\([^\"]*\\)\".*/\\1/' < \"${TOPDIR}/treebuild.xml\" |
        while read HDR
        do      if action_needed \"${MODIFSNAME}\" \"${IFSDIR}/include/${HDR}\"
                then    echo recompile
                        break
                fi
        done`" ]
    then    return 0
    fi

    CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('${2}')"
    CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
    CMD="${CMD} LOCALETYPE(*LOCALE) FLAG(10)"
    CMD="${CMD} INCDIR('${IFSDIR}/include' ${INCLUDES})"
    CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
    CMD="${CMD} OUTPUT(${OUTPUT})"
    CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
    CMD="${CMD} DBGVIEW(${DEBUG})"
    system "${CMD}"
    LINK=YES
}

#       Determine DB2 object name from IFS name.

db2_name()

{
        basename "${1}"                                                 |
        tr 'a-z-' 'A-Z_'                                                |
        sed -e 's/\..*//'                                               \
            -e 's/^\(.\).*\(.........\)$/\1\2/'
}

#       Force enumeration types to be the same size as integers.

copy_hfile()

{
        sed -e '1i\
#pragma enum(int)\
' "${@}" -e '$a\
#pragma enum(pop)\
'
}

################################################################################
#
#                             Script initialization.
#
################################################################################

SCRIPTDIR=`dirname "${0}"`

case "${SCRIPTDIR}" in
/*)     ;;
*)      SCRIPTDIR="`pwd`/${SCRIPTDIR}"
esac

while true
do      case "${SCRIPTDIR}" in
        */.)    SCRIPTDIR="${SCRIPTDIR%/.}";;
        *)      break;;
        esac
done

#  The script directory is supposed to be in ${TOPDIR}/os400.

TOPDIR=`dirname "${SCRIPTDIR}"`
export SCRIPTDIR TOPDIR
cd "${TOPDIR}"

#  Extract the version from the master compilation XML file.

VERSION=`sed -e '/^<package /!d'                                        \
            -e 's/^.* version="\([0-9.]*\)".*$/\1/' -e 'q'              \
            < treebuild.xml`
export VERSION

################################################################################

#       Create the OS/400 library if it does not exist.

if action_needed "${LIBIFSNAME}"
then    CMD="CRTLIB LIB(${TARGETLIB}) TEXT('ZLIB: Data compression API')"
        system "${CMD}"
fi

#       Create the DOCS source file if it does not exist.

if action_needed "${LIBIFSNAME}/DOCS.FILE"
then    CMD="CRTSRCPF FILE(${TARGETLIB}/DOCS) RCDLEN(112)"
        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('Documentation texts')"
        system "${CMD}"
fi

#       Copy some documentation files if needed.

for TEXT in "${TOPDIR}/ChangeLog" "${TOPDIR}/FAQ"                       \
    "${TOPDIR}/README" "${SCRIPTDIR}/README400"
do      MEMBER="${LIBIFSNAME}/DOCS.FILE/`db2_name \"${TEXT}\"`.MBR"

        if action_needed "${MEMBER}" "${TEXT}"
        then    CMD="CPY OBJ('${TEXT}') TOOBJ('${MEMBER}') TOCCSID(${TGTCCSID})"
                CMD="${CMD} DTAFMT(*TEXT) REPLACE(*YES)"
                system "${CMD}"
        fi
done

#       Create the OS/400 source program file for the C header files.

SRCPF="${LIBIFSNAME}/H.FILE"

if action_needed "${SRCPF}"
then    CMD="CRTSRCPF FILE(${TARGETLIB}/H) RCDLEN(112)"
        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ZLIB: C/C++ header files')"
        system "${CMD}"
fi

#       Create the IFS directory for the C header files.

if action_needed "${IFSDIR}/include"
then    mkdir -p "${IFSDIR}/include"
fi

#       Copy the header files to DB2 library. Link from IFS include directory.

for HFILE in "${TOPDIR}/"*.h
do      DEST="${SRCPF}/`db2_name \"${HFILE}\"`.MBR"

        if action_needed "${DEST}" "${HFILE}"
        then    copy_hfile < "${HFILE}" > tmphdrfile

                #       Need to translate to target CCSID.

                CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')"
                CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
                system "${CMD}"
                # touch -r "${HFILE}" "${DEST}"
                rm -f tmphdrfile
        fi

        IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`"

        if action_needed "${IFSFILE}" "${DEST}"
        then    rm -f "${IFSFILE}"
                ln -s "${DEST}" "${IFSFILE}"
        fi
done

#       Install the ILE/RPG header file.

HFILE="${SCRIPTDIR}/zlib.inc"
DEST="${SRCPF}/ZLIB.INC.MBR"

if action_needed "${DEST}" "${HFILE}"
then    CMD="CPY OBJ('${HFILE}') TOOBJ('${DEST}')"
        CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
        system "${CMD}"
        # touch -r "${HFILE}" "${DEST}"
fi

IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`"

if action_needed "${IFSFILE}" "${DEST}"
then    rm -f "${IFSFILE}"
        ln -s "${DEST}" "${IFSFILE}"
fi

#      Create and compile the identification source file.

echo '#pragma comment(user, "ZLIB version '"${VERSION}"'")' > os400.c
echo '#pragma comment(user, __DATE__)' >> os400.c
echo '#pragma comment(user, __TIME__)' >> os400.c
echo '#pragma comment(copyright, "Copyright (C) 1995-2017 Jean-Loup Gailly, Mark Adler. OS/400 version by P. Monnerat.")' >> os400.c
make_module     OS400           os400.c
LINK=                           # No need to rebuild service program yet.
MODULES=

#       Get source list.

CSOURCES=`sed -e '/<source name="/!d'                                   \
    -e 's/.* name="\([^"]*\)".*/\1/' < treebuild.xml`

#       Compile the sources into modules.

for SRC in ${CSOURCES}
do      MODULE=`db2_name "${SRC}"`
        make_module "${MODULE}" "${SRC}"
done

#       If needed, (re)create the static binding directory.

if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
then    LINK=YES
fi

if [ "${LINK}" ]
then    rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
        CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
        CMD="${CMD} TEXT('ZLIB static binding directory')"
        system "${CMD}"

        for MODULE in ${MODULES}
        do      CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${STATBNDDIR})"
                CMD="${CMD} OBJ((${TARGETLIB}/${MODULE} *MODULE))"
                system "${CMD}"
        done
fi

#       The exportation file for service program creation must be in a DB2
#               source file, so make sure it exists.

if action_needed "${LIBIFSNAME}/TOOLS.FILE"
then    CMD="CRTSRCPF FILE(${TARGETLIB}/TOOLS) RCDLEN(112)"
        CMD="${CMD} CCSID(${TGTCCSID}) TEXT('ZLIB: build tools')"
        system "${CMD}"
fi

DEST="${LIBIFSNAME}/TOOLS.FILE/BNDSRC.MBR"

if action_needed "${SCRIPTDIR}/bndsrc" "${DEST}"
then    CMD="CPY OBJ('${SCRIPTDIR}/bndsrc') TOOBJ('${DEST}')"
        CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
        system "${CMD}"
        # touch -r "${SCRIPTDIR}/bndsrc" "${DEST}"
        LINK=YES
fi

#       Build the service program if needed.

if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
then    LINK=YES
fi

if [ "${LINK}" ]
then    CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
        CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
        CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
        CMD="${CMD} BNDDIR(${TARGETLIB}/${STATBNDDIR})"
        CMD="${CMD} TEXT('ZLIB ${VERSION} dynamic library')"
        CMD="${CMD} TGTRLS(${TGTRLS})"
        system "${CMD}"
        LINK=YES

        #       Duplicate the service program for a versioned backup.

        BACKUP=`echo "${SRVPGM}${VERSION}"                              |
                sed -e 's/.*\(..........\)$/\1/' -e 's/\./_/g'`
        BACKUP="`db2_name \"${BACKUP}\"`"
        BKUPIFSNAME="${LIBIFSNAME}/${BACKUP}.SRVPGM"
        rm -f "${BKUPIFSNAME}"
        CMD="CRTDUPOBJ OBJ(${SRVPGM}) FROMLIB(${TARGETLIB})"
        CMD="${CMD} OBJTYPE(*SRVPGM) NEWOBJ(${BACKUP})"
        system "${CMD}"
fi

#       If needed, (re)create the dynamic binding directory.

if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
then    LINK=YES
fi

if [ "${LINK}" ]
then    rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
        CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
        CMD="${CMD} TEXT('ZLIB dynamic binding directory')"
        system "${CMD}"
        CMD="ADDBNDDIRE BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
        CMD="${CMD} OBJ((*LIBL/${SRVPGM} *SRVPGM))"
        system "${CMD}"
fi


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

# Build b2
echo "Building the B2 engine.."
pwd=`pwd`
"${pwd}/src/engine/build.sh" "$@"
if [ $? -ne 0 ]; then
    echo
    echo "Failed to build the B2 engine." 1>&2
    exit 1
fi
cd "$pwd"
cp "./src/engine/b2" .

cat << EOF

Building is done. To install, run:

    ./b2 install --prefix=<DIR>

EOF


#!/bin/sh

#~ Copyright 2002-2020 Rene Rivera.
#~ 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)

FALSE=1
TRUE=0

# Reset the toolset.
B2_TOOLSET=
B2_SETUP=

# Internal options.
B2_VERBOSE_OPT=${B2_VERBOSE_OPT:=${FALSE}}
B2_DEBUG_OPT=${B2_DEBUG_OPT:=${FALSE}}
B2_GUESS_TOOLSET_OPT=${FALSE}
B2_HELP_OPT=${FALSE}
B2_CXX_OPT=
B2_CXXFLAGS_OPT=

# We need to calculate and set SCRIPT_PATH and SCRIPT_DIR to reference this
# script so that we can refer to file relative to it.
SCRIPT_PATH=""
if test "${BASH_SOURCE}" ; then
    SCRIPT_PATH=${BASH_SOURCE}
fi
if test "${SCRIPT_PATH}" = "" ; then
    SCRIPT_PATH=$0
fi
SCRIPT_DIR="$( cd "$( dirname "${SCRIPT_PATH}" )" && pwd )"

# This script needs to operate at engine source directory.
SAVED_PWD="${PWD}"
cd "${SCRIPT_DIR}"

test_true ()
{
    if test $1 -eq ${TRUE} ; then
        return ${TRUE}
    fi
    return ${FALSE}
}

# Run a command, and echo before doing so. Also checks the exit status and quits
# if there was an error.
echo_run ()
{
    if test_true ${B2_VERBOSE_OPT} ; then echo "> $@" ; fi
    $@
    r=$?
    if test $r -ne ${TRUE} ; then
        exit $r
    fi
}

# Print an error message, and exit with a status of 1.
error_exit ()
{
    echo "
${@}

You can specify the toolset as the argument, i.e.:
    ./build.sh [options] gcc

Toolsets supported by this script are:
    acc, clang, como, gcc, intel-darwin, intel-linux, kcc, kylix, mipspro,
    pathscale, pgi, qcc, sun, sunpro, tru64cxx, vacpp

For any toolset you can override the path to the compiler with the '--cxx'
option. You can also use additional flags for the compiler with the
'--cxxflags' option.

A special toolset; cxx, is available which is used as a fallback when a more
specific toolset is not found and the cxx command is detected. The 'cxx'
toolset will use the '--cxx' and '--cxxflags' options, if present.

Options:
    --help                  Show this help message.
    --verbose               Show messages about what this script is doing.
    --debug                 Build b2 with debug information, and no
                            optimizations.
    --guess-toolset         Print the toolset we can detect for building.
    --cxx=CXX               The compiler exec to use instead of the detected
                            compiler exec.
    --cxxflags=CXXFLAGS     The compiler flags to use in addition to the
                            flags for the detected compiler.

" 1>&2
    exit 1
}

# Check that a command is in the PATH.
test_path ()
{
    if `command -v command 1>/dev/null 2>/dev/null`; then
        command -v $1 1>/dev/null 2>/dev/null
    else
        hash $1 1>/dev/null 2>/dev/null
    fi
}

# Check that the OS name, as returned by "uname", is as given.
test_uname ()
{
    if test_path uname; then
        test `uname` = $*
    fi
}

test_compiler ()
{
    EXE="${B2_CXX_OPT:-$1}"
    shift
    CMD="${EXE} $@ ${B2_CXXFLAGS_OPT:-}"
    SETUP=${B2_SETUP:-true}
    if test_true ${B2_VERBOSE_OPT} ; then
        echo "> ${CMD} check_cxx11.cpp"
        ( ${SETUP} ; ${CMD} check_clib.cpp check_cxx11.cpp )
    else
        ( ${SETUP} ; ${CMD} check_clib.cpp check_cxx11.cpp ) 1>/dev/null 2>/dev/null
    fi
    CHECK_RESULT=$?
    if test_true ${CHECK_RESULT} ; then
        B2_CXX=${CMD}
    fi
    rm -rf check_cxx11.o* a.out a.exe 1>/dev/null 2>/dev/null
    return ${CHECK_RESULT}
}

test_toolset ()
{
    if test "${TOOLSET}" = "" ; then return ${TRUE} ; fi
    if test "${TOOLSET}" = "$1" -o "${TOOLSET}" = "$2" -o "${TOOLSET}" = "$3" ; then return ${TRUE} ; fi
    return 1
}

# Check the toolset to bootstrap the build with. The one optional argument to
# the function is a toolset name. This operates as follows based on these
# contextual vars, if set, and if an arg is given:
#
# No vars set:
#   Checks, in some priority order, possible toolset commands. Upon finding the
#   first working command sets B2_TOOLSET to the toolset and B2_CXX to the
#   compile command with any base options.
#
# B2_TOOLSET set:
#   Checks that toolset for possible compile commands and sets B2_CXX to the
#   command that works for the toolset.
#
check_toolset ()
{
    TOOLSET=${B2_TOOLSET%%-[0-9]*}
    TOOLSET_SUFFIX=${B2_TOOLSET##$TOOLSET}

    # Prefer Clang (clang) on macOS..
    if test_toolset clang && test_uname Darwin && test_compiler clang++$TOOLSET_SUFFIX -x c++ -std=c++11 ; then B2_TOOLSET=clang$TOOLSET_SUFFIX ; return ${TRUE} ; fi
    # GCC (gcc)..
    if test_toolset gcc && test_compiler g++$TOOLSET_SUFFIX -x c++ -std=c++11 ; then B2_TOOLSET=gcc$TOOLSET_SUFFIX ; return ${TRUE} ; fi
    if test_toolset gcc && test_compiler g++$TOOLSET_SUFFIX -x c++ -std=c++11 -D_GNU_SOURCE ; then B2_TOOLSET=gcc$TOOLSET_SUFFIX ; return ${TRUE} ; fi
    # GCC (gcc) with -pthread arg (for AIX)..
    if test_toolset gcc && test_compiler g++$TOOLSET_SUFFIX -x c++ -std=c++11 -pthread ; then B2_TOOLSET=gcc$TOOLSET_SUFFIX ; return ${TRUE} ; fi
    # Clang (clang)..
    if test_toolset clang && test_compiler clang++$TOOLSET_SUFFIX -x c++ -std=c++11 ; then B2_TOOLSET=clang$TOOLSET_SUFFIX ; return ${TRUE} ; fi
    # Intel macOS (intel-darwin)
    if test_toolset intel-darwin && test -r "${HOME}/intel/oneapi/setvars.sh" && test_uname Darwin ; then
        B2_SETUP="source ${HOME}/intel/oneapi/setvars.sh"
        if test_toolset intel-darwin && test_compiler icpx -x c++ -std=c++11 ; then B2_TOOLSET=intel-darwin ; return ${TRUE} ; fi
        if test_toolset intel-darwin && test_compiler icc -x c++ -std=c++11 ; then B2_TOOLSET=intel-darwin ; return ${TRUE} ; fi
        B2_SETUP=
    fi
    if test_toolset intel-darwin && test -r "/opt/intel/oneapi/setvars.sh" && test_uname Darwin ; then
        B2_SETUP="source /opt/intel/oneapi/setvars.sh"
        if test_toolset intel-darwin && test_compiler icpx -x c++ -std=c++11 ; then B2_TOOLSET=intel-darwin ; return ${TRUE} ; fi
        if test_toolset intel-darwin && test_compiler icc -x c++ -std=c++11 ; then B2_TOOLSET=intel-darwin ; return ${TRUE} ; fi
        B2_SETUP=
    fi
    # Intel oneAPI (intel-linux)
    if test_toolset intel-linux && test_path icpx ; then
        if test_compiler icpx -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
    fi
    if test_toolset xyz && test_path icc ; then
        if test_compiler icc -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
    fi
    if test_toolset intel-linux && test -r "${HOME}/intel/oneapi/setvars.sh" ; then
        B2_SETUP="source ${HOME}/intel/oneapi/setvars.sh"
        if test_toolset intel-linux && test_compiler icpx -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
        if test_toolset intel-linux && test_compiler icc -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
        B2_SETUP=
    fi
    if test_toolset intel-linux && test -r "/opt/intel/oneapi/setvars.sh" ; then
        B2_SETUP="source /opt/intel/oneapi/setvars.sh"
        if test_toolset intel-linux && test_compiler icpx -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
        if test_toolset intel-linux && test_compiler icc -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
        B2_SETUP=
    fi
    # Intel Pro (intel-linux)
    if test_toolset intel-linux && test_path icpc ; then
        if test_compiler icpc -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
    fi
    if test_toolset intel-linux && test -r "/opt/intel/inteloneapi/setvars.sh" ; then
        B2_SETUP="source /opt/intel/inteloneapi/setvars.sh"
        if test_compiler icpc -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
        B2_SETUP=
    fi
    if test_toolset intel-linux && test -r "/opt/intel/cc/9.0/bin/iccvars.sh" ; then
        B2_SETUP="source /opt/intel/cc/9.0/bin/iccvars.sh"
        if test_compiler icpc -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
        B2_SETUP=
    fi
    if test_toolset intel-linux && test -r "/opt/intel_cc_80/bin/iccvars.sh" ; then
        B2_SETUP="source /opt/intel_cc_80/bin/iccvars.sh"
        if test_compiler icpc -x c++ -std=c++11 ; then B2_TOOLSET=intel-linux ; return ${TRUE} ; fi
        B2_SETUP=
    fi
    # Mips Pro (mipspro)
    if test_toolset mipspro && test_uname IRIX && test_compiler CC -FE:template_in_elf_section -ptused ; then B2_TOOLSET=mipspro ; return ${TRUE} ; fi
    if test_toolset mipspro && test_uname IRIX64 && test_compiler CC -FE:template_in_elf_section -ptused ; then B2_TOOLSET=mipspro ; return ${TRUE} ; fi
    # OSF Tru64 C++ (tru64cxx)
    if test_toolset tru64cxx && test_uname OSF1 && test_compiler cc ; then B2_TOOLSET=mipspro ; return ${TRUE} ; fi
    # QNX (qcc)
    if test_toolset qcc && test_uname QNX && test_compiler QCC ; then B2_TOOLSET=mipspro ; return ${TRUE} ; fi
    # Linux XL/VA C++ (xlcpp, vacpp)
    if test_toolset xlcpp vacpp && test_uname Linux && test_compiler xlC_r ; then
        if /usr/bin/lscpu | grep Byte | grep Little > /dev/null 2>&1 ; then
            # Little endian linux
            B2_TOOLSET=xlcpp
            return ${TRUE}
        else
            # Big endian linux
            B2_TOOLSET=vacpp
            return ${TRUE}
        fi
    fi
    # AIX VA C++ (vacpp)
    if test_toolset vacpp && test_uname AIX && test_compiler xlC_r ; then B2_TOOLSET=vacpp ; return ${TRUE} ; fi
    # PGI (pgi)
    if test_toolset pgi && test_compiler pgc++ -std=c++11 ; then B2_TOOLSET=pgi ; return ${TRUE} ; fi
    # Pathscale C++ (pathscale)
    if test_toolset pathscale && test_compiler pathCC ; then B2_TOOLSET=pathscale ; return ${TRUE} ; fi
    # Como (como)
    if test_toolset como && test_compiler como ; then B2_TOOLSET=como ; return ${TRUE} ; fi
    # Borland C++ (kylix)
    if test_toolset kylix && test_compiler bc++ -tC -q ; then B2_TOOLSET=kylix ; return ${TRUE} ; fi
    # aCC (acc)
    if test_toolset acc && test_compiler aCC -AA ; then B2_TOOLSET=acc ; return ${TRUE} ; fi
    # Sun Pro C++ (sunpro)
    if test_toolset sunpro && test_compiler /opt/SUNWspro/bin/CC -std=c++11 ; then B2_TOOLSET=sunpro ; return ${TRUE} ; fi
    # Generic (cxx)
    if test_toolset cxx && test_compiler cxx ; then B2_TOOLSET=cxx ; return ${TRUE} ; fi
    if test_toolset cxx && test_compiler cpp ; then B2_TOOLSET=cxx ; return ${TRUE} ; fi
    if test_toolset cxx && test_compiler CC ; then B2_TOOLSET=cxx ; return ${TRUE} ; fi

    # Nothing found.
    if test "${B2_TOOLSET}" = "" ; then
        error_exit "Could not find a suitable toolset."
    fi
    return ${FALSE}
}

# Handle command options and args.
while test $# -gt 0
do
    case "$1" in
        --verbose) B2_VERBOSE_OPT=${TRUE} ;;
        --debug) B2_DEBUG_OPT=${TRUE} ;;
        --guess-toolset) B2_GUESS_TOOLSET_OPT=${TRUE} ;;
        --help) B2_HELP_OPT=${TRUE} ;;
        --cxx=*) B2_CXX_OPT=`expr "x$1" : "x--cxx=\(.*\)"` ;;
        --cxxflags=*) B2_CXXFLAGS_OPT=`expr "x$1" : "x--cxxflags=\(.*\)"` ;;
        -*) ;;
        ?*) B2_TOOLSET=$1 ;;
    esac
    shift
done

# Show some help, if requested.
if test_true ${B2_HELP_OPT} ; then
    error_exit
fi

# If we have a CXX but no B2_TOOLSET specified by the user we assume they meant
# "cxx" as the toolset.
if test "${B2_CXX_OPT}" != "" -a "${B2_TOOLSET}" = "" ; then
    B2_TOOLSET=cxx
fi

# If we have B2_TOOLSET=cxx but no B2_CXX_OPT nor B2_CXXFLAGS_OPT specified by the user
# we assume they meant $CXX and $CXXFLAGS.
if test "${B2_TOOLSET}" = "cxx" -a "${B2_CXX_OPT}" = "" -a "${B2_CXXFLAGS_OPT}" = "" ; then
    B2_CXX_OPT="${CXX}"
    B2_CXXFLAGS_OPT="${CXXFLAGS}"
fi

# Guess toolset, or toolset commands.
check_toolset
TOOLSET_CHECK=$?

# We can bail from the rest of the checks and build if we are just guessing
# the toolset.
if test_true ${B2_GUESS_TOOLSET_OPT} ; then
    echo "${B2_TOOLSET}"
    exit 0
fi

# We need a viable compiler. Check here and give some feedback about it.
if ! test_true ${TOOLSET_CHECK} ; then
    echo "
A C++11 capable compiler is required for building the B2 engine.
Toolset '${B2_TOOLSET}' does not appear to support C++11.
"
    (B2_VERBOSE_OPT=${TRUE} check_toolset)
    error_exit "
** Note, the C++11 capable compiler is _only_ required for building the B2
** engine. The B2 build system allows for using any C++ level and any other
** supported language and resource in your projects.
"
fi

# Set the additional options needed to build the engine based on the toolset.
case "${B2_TOOLSET}" in

    gcc|gcc-*)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-O2 -s"
        B2_CXXFLAGS_DEBUG="-O0 -g"
    ;;

    intel-*)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-O3 -s -static"
        B2_CXXFLAGS_DEBUG="-O0 -g -p -static"
    ;;

    vacpp)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:--qversion}
        B2_CXXFLAGS_RELEASE="-O3 -s -qstrict -qinline"
        B2_CXXFLAGS_DEBUG="-g -qNOOPTimize -qnoinline -pg"
    ;;

    xlcpp)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:--qversion}
        B2_CXXFLAGS_RELEASE="-s -O3 -qstrict -qinline"
        B2_CXXFLAGS_DEBUG="-g -qNOOPTimize -qnoinline -pg"
    ;;

    como)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-O3 --inlining"
        B2_CXXFLAGS_DEBUG="-O0 -g --no_inlining --long_long"
    ;;

    kcc)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="+K2 -s"
        B2_CXXFLAGS_DEBUG="+K0 -g"
    ;;

    kylix)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-O2 -vi -w-inl -s"
        B2_CXXFLAGS_DEBUG="-Od -v -vi-"
    ;;

    mipspro)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-Ofast -g0 \"-INLINE:none\" -s"
        B2_CXXFLAGS_DEBUG="-O0 -INLINE -g"
    ;;

    pathscale)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-O3 -inline -s"
        B2_CXXFLAGS_DEBUG="-O0 -noinline -ggdb"
    ;;

    pgi)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-fast -s"
        B2_CXXFLAGS_DEBUG="-O0 -gopt"
    ;;

    sun*)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:--V}
        B2_CXXFLAGS_RELEASE="-xO4 -s"
        B2_CXXFLAGS_DEBUG="-g"
    ;;

    clang|clang-*)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-O3 -s"
        B2_CXXFLAGS_DEBUG="-O0 -fno-inline -g"
    ;;

    tru64cxx)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-O5 -inline speed -s"
        B2_CXXFLAGS_DEBUG="-O0 -pg -g"
    ;;

    acc)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-O3 -s"
        B2_CXXFLAGS_DEBUG="+d -g"
    ;;

    qcc)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
        B2_CXXFLAGS_RELEASE="-O3 -Wc,-finline-functions"
        B2_CXXFLAGS_DEBUG="O0 -Wc,-fno-inline -gstabs+"
    ;;

    cxx)
        CXX_VERSION_OPT=${CXX_VERSION_OPT:---version}
    ;;

    *)
        error_exit "Unknown toolset: ${B2_TOOLSET}"
    ;;
esac

build_b2 ()
{
    echo "
###
###
### Using '${B2_TOOLSET}' toolset.
###
###
"
    echo_run ${B2_CXX} ${CXX_VERSION_OPT}
echo "
###
###
"
    B2_SOURCES="\
builtins.cpp \
class.cpp \
command.cpp \
compile.cpp \
constants.cpp \
cwd.cpp \
debug.cpp \
debugger.cpp \
execcmd.cpp \
execnt.cpp \
execunix.cpp \
filesys.cpp \
filent.cpp \
fileunix.cpp \
frames.cpp \
function.cpp \
glob.cpp \
hash.cpp \
hcache.cpp \
hdrmacro.cpp \
headers.cpp \
jam_strings.cpp \
jam.cpp \
jamgram.cpp \
lists.cpp \
make.cpp \
make1.cpp \
md5.cpp \
mem.cpp \
modules.cpp \
native.cpp \
object.cpp \
option.cpp \
output.cpp \
parse.cpp \
pathnt.cpp \
pathsys.cpp \
pathunix.cpp \
regexp.cpp \
rules.cpp \
scan.cpp \
search.cpp \
startup.cpp \
subst.cpp \
sysinfo.cpp \
timestamp.cpp \
variable.cpp \
w32_getreg.cpp \
modules/order.cpp \
modules/path.cpp \
modules/property-set.cpp \
modules/regex.cpp \
modules/sequence.cpp \
modules/set.cpp \
"

    if test_true ${B2_DEBUG_OPT} ; then B2_CXXFLAGS="${B2_CXXFLAGS_DEBUG}"
    else B2_CXXFLAGS="${B2_CXXFLAGS_RELEASE} -DNDEBUG"
    fi
    ( B2_VERBOSE_OPT=${TRUE} echo_run ${B2_CXX} ${B2_CXXFLAGS} ${B2_SOURCES} -o b2 )
    ( B2_VERBOSE_OPT=${TRUE} echo_run cp b2 bjam )
}

if test_true ${B2_VERBOSE_OPT} ; then
    (
        ${B2_SETUP}
        build_b2
    )
else
    (
        ${B2_SETUP} 1>/dev/null 2>/dev/null
        build_b2
    )
fi


#!/usr/bin/bash

# Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
#
# 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)

mkdir -p temp
doxygen source.dox
cd temp
xsltproc combine.xslt index.xml > all.xml
xsltproc ../reference.xsl all.xml > ../reference.qbk


# This script runs a build and compares the scrubbed/normalized
# results against the scrubbed results of a previous build (run using
# update-baseline-html.sh). It is primarily used to guard against
# XSLT regressions in docca.

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

! test -d htmlPREVIOUS_SCRUBBED && echo "First run update-baseline-html.sh" && exit

rm -rf html_SCRUBBED

echo "Running clean build..."
b2 clean
b2

echo "Scrubbing results and storing as html_SCRUBBED..."
cp -r html html_SCRUBBED
cd html_SCRUBBED
grep -rl -f ${SCRIPT_DIR}/grep-expressions . | xargs sed -i -f ${SCRIPT_DIR}/sed-commands

echo "Showing diffs from previous build (stored in diffs.txt):"
cd ..
diff -r htmlPREVIOUS_SCRUBBED html_SCRUBBED >diffs.txt
cat diffs.txt


# This script runs a new build and moves the results so they
# can be used as a comparison baseline against subsequent builds
# that are run using build-and-compare.sh

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

rm -rf htmlPREVIOUS htmlPREVIOUS_SCRUBBED

echo "Running clean build..."
b2 clean
b2

echo "Moving results to htmlPREVIOUS..."
mv html htmlPREVIOUS

echo "Scrubbing htmlPREVIOUS and storing as htmlPREVIOUS_SCRUBBED for use by build-and-compare.sh..."
cp -r htmlPREVIOUS htmlPREVIOUS_SCRUBBED
cd htmlPREVIOUS_SCRUBBED
grep -rl -f ${SCRIPT_DIR}/grep-expressions . | xargs sed -i -f ${SCRIPT_DIR}/sed-commands


#! /usr/bin/env bash

# boost::hs installer
#
# Copyright 2006 Matias Capeletto
# 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)

# This script install the .xml kate syntax files in KDE

echo "Installing boost::hs"
echo "A few xml files will be copy to the place KDE store katepart sources."
echo "Files to install"

ls syntax/*.xml -1

echo "Installing..."

cp syntax/*.xml /usr/share/apps/katepart/syntax

echo "Done!"
echo ""


#==============================================================================
#   Copyright (c) 2017-2018 Daniel James
#
#   Use, modification and distribution is subject to 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)
#==============================================================================

#!/usr/bin/env bash

cd $(dirname $0)

cd ..
b2 -q || exit 1
cd -

find . -name "*.gold" | while read gold_file
do
    flags="--debug"

    quickbook_file=$(echo $gold_file | sed 's/[.]gold/.quickbook/')
    html_file=$(echo $gold_file | sed 's/[.]gold/.gold-html/')

    if [[ $gold_file =~ .*xinclude/.*-alt\.gold ]]
    then
        quickbook_file=$(echo $quickbook_file | sed 's/-alt\.quickbook/.quickbook/')
        flags="$flags --xinclude-base xinclude/sub"
    elif [[ $gold_file =~ .*xinclude/.*\.gold ]]
    then
        flags="$flags --xinclude-base xinclude/../.."
    fi

    if [[ $gold_file =~ .*include/filename[-_]path.* ]]
    then
        flags="$flags -I include/sub"
    fi

    if [[ $gold_file =~ .*command_line_macro.* ]]
    then
        flags="$flags -D__macro__=*bold* -D__empty__"
    fi

    ../../../dist/bin/quickbook $quickbook_file $flags --output-file $gold_file ||
        echo "*** Error generating boostbook from $quickbook_file"
    ../../../dist/bin/quickbook $quickbook_file $flags --output-file $html_file --output-format onehtml ||
        echo "*** Error generating html from $quickbook_file"
done