diff --git a/mosesdecoder/jam-files/LICENSE_1_0.txt b/mosesdecoder/jam-files/LICENSE_1_0.txt new file mode 100644 index 0000000000000000000000000000000000000000..36b7cd93cdfbac762f5be4c6ce276df2ea6305c2 --- /dev/null +++ b/mosesdecoder/jam-files/LICENSE_1_0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/mosesdecoder/jam-files/boost-build/tools/auto-index.jam b/mosesdecoder/jam-files/boost-build/tools/auto-index.jam new file mode 100644 index 0000000000000000000000000000000000000000..5c5c1d06cf35e960592d1c6797d4654fa74545d0 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/auto-index.jam @@ -0,0 +1,212 @@ + +import feature ; +import generators ; +import "class" ; +import toolset ; +import targets ; +import "class" : new ; +import project ; + +feature.feature auto-index : off "on" ; +feature.feature auto-index-internal : off "on" ; +feature.feature auto-index-verbose : off "on" ; +feature.feature auto-index-no-duplicates : off "on" ; +feature.feature auto-index-script : : free path ; +feature.feature auto-index-prefix : : free path ; +feature.feature auto-index-type : : free ; +feature.feature auto-index-section-names : "on" off ; + +toolset.flags auto-index.auto-index FLAGS on : --internal-index ; +toolset.flags auto-index.auto-index SCRIPT ; +toolset.flags auto-index.auto-index PREFIX ; +toolset.flags auto-index.auto-index INDEX_TYPE ; +toolset.flags auto-index.auto-index FLAGS on : --verbose ; +toolset.flags auto-index.auto-index FLAGS on : --no-duplicates ; +toolset.flags auto-index.auto-index FLAGS off : --no-section-names ; + +# shell command to run AutoIndex +# targets to build AutoIndex from sources. +feature.feature : : free ; +feature.feature : : free dependency ; + +class auto-index-generator : generator +{ + import common modules path targets build-system ; + rule run ( project name ? : property-set : sources * ) + { + # AutoIndex invocation command and dependencies. + local auto-index-binary = [ modules.peek auto-index : .command ] ; + local auto-index-binary-dependencies ; + + if $(auto-index-binary) + { + # Use user-supplied command. + auto-index-binary = [ common.get-invocation-command auto-index : auto-index : $(auto-index-binary) ] ; + } + else + { + # Search for AutoIndex sources in sensible places, like + # $(BOOST_ROOT)/tools/auto_index + # $(BOOST_BUILD_PATH)/../../auto_index + + # And build auto-index executable from sources. + + local boost-root = [ modules.peek : BOOST_ROOT ] ; + local boost-build-path = [ build-system.location ] ; + local boost-build-path2 = [ modules.peek : BOOST_BUILD_PATH ] ; + + local auto-index-dir ; + + if $(boost-root) + { + auto-index-dir += [ path.join $(boost-root) tools ] ; + } + + if $(boost-build-path) + { + auto-index-dir += $(boost-build-path)/../.. ; + } + if $(boost-build-path2) + { + auto-index-dir += $(boost-build-path2)/.. ; + } + + #ECHO $(auto-index-dir) ; + auto-index-dir = [ path.glob $(auto-index-dir) : auto_index ] ; + #ECHO $(auto-index-dir) ; + + # If the AutoIndex source directory was found, mark its main target + # as a dependency for the current project. Otherwise, try to find + # 'auto-index' in user's PATH + if $(auto-index-dir) + { + auto-index-dir = [ path.make $(auto-index-dir[1]) ] ; + auto-index-dir = $(auto-index-dir)/build ; + + #ECHO $(auto-index-dir) ; + + # Get the main-target in AutoIndex directory. + local auto-index-main-target = [ targets.resolve-reference $(auto-index-dir) : $(project) ] ; + + #ECHO $(auto-index-main-target) ; + + # The first element are actual targets, the second are + # properties found in target-id. We do not care about these + # since we have passed the id ourselves. + auto-index-main-target = + [ $(auto-index-main-target[1]).main-target auto_index ] ; + + #ECHO $(auto-index-main-target) ; + + auto-index-binary-dependencies = + [ $(auto-index-main-target).generate [ $(property-set).propagated ] ] ; + + # Ignore usage-requirements returned as first element. + auto-index-binary-dependencies = $(auto-index-binary-dependencies[2-]) ; + + # Some toolsets generate extra targets (e.g. RSP). We must mark + # all targets as dependencies for the project, but we will only + # use the EXE target for auto-index-to-boostbook translation. + for local target in $(auto-index-binary-dependencies) + { + if [ $(target).type ] = EXE + { + auto-index-binary = + [ path.native + [ path.join + [ $(target).path ] + [ $(target).name ] + ] + ] ; + } + } + } + else + { + ECHO "AutoIndex warning: The path to the auto-index executable was" ; + ECHO " not provided. Additionally, couldn't find AutoIndex" ; + ECHO " sources searching in" ; + ECHO " * BOOST_ROOT/tools/auto-index" ; + ECHO " * BOOST_BUILD_PATH/../../auto-index" ; + ECHO " Will now try to find a precompiled executable by searching" ; + ECHO " the PATH for 'auto-index'." ; + ECHO " To disable this warning in the future, or to completely" ; + ECHO " avoid compilation of auto-index, you can explicitly set the" ; + ECHO " path to a auto-index executable command in user-config.jam" ; + ECHO " or site-config.jam with the call" ; + ECHO " using auto-index : /path/to/auto-index ;" ; + + # As a last resort, search for 'auto-index' command in path. Note + # that even if the 'auto-index' command is not found, + # get-invocation-command will still return 'auto-index' and might + # generate an error while generating the virtual-target. + + auto-index-binary = [ common.get-invocation-command auto-index : auto-index ] ; + } + } + + # Add $(auto-index-binary-dependencies) as a dependency of the current + # project and set it as the feature for the + # auto-index-to-boostbook rule, below. + property-set = [ $(property-set).add-raw + $(auto-index-binary-dependencies) + $(auto-index-binary) + $(auto-index-binary-dependencies) + ] ; + + #ECHO "binary = " $(auto-index-binary) ; + #ECHO "dependencies = " $(auto-index-binary-dependencies) ; + + if [ $(property-set).get ] = "on" + { + return [ generator.run $(project) $(name) : $(property-set) : $(sources) ] ; + } + else + { + return [ generators.construct $(project) $(name) : DOCBOOK : $(property-set) + : $(sources) ] ; + } + } +} + +# Initialization of toolset. +# +# Parameters: +# command ? -> path to AutoIndex executable. +# +# When command is not supplied toolset will search for AutoIndex directory and +# compile the executable from source. If that fails we still search the path for +# 'auto_index'. +# +rule init ( + command ? # path to the AutoIndex executable. + ) +{ + if ! $(.initialized) + { + .initialized = true ; + .command = $(command) ; + } +} + +toolset.flags auto-index.auto-index AI-COMMAND ; +toolset.flags auto-index.auto-index AI-DEPENDENCIES ; + +generators.register [ class.new auto-index-generator auto-index.auto-index : DOCBOOK : DOCBOOK(%.auto_index) ] ; +generators.override auto-index.auto-index : boostbook.boostbook-to-docbook ; + +rule auto-index ( target : source : properties * ) +{ + # Signal dependency of auto-index sources on + # upon invocation of auto-index-to-boostbook. + #ECHO "AI-COMMAND= " $(AI-COMMAND) ; + DEPENDS $(target) : [ on $(target) return $(AI-DEPENDENCIES) ] ; + #DEPENDS $(target) : [ on $(target) return $(SCRIPT) ] ; +} + +actions auto-index +{ + $(AI-COMMAND) $(FLAGS) "--prefix="$(PREFIX) "--script="$(SCRIPT) "--index-type="$(INDEX_TYPE) "--in="$(>) "--out="$(<) +} + + diff --git a/mosesdecoder/jam-files/boost-build/tools/bison.jam b/mosesdecoder/jam-files/boost-build/tools/bison.jam new file mode 100644 index 0000000000000000000000000000000000000000..0689d4bd893f99192882c17e42d6ed7d46ec9ccd --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/bison.jam @@ -0,0 +1,32 @@ +# Copyright 2003 Vladimir Prus +# 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) + +import generators ; +import feature ; +import type ; +import property ; + +feature.feature bison.prefix : : free ; +type.register Y : y ; +type.register YY : yy ; +generators.register-standard bison.bison : Y : C H ; +generators.register-standard bison.bison : YY : CPP HPP ; + +rule init ( ) +{ +} + +rule bison ( dst dst_header : src : properties * ) +{ + local r = [ property.select bison.prefix : $(properties) ] ; + if $(r) + { + PREFIX_OPT on $(<) = -p $(r:G=) ; + } +} + +actions bison +{ + bison $(PREFIX_OPT) -d -o $(<[1]) $(>) +} diff --git a/mosesdecoder/jam-files/boost-build/tools/boostbook-config.jam b/mosesdecoder/jam-files/boost-build/tools/boostbook-config.jam new file mode 100644 index 0000000000000000000000000000000000000000..6e3f3ddc10132980ac45a5a70db81b0616ce5b3c --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/boostbook-config.jam @@ -0,0 +1,13 @@ +#~ Copyright 2005 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) + +# Automatic configuration for BoostBook tools. To use, just import this module. +# +# This module is deprecated. +# using boostbook ; +# with no arguments now suffices. + +import toolset : using ; + +using boostbook ; diff --git a/mosesdecoder/jam-files/boost-build/tools/borland.jam b/mosesdecoder/jam-files/boost-build/tools/borland.jam new file mode 100644 index 0000000000000000000000000000000000000000..6e43ca93a5a9d6106b18f17fbf388b44490f4125 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/borland.jam @@ -0,0 +1,220 @@ +# Copyright 2005 Dave Abrahams +# Copyright 2003 Rene Rivera +# Copyright 2003, 2004, 2005 Vladimir Prus +# 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) + +# Support for the Borland's command line compiler + +import property ; +import generators ; +import os ; +import toolset : flags ; +import feature : get-values ; +import type ; +import common ; + +feature.extend toolset : borland ; + +rule init ( version ? : command * : options * ) +{ + local condition = [ common.check-init-parameters borland : + version $(version) ] ; + + local command = [ common.get-invocation-command borland : bcc32.exe + : $(command) ] ; + + common.handle-options borland : $(condition) : $(command) : $(options) ; + + if $(command) + { + command = [ common.get-absolute-tool-path $(command[-1]) ] ; + } + root = $(command:D) ; + + flags borland.compile STDHDRS $(condition) : $(root)/include/ ; + flags borland.link STDLIBPATH $(condition) : $(root)/lib ; + flags borland.link RUN_PATH $(condition) : $(root)/bin ; + flags borland .root $(condition) : $(root)/bin/ ; +} + + +# A borland-specific target type +type.register BORLAND.TDS : tds ; + +# Declare generators + +generators.register-linker borland.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : borland ; +generators.register-linker borland.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : borland ; + +generators.register-archiver borland.archive : OBJ : STATIC_LIB : borland ; +generators.register-c-compiler borland.compile.c++ : CPP : OBJ : borland ; +generators.register-c-compiler borland.compile.c : C : OBJ : borland ; +generators.register-standard borland.asm : ASM : OBJ : borland ; + +# Declare flags + +flags borland.compile OPTIONS on : -v ; +flags borland.link OPTIONS on : -v ; + +flags borland.compile OPTIONS off : -Od ; +flags borland.compile OPTIONS speed : -O2 ; +flags borland.compile OPTIONS space : -O1 ; + +if $(.BORLAND_HAS_FIXED_INLINING_BUGS) +{ + flags borland CFLAGS off : -vi- ; + flags borland CFLAGS on : -vi -w-inl ; + flags borland CFLAGS full : -vi -w-inl ; +} +else +{ + flags borland CFLAGS : -vi- ; +} + +flags borland.compile OPTIONS off : -w- ; +flags borland.compile OPTIONS all : -w ; +flags borland.compile OPTIONS on : -w! ; + + +# Deal with various runtime configs... + +# This should be not for DLL +flags borland OPTIONS console : -tWC ; + +# -tWR sets -tW as well, so we turn it off here and then turn it +# on again later if we need it: +flags borland OPTIONS shared : -tWR -tWC ; +flags borland OPTIONS gui : -tW ; + +flags borland OPTIONS LIB/shared : -tWD ; +# Hmm.. not sure what's going on here. +flags borland OPTIONS : -WM- ; +flags borland OPTIONS multi : -tWM ; + + + +flags borland.compile OPTIONS ; +flags borland.compile DEFINES ; +flags borland.compile INCLUDES ; + +flags borland NEED_IMPLIB LIB/shared : "" ; + +# +# for C++ compiles the following options are turned on by default: +# +# -j5 stops after 5 errors +# -g255 allow an unlimited number of warnings +# -q no banner +# -c compile to object +# -P C++ code regardless of file extention +# -a8 8 byte alignment, this option is on in the IDE by default +# and effects binary compatibility. +# + +# -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)" -I"$(STDHDRS)" -o"$(<)" "$(>)" + + +actions compile.c++ +{ + "$(CONFIG_COMMAND)" -j5 -g255 -q -c -P -a8 -Vx- -Ve- -b- $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)" +} + +# For C, we don't pass -P flag +actions compile.c +{ + "$(CONFIG_COMMAND)" -j5 -g255 -q -c -a8 -Vx- -Ve- -b- $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)" +} + + +# Declare flags and action for linking +toolset.flags borland.link OPTIONS on : -v ; +toolset.flags borland.link LIBRARY_PATH ; +toolset.flags borland.link FINDLIBS_ST ; +toolset.flags borland.link FINDLIBS_SA ; +toolset.flags borland.link LIBRARIES ; + +flags borland.link OPTIONS ; +flags borland.link OPTIONS shared : -tWD ; + +flags borland.link LIBRARY_PATH_OPTION borland : -L : unchecked ; +flags borland.link LIBRARY_OPTION borland : "" : unchecked ; + + + +# bcc32 needs to have ilink32 in the path in order to invoke it, so explicitly +# specifying $(BCC_TOOL_PATH)bcc32 doesn't help. You need to add +# $(BCC_TOOL_PATH) to the path +# The NEED_IMPLIB variable controls whether we need to invoke implib. + +flags borland.archive AROPTIONS ; + +# Declare action for archives. We don't use response file +# since it's hard to get "+-" there. +# The /P256 increases 'page' size -- with too low +# values tlib fails when building large applications. +# CONSIDER: don't know what 'together' is for... +actions updated together piecemeal archive +{ + $(.set-path)$(.root:W)$(.old-path) + tlib $(AROPTIONS) /P256 /u /a /C "$(<:W)" +-"$(>:W)" +} + + +if [ os.name ] = CYGWIN +{ + .set-path = "cmd /S /C set \"PATH=" ; + .old-path = ";%PATH%\" \"&&\"" ; + + + # Couldn't get TLIB to stop being confused about pathnames + # containing dashes (it seemed to treat them as option separators + # when passed through from bash), so we explicitly write the + # command into a .bat file and execute that. TLIB is also finicky + # about pathname style! Forward slashes, too, are treated as + # options. + actions updated together piecemeal archive + { + chdir $(<:D) + echo +-$(>:BS) > $(<:BS).rsp + $(.set-path)$(.root)$(.old-path) "tlib.exe" $(AROPTIONS) /P256 /C $(<:BS) @$(<:BS).rsp && $(RM) $(<:BS).rsp + } +} +else if [ os.name ] = NT +{ + .set-path = "set \"PATH=" ; + .old-path = ";%PATH%\" + " ; +} +else +{ + .set-path = "PATH=\"" ; + .old-path = "\":$PATH + export PATH + " ; +} + +RM = [ common.rm-command ] ; + +nl = " +" ; + +actions link +{ + $(.set-path)$(.root:W)$(.old-path) "$(CONFIG_COMMAND)" -v -q $(OPTIONS) -L"$(LIBRARY_PATH:W)" -L"$(STDLIBPATH:W)" -e"$(<[1]:W)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" +} + + +actions link.dll bind LIBRARIES RSP +{ + $(.set-path)$(.root:W)$(.old-path) "$(CONFIG_COMMAND)" -v -q $(OPTIONS) -L"$(LIBRARY_PATH:W)" -L"$(STDLIBPATH:W)" -e"$(<[1]:W)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" && "$(.root)implib" "$(<[2]:W)" "$(<[1]:W)" +} + +# It seems impossible to specify output file with directory when compiling +# asm files using bcc32, so use tasm32 directly. +# /ml makes all symbol names case-sensitive +actions asm +{ + $(.set-path)$(.root:W)$(.old-path) tasm32.exe /ml "$(>)" "$(<)" +} + diff --git a/mosesdecoder/jam-files/boost-build/tools/builtin.jam b/mosesdecoder/jam-files/boost-build/tools/builtin.jam new file mode 100644 index 0000000000000000000000000000000000000000..d1351a42319e4543f85277b8c824482c7d872640 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/builtin.jam @@ -0,0 +1,960 @@ +# Copyright 2002, 2003, 2004, 2005 Dave Abrahams +# Copyright 2002, 2005, 2006, 2007, 2010 Rene Rivera +# Copyright 2006 Juergen Hunold +# Copyright 2005 Toon Knapen +# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus +# 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) + +# Defines standard features and rules. + +import alias ; +import "class" : new ; +import errors ; +import feature ; +import generators ; +import numbers ; +import os ; +import path ; +import print ; +import project ; +import property ; +import regex ; +import scanner ; +import sequence ; +import stage ; +import symlink ; +import toolset ; +import type ; +import targets ; +import types/register ; +import utility ; +import virtual-target ; +import message ; +import convert ; + +# FIXME: the following generate module import is not needed here but removing it +# too hastly will break using code (e.g. the main Boost library Jamroot file) +# that forgot to import the generate module before calling the generate rule. +import generate ; + + +.os-names = aix bsd cygwin darwin freebsd hpux iphone linux netbsd + openbsd osf qnx qnxnto sgi solaris unix unixware windows + elf # Not actually an OS -- used for targeting bare metal where + # object format is ELF. This catches both -elf and -eabi gcc + # targets and well as other compilers targeting ELF. It is not + # clear how often do we need to key of ELF specifically as opposed + # to other bare metal targets, but let's stick with gcc naming. + ; + +# Feature used to determine which OS we're on. New and +# features should be used instead. +local os = [ modules.peek : OS ] ; +feature.feature os : $(os) : propagated link-incompatible ; + + +# Translates from bjam current OS to the os tags used in host-os and target-os, +# i.e. returns the running host-os. +# +local rule default-host-os ( ) +{ + local host-os ; + if [ os.name ] in $(.os-names:U) + { + host-os = [ os.name ] ; + } + else + { + switch [ os.name ] + { + case NT : host-os = windows ; + case AS400 : host-os = unix ; + case MINGW : host-os = windows ; + case BSDI : host-os = bsd ; + case COHERENT : host-os = unix ; + case DRAGONFLYBSD : host-os = bsd ; + case IRIX : host-os = sgi ; + case MACOSX : host-os = darwin ; + case KFREEBSD : host-os = freebsd ; + case LINUX : host-os = linux ; + case SUNOS : + ECHO "SunOS is not a supported operating system." ; + ECHO "We believe last version of SunOS was released in 1992, " ; + ECHO "so if you get this message, something is very wrong with configuration logic. " ; + ECHO "Please report this as a bug. " ; + EXIT ; + case * : host-os = unix ; + } + } + return $(host-os:L) ; +} + + +# The two OS features define a known set of abstract OS names. The host-os is +# the OS under which bjam is running. Even though this should really be a fixed +# property we need to list all the values to prevent unknown value errors. Both +# set the default value to the current OS to account for the default use case of +# building on the target OS. +feature.feature host-os : $(.os-names) ; +feature.set-default host-os : [ default-host-os ] ; + +feature.feature target-os : $(.os-names) : propagated link-incompatible ; +feature.set-default target-os : [ default-host-os ] ; + + +feature.feature toolset : : implicit propagated symmetric ; +feature.feature stdlib : native : propagated composite ; +feature.feature link : shared static : propagated ; +feature.feature runtime-link : shared static : propagated ; +feature.feature runtime-debugging : on off : propagated ; +feature.feature optimization : off speed space : propagated ; +feature.feature profiling : off on : propagated ; +feature.feature inlining : off on full : propagated ; +feature.feature threading : single multi : propagated ; +feature.feature rtti : on off : propagated ; +feature.feature exception-handling : on off : propagated ; + +# Whether there is support for asynchronous EH (e.g. catching SEGVs). +feature.feature asynch-exceptions : off on : propagated ; + +# Whether all extern "C" functions are considered nothrow by default. +feature.feature extern-c-nothrow : off on : propagated ; + +feature.feature debug-symbols : on off : propagated ; +# Controls whether the binary should be stripped -- that is have +# everything not necessary to running removed. This option should +# not be very often needed. Also, this feature will show up in +# target paths of everything, not just binaries. Should fix that +# when impelementing feature relevance. +feature.feature strip : off on : propagated ; +feature.feature define : : free ; +feature.feature undef : : free ; +feature.feature "include" : : free path ; #order-sensitive ; +feature.feature cflags : : free ; +feature.feature cxxflags : : free ; +feature.feature fflags : : free ; +feature.feature asmflags : : free ; +feature.feature linkflags : : free ; +feature.feature archiveflags : : free ; +feature.feature version : : free ; + +# Generic, i.e. non-language specific, flags for tools. +feature.feature flags : : free ; +feature.feature location-prefix : : free ; + + +# The following features are incidental since they have no effect on built +# products. Not making them incidental will result in problems in corner cases, +# e.g.: +# +# unit-test a : a.cpp : b ; +# lib b : a.cpp b ; +# +# Here, if is not incidental, we would decide we have two targets for +# a.obj with different properties and complain about it. +# +# Note that making a feature incidental does not mean it is ignored. It may be +# ignored when creating a virtual target, but the rest of build process will use +# them. +feature.feature use : : free dependency incidental ; +feature.feature dependency : : free dependency incidental ; +feature.feature implicit-dependency : : free dependency incidental ; + +feature.feature warnings : + on # Enable default/"reasonable" warning level for the tool. + all # Enable all possible warnings issued by the tool. + off # Disable all warnings issued by the tool. + : incidental propagated ; + +feature.feature warnings-as-errors : + off # Do not fail the compilation if there are warnings. + on # Fail the compilation if there are warnings. + : incidental propagated ; + +# Feature that allows us to configure the maximal template instantiation depth +# level allowed by a C++ compiler. Applies only to C++ toolsets whose compilers +# actually support this configuration setting. +# +# Note that Boost Build currently does not allow defining features that take any +# positive integral value as a parameter, which is what we need here, so we just +# define some of the values here and leave it up to the user to extend this set +# as he needs using the feature.extend rule. +# +# TODO: This should be upgraded as soon as Boost Build adds support for custom +# validated feature values or at least features allowing any positive integral +# value. See related Boost Build related trac ticket #194. +# +feature.feature c++-template-depth + : + [ numbers.range 64 1024 : 64 ] + [ numbers.range 20 1000 : 10 ] + # Maximum template instantiation depth guaranteed for ANSI/ISO C++ + # conforming programs. + 17 + : + incidental optional propagated ; + +feature.feature source : : free dependency incidental ; +feature.feature library : : free dependency incidental ; +feature.feature file : : free dependency incidental ; +feature.feature find-shared-library : : free ; #order-sensitive ; +feature.feature find-static-library : : free ; #order-sensitive ; +feature.feature library-path : : free path ; #order-sensitive ; + +# Internal feature. +feature.feature library-file : : free dependency ; + +feature.feature name : : free ; +feature.feature tag : : free ; +feature.feature search : : free path ; #order-sensitive ; +feature.feature location : : free path ; +feature.feature dll-path : : free path ; +feature.feature hardcode-dll-paths : true false : incidental ; + + +# An internal feature that holds the paths of all dependency shared libraries. +# On Windows, it is needed so that we can add all those paths to PATH when +# running applications. On Linux, it is needed to add proper -rpath-link command +# line options. +feature.feature xdll-path : : free path ; + +# Provides means to specify def-file for windows DLLs. +feature.feature def-file : : free dependency ; + +feature.feature suppress-import-lib : false true : incidental ; + +# Internal feature used to store the name of a bjam action to call when building +# a target. +feature.feature action : : free ; + +# This feature is used to allow specific generators to run. For example, QT +# tools can only be invoked when QT library is used. In that case, qt +# will be in usage requirement of the library. +feature.feature allow : : free ; + +# The addressing model to generate code for. Currently a limited set only +# specifying the bit size of pointers. +feature.feature address-model : 16 32 64 32_64 : propagated optional ; + +# Type of CPU architecture to compile for. +feature.feature architecture : + # x86 and x86-64 + x86 + + # ia64 + ia64 + + # Sparc + sparc + + # RS/6000 & PowerPC + power + + # MIPS/SGI + mips1 mips2 mips3 mips4 mips32 mips32r2 mips64 + + # HP/PA-RISC + parisc + + # Advanced RISC Machines + arm + + # Combined architectures for platforms/toolsets that support building for + # multiple architectures at once. "combined" would be the default multi-arch + # for the toolset. + combined + combined-x86-power + + : propagated optional ; + +# The specific instruction set in an architecture to compile. +feature.feature instruction-set : + # x86 and x86-64 + native i386 i486 i586 i686 pentium pentium-mmx pentiumpro pentium2 pentium3 + pentium3m pentium-m pentium4 pentium4m prescott nocona core2 conroe conroe-xe + conroe-l allendale mermon mermon-xe kentsfield kentsfield-xe penryn wolfdale + yorksfield nehalem k6 k6-2 k6-3 athlon athlon-tbird athlon-4 athlon-xp + athlon-mp k8 opteron athlon64 athlon-fx winchip-c6 winchip2 c3 c3-2 + + # ia64 + itanium itanium1 merced itanium2 mckinley + + # Sparc + v7 cypress v8 supersparc sparclite hypersparc sparclite86x f930 f934 + sparclet tsc701 v9 ultrasparc ultrasparc3 + + # RS/6000 & PowerPC + 401 403 405 405fp 440 440fp 505 601 602 603 603e 604 604e 620 630 740 7400 + 7450 750 801 821 823 860 970 8540 power-common ec603e g3 g4 g5 power power2 + power3 power4 power5 powerpc powerpc64 rios rios1 rsc rios2 rs64a + + # MIPS + 4kc 4kp 5kc 20kc m4k r2000 r3000 r3900 r4000 r4100 r4300 r4400 r4600 r4650 + r6000 r8000 rm7000 rm9000 orion sb1 vr4100 vr4111 vr4120 vr4130 vr4300 + vr5000 vr5400 vr5500 + + # HP/PA-RISC + 700 7100 7100lc 7200 7300 8000 + + # Advanced RISC Machines + armv2 armv2a armv3 armv3m armv4 armv4t armv5 armv5t armv5te armv6 armv6j iwmmxt ep9312 + + : propagated optional ; + +# Used to select a specific variant of C++ ABI if the compiler supports several. +feature.feature c++abi : : propagated optional ; + +feature.feature conditional : : incidental free ; + +# The value of 'no' prevents building of a target. +feature.feature build : yes no : optional ; + +# Windows-specific features + +feature.feature user-interface : console gui wince native auto ; + +feature.feature variant : : implicit composite propagated symmetric ; + + +# Declares a new variant. +# +# First determines explicit properties for this variant, by refining parents' +# explicit properties with the passed explicit properties. The result is +# remembered and will be used if this variant is used as parent. +# +# Second, determines the full property set for this variant by adding to the +# explicit properties default values for all missing non-symmetric properties. +# +# Lastly, makes appropriate value of 'variant' property expand to the full +# property set. +# +rule variant ( name # Name of the variant + : parents-or-properties * # Specifies parent variants, if + # 'explicit-properties' are given, and + # explicit-properties or parents otherwise. + : explicit-properties * # Explicit properties. + ) +{ + local parents ; + if ! $(explicit-properties) + { + if $(parents-or-properties[1]:G) + { + explicit-properties = $(parents-or-properties) ; + } + else + { + parents = $(parents-or-properties) ; + } + } + else + { + parents = $(parents-or-properties) ; + } + + # The problem is that we have to check for conflicts between base variants. + if $(parents[2]) + { + errors.error "multiple base variants are not yet supported" ; + } + + local inherited ; + # Add explicitly specified properties for parents. + for local p in $(parents) + { + # TODO: This check may be made stricter. + if ! [ feature.is-implicit-value $(p) ] + { + errors.error "Invalid base variant" $(p) ; + } + + inherited += $(.explicit-properties.$(p)) ; + } + property.validate $(explicit-properties) ; + explicit-properties = [ property.refine $(inherited) + : $(explicit-properties) ] ; + + # Record explicitly specified properties for this variant. We do this after + # inheriting parents' properties so they affect other variants derived from + # this one. + .explicit-properties.$(name) = $(explicit-properties) ; + + feature.extend variant : $(name) ; + feature.compose $(name) : $(explicit-properties) ; +} +IMPORT $(__name__) : variant : : variant ; + + +variant debug : off on off + on ; +variant release : speed off full + off NDEBUG ; +variant profile : release : on on ; + + +class searched-lib-target : abstract-file-target +{ + rule __init__ ( name + : project + : shared ? + : search * + : action + ) + { + abstract-file-target.__init__ $(name) : SEARCHED_LIB : $(project) + : $(action) : ; + + self.shared = $(shared) ; + self.search = $(search) ; + } + + rule shared ( ) + { + return $(self.shared) ; + } + + rule search ( ) + { + return $(self.search) ; + } + + rule actualize-location ( target ) + { + NOTFILE $(target) ; + } + + rule path ( ) + { + } +} + + +# The generator class for libraries (target type LIB). Depending on properties +# it will request building of the appropriate specific library type -- +# -- SHARED_LIB, STATIC_LIB or SHARED_LIB. +# +class lib-generator : generator +{ + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule run ( project name ? : property-set : sources * ) + { + # The lib generator is composing, and can be only invoked with an + # explicit name. This check is present in generator.run (and so in + # builtin.linking-generator) but duplicated here to avoid doing extra + # work. + if $(name) + { + local properties = [ $(property-set).raw ] ; + # Determine the needed target type. + local actual-type ; + # files can be generated by @rule feature + # in which case we do not consider it a SEARCHED_LIB type. + if ! in $(properties:G) && + ( in $(properties:G) || in $(properties:G) ) + { + actual-type = SEARCHED_LIB ; + } + else if in $(properties:G) + { + actual-type = LIB ; + } + else if shared in $(properties) + { + actual-type = SHARED_LIB ; + } + else + { + actual-type = STATIC_LIB ; + } + property-set = [ $(property-set).add-raw LIB ] ; + # Construct the target. + return [ generators.construct $(project) $(name) : $(actual-type) + : $(property-set) : $(sources) ] ; + } + } + + rule viable-source-types ( ) + { + return * ; + } +} + + +generators.register [ new lib-generator builtin.lib-generator : : LIB ] ; + + +# The implementation of the 'lib' rule. Beyond standard syntax that rule allows +# simplified: "lib a b c ;". +# +rule lib ( names + : sources * : requirements * : default-build * : + usage-requirements * ) +{ + if $(names[2]) + { + if in $(requirements:G) + { + errors.user-error "When several names are given to the 'lib' rule" : + "it is not allowed to specify the feature." ; + } + if $(sources) + { + errors.user-error "When several names are given to the 'lib' rule" : + "it is not allowed to specify sources." ; + } + } + + # This is a circular module dependency so it must be imported here. + import targets ; + + local project = [ project.current ] ; + local result ; + + for local name in $(names) + { + local r = $(requirements) ; + # Support " lib a ; " and " lib a b c ; " syntax. + if ! $(sources) && ! in $(requirements:G) + && ! in $(requirements:G) + { + r += $(name) ; + } + result += [ targets.main-target-alternative + [ new typed-target $(name) : $(project) : LIB + : [ targets.main-target-sources $(sources) : $(name) ] + : [ targets.main-target-requirements $(r) : $(project) ] + : [ targets.main-target-default-build $(default-build) : $(project) ] + : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ] + ] ] ; + } + return $(result) ; +} +IMPORT $(__name__) : lib : : lib ; + + +class searched-lib-generator : generator +{ + import property-set ; + + rule __init__ ( ) + { + # The requirements cause the generators to be tried *only* when we're + # building a lib target with a 'search' feature. This seems ugly --- all + # we want is to make sure searched-lib-generator is not invoked deep + # inside transformation search to produce intermediate targets. + generator.__init__ searched-lib-generator : : SEARCHED_LIB ; + } + + rule run ( project name ? : property-set : sources * ) + { + if $(name) + { + # If 'name' is empty, it means we have not been called to build a + # top-level target. In this case, we just fail immediately, because + # searched-lib-generator cannot be used to produce intermediate + # targets. + + local properties = [ $(property-set).raw ] ; + local shared ; + if shared in $(properties) + { + shared = true ; + } + + local search = [ feature.get-values : $(properties) ] ; + + local a = [ new null-action $(property-set) ] ; + local lib-name = [ feature.get-values : $(properties) ] ; + lib-name ?= $(name) ; + local t = [ new searched-lib-target $(lib-name) : $(project) + : $(shared) : $(search) : $(a) ] ; + # We return sources for a simple reason. If there is + # lib png : z : png ; + # the 'z' target should be returned, so that apps linking to 'png' + # will link to 'z', too. + return [ property-set.create $(search) ] + [ virtual-target.register $(t) ] $(sources) ; + } + } +} + +generators.register [ new searched-lib-generator ] ; + + +class prebuilt-lib-generator : generator +{ + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule run ( project name ? : property-set : sources * ) + { + local f = [ $(property-set).get ] ; + return $(f) $(sources) ; + } +} + +generators.register + [ new prebuilt-lib-generator builtin.prebuilt : : LIB : ] ; + +generators.override builtin.prebuilt : builtin.lib-generator ; + +class preprocessed-target-class : basic-target +{ + import generators ; + rule construct ( name : sources * : property-set ) + { + local result = [ generators.construct [ project ] + $(name) : PREPROCESSED_CPP : $(property-set) : $(sources) ] ; + if ! $(result) + { + result = [ generators.construct [ project ] + $(name) : PREPROCESSED_C : $(property-set) : $(sources) ] ; + } + if ! $(result) + { + local s ; + for x in $(sources) + { + s += [ $(x).name ] ; + } + local p = [ project ] ; + errors.user-error + "In project" [ $(p).name ] : + "Could not construct preprocessed file \"$(name)\" from $(s:J=, )." ; + } + return $(result) ; + } +} + +rule preprocessed ( name : sources * : requirements * : default-build * : + usage-requirements * ) +{ + local project = [ project.current ] ; + return [ targets.main-target-alternative + [ new preprocessed-target-class $(name) : $(project) + : [ targets.main-target-sources $(sources) : $(name) ] + : [ targets.main-target-requirements $(r) : $(project) ] + : [ targets.main-target-default-build $(default-build) : $(project) ] + : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ] + ] ] ; +} + +IMPORT $(__name__) : preprocessed : : preprocessed ; + +class compile-action : action +{ + import sequence ; + + rule __init__ ( targets * : sources * : action-name : properties * ) + { + action.__init__ $(targets) : $(sources) : $(action-name) : $(properties) ; + } + + # For all virtual targets for the same dependency graph as self, i.e. which + # belong to the same main target, add their directories to the include path. + # + rule adjust-properties ( property-set ) + { + local s = [ $(self.targets[1]).creating-subvariant ] ; + return [ $(property-set).add-raw + [ $(s).implicit-includes "include" : H ] ] ; + } +} + + +# Declare a special compiler generator. The only thing it does is changing the +# type used to represent 'action' in the constructed dependency graph to +# 'compile-action'. That class in turn adds additional include paths to handle +# cases when a source file includes headers which are generated themselves. +# +class C-compiling-generator : generator +{ + rule __init__ ( id : source-types + : target-types + : requirements * + : optional-properties * ) + { + generator.__init__ $(id) : $(source-types) : $(target-types) : + $(requirements) : $(optional-properties) ; + } + + rule action-class ( ) + { + return compile-action ; + } +} + + +rule register-c-compiler ( id : source-types + : target-types + : requirements * + : optional-properties * ) +{ + generators.register [ new C-compiling-generator $(id) : $(source-types) : + $(target-types) : $(requirements) : $(optional-properties) ] ; +} + +# FIXME: this is ugly, should find a better way (we would like client code to +# register all generators as "generators.some-rule" instead of +# "some-module.some-rule".) +# +IMPORT $(__name__) : register-c-compiler : : generators.register-c-compiler ; + + +# The generator class for handling EXE and SHARED_LIB creation. +# +class linking-generator : generator +{ + import path ; + import project ; + import property-set ; + import type ; + + rule __init__ ( id + composing ? : # The generator will be composing if a non-empty + # string is passed or the parameter is not given. To + # make the generator non-composing, pass an empty + # string (""). + source-types + : + target-types + : + requirements * ) + { + composing ?= true ; + generator.__init__ $(id) $(composing) : $(source-types) + : $(target-types) : $(requirements) ; + } + + rule run ( project name ? : property-set : sources + ) + { + sources += [ $(property-set).get ] ; + + # Add properties for all searched libraries. + local extra ; + for local s in $(sources) + { + if [ $(s).type ] = SEARCHED_LIB + { + local search = [ $(s).search ] ; + extra += $(search) ; + } + } + + # It is possible that sources include shared libraries that did not came + # from 'lib' targets, e.g. .so files specified as sources. In this case + # we have to add extra dll-path properties and propagate extra xdll-path + # properties so that application linking to us will get xdll-path to + # those libraries. + local extra-xdll-paths ; + for local s in $(sources) + { + if [ type.is-derived [ $(s).type ] SHARED_LIB ] && ! [ $(s).action ] + { + # Unfortunately, we do not have a good way to find the path to a + # file, so use this nasty approach. + # + # TODO: This needs to be done better. One thing that is really + # broken with this is that it does not work correctly with + # projects having multiple source locations. + local p = [ $(s).project ] ; + local location = [ path.root [ $(s).name ] + [ $(p).get source-location ] ] ; + extra-xdll-paths += [ path.parent $(location) ] ; + } + } + + # Hardcode DLL paths only when linking executables. + # Pros: do not need to relink libraries when installing. + # Cons: "standalone" libraries (plugins, python extensions) can not + # hardcode paths to dependent libraries. + if [ $(property-set).get ] = true + && [ type.is-derived $(self.target-types[1]) EXE ] + { + local xdll-path = [ $(property-set).get ] ; + extra += $(xdll-path) $(extra-xdll-paths) ; + } + + if $(extra) + { + property-set = [ $(property-set).add-raw $(extra) ] ; + } + + local result = [ generator.run $(project) $(name) : $(property-set) + : $(sources) ] ; + + local ur ; + if $(result) + { + ur = [ extra-usage-requirements $(result) : $(property-set) ] ; + ur = [ $(ur).add + [ property-set.create $(extra-xdll-paths) ] ] ; + } + return $(ur) $(result) ; + } + + rule extra-usage-requirements ( created-targets * : property-set ) + { + local result = [ property-set.empty ] ; + local extra ; + + # Add appropricate usage requirements. + local raw = [ $(property-set).raw ] ; + if shared in $(raw) + { + local paths ; + local pwd = [ path.pwd ] ; + for local t in $(created-targets) + { + if [ type.is-derived [ $(t).type ] SHARED_LIB ] + { + paths += [ path.root [ path.make [ $(t).path ] ] $(pwd) ] ; + } + } + extra += $(paths:G=) ; + } + + # We need to pass features that we've got from sources, + # because if a shared library is built, exe using it needs to know paths + # to other shared libraries this one depends on in order to be able to + # find them all at runtime. + + # Just pass all features in property-set, it is theorically possible + # that we will propagate features explicitly specified by + # the user, but then the user is to blaim for using an internal feature. + local values = [ $(property-set).get ] ; + extra += $(values:G=) ; + + if $(extra) + { + result = [ property-set.create $(extra) ] ; + } + return $(result) ; + } + + rule generated-targets ( sources + : property-set : project name ? ) + { + local sources2 ; # Sources to pass to inherited rule. + local properties2 ; # Properties to pass to inherited rule. + local libraries ; # Library sources. + + # Searched libraries are not passed as arguments to the linker but via + # some option. So, we pass them to the action using a property. + properties2 = [ $(property-set).raw ] ; + local fsa ; + local fst ; + for local s in $(sources) + { + if [ type.is-derived [ $(s).type ] SEARCHED_LIB ] + { + local name = [ $(s).name ] ; + if [ $(s).shared ] + { + fsa += $(name) ; + } + else + { + fst += $(name) ; + } + } + else + { + sources2 += $(s) ; + } + } + properties2 += $(fsa:J=&&) + $(fst:J=&&) ; + + return [ generator.generated-targets $(sources2) + : [ property-set.create $(properties2) ] : $(project) $(name) ] ; + } +} + + +rule register-linker ( id composing ? : source-types + : target-types + + : requirements * ) +{ + generators.register [ new linking-generator $(id) $(composing) + : $(source-types) : $(target-types) : $(requirements) ] ; +} + + +# The generator class for handling STATIC_LIB creation. +# +class archive-generator : generator +{ + import property-set ; + + rule __init__ ( id composing ? : source-types + : target-types + + : requirements * ) + { + composing ?= true ; + generator.__init__ $(id) $(composing) : $(source-types) + : $(target-types) : $(requirements) ; + } + + rule run ( project name ? : property-set : sources + ) + { + sources += [ $(property-set).get ] ; + + local result = [ generator.run $(project) $(name) : $(property-set) + : $(sources) ] ; + + # For static linking, if we get a library in source, we can not directly + # link to it so we need to cause our dependencies to link to that + # library. There are two approaches: + # - adding the library to the list of returned targets. + # - using the usage requirements. + # The problem with the first is: + # + # lib a1 : : liba1.a ; + # lib a2 : a2.cpp a1 : static ; + # install dist : a2 ; + # + # here we will try to install 'a1', even though it is not necessary in + # the general case. With the second approach, even indirect dependants + # will link to the library, but it should not cause any harm. So, return + # all LIB sources together with created targets, so that dependants link + # to them. + local usage-requirements ; + if [ $(property-set).get ] = static + { + for local t in $(sources) + { + if [ type.is-derived [ $(t).type ] LIB ] + { + usage-requirements += $(t) ; + } + } + } + + usage-requirements = [ property-set.create $(usage-requirements) ] ; + + return $(usage-requirements) $(result) ; + } +} + + +rule register-archiver ( id composing ? : source-types + : target-types + + : requirements * ) +{ + generators.register [ new archive-generator $(id) $(composing) + : $(source-types) : $(target-types) : $(requirements) ] ; +} + + +# Generator that accepts everything and produces nothing. Useful as a general +# fallback for toolset-specific actions like PCH generation. +# +class dummy-generator : generator +{ + import property-set ; + + rule run ( project name ? : property-set : sources + ) + { + return [ property-set.empty ] ; + } +} + +IMPORT $(__name__) : register-linker register-archiver + : : generators.register-linker generators.register-archiver ; diff --git a/mosesdecoder/jam-files/boost-build/tools/cast.jam b/mosesdecoder/jam-files/boost-build/tools/cast.jam new file mode 100644 index 0000000000000000000000000000000000000000..211ce63296419d5951bb6cd5f4ddd8ceffa557e6 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/cast.jam @@ -0,0 +1,91 @@ +# Copyright 2005 Vladimir Prus. +# 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) + +# Defines main target 'cast', used to change type for target. For example, in Qt +# library one wants two kinds of CPP files -- those that just compiled and those +# that are passed via the MOC tool. +# +# This is done with: +# +# exe main : main.cpp [ cast _ moccable-cpp : widget.cpp ] ; +# +# Boost.Build will assign target type CPP to both main.cpp and widget.cpp. Then, +# the cast rule will change target type of widget.cpp to MOCCABLE-CPP, and Qt +# support will run the MOC tool as part of the build process. +# +# At the moment, the 'cast' rule only works for non-derived (source) targets. +# +# TODO: The following comment is unclear or incorrect. Clean it up. +# > Another solution would be to add a separate main target 'moc-them' that +# > would moc all the passed sources, no matter what their type is, but I prefer +# > cast, as defining a new target type + generator for that type is somewhat +# > simpler than defining a main target rule. + +import "class" : new ; +import errors ; +import project ; +import property-set ; +import targets ; +import type ; + + +class cast-target-class : typed-target +{ + import type ; + + rule __init__ ( name : project : type : sources * : requirements * : + default-build * : usage-requirements * ) + { + typed-target.__init__ $(name) : $(project) : $(type) : $(sources) : + $(requirements) : $(default-build) : $(usage-requirements) ; + } + + rule construct ( name : source-targets * : property-set ) + { + local result ; + for local s in $(source-targets) + { + if ! [ class.is-a $(s) : file-target ] + { + import errors ; + errors.user-error Source to the 'cast' rule is not a file! ; + } + if [ $(s).action ] + { + import errors ; + errors.user-error Only non-derived target are allowed for + 'cast'. : when building [ full-name ] ; + } + local r = [ $(s).clone-with-different-type $(self.type) ] ; + result += [ virtual-target.register $(r) ] ; + } + return [ property-set.empty ] $(result) ; + } +} + + +rule cast ( name type : sources * : requirements * : default-build * : + usage-requirements * ) +{ + local project = [ project.current ] ; + + local real-type = [ type.type-from-rule-name $(type) ] ; + if ! $(real-type) + { + errors.user-error No type corresponds to the main target rule name + '$(type)' : "Hint: try a lowercase name" ; + } + + targets.main-target-alternative [ new cast-target-class $(name) : $(project) + : $(real-type) + : [ targets.main-target-sources $(sources) : $(name) ] + : [ targets.main-target-requirements $(requirements) : $(project) ] + : [ targets.main-target-default-build $(default-build) : $(project) ] + : [ targets.main-target-usage-requirements $(usage-requirements) : + $(project) ] ] ; +} + + +IMPORT $(__name__) : cast : : cast ; diff --git a/mosesdecoder/jam-files/boost-build/tools/common.jam b/mosesdecoder/jam-files/boost-build/tools/common.jam new file mode 100644 index 0000000000000000000000000000000000000000..53e91b428fd7b5c942f7d1d433c2702fba3604f8 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/common.jam @@ -0,0 +1,983 @@ +# Copyright 2003, 2005 Dave Abrahams +# Copyright 2005, 2006 Rene Rivera +# Copyright 2005 Toon Knapen +# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus +# 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) + +# Provides actions common to all toolsets, such as creating directories and +# removing files. + +import os ; +import modules ; +import utility ; +import print ; +import type ; +import feature ; +import errors ; +import path ; +import sequence ; +import toolset ; +import virtual-target ; + +if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] +{ + .debug-configuration = true ; +} +if [ MATCH (--show-configuration) : [ modules.peek : ARGV ] ] +{ + .show-configuration = true ; +} + +# Configurations +# +# The following class helps to manage toolset configurations. Each configuration +# has a unique ID and one or more parameters. A typical example of a unique ID +# is a condition generated by 'common.check-init-parameters' rule. Other kinds +# of IDs can be used. Parameters may include any details about the configuration +# like 'command', 'path', etc. +# +# A toolset configuration may be in one of the following states: +# +# - registered +# Configuration has been registered (e.g. explicitly or by auto-detection +# code) but has not yet been marked as used, i.e. 'toolset.using' rule has +# not yet been called for it. +# - used +# Once called 'toolset.using' rule marks the configuration as 'used'. +# +# The main difference between the states above is that while a configuration is +# 'registered' its options can be freely changed. This is useful in particular +# for autodetection code - all detected configurations may be safely overwritten +# by user code. + +class configurations +{ + import errors ; + + rule __init__ ( ) + { + } + + # Registers a configuration. + # + # Returns 'true' if the configuration has been added and an empty value if + # it already exists. Reports an error if the configuration is 'used'. + # + rule register ( id ) + { + if $(id) in $(self.used) + { + errors.error "common: the configuration '$(id)' is in use" ; + } + + local retval ; + + if ! $(id) in $(self.all) + { + self.all += $(id) ; + + # Indicate that a new configuration has been added. + retval = true ; + } + + return $(retval) ; + } + + # Mark a configuration as 'used'. + # + # Returns 'true' if the state of the configuration has been changed to + # 'used' and an empty value if it the state has not been changed. Reports an + # error if the configuration is not known. + # + rule use ( id ) + { + if ! $(id) in $(self.all) + { + errors.error "common: the configuration '$(id)' is not known" ; + } + + local retval ; + + if ! $(id) in $(self.used) + { + self.used += $(id) ; + + # Indicate that the configuration has been marked as 'used'. + retval = true ; + } + + return $(retval) ; + } + + # Return all registered configurations. + # + rule all ( ) + { + return $(self.all) ; + } + + # Return all used configurations. + # + rule used ( ) + { + return $(self.used) ; + } + + # Returns the value of a configuration parameter. + # + rule get ( id : param ) + { + return $(self.$(param).$(id)) ; + } + + # Sets the value of a configuration parameter. + # + rule set ( id : param : value * ) + { + self.$(param).$(id) = $(value) ; + } +} + + +# The rule for checking toolset parameters. Trailing parameters should all be +# parameter name/value pairs. The rule will check that each parameter either has +# a value in each invocation or has no value in each invocation. Also, the rule +# will check that the combination of all parameter values is unique in all +# invocations. +# +# Each parameter name corresponds to a subfeature. This rule will declare a +# subfeature the first time a non-empty parameter value is passed and will +# extend it with all the values. +# +# The return value from this rule is a condition to be used for flags settings. +# +rule check-init-parameters ( toolset requirement * : * ) +{ + local sig = $(toolset) ; + local condition = $(toolset) ; + local subcondition ; + for local index in 2 3 4 5 6 7 8 9 + { + local name = $($(index)[1]) ; + local value = $($(index)[2]) ; + + if $(value)-is-not-empty + { + condition = $(condition)-$(value) ; + if $(.had-unspecified-value.$(toolset).$(name)) + { + errors.user-error + "$(toolset) initialization: parameter '$(name)'" + "inconsistent" : "no value was specified in earlier" + "initialization" : "an explicit value is specified now" ; + } + # The below logic is for intel compiler. It calls this rule with + # 'intel-linux' and 'intel-win' as toolset, so we need to get the + # base part of toolset name. We can not pass 'intel' as toolset + # because in that case it will be impossible to register versionless + # intel-linux and intel-win toolsets of a specific version. + local t = $(toolset) ; + local m = [ MATCH ([^-]*)- : $(toolset) ] ; + if $(m) + { + t = $(m[1]) ; + } + if ! $(.had-value.$(toolset).$(name)) + { + if ! $(.declared-subfeature.$(t).$(name)) + { + feature.subfeature toolset $(t) : $(name) : : propagated ; + .declared-subfeature.$(t).$(name) = true ; + } + .had-value.$(toolset).$(name) = true ; + } + feature.extend-subfeature toolset $(t) : $(name) : $(value) ; + subcondition += $(value) ; + } + else + { + if $(.had-value.$(toolset).$(name)) + { + errors.user-error + "$(toolset) initialization: parameter '$(name)'" + "inconsistent" : "an explicit value was specified in an" + "earlier initialization" : "no value is specified now" ; + } + .had-unspecified-value.$(toolset).$(name) = true ; + } + sig = $(sig)$(value:E="")- ; + } + if $(sig) in $(.all-signatures) + { + local message = + "duplicate initialization of $(toolset) with the following parameters: " ; + for local index in 2 3 4 5 6 7 8 9 + { + local p = $($(index)) ; + if $(p) + { + message += "$(p[1]) = $(p[2]:E=)" ; + } + } + message += "previous initialization at $(.init-loc.$(sig))" ; + errors.user-error + $(message[1]) : $(message[2]) : $(message[3]) : $(message[4]) : + $(message[5]) : $(message[6]) : $(message[7]) : $(message[8]) ; + } + .all-signatures += $(sig) ; + .init-loc.$(sig) = [ errors.nearest-user-location ] ; + + # If we have a requirement, this version should only be applied under that + # condition. To accomplish this we add a toolset requirement that imposes + # the toolset subcondition, which encodes the version. + if $(requirement) + { + local r = $(toolset) $(requirement) ; + r = $(r:J=,) ; + toolset.add-requirements $(r):$(subcondition) ; + } + + # We add the requirements, if any, to the condition to scope the toolset + # variables and options to this specific version. + condition += $(requirement) ; + + if $(.show-configuration) + { + ECHO notice: $(condition) ; + } + return $(condition:J=/) ; +} + + +# A helper rule to get the command to invoke some tool. If +# 'user-provided-command' is not given, tries to find binary named 'tool' in +# PATH and in the passed 'additional-path'. Otherwise, verifies that the first +# element of 'user-provided-command' is an existing program. +# +# This rule returns the command to be used when invoking the tool. If we can not +# find the tool, a warning is issued. If 'path-last' is specified, PATH is +# checked after 'additional-paths' when searching for 'tool'. +# +rule get-invocation-command-nodefault ( toolset : tool : + user-provided-command * : additional-paths * : path-last ? ) +{ + local command ; + if ! $(user-provided-command) + { + command = [ find-tool $(tool) : $(additional-paths) : $(path-last) ] ; + if ! $(command) && $(.debug-configuration) + { + ECHO "warning: toolset $(toolset) initialization: can not find tool $(tool)" ; + ECHO "warning: initialized from" [ errors.nearest-user-location ] ; + } + } + else + { + command = [ check-tool $(user-provided-command) ] ; + if ! $(command) && $(.debug-configuration) + { + ECHO "warning: toolset $(toolset) initialization: " ; + ECHO "warning: can not find user-provided command " '$(user-provided-command)' ; + ECHO "warning: initialized from" [ errors.nearest-user-location ] ; + } + } + + return $(command) ; +} + + +# Same as get-invocation-command-nodefault, except that if no tool is found, +# returns either the user-provided-command, if present, or the 'tool' parameter. +# +rule get-invocation-command ( toolset : tool : user-provided-command * : + additional-paths * : path-last ? ) +{ + local result = [ get-invocation-command-nodefault $(toolset) : $(tool) : + $(user-provided-command) : $(additional-paths) : $(path-last) ] ; + + if ! $(result) + { + if $(user-provided-command) + { + result = $(user-provided-command) ; + } + else + { + result = $(tool) ; + } + } + return $(result) ; +} + + +# Given an invocation command return the absolute path to the command. This +# works even if command has no path element and was found on the PATH. +# +rule get-absolute-tool-path ( command ) +{ + if $(command:D) + { + return $(command:D) ; + } + else + { + local m = [ GLOB [ modules.peek : PATH Path path ] : $(command) $(command).exe ] ; + return $(m[1]:D) ; + } +} + + +# Attempts to find tool (binary) named 'name' in PATH and in 'additional-paths'. +# If found in PATH, returns 'name' and if found in additional paths, returns +# absolute name. If the tool is found in several directories, returns the +# first path found. Otherwise, returns an empty string. If 'path-last' is +# specified, PATH is searched after 'additional-paths'. +# +rule find-tool ( name : additional-paths * : path-last ? ) +{ + local path = [ path.programs-path ] ; + local match = [ path.glob $(path) : $(name) $(name).exe ] ; + local additional-match = [ path.glob $(additional-paths) : $(name) $(name).exe ] ; + + local result ; + if $(path-last) + { + result = $(additional-match) ; + if ! $(result) && $(match) + { + result = $(name) ; + } + } + else + { + if $(match) + { + result = $(name) ; + } + else + { + result = $(additional-match) ; + } + } + if $(result) + { + return [ path.native $(result[1]) ] ; + } +} + + +# Checks if 'command' can be found either in path or is a full name to an +# existing file. +# +local rule check-tool-aux ( command ) +{ + if $(command:D) + { + if [ path.exists $(command) ] + # Both NT and Cygwin will run .exe files by their unqualified names. + || ( [ os.on-windows ] && [ path.exists $(command).exe ] ) + # Only NT will run .bat & .cmd files by their unqualified names. + || ( ( [ os.name ] = NT ) && ( [ path.exists $(command).bat ] || + [ path.exists $(command).cmd ] ) ) + { + return $(command) ; + } + } + else + { + if [ GLOB [ modules.peek : PATH Path path ] : $(command) ] + { + return $(command) ; + } + } +} + + +# Checks that a tool can be invoked by 'command'. If command is not an absolute +# path, checks if it can be found in 'path'. If comand is an absolute path, +# check that it exists. Returns 'command' if ok or empty string otherwise. +# +local rule check-tool ( xcommand + ) +{ + if [ check-tool-aux $(xcommand[1]) ] || + [ check-tool-aux $(xcommand[-1]) ] + { + return $(xcommand) ; + } +} + + +# Handle common options for toolset, specifically sets the following flag +# variables: +# - CONFIG_COMMAND to $(command) +# - OPTIONS for compile to the value of in $(options) +# - OPTIONS for compile.c to the value of in $(options) +# - OPTIONS for compile.c++ to the value of in $(options) +# - OPTIONS for compile.fortran to the value of in $(options) +# - OPTIONS for link to the value of in $(options) +# +rule handle-options ( toolset : condition * : command * : options * ) +{ + if $(.debug-configuration) + { + ECHO "notice: will use '$(command)' for $(toolset), condition $(condition:E=(empty))" ; + } + + # The last parameter ('unchecked') says it is OK to set flags for another + # module. + toolset.flags $(toolset) CONFIG_COMMAND $(condition) : $(command) + : unchecked ; + + toolset.flags $(toolset).compile OPTIONS $(condition) : + [ feature.get-values : $(options) ] : unchecked ; + + toolset.flags $(toolset).compile.c OPTIONS $(condition) : + [ feature.get-values : $(options) ] : unchecked ; + + toolset.flags $(toolset).compile.c++ OPTIONS $(condition) : + [ feature.get-values : $(options) ] : unchecked ; + + toolset.flags $(toolset).compile.fortran OPTIONS $(condition) : + [ feature.get-values : $(options) ] : unchecked ; + + toolset.flags $(toolset).link OPTIONS $(condition) : + [ feature.get-values : $(options) ] : unchecked ; +} + + +# Returns the location of the "program files" directory on a Windows platform. +# +rule get-program-files-dir ( ) +{ + local ProgramFiles = [ modules.peek : ProgramFiles ] ; + if $(ProgramFiles) + { + ProgramFiles = "$(ProgramFiles:J= )" ; + } + else + { + ProgramFiles = "c:\\Program Files" ; + } + return $(ProgramFiles) ; +} + + +if [ os.name ] = NT +{ + RM = del /f /q ; + CP = copy /b ; + IGNORE = "2>nul >nul & setlocal" ; + LN ?= $(CP) ; + # Ugly hack to convince copy to set the timestamp of the + # destination to the current time by concatenating the + # source with a nonexistent file. Note that this requires + # /b (binary) as the default when concatenating files is /a (ascii). + WINDOWS-CP-HACK = "+ this-file-does-not-exist-A698EE7806899E69" ; +} +else +{ + RM = rm -f ; + CP = cp ; + LN = ln ; +} + + +rule rm-command ( ) +{ + return $(RM) ; +} + + +rule copy-command ( ) +{ + return $(CP) ; +} + + +if "\n" = "n" +{ + # Escape characters are not supported. Use ugly hacks that won't work, + # see below. + nl = " +" ; + q = "" ; +} +else +{ + nl = "\n" ; + q = "\"" ; +} + +# Returns the command needed to set an environment variable on the current +# platform. The variable setting persists through all following commands and is +# visible in the environment seen by subsequently executed commands. In other +# words, on Unix systems, the variable is exported, which is consistent with the +# only possible behavior on Windows systems. +# +rule variable-setting-command ( variable : value ) +{ + if [ os.name ] = NT + { + return "set $(variable)=$(value)$(nl)" ; + } + else + { + # If we don't have escape characters support in bjam, the below blows + # up on CYGWIN, since the $(nl) variable holds a Windows new-line \r\n + # sequence that messes up the executed export command which then reports + # that the passed variable name is incorrect. + # But we have a check for cygwin in kernel/bootstrap.jam already. + return "$(variable)=$(q)$(value)$(q)$(nl)export $(variable)$(nl)" ; + } +} + + +# Returns a command to sets a named shell path variable to the given NATIVE +# paths on the current platform. +# +rule path-variable-setting-command ( variable : paths * ) +{ + local sep = [ os.path-separator ] ; + return [ variable-setting-command $(variable) : $(paths:J=$(sep)) ] ; +} + + +# Returns a command that prepends the given paths to the named path variable on +# the current platform. +# +rule prepend-path-variable-command ( variable : paths * ) +{ + return [ path-variable-setting-command $(variable) + : $(paths) [ os.expand-variable $(variable) ] ] ; +} + + +# Return a command which can create a file. If 'r' is result of invocation, then +# 'r foobar' will create foobar with unspecified content. What happens if file +# already exists is unspecified. +# +rule file-creation-command ( ) +{ + if [ os.name ] = NT + { + # A few alternative implementations on Windows: + # + # 'type NUL >> ' + # That would construct an empty file instead of a file containing + # a space and an end-of-line marker but it would also not change + # the target's timestamp in case the file already exists. + # + # 'type NUL > ' + # That would construct an empty file instead of a file containing + # a space and an end-of-line marker but it would also destroy an + # already existing file by overwriting it with an empty one. + # + # I guess the best solution would be to allow Boost Jam to define + # built-in functions such as 'create a file', 'touch a file' or 'copy a + # file' which could be used from inside action code. That would allow + # completely portable operations without this kind of kludge. + # (22.02.2009.) (Jurko) + return "echo. > " ; + } + else + { + return "touch " ; + } +} + + +# Returns a command that may be used for 'touching' files. It is not a real +# 'touch' command on NT because it adds an empty line at the end of file but it +# works with source files. +# +rule file-touch-command ( ) +{ + if [ os.name ] = NT + { + return "echo. >> " ; + } + else + { + return "touch " ; + } +} + + +rule MkDir +{ + # If dir exists, do not update it. Do this even for $(DOT). + NOUPDATE $(<) ; + + if $(<) != $(DOT) && ! $($(<)-mkdir) + { + # Cheesy gate to prevent multiple invocations on same dir. + $(<)-mkdir = true ; + + # Schedule the mkdir build action. + common.mkdir $(<) ; + + # Prepare a Jam 'dirs' target that can be used to make the build only + # construct all the target directories. + DEPENDS dirs : $(<) ; + + # Recursively create parent directories. $(<:P) = $(<)'s parent & we + # recurse until root. + + local s = $(<:P) ; + if [ os.name ] = NT + { + switch $(s) + { + case *: : s = ; + case *:\\ : s = ; + } + } + + if $(s) + { + if $(s) != $(<) + { + DEPENDS $(<) : $(s) ; + MkDir $(s) ; + } + else + { + NOTFILE $(s) ; + } + } + } +} + + +#actions MkDir1 +#{ +# mkdir "$(<)" +#} + +# The following quick-fix actions should be replaced using the original MkDir1 +# action once Boost Jam gets updated to correctly detect different paths leading +# up to the same filesystem target and triggers their build action only once. +# (todo) (04.07.2008.) (Jurko) + +if [ os.name ] = NT +{ + actions mkdir + { + if not exist "$(<)\\" mkdir "$(<)" + } +} +else +{ + actions mkdir + { + mkdir -p "$(<)" + } +} + +actions piecemeal together existing Clean +{ + $(RM) "$(>)" +} + + +rule copy +{ +} + + +actions copy +{ + $(CP) "$(>)" $(WINDOWS-CP-HACK) "$(<)" +} + + +rule RmTemps +{ +} + + +actions quietly updated piecemeal together RmTemps +{ + $(RM) "$(>)" $(IGNORE) +} + + +actions hard-link +{ + $(RM) "$(<)" 2$(NULL_OUT) $(NULL_OUT) + $(LN) "$(>)" "$(<)" $(NULL_OUT) +} + + +# Given a target, as given to a custom tag rule, returns a string formatted +# according to the passed format. Format is a list of properties that is +# represented in the result. For each element of format the corresponding target +# information is obtained and added to the result string. For all, but the +# literal, the format value is taken as the as string to prepend to the output +# to join the item to the rest of the result. If not given "-" is used as a +# joiner. +# +# The format options can be: +# +# [joiner] +# :: The basename of the target name. +# [joiner] +# :: The abbreviated toolset tag being used to build the target. +# [joiner] +# :: Indication of a multi-threaded build. +# [joiner] +# :: Collective tag of the build runtime. +# [joiner] +# :: Short version tag taken from the given "version-feature" in the +# build properties. Or if not present, the literal value as the +# version number. +# [joiner] +# :: Direct lookup of the given property-name value in the build +# properties. /property-name/ is a regular expression. E.g. +# will match every toolset. +# /otherwise/ +# :: The literal value of the format argument. +# +# For example this format: +# +# boost_ +# +# Might return: +# +# boost_thread-vc80-mt-gd-1_33.dll, or +# boost_regex-vc80-gd-1_33.dll +# +# The returned name also has the target type specific prefix and suffix which +# puts it in a ready form to use as the value from a custom tag rule. +# +rule format-name ( format * : name : type ? : property-set ) +{ + local result = "" ; + for local f in $(format) + { + switch $(f:G) + { + case : + result += $(name:B) ; + + case : + result += [ join-tag $(f:G=) : [ toolset-tag $(name) : $(type) : + $(property-set) ] ] ; + + case : + result += [ join-tag $(f:G=) : [ threading-tag $(name) : $(type) + : $(property-set) ] ] ; + + case : + result += [ join-tag $(f:G=) : [ runtime-tag $(name) : $(type) : + $(property-set) ] ] ; + + case : + result += [ join-tag $(f:G=) : [ qt-tag $(name) : $(type) : + $(property-set) ] ] ; + + case : + result += [ join-tag $(f:G=) : [ address-model-tag $(name) : $(type) : + $(property-set) ] ] ; + + case : + local key = [ MATCH : $(f:G) ] ; + local version = [ $(property-set).get <$(key)> ] ; + version ?= $(key) ; + version = [ MATCH "^([^.]+)[.]([^.]+)[.]?([^.]*)" : $(version) ] ; + result += [ join-tag $(f:G=) : $(version[1])_$(version[2]) ] ; + + case : + local key = [ MATCH : $(f:G) ] ; + local p0 = [ MATCH <($(key))> : [ $(property-set).raw ] ] ; + if $(p0) + { + local p = [ $(property-set).get <$(p0)> ] ; + if $(p) + { + result += [ join-tag $(f:G=) : $(p) ] ; + } + } + + case * : + result += $(f:G=) ; + } + } + result = [ virtual-target.add-prefix-and-suffix $(result:J=) : $(type) : + $(property-set) ] ; + return $(result) ; +} + + +local rule join-tag ( joiner ? : tag ? ) +{ + if ! $(joiner) { joiner = - ; } + return $(joiner)$(tag) ; +} + + +local rule toolset-tag ( name : type ? : property-set ) +{ + local tag = ; + + local properties = [ $(property-set).raw ] ; + switch [ $(property-set).get ] + { + case borland* : tag += bcb ; + case clang* : + { + switch [ $(property-set).get ] + { + case darwin : tag += clang-darwin ; + case linux : tag += clang ; + } + } + case como* : tag += como ; + case cw : tag += cw ; + case darwin* : tag += xgcc ; + case edg* : tag += edg ; + case gcc* : + { + switch [ $(property-set).get ] + { + case *mingw* : tag += mgw ; + case * : tag += gcc ; + } + } + case intel : + if [ $(property-set).get ] = win + { + tag += iw ; + } + else + { + tag += il ; + } + case kcc* : tag += kcc ; + case kylix* : tag += bck ; + #case metrowerks* : tag += cw ; + #case mingw* : tag += mgw ; + case mipspro* : tag += mp ; + case msvc* : tag += vc ; + case qcc* : tag += qcc ; + case sun* : tag += sw ; + case tru64cxx* : tag += tru ; + case vacpp* : tag += xlc ; + } + local version = [ MATCH "([0123456789]+)[.]([0123456789]*)" + : $(properties) ] ; + # For historical reasons, vc6.0 and vc7.0 use different naming. + if $(tag) = vc + { + if $(version[1]) = 6 + { + # Cancel minor version. + version = 6 ; + } + else if $(version[1]) = 7 && $(version[2]) = 0 + { + version = 7 ; + } + } + # On intel, version is not added, because it does not matter and it is the + # version of vc used as backend that matters. Ideally, we should encode the + # backend version but that would break compatibility with V1. + if $(tag) = iw + { + version = ; + } + + # On borland, version is not added for compatibility with V1. + if $(tag) = bcb + { + version = ; + } + + tag += $(version) ; + + return $(tag:J=) ; +} + + +local rule threading-tag ( name : type ? : property-set ) +{ + local tag = ; + local properties = [ $(property-set).raw ] ; + if multi in $(properties) { tag = mt ; } + + return $(tag:J=) ; +} + + +local rule runtime-tag ( name : type ? : property-set ) +{ + local tag = ; + + local properties = [ $(property-set).raw ] ; + if static in $(properties) { tag += s ; } + + # This is an ugly thing. In V1, there is code to automatically detect which + # properties affect a target. So, if does not affect gcc + # toolset, the tag rules will not even see . Similar + # functionality in V2 is not implemented yet, so we just check for toolsets + # known to care about runtime debugging. + if ( msvc in $(properties) ) || + ( stlport in $(properties) ) || + ( win in $(properties) ) + { + if on in $(properties) { tag += g ; } + } + + if on in $(properties) { tag += y ; } + if debug in $(properties) { tag += d ; } + if stlport in $(properties) { tag += p ; } + if hostios in $(properties) { tag += n ; } + + return $(tag:J=) ; +} + +# Create a tag for the Qt library version +# "4.6.0" will result in tag "qt460" +local rule qt-tag ( name : type ? : property-set ) +{ + local properties = [ $(property-set).get ] ; + local version = [ MATCH "([0123456789]+)[.]?([0123456789]*)[.]?([0123456789]*)" + : $(properties) ] ; + local tag = "qt"$(version:J=) ; + return $(tag) ; +} + +# Create a tag for the address-model +# 64 will simply generate "64" +local rule address-model-tag ( name : type ? : property-set ) +{ + local tag = ; + local version = [ $(property-set).get ] ; + return $(version) ; +} + +rule __test__ ( ) +{ + import assert ; + + local save-os = [ modules.peek os : .name ] ; + + modules.poke os : .name : LINUX ; + + assert.result "PATH=\"foo:bar:baz\"\nexport PATH\n" + : path-variable-setting-command PATH : foo bar baz ; + + assert.result "PATH=\"foo:bar:$PATH\"\nexport PATH\n" + : prepend-path-variable-command PATH : foo bar ; + + modules.poke os : .name : NT ; + + assert.result "set PATH=foo;bar;baz\n" + : path-variable-setting-command PATH : foo bar baz ; + + assert.result "set PATH=foo;bar;%PATH%\n" + : prepend-path-variable-command PATH : foo bar ; + + modules.poke os : .name : $(save-os) ; +} diff --git a/mosesdecoder/jam-files/boost-build/tools/como.jam b/mosesdecoder/jam-files/boost-build/tools/como.jam new file mode 100644 index 0000000000000000000000000000000000000000..04a05a94b1274579e303fd884decea8424dc8f20 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/como.jam @@ -0,0 +1,29 @@ +# Copyright Vladimir Prus 2004. +# 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 is a generic 'como' toolset. Depending on the current system, it +# forwards either to 'como-linux' or 'como-win' modules. + +import feature ; +import os ; +import toolset ; + +feature.extend toolset : como ; +feature.subfeature toolset como : platform : : propagated link-incompatible ; + +rule init ( * : * ) +{ + if [ os.name ] = LINUX + { + toolset.using como-linux : + $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + else + { + toolset.using como-win : + $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + + } +} diff --git a/mosesdecoder/jam-files/boost-build/tools/cray.jam b/mosesdecoder/jam-files/boost-build/tools/cray.jam new file mode 100644 index 0000000000000000000000000000000000000000..1d5271e972b0f2afdc77c089a86cd4a90e77e63a --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/cray.jam @@ -0,0 +1,112 @@ +# Copyright 2001 David Abrahams. +# Copyright 2004, 2005 Markus Schoepflin. +# Copyright 2011, John Maddock +# 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) + +# +# Cray C++ Compiler +# See http://docs.cray.com/books/S-2179-50/html-S-2179-50/S-2179-50-toc.html +# + +import feature generators common ; +import toolset : flags ; + +feature.extend toolset : cray ; + +# Inherit from Unix toolset to get library ordering magic. +toolset.inherit cray : unix ; + +generators.override cray.prebuilt : builtin.lib-generator ; +generators.override cray.prebuilt : builtin.prebuilt ; +generators.override cray.searched-lib-generator : searched-lib-generator ; + + +rule init ( version ? : command * : options * ) +{ + local condition = [ common.check-init-parameters cray : version $(version) ] ; + + local command = [ common.get-invocation-command cray : CC : $(command) ] ; + + if $(command) + { + local root = [ common.get-absolute-tool-path $(command[-1]) ] ; + + if $(root) + { + flags cray .root $(condition) : "\"$(root)\"/" ; + } + } + # If we can't find 'CC' anyway, at least show 'CC' in the commands + command ?= CC ; + + common.handle-options cray : $(condition) : $(command) : $(options) ; +} + +generators.register-c-compiler cray.compile.c++ : CPP : OBJ : cray ; +generators.register-c-compiler cray.compile.c : C : OBJ : cray ; + + + +# No static linking as far as I can tell. +# flags cxx LINKFLAGS static : -bstatic ; +flags cray.compile OPTIONS on : -Gn ; +flags cray.link OPTIONS on : -Gn ; + +flags cray.compile OPTIONS off : -O0 ; +flags cray.compile OPTIONS speed : -O3 ; +flags cray.compile OPTIONS space : -O1 ; + +flags cray.compile OPTIONS ; +flags cray.compile.c++ OPTIONS ; +flags cray.compile DEFINES ; +flags cray.compile INCLUDES ; +flags cray.link OPTIONS ; + +flags cray.link LIBPATH ; +flags cray.link LIBRARIES ; +flags cray.link FINDLIBS-ST ; +flags cray.link FINDLIBS-SA ; + +actions link bind LIBRARIES +{ + $(CONFIG_COMMAND) $(OPTIONS) -o "$(<)" -L$(LIBPATH) "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) +} + +# When creating dynamic libraries, we don't want to be warned about unresolved +# symbols, therefore all unresolved symbols are marked as expected by +# '-expect_unresolved *'. This also mirrors the behaviour of the GNU tool +# chain. + +actions link.dll bind LIBRARIES +{ + $(CONFIG_COMMAND) -shared $(OPTIONS) -o "$(<[1])" -L$(LIBPATH) "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) +} + + +# Note: Relaxed ANSI mode (-std) is used for compilation because in strict ANSI +# C89 mode (-std1) the compiler doesn't accept C++ comments in C files. As -std +# is the default, no special flag is needed. +actions compile.c +{ + $(.root:E=)cc -c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)" +} + +# Note: The compiler is forced to compile the files as C++ (-x cxx) because +# otherwise it will silently ignore files with no file extension. +# +# Note: We deliberately don't suppress any warnings on the compiler command +# line, the user can always do this in a customized toolset later on. + +actions compile.c++ +{ + $(CONFIG_COMMAND) -c -h gnu $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)" +} + +# Always create archive from scratch. See the gcc toolet for rationale. +RM = [ common.rm-command ] ; +actions together piecemeal archive +{ + $(RM) "$(<)" + ar rc $(<) $(>) +} diff --git a/mosesdecoder/jam-files/boost-build/tools/cw.jam b/mosesdecoder/jam-files/boost-build/tools/cw.jam new file mode 100644 index 0000000000000000000000000000000000000000..ddcbfeb2b6cf9886061dee056b7db66ec8972aad --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/cw.jam @@ -0,0 +1,246 @@ +# Copyright (C) Reece H Dunn 2004 +# 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) + +# based on the msvc.jam toolset + +import property ; +import generators ; +import os ; +import type ; +import toolset : flags ; +import errors : error ; +import feature : feature get-values ; +import path ; +import sequence : unique ; +import common ; + +if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] +{ + .debug-configuration = true ; +} + +feature.extend toolset : cw ; + +toolset.add-requirements cw,shared:multi ; + +nl = " +" ; + +rule init ( version ? : command * : options * ) +{ + # TODO: fix the $(command[1]) = $(compiler) issue + + setup = [ get-values : $(options) ] ; + setup ?= cwenv.bat ; + compiler = [ get-values : $(options) ] ; + compiler ?= mwcc ; + linker = [ get-values : $(options) ] ; + linker ?= mwld ; + + local condition = [ common.check-init-parameters cw : + version $(version) ] ; + + command = [ common.get-invocation-command cw : mwcc.exe : $(command) : + [ default-paths $(version) ] ] ; + + common.handle-options cw : $(condition) : $(command) : $(options) ; + + local root = [ feature.get-values : $(options) ] ; + if $(command) + { + command = [ common.get-absolute-tool-path $(command[-1]) ] ; + } + local tool-root = $(command) ; + + setup = $(tool-root)\\$(setup) ; + + # map the batch file in setup so it can be executed + + other-tools = $(tool-root:D) ; + root ?= $(other-tools:D) ; + + flags cw.link RUN_PATH $(condition) : + "$(root)\\Win32-x86 Support\\Libraries\\Runtime" + "$(root)\\Win32-x86 Support\\Libraries\\Runtime\\Libs\\MSL_All-DLLs" ; + + setup = "set \"CWFOLDER="$(root)"\" && call \""$(setup)"\" > nul " ; + + if [ os.name ] = NT + { + setup = $(setup)" +" ; + } + else + { + setup = "cmd /S /C "$(setup)" \"&&\" " ; + } + + # bind the setup command to the tool so it can be executed before the + # command + + local prefix = $(setup) ; + + flags cw.compile .CC $(condition) : $(prefix)$(compiler) ; + flags cw.link .LD $(condition) : $(prefix)$(linker) ; + flags cw.archive .LD $(condition) : $(prefix)$(linker) ; + + if [ MATCH ^([89]\\.) : $(version) ] + { + if [ os.name ] = NT + { + # The runtime libraries + flags cw.compile CFLAGS static/single/off : -runtime ss ; + flags cw.compile CFLAGS static/single/on : -runtime ssd ; + + flags cw.compile CFLAGS static/multi/off : -runtime sm ; + flags cw.compile CFLAGS static/multi/on : -runtime smd ; + + flags cw.compile CFLAGS shared/off : -runtime dm ; + flags cw.compile CFLAGS shared/on : -runtime dmd ; + } + } +} + + +local rule default-paths ( version ? ) # FIXME +{ + local possible-paths ; + local ProgramFiles = [ common.get-program-files-dir ] ; + + # TODO: add support for cw8 and cw9 detection + + local version-6-path = $(ProgramFiles)"\\Metrowerks\\CodeWarrior" ; + possible-paths += $(version-6-path) ; + + # perform post-processing + + possible-paths + = $(possible-paths)"\\Other Metrowerks Tools\\Command Line Tools" ; + + possible-paths += [ modules.peek : PATH Path path ] ; + + return $(possible-paths) ; +} + + + + +## declare generators + +generators.register-c-compiler cw.compile.c++ : CPP : OBJ : cw ; +generators.register-c-compiler cw.compile.c : C : OBJ : cw ; + +generators.register-linker cw.link + : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB + : EXE + : cw + ; +generators.register-linker cw.link.dll + : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB + : SHARED_LIB IMPORT_LIB + : cw + ; + +generators.register-archiver cw.archive + : OBJ + : STATIC_LIB + : cw + ; + +## compilation phase + +flags cw WHATEVER ; + +flags cw.compile CFLAGS on : -g ; +flags cw.compile CFLAGS off : -O0 ; +flags cw.compile CFLAGS speed : -O4,p ; +flags cw.compile CFLAGS space : -O4,s ; +flags cw.compile CFLAGS off : -inline off ; +flags cw.compile CFLAGS on : -inline on ; +flags cw.compile CFLAGS full : -inline all ; +flags cw.compile CFLAGS off : -Cpp_exceptions off ; + + +flags cw.compile CFLAGS on : -RTTI on ; +flags cw.compile CFLAGS off : -RTTI off ; + +flags cw.compile CFLAGS on : -w on ; +flags cw.compile CFLAGS off : -w off ; +flags cw.compile CFLAGS all : -w all ; +flags cw.compile CFLAGS on : -w error ; + +flags cw.compile USER_CFLAGS : ; +flags cw.compile.c++ USER_CFLAGS : ; + +flags cw.compile DEFINES ; +flags cw.compile UNDEFS ; +flags cw.compile INCLUDES ; + +actions compile.c +{ + $(.CC) -c -cwd include -lang c -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) -I- -o "$(<)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" +} +actions compile.c++ +{ + $(.CC) -c -cwd include -lang c++ -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) -I- -o "$(<)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" +} + +## linking phase + +flags cw.link DEF_FILE ; + +flags cw LINKFLAGS : -search ; +flags cw LINKFLAGS on : -g ; +flags cw LINKFLAGS console : -subsystem console ; +flags cw LINKFLAGS gui : -subsystem windows ; +flags cw LINKFLAGS wince : -subsystem wince ; +flags cw LINKFLAGS native : -subsystem native ; +flags cw LINKFLAGS auto : -subsystem auto ; + +flags cw LINKFLAGS LIB/static : -library ; + +flags cw.link USER_LINKFLAGS ; +flags cw.link LINKPATH ; + +flags cw.link FINDLIBS_ST ; +flags cw.link FINDLIBS_SA ; +flags cw.link LIBRARY_OPTION cw : "" : unchecked ; +flags cw.link LIBRARIES_MENTIONED_BY_FILE : ; + +rule link.dll ( targets + : sources * : properties * ) +{ + DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ; +} + +if [ os.name ] in NT +{ + actions archive + { + if exist "$(<[1])" DEL "$(<[1])" + $(.LD) -library -o "$(<[1])" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" + } +} +else # cygwin +{ + actions archive + { + _bbv2_out_="$(<)" + if test -f "$_bbv2_out_" ; then + _bbv2_existing_="$(<:W)" + fi + $(.LD) -library -o "$(<:W)" $_bbv2_existing_ @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" + } +} + +actions link bind DEF_FILE +{ + $(.LD) -o "$(<[1]:W)" -L"$(LINKPATH)" $(LINKFLAGS) $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" +} + +actions link.dll bind DEF_FILE +{ + $(.LD) -shared -o "$(<[1]:W)" -implib "$(<[2]:W)" -L"$(LINKPATH)" $(LINKFLAGS) -f"$(DEF_FILE)" $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" +} + diff --git a/mosesdecoder/jam-files/boost-build/tools/darwin.jam b/mosesdecoder/jam-files/boost-build/tools/darwin.jam new file mode 100644 index 0000000000000000000000000000000000000000..dd6eacb114c1a1168981a0884bcb8d065c9ae888 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/darwin.jam @@ -0,0 +1,583 @@ +# Copyright 2003 Christopher Currie +# Copyright 2006 Dave Abrahams +# Copyright 2003, 2004, 2005, 2006 Vladimir Prus +# Copyright 2005-2007 Mat Marcus +# Copyright 2005-2007 Adobe Systems Incorporated +# Copyright 2007-2010 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) + +# Please see http://article.gmane.org/gmane.comp.lib.boost.build/3389/ +# for explanation why it's a separate toolset. + +import feature : feature ; +import toolset : flags ; +import type ; +import common ; +import generators ; +import path : basename ; +import version ; +import property-set ; +import regex ; +import errors ; + +## Use a framework. +feature framework : : free ; + +## The MacOSX version to compile for, which maps to the SDK to use (sysroot). +feature macosx-version : : propagated link-incompatible symmetric optional ; + +## The minimal MacOSX version to target. +feature macosx-version-min : : propagated optional ; + +## A dependency, that is forced to be included in the link. +feature force-load : : free dependency incidental ; + +############################################################################# + +if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] +{ + .debug-configuration = true ; +} + +feature.extend toolset : darwin ; +import gcc ; +toolset.inherit-generators darwin : gcc : gcc.mingw.link gcc.mingw.link.dll ; + +generators.override darwin.prebuilt : builtin.prebuilt ; +generators.override darwin.searched-lib-generator : searched-lib-generator ; + +# Override default do-nothing generators. +generators.override darwin.compile.c.pch : pch.default-c-pch-generator ; +generators.override darwin.compile.c++.pch : pch.default-cpp-pch-generator ; + +type.set-generated-target-suffix PCH : darwin : gch ; + +toolset.inherit-rules darwin : gcc : localize ; +toolset.inherit-flags darwin : gcc + : static + arm/32 + arm/64 + arm/ + x86/32 + x86/64 + x86/ + power/32 + power/64 + power/ ; + +# Options: +# +# PATH +# Platform root path. The common autodetection will set this to +# "/Developer". And when a command is given it will be set to +# the corresponding "*.platform/Developer" directory. +# +rule init ( version ? : command * : options * : requirement * ) +{ + # First time around, figure what is host OSX version + if ! $(.host-osx-version) + { + .host-osx-version = [ MATCH "^([0-9.]+)" + : [ SHELL "/usr/bin/sw_vers -productVersion" ] ] ; + if $(.debug-configuration) + { + ECHO notice: OSX version on this machine is $(.host-osx-version) ; + } + } + + # - The root directory of the tool install. + local root = [ feature.get-values : $(options) ] ; + + # - The bin directory where to find the commands to execute. + local bin ; + + # - The configured compile driver command. + local command = [ common.get-invocation-command darwin : g++ : $(command) ] ; + + # The version as reported by the compiler + local real-version ; + + # - Autodetect the root and bin dir if not given. + if $(command) + { + bin ?= [ common.get-absolute-tool-path $(command[1]) ] ; + if $(bin) = "/usr/bin" + { + root ?= /Developer ; + } + else + { + local r = $(bin:D) ; + r = $(r:D) ; + root ?= $(r) ; + } + } + + # - Autodetect the version if not given. + if $(command) + { + # - The 'command' variable can have multiple elements. When calling + # the SHELL builtin we need a single string. + local command-string = $(command:J=" ") ; + real-version = [ MATCH "^([0-9.]+)" + : [ SHELL "$(command-string) -dumpversion" ] ] ; + version ?= $(real-version) ; + } + + .real-version.$(version) = $(real-version) ; + + # - Define the condition for this toolset instance. + local condition = + [ common.check-init-parameters darwin $(requirement) : version $(version) ] ; + + # - Set the toolset generic common options. + common.handle-options darwin : $(condition) : $(command) : $(options) ; + + # - GCC 4.0 and higher in Darwin does not have -fcoalesce-templates. + if $(real-version) < "4.0.0" + { + flags darwin.compile.c++ OPTIONS $(condition) : -fcoalesce-templates ; + } + # - GCC 4.2 and higher in Darwin does not have -Wno-long-double. + if $(real-version) < "4.2.0" + { + flags darwin.compile OPTIONS $(condition) : -Wno-long-double ; + } + + # - Set the link flags common with the GCC toolset. + gcc.init-link-flags darwin darwin $(condition) ; + + # - The symbol strip program. + local strip ; + if in $(options) + { + # We can turn off strip by specifying it as empty. In which + # case we switch to using the linker to do the strip. + flags darwin.link.dll OPTIONS + $(condition)/LIB/shared/32/on : -Wl,-x ; + flags darwin.link.dll OPTIONS + $(condition)/LIB/shared//on : -Wl,-x ; + flags darwin.link OPTIONS + $(condition)/EXE/32/on : -s ; + flags darwin.link OPTIONS + $(condition)/EXE//on : -s ; + } + else + { + # Otherwise we need to find a strip program to use. And hence + # also tell the link action that we need to use a strip + # post-process. + flags darwin.link NEED_STRIP $(condition)/on : "" ; + strip = + [ common.get-invocation-command darwin + : strip : [ feature.get-values : $(options) ] : $(bin) : search-path ] ; + flags darwin.link .STRIP $(condition) : $(strip[1]) ; + if $(.debug-configuration) + { + ECHO notice: using strip for $(condition) at $(strip[1]) ; + } + } + + # - The archive builder (libtool is the default as creating + # archives in darwin is complicated. + local archiver = + [ common.get-invocation-command darwin + : libtool : [ feature.get-values : $(options) ] : $(bin) : search-path ] ; + flags darwin.archive .LIBTOOL $(condition) : $(archiver[1]) ; + if $(.debug-configuration) + { + ECHO notice: using archiver for $(condition) at $(archiver[1]) ; + } + + # - Initialize the SDKs available in the root for this tool. + local sdks = [ init-available-sdk-versions $(condition) : $(root) ] ; + + #~ ECHO --- ; + #~ ECHO --- bin :: $(bin) ; + #~ ECHO --- root :: $(root) ; + #~ ECHO --- version :: $(version) ; + #~ ECHO --- condition :: $(condition) ; + #~ ECHO --- strip :: $(strip) ; + #~ ECHO --- archiver :: $(archiver) ; + #~ ECHO --- sdks :: $(sdks) ; + #~ ECHO --- ; + #~ EXIT ; +} + +# Add and set options for a discovered SDK version. +local rule init-sdk ( condition * : root ? : version + : version-feature ? ) +{ + local rule version-to-feature ( version + ) + { + switch $(version[1]) + { + case iphone* : + { + return $(version[1])-$(version[2-]:J=.) ; + } + case mac* : + { + return $(version[2-]:J=.) ; + } + case * : + { + return $(version:J=.) ; + } + } + } + + if $(version-feature) + { + if $(.debug-configuration) + { + ECHO notice: available sdk for $(condition)/$(version-feature) at $(root) ; + } + + # Add the version to the features for specifying them. + if ! $(version-feature) in [ feature.values macosx-version ] + { + feature.extend macosx-version : $(version-feature) ; + } + if ! $(version-feature) in [ feature.values macosx-version-min ] + { + feature.extend macosx-version-min : $(version-feature) ; + } + + # Set the flags the version needs to compile with, first + # generic options. + flags darwin.compile OPTIONS $(condition)/$(version-feature) + : -isysroot $(root) ; + flags darwin.link OPTIONS $(condition)/$(version-feature) + : -isysroot $(root) ; + + # Then device variation options. + switch $(version[1]) + { + case iphonesim* : + { + local N = $(version[2]) ; + if ! $(version[3]) { N += 00 ; } + else if [ regex.match (..) : $(version[3]) ] { N += $(version[3]) ; } + else { N += 0$(version[3]) ; } + if ! $(version[4]) { N += 00 ; } + else if [ regex.match (..) : $(version[4]) ] { N += $(version[4]) ; } + else { N += 0$(version[4]) ; } + N = $(N:J=) ; + flags darwin.compile OPTIONS $(version-feature) + : -D__IPHONE_OS_VERSION_MIN_REQUIRED=$(N) ; + flags darwin.link OPTIONS $(version-feature) + : -D__IPHONE_OS_VERSION_MIN_REQUIRED=$(N) ; + } + + case iphone* : + { + flags darwin.compile OPTIONS $(version-feature) + : -miphoneos-version-min=$(version[2-]:J=.) ; + flags darwin.link OPTIONS $(version-feature) + : -miphoneos-version-min=$(version[2-]:J=.) ; + } + + case mac* : + { + flags darwin.compile OPTIONS $(version-feature) + : -mmacosx-version-min=$(version[2-]:J=.) ; + flags darwin.link OPTIONS $(version-feature) + : -mmacosx-version-min=$(version[2-]:J=.) ; + } + } + + if $(version[3]) > 0 + { + # We have a minor version of an SDK. We want to set up + # previous minor versions, plus the current minor version. + # So we recurse to set up the previous minor versions, up to + # the current version. + local minor-minus-1 = [ CALC $(version[3]) - 1 ] ; + return + [ init-sdk $(condition) : $(root) + : $(version[1-2]) $(minor-minus-1) : [ version-to-feature $(version[1-2]) $(minor-minus-1) ] ] + $(version-feature) ; + } + else + { + return $(version-feature) ; + } + } + else if $(version[4]) + { + # We have a patch version of an SDK. We want to set up + # both the specific patch version, and the minor version. + # So we recurse to set up the patch version. Plus the minor version. + return + [ init-sdk $(condition) : $(root) + : $(version[1-3]) : [ version-to-feature $(version[1-3]) ] ] + [ init-sdk $(condition) : $(root) + : $(version) : [ version-to-feature $(version) ] ] ; + } + else + { + # Yes, this is intentionally recursive. + return + [ init-sdk $(condition) : $(root) + : $(version) : [ version-to-feature $(version) ] ] ; + } +} + +# Determine the MacOSX SDK versions installed and their locations. +local rule init-available-sdk-versions ( condition * : root ? ) +{ + root ?= /Developer ; + local sdks-root = $(root)/SDKs ; + local sdks = [ GLOB $(sdks-root) : MacOSX*.sdk iPhoneOS*.sdk iPhoneSimulator*.sdk ] ; + local result ; + for local sdk in $(sdks) + { + local sdk-match = [ MATCH ([^0-9]+)([0-9]+)[.]([0-9x]+)[.]?([0-9x]+)? : $(sdk:D=) ] ; + local sdk-platform = $(sdk-match[1]:L) ; + local sdk-version = $(sdk-match[2-]) ; + if $(sdk-version) + { + switch $(sdk-platform) + { + case macosx : + { + sdk-version = mac $(sdk-version) ; + } + case iphoneos : + { + sdk-version = iphone $(sdk-version) ; + } + case iphonesimulator : + { + sdk-version = iphonesim $(sdk-version) ; + } + case * : + { + sdk-version = $(sdk-version:J=-) ; + } + } + result += [ init-sdk $(condition) : $(sdk) : $(sdk-version) ] ; + } + } + return $(result) ; +} + +# Generic options. +flags darwin.compile OPTIONS ; + +# The following adds objective-c support to darwin. +# Thanks to http://thread.gmane.org/gmane.comp.lib.boost.build/13759 + +generators.register-c-compiler darwin.compile.m : OBJECTIVE_C : OBJ : darwin ; +generators.register-c-compiler darwin.compile.mm : OBJECTIVE_CPP : OBJ : darwin ; + +rule setup-address-model ( targets * : sources * : properties * ) +{ + local ps = [ property-set.create $(properties) ] ; + local arch = [ $(ps).get ] ; + local address-model = [ $(ps).get ] ; + local osx-version = [ $(ps).get ] ; + local gcc-version = [ $(ps).get ] ; + gcc-version = $(.real-version.$(gcc-version)) ; + local options ; + + local support-ppc64 = 1 ; + + osx-version ?= $(.host-osx-version) ; + + switch $(osx-version) + { + case iphone* : + { + support-ppc64 = ; + } + + case * : + if $(osx-version) && ! [ version.version-less [ regex.split $(osx-version) \\. ] : 10 6 ] + { + # When targeting 10.6: + # - gcc 4.2 will give a compiler errir if ppc64 compilation is requested + # - gcc 4.0 will compile fine, somehow, but then fail at link time + support-ppc64 = ; + } + } + switch $(arch) + { + case combined : + { + if $(address-model) = 32_64 { + if $(support-ppc64) { + options = -arch i386 -arch ppc -arch x86_64 -arch ppc64 ; + } else { + # Build 3-way binary + options = -arch i386 -arch ppc -arch x86_64 ; + } + } else if $(address-model) = 64 { + if $(support-ppc64) { + options = -arch x86_64 -arch ppc64 ; + } else { + errors.user-error "64-bit PPC compilation is not supported when targeting OSX 10.6 or later" ; + } + } else { + options = -arch i386 -arch ppc ; + } + } + + case x86 : + { + if $(address-model) = 32_64 { + options = -arch i386 -arch x86_64 ; + } else if $(address-model) = 64 { + options = -arch x86_64 ; + } else { + options = -arch i386 ; + } + } + + case power : + { + if ! $(support-ppc64) + && ( $(address-model) = 32_64 || $(address-model) = 64 ) + { + errors.user-error "64-bit PPC compilation is not supported when targeting OSX 10.6 or later" ; + } + + if $(address-model) = 32_64 { + options = -arch ppc -arch ppc64 ; + } else if $(address-model) = 64 { + options = -arch ppc64 ; + } else { + options = -arch ppc ; + } + } + + case arm : + { + options = -arch armv6 ; + } + } + + if $(options) + { + OPTIONS on $(targets) += $(options) ; + } +} + +rule setup-threading ( targets * : sources * : properties * ) +{ + gcc.setup-threading $(targets) : $(sources) : $(properties) ; +} + +rule setup-fpic ( targets * : sources * : properties * ) +{ + gcc.setup-fpic $(targets) : $(sources) : $(properties) ; +} + +rule compile.m ( targets * : sources * : properties * ) +{ + LANG on $(<) = "-x objective-c" ; + gcc.setup-fpic $(targets) : $(sources) : $(properties) ; + setup-address-model $(targets) : $(sources) : $(properties) ; +} + +actions compile.m +{ + "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +rule compile.mm ( targets * : sources * : properties * ) +{ + LANG on $(<) = "-x objective-c++" ; + gcc.setup-fpic $(targets) : $(sources) : $(properties) ; + setup-address-model $(targets) : $(sources) : $(properties) ; +} + +actions compile.mm +{ + "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +# Set the max header padding to allow renaming of libs for installation. +flags darwin.link.dll OPTIONS : -headerpad_max_install_names ; + +# To link the static runtime we need to link to all the core runtime libraries. +flags darwin.link OPTIONS static + : -nodefaultlibs -shared-libgcc -lstdc++-static -lgcc_eh -lgcc -lSystem ; + +# Strip as much as possible when optimizing. +flags darwin.link OPTIONS speed : -Wl,-dead_strip -no_dead_strip_inits_and_terms ; +flags darwin.link OPTIONS space : -Wl,-dead_strip -no_dead_strip_inits_and_terms ; + +# Dynamic/shared linking. +flags darwin.compile OPTIONS shared : -dynamic ; + +# Misc options. +flags darwin.compile OPTIONS : -gdwarf-2 -fexceptions ; +#~ flags darwin.link OPTIONS : -fexceptions ; + +# Add the framework names to use. +flags darwin.link FRAMEWORK ; + +# +flags darwin.link FORCE_LOAD ; + +# This is flag is useful for debugging the link step +# uncomment to see what libtool is doing under the hood +#~ flags darwin.link.dll OPTIONS : -Wl,-v ; + +_ = " " ; + +# set up the -F option to include the paths to any frameworks used. +local rule prepare-framework-path ( target + ) +{ + # The -framework option only takes basename of the framework. + # The -F option specifies the directories where a framework + # is searched for. So, if we find feature + # with some path, we need to generate property -F option. + local framework-paths = [ on $(target) return $(FRAMEWORK:D) ] ; + + # Be sure to generate no -F if there's no path. + for local framework-path in $(framework-paths) + { + if $(framework-path) != "" + { + FRAMEWORK_PATH on $(target) += -F$(framework-path) ; + } + } +} + +rule link ( targets * : sources * : properties * ) +{ + DEPENDS $(targets) : [ on $(targets) return $(FORCE_LOAD) ] ; + setup-address-model $(targets) : $(sources) : $(properties) ; + prepare-framework-path $(<) ; +} + +# Note that using strip without any options was reported to result in broken +# binaries, at least on OS X 10.5.5, see: +# http://svn.boost.org/trac/boost/ticket/2347 +# So we pass -S -x. +actions link bind LIBRARIES FORCE_LOAD +{ + "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -o "$(<)" "$(>)" -Wl,-force_load$(_)"$(FORCE_LOAD)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(FRAMEWORK_PATH) -framework$(_)$(FRAMEWORK:D=:S=) $(OPTIONS) $(USER_OPTIONS) + $(NEED_STRIP)"$(.STRIP)" $(NEED_STRIP)-S $(NEED_STRIP)-x $(NEED_STRIP)"$(<)" +} + +rule link.dll ( targets * : sources * : properties * ) +{ + setup-address-model $(targets) : $(sources) : $(properties) ; + prepare-framework-path $(<) ; +} + +actions link.dll bind LIBRARIES +{ + "$(CONFIG_COMMAND)" -dynamiclib -Wl,-single_module -install_name "$(<:B)$(<:S)" -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(FRAMEWORK_PATH) -framework$(_)$(FRAMEWORK:D=:S=) $(OPTIONS) $(USER_OPTIONS) +} + +# We use libtool instead of ar to support universal binary linking +# TODO: Find a way to use the underlying tools, i.e. lipo, to do this. +actions piecemeal archive +{ + "$(.LIBTOOL)" -static -o "$(<:T)" $(ARFLAGS) "$(>:T)" +} diff --git a/mosesdecoder/jam-files/boost-build/tools/docutils.jam b/mosesdecoder/jam-files/boost-build/tools/docutils.jam new file mode 100644 index 0000000000000000000000000000000000000000..fc775b6fc3cee4b00d211ec4f24a749023a6dba4 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/docutils.jam @@ -0,0 +1,85 @@ +# Copyright David Abrahams 2004. 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) + +# Support for docutils ReStructuredText processing. + +import type ; +import scanner ; +import generators ; +import os ; +import common ; +import toolset ; +import path ; +import feature : feature ; +import property ; + +.initialized = ; + +type.register ReST : rst ; + +class rst-scanner : common-scanner +{ + rule __init__ ( paths * ) + { + common-scanner.__init__ . $(paths) ; + } + + rule pattern ( ) + { + return "^[ ]*\\.\\.[ ]+include::[ ]+([^ +]+)" + "^[ ]*\\.\\.[ ]+image::[ ]+([^ +]+)" + "^[ ]*\\.\\.[ ]+figure::[ ]+([^ +]+)" + ; + } +} + +scanner.register rst-scanner : include ; +type.set-scanner ReST : rst-scanner ; + +generators.register-standard docutils.html : ReST : HTML ; + +rule init ( docutils-dir ? : tools-dir ? ) +{ + docutils-dir ?= [ modules.peek : DOCUTILS_DIR ] ; + tools-dir ?= $(docutils-dir)/tools ; + + if ! $(.initialized) + { + .initialized = true ; + .docutils-dir = $(docutils-dir) ; + .tools-dir = $(tools-dir:R="") ; + + .setup = [ + common.prepend-path-variable-command PYTHONPATH + : $(.docutils-dir) $(.docutils-dir)/extras ] ; + RST2XXX = [ common.find-tool rst2html ] ; + } +} + +rule html ( target : source : properties * ) +{ + if ! [ on $(target) return $(RST2XXX) ] + { + local python-cmd = [ property.select : $(properties) ] ; + RST2XXX on $(target) = $(python-cmd:G=:E="python") $(.tools-dir)/rst2html.py ; + } +} + + +feature docutils : : free ; +feature docutils-html : : free ; +feature docutils-cmd : : free ; +toolset.flags docutils COMMON-FLAGS : ; +toolset.flags docutils HTML-FLAGS : ; +toolset.flags docutils RST2XXX : ; + +actions html +{ + $(.setup) + "$(RST2XXX)" $(COMMON-FLAGS) $(HTML-FLAGS) $(>) $(<) +} + diff --git a/mosesdecoder/jam-files/boost-build/tools/doxygen-config.jam b/mosesdecoder/jam-files/boost-build/tools/doxygen-config.jam new file mode 100644 index 0000000000000000000000000000000000000000..2cd2ccaeb1c67f4ff900434fc300c07a02b4c860 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/doxygen-config.jam @@ -0,0 +1,11 @@ +#~ Copyright 2005, 2006 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) + +# Automatic configuration for Doxygen tools. To use, just import this module. + +import toolset : using ; + +ECHO "warning: doxygen-config.jam is deprecated. Use 'using doxygen ;' instead." ; + +using doxygen ; diff --git a/mosesdecoder/jam-files/boost-build/tools/fortran.jam b/mosesdecoder/jam-files/boost-build/tools/fortran.jam new file mode 100644 index 0000000000000000000000000000000000000000..37665825efac8f91d63c6c69abffe436cb719a30 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/fortran.jam @@ -0,0 +1,55 @@ +# Copyright (C) 2004 Toon Knapen +# +# Use, modification and distribution is subject to the Boost Software +# License Version 1.0. (See accompanying file LICENSE_1_0.txt or +# http://www.boost.org/LICENSE_1_0.txt) + +# +# This file contains common settings for all fortran tools +# + +import "class" : new ; +import feature : feature ; + +import type ; +import generators ; +import common ; + +type.register FORTRAN : f F for f77 ; +type.register FORTRAN90 : f90 F90 ; + +feature fortran : : free ; +feature fortran90 : : free ; + +class fortran-compiling-generator : generator +{ + rule __init__ ( id : source-types + : target-types + : requirements * : optional-properties * ) + { + generator.__init__ $(id) : $(source-types) : $(target-types) : $(requirements) : $(optional-properties) ; + } +} + +rule register-fortran-compiler ( id : source-types + : target-types + : requirements * : optional-properties * ) +{ + local g = [ new fortran-compiling-generator $(id) : $(source-types) : $(target-types) : $(requirements) : $(optional-properties) ] ; + generators.register $(g) ; +} + +class fortran90-compiling-generator : generator +{ + rule __init__ ( id : source-types + : target-types + : requirements * : optional-properties * ) + { + generator.__init__ $(id) : $(source-types) : $(target-types) : $(requirements) : $(optional-properties) ; + } +} + +rule register-fortran90-compiler ( id : source-types + : target-types + : requirements * : optional-properties * ) +{ + local g = [ new fortran90-compiling-generator $(id) : $(source-types) : $(target-types) : $(requirements) : $(optional-properties) ] ; + generators.register $(g) ; +} + +# FIXME: this is ugly, should find a better way (we'd want client code to +# register all generators as "generator.some-rule", not with "some-module.some-rule".) +IMPORT $(__name__) : register-fortran-compiler : : generators.register-fortran-compiler ; +IMPORT $(__name__) : register-fortran90-compiler : : generators.register-fortran90-compiler ; diff --git a/mosesdecoder/jam-files/boost-build/tools/gettext.jam b/mosesdecoder/jam-files/boost-build/tools/gettext.jam new file mode 100644 index 0000000000000000000000000000000000000000..99a43ffe9aeb9163a8b197c614bc86b84d620cc0 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/gettext.jam @@ -0,0 +1,230 @@ +# Copyright 2003, 2004, 2005, 2006 Vladimir Prus +# 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) + +# This module support GNU gettext internationalization utilities. +# +# It provides two main target rules: 'gettext.catalog', used for +# creating machine-readable catalogs from translations files, and +# 'gettext.update', used for update translation files from modified +# sources. +# +# To add i18n support to your application you should follow these +# steps. +# +# - Decide on a file name which will contain translations and +# what main target name will be used to update it. For example:: +# +# gettext.update update-russian : russian.po a.cpp my_app ; +# +# - Create the initial translation file by running:: +# +# bjam update-russian +# +# - Edit russian.po. For example, you might change fields like LastTranslator. +# +# - Create a main target for final message catalog:: +# +# gettext.catalog russian : russian.po ; +# +# The machine-readable catalog will be updated whenever you update +# "russian.po". The "russian.po" file will be updated only on explicit +# request. When you're ready to update translations, you should +# +# - Run:: +# +# bjam update-russian +# +# - Edit "russian.po" in appropriate editor. +# +# The next bjam run will convert "russian.po" into machine-readable form. +# +# By default, translations are marked by 'i18n' call. The 'gettext.keyword' +# feature can be used to alter this. + + +import targets ; +import property-set ; +import virtual-target ; +import "class" : new ; +import project ; +import type ; +import generators ; +import errors ; +import feature : feature ; +import toolset : flags ; +import regex ; + +.path = "" ; + +# Initializes the gettext module. +rule init ( path ? # Path where all tools are located. If not specified, + # they should be in PATH. + ) +{ + if $(.initialized) && $(.path) != $(path) + { + errors.error "Attempt to reconfigure with different path" ; + } + .initialized = true ; + if $(path) + { + .path = $(path)/ ; + } +} + +# Creates a main target 'name', which, when updated, will cause +# file 'existing-translation' to be updated with translations +# extracted from 'sources'. It's possible to specify main target +# in sources --- it which case all target from dependency graph +# of those main targets will be scanned, provided they are of +# appropricate type. The 'gettext.types' feature can be used to +# control the types. +# +# The target will be updated only if explicitly requested on the +# command line. +rule update ( name : existing-translation sources + : requirements * ) +{ + local project = [ project.current ] ; + + targets.main-target-alternative + [ new typed-target $(name) : $(project) : gettext.UPDATE : + $(existing-translation) $(sources) + : [ targets.main-target-requirements $(requirements) : $(project) ] + ] ; + $(project).mark-target-as-explicit $(name) ; +} + + +# The human editable source, containing translation. +type.register gettext.PO : po ; +# The machine readable message catalog. +type.register gettext.catalog : mo ; +# Intermediate type produce by extracting translations from +# sources. +type.register gettext.POT : pot ; +# Pseudo type used to invoke update-translations generator +type.register gettext.UPDATE ; + +# Identifies the keyword that should be used when scanning sources. +# Default: i18n +feature gettext.keyword : : free ; +# Contains space-separated list of sources types which should be scanned. +# Default: "C CPP" +feature gettext.types : : free ; + +generators.register-standard gettext.compile : gettext.PO : gettext.catalog ; + +class update-translations-generator : generator +{ + import regex : split ; + import property-set ; + + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + # The rule should be called with at least two sources. The first source + # is the translation (.po) file to update. The remaining sources are targets + # which should be scanned for new messages. All sources files for those targets + # will be found and passed to the 'xgettext' utility, which extracts the + # messages for localization. Those messages will be merged to the .po file. + rule run ( project name ? : property-set : sources * : multiple ? ) + { + local types = [ $(property-set).get ] ; + types ?= "C CPP" ; + types = [ regex.split $(types) " " ] ; + + local keywords = [ $(property-set).get ] ; + property-set = [ property-set.create $(keywords:G=) ] ; + + # First deterime the list of sources that must be scanned for + # messages. + local all-sources ; + # CONSIDER: I'm not sure if the logic should be the same as for 'stage': + # i.e. following dependency properties as well. + for local s in $(sources[2-]) + { + all-sources += [ virtual-target.traverse $(s) : : include-sources ] ; + } + local right-sources ; + for local s in $(all-sources) + { + if [ $(s).type ] in $(types) + { + right-sources += $(s) ; + } + } + + local .constructed ; + if $(right-sources) + { + # Create the POT file, which will contain list of messages extracted + # from the sources. + local extract = + [ new action $(right-sources) : gettext.extract : $(property-set) ] ; + local new-messages = [ new file-target $(name) : gettext.POT + : $(project) : $(extract) ] ; + + # Create a notfile target which will update the existing translation file + # with new messages. + local a = [ new action $(sources[1]) $(new-messages) + : gettext.update-po-dispatch ] ; + local r = [ new notfile-target $(name) : $(project) : $(a) ] ; + .constructed = [ virtual-target.register $(r) ] ; + } + else + { + errors.error "No source could be scanned by gettext tools" ; + } + return $(.constructed) ; + } +} +generators.register [ new update-translations-generator gettext.update : : gettext.UPDATE ] ; + +flags gettext.extract KEYWORD ; +actions extract +{ + $(.path)xgettext -k$(KEYWORD:E=i18n) -o $(<) $(>) +} + +# Does realy updating of po file. The tricky part is that +# we're actually updating one of the sources: +# $(<) is the NOTFILE target we're updating +# $(>[1]) is the PO file to be really updated. +# $(>[2]) is the PO file created from sources. +# +# When file to be updated does not exist (during the +# first run), we need to copy the file created from sources. +# In all other cases, we need to update the file. +rule update-po-dispatch +{ + NOCARE $(>[1]) ; + gettext.create-po $(<) : $(>) ; + gettext.update-po $(<) : $(>) ; + _ on $(<) = " " ; + ok on $(<) = "" ; + EXISTING_PO on $(<) = $(>[1]) ; +} + +# Due to fancy interaction of existing and updated, this rule can be called with +# one source, in which case we copy the lonely source into EXISTING_PO, or with +# two sources, in which case the action body expands to nothing. I'd really like +# to have "missing" action modifier. +actions quietly existing updated create-po bind EXISTING_PO +{ + cp$(_)"$(>[1])"$(_)"$(EXISTING_PO)"$($(>[2]:E=ok)) +} + +actions updated update-po bind EXISTING_PO +{ + $(.path)msgmerge$(_)-U$(_)"$(EXISTING_PO)"$(_)"$(>[1])" +} + +actions gettext.compile +{ + $(.path)msgfmt -o $(<) $(>) +} + +IMPORT $(__name__) : update : : gettext.update ; diff --git a/mosesdecoder/jam-files/boost-build/tools/ifort.jam b/mosesdecoder/jam-files/boost-build/tools/ifort.jam new file mode 100644 index 0000000000000000000000000000000000000000..eb7c198818b4d146530b83f1c48d73e94cb8064d --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/ifort.jam @@ -0,0 +1,44 @@ +# Copyright (C) 2004 Toon Knapen +# +# Use, modification and distribution is subject to the Boost Software +# License Version 1.0. (See accompanying file LICENSE_1_0.txt or +# http://www.boost.org/LICENSE_1_0.txt) + +import toolset : flags ; +import feature ; +import fortran ; + +rule init ( version ? : command * : options * ) +{ +} + +# Declare flags and action for compilation +flags ifort OPTIONS ; + +flags ifort OPTIONS off : /Od ; +flags ifort OPTIONS speed : /O3 ; +flags ifort OPTIONS space : /O1 ; + +flags ifort OPTIONS on : /debug:full ; +flags ifort OPTIONS on : /Qprof_gen ; + +flags ifort.compile FFLAGS off/shared : /MD ; +flags ifort.compile FFLAGS on/shared : /MDd ; +flags ifort.compile FFLAGS off/static/single : /ML ; +flags ifort.compile FFLAGS on/static/single : /MLd ; +flags ifort.compile FFLAGS off/static/multi : /MT ; +flags ifort.compile FFLAGS on/static/multi : /MTd ; + +flags ifort DEFINES ; +flags ifort INCLUDES ; + +rule compile.fortran +{ +} + +actions compile.fortran +{ + ifort $(FFLAGS) $(OPTIONS) /names:lowercase /D$(DEFINES) /I"$(INCLUDES)" /c /object:"$(<)" "$(>)" +} + +generators.register-fortran-compiler ifort.compile.fortran : FORTRAN : OBJ ; diff --git a/mosesdecoder/jam-files/boost-build/tools/intel-darwin.jam b/mosesdecoder/jam-files/boost-build/tools/intel-darwin.jam new file mode 100644 index 0000000000000000000000000000000000000000..aa0fd8fb6d492d976c8fcbfa69fdacb1b9886cd4 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/intel-darwin.jam @@ -0,0 +1,220 @@ +# Copyright Vladimir Prus 2004. +# Copyright Noel Belcourt 2007. +# 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 intel ; +import feature : feature ; +import os ; +import toolset ; +import toolset : flags ; +import gcc ; +import common ; +import errors ; +import generators ; + +feature.extend-subfeature toolset intel : platform : darwin ; + +toolset.inherit-generators intel-darwin + intel darwin + : gcc + # Don't inherit PCH generators. They were not tested, and probably + # don't work for this compiler. + : gcc.mingw.link gcc.mingw.link.dll gcc.compile.c.pch gcc.compile.c++.pch + ; + +generators.override intel-darwin.prebuilt : builtin.lib-generator ; +generators.override intel-darwin.prebuilt : builtin.prebuilt ; +generators.override intel-darwin.searched-lib-generator : searched-lib-generator ; + +toolset.inherit-rules intel-darwin : gcc ; +toolset.inherit-flags intel-darwin : gcc + : off on full space + off all on + x86/32 + x86/64 + ; + +if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] +{ + .debug-configuration = true ; +} + +# vectorization diagnostics +feature vectorize : off on full ; + +# Initializes the intel-darwin toolset +# version in mandatory +# name (default icc) is used to invoke the specified intel complier +# compile and link options allow you to specify addition command line options for each version +rule init ( version ? : command * : options * ) +{ + local condition = [ common.check-init-parameters intel-darwin + : version $(version) ] ; + + command = [ common.get-invocation-command intel-darwin : icc + : $(command) : /opt/intel_cc_80/bin ] ; + + common.handle-options intel-darwin : $(condition) : $(command) : $(options) ; + + gcc.init-link-flags intel-darwin darwin $(condition) ; + + # handle + # local library-path = [ feature.get-values : $(options) ] ; + # flags intel-darwin.link USER_OPTIONS $(condition) : [ feature.get-values : $(options) ] ; + + local root = [ feature.get-values : $(options) ] ; + local bin ; + if $(command) || $(root) + { + bin ?= [ common.get-absolute-tool-path $(command[-1]) ] ; + root ?= $(bin:D) ; + + if $(root) + { + # Libraries required to run the executable may be in either + # $(root)/lib (10.1 and earlier) + # or + # $(root)/lib/architecture-name (11.0 and later: + local lib_path = $(root)/lib $(root:P)/lib/$(bin:B) ; + if $(.debug-configuration) + { + ECHO notice: using intel libraries :: $(condition) :: $(lib_path) ; + } + flags intel-darwin.link RUN_PATH $(condition) : $(lib_path) ; + } + } + + local m = [ MATCH (..).* : $(version) ] ; + local n = [ MATCH (.)\\. : $(m) ] ; + if $(n) { + m = $(n) ; + } + + local major = $(m) ; + + if $(major) = "9" { + flags intel-darwin.compile OPTIONS $(condition)/off : -Ob0 ; + flags intel-darwin.compile OPTIONS $(condition)/on : -Ob1 ; + flags intel-darwin.compile OPTIONS $(condition)/full : -Ob2 ; + flags intel-darwin.compile OPTIONS $(condition)/off : -vec-report0 ; + flags intel-darwin.compile OPTIONS $(condition)/on : -vec-report1 ; + flags intel-darwin.compile OPTIONS $(condition)/full : -vec-report5 ; + flags intel-darwin.link OPTIONS $(condition)/static : -static -static-libcxa -lstdc++ -lpthread ; + flags intel-darwin.link OPTIONS $(condition)/shared : -shared-libcxa -lstdc++ -lpthread ; + } + else { + flags intel-darwin.compile OPTIONS $(condition)/off : -inline-level=0 ; + flags intel-darwin.compile OPTIONS $(condition)/on : -inline-level=1 ; + flags intel-darwin.compile OPTIONS $(condition)/full : -inline-level=2 ; + flags intel-darwin.compile OPTIONS $(condition)/off : -vec-report0 ; + flags intel-darwin.compile OPTIONS $(condition)/on : -vec-report1 ; + flags intel-darwin.compile OPTIONS $(condition)/full : -vec-report5 ; + flags intel-darwin.link OPTIONS $(condition)/static : -static -static-intel -lstdc++ -lpthread ; + flags intel-darwin.link OPTIONS $(condition)/shared : -shared-intel -lstdc++ -lpthread ; + } + + local minor = [ MATCH ".*\\.(.).*" : $(version) ] ; + + # wchar_t char_traits workaround for compilers older than 10.2 + if $(major) = "9" || ( $(major) = "10" && ( $(minor) = "0" || $(minor) = "1" ) ) { + flags intel-darwin.compile DEFINES $(condition) : __WINT_TYPE__=int : unchecked ; + } +} + +SPACE = " " ; + +flags intel-darwin.compile OPTIONS ; +flags intel-darwin.compile OPTIONS ; +# flags intel-darwin.compile INCLUDES ; + +flags intel-darwin.compile OPTIONS space : -O1 ; # no specific space optimization flag in icc + +# +cpu-type-em64t = prescott nocona ; +flags intel-darwin.compile OPTIONS $(cpu-type-em64t)/32 : -m32 ; # -mcmodel=small ; +flags intel-darwin.compile OPTIONS $(cpu-type-em64t)/64 : -m64 ; # -mcmodel=large ; + +flags intel-darwin.compile.c OPTIONS off : -w0 ; +flags intel-darwin.compile.c OPTIONS on : -w1 ; +flags intel-darwin.compile.c OPTIONS all : -w2 ; + +flags intel-darwin.compile.c++ OPTIONS off : -w0 ; +flags intel-darwin.compile.c++ OPTIONS on : -w1 ; +flags intel-darwin.compile.c++ OPTIONS all : -w2 ; + +actions compile.c +{ + "$(CONFIG_COMMAND)" -xc $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +actions compile.c++ +{ + "$(CONFIG_COMMAND)" -xc++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +flags intel-darwin ARFLAGS ; + +# Default value. Mostly for the sake of intel-linux +# that inherits from gcc, but does not has the same +# logic to set the .AR variable. We can put the same +# logic in intel-linux, but that's hardly worth the trouble +# as on Linux, 'ar' is always available. +.AR = ar ; + +rule archive ( targets * : sources * : properties * ) +{ + # Always remove archive and start again. Here's rationale from + # Andre Hentz: + # + # I had a file, say a1.c, that was included into liba.a. + # I moved a1.c to a2.c, updated my Jamfiles and rebuilt. + # My program was crashing with absurd errors. + # After some debugging I traced it back to the fact that a1.o was *still* + # in liba.a + # + # Rene Rivera: + # + # Originally removing the archive was done by splicing an RM + # onto the archive action. That makes archives fail to build on NT + # when they have many files because it will no longer execute the + # action directly and blow the line length limit. Instead we + # remove the file in a different action, just before the building + # of the archive. + # + local clean.a = $(targets[1])(clean) ; + TEMPORARY $(clean.a) ; + NOCARE $(clean.a) ; + LOCATE on $(clean.a) = [ on $(targets[1]) return $(LOCATE) ] ; + DEPENDS $(clean.a) : $(sources) ; + DEPENDS $(targets) : $(clean.a) ; + common.RmTemps $(clean.a) : $(targets) ; +} + +actions piecemeal archive +{ + "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)" + "ranlib" -cs "$(<)" +} + +flags intel-darwin.link USER_OPTIONS ; + +# Declare actions for linking +rule link ( targets * : sources * : properties * ) +{ + SPACE on $(targets) = " " ; + # Serialize execution of the 'link' action, since + # running N links in parallel is just slower. + JAM_SEMAPHORE on $(targets) = intel-darwin-link-semaphore ; +} + +actions link bind LIBRARIES +{ + "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(OPTIONS) +} + +actions link.dll bind LIBRARIES +{ + "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" -single_module -dynamiclib -install_name "$(<[1]:D=)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(OPTIONS) +} diff --git a/mosesdecoder/jam-files/boost-build/tools/intel-win.jam b/mosesdecoder/jam-files/boost-build/tools/intel-win.jam new file mode 100644 index 0000000000000000000000000000000000000000..c9adac0d96f0c917af2ccccda2ddf78851f5fe06 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/intel-win.jam @@ -0,0 +1,184 @@ +# Copyright Vladimir Prus 2004. +# 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) + +# Importing common is needed because the rules we inherit here depend on it. +# That is nasty. +import common ; +import errors ; +import feature ; +import intel ; +import msvc ; +import os ; +import toolset ; +import generators ; +import type ; + +feature.extend-subfeature toolset intel : platform : win ; + +toolset.inherit-generators intel-win intel win : msvc ; +toolset.inherit-flags intel-win : msvc : : YLOPTION ; +toolset.inherit-rules intel-win : msvc ; + +# Override default do-nothing generators. +generators.override intel-win.compile.c.pch : pch.default-c-pch-generator ; +generators.override intel-win.compile.c++.pch : pch.default-cpp-pch-generator ; +generators.override intel-win.compile.rc : rc.compile.resource ; +generators.override intel-win.compile.mc : mc.compile ; + +toolset.flags intel-win.compile PCH_SOURCE on : ; + +toolset.add-requirements intel-win,shared:multi ; + +# Initializes the intel toolset for windows +rule init ( version ? : # the compiler version + command * : # the command to invoke the compiler itself + options * # Additional option: + # either 'vc6', 'vc7', 'vc7.1' + # or 'native'(default). + ) +{ + local compatibility = + [ feature.get-values : $(options) ] ; + local condition = [ common.check-init-parameters intel-win + : version $(version) : compatibility $(compatibility) ] ; + + command = [ common.get-invocation-command intel-win : icl.exe : + $(command) ] ; + + common.handle-options intel-win : $(condition) : $(command) : $(options) ; + + local root ; + if $(command) + { + root = [ common.get-absolute-tool-path $(command[-1]) ] ; + root = $(root)/ ; + } + + local setup ; + setup = [ GLOB $(root) : iclvars_*.bat ] ; + if ! $(setup) + { + setup = $(root)/iclvars.bat ; + } + setup = "call \""$(setup)"\" > nul " ; + + if [ os.name ] = NT + { + setup = $(setup)" +" ; + } + else + { + setup = "cmd /S /C "$(setup)" \"&&\" " ; + } + + toolset.flags intel-win.compile .CC $(condition) : $(setup)icl ; + toolset.flags intel-win.link .LD $(condition) : $(setup)xilink ; + toolset.flags intel-win.archive .LD $(condition) : $(setup)xilink /lib ; + toolset.flags intel-win.link .MT $(condition) : $(setup)mt -nologo ; + toolset.flags intel-win.compile .MC $(condition) : $(setup)mc ; + toolset.flags intel-win.compile .RC $(condition) : $(setup)rc ; + + local m = [ MATCH (.).* : $(version) ] ; + local major = $(m[1]) ; + + local C++FLAGS ; + + C++FLAGS += /nologo ; + + # Reduce the number of spurious error messages + C++FLAGS += /Qwn5 /Qwd985 ; + + # Enable ADL + C++FLAGS += -Qoption,c,--arg_dep_lookup ; #"c" works for C++, too + + # Disable Microsoft "secure" overloads in Dinkumware libraries since they + # cause compile errors with Intel versions 9 and 10. + C++FLAGS += -D_SECURE_SCL=0 ; + + if $(major) > 5 + { + C++FLAGS += /Zc:forScope ; # Add support for correct for loop scoping. + } + + # Add options recognized only by intel7 and above. + if $(major) >= 7 + { + C++FLAGS += /Qansi_alias ; + } + + if $(compatibility) = vc6 + { + C++FLAGS += + # Emulate VC6 + /Qvc6 + + # No wchar_t support in vc6 dinkum library. Furthermore, in vc6 + # compatibility-mode, wchar_t is not a distinct type from unsigned + # short. + -DBOOST_NO_INTRINSIC_WCHAR_T + ; + } + else + { + if $(major) > 5 + { + # Add support for wchar_t + C++FLAGS += /Zc:wchar_t + # Tell the dinkumware library about it. + -D_NATIVE_WCHAR_T_DEFINED + ; + } + } + + if $(compatibility) && $(compatibility) != native + { + C++FLAGS += /Q$(base-vc) ; + } + else + { + C++FLAGS += + -Qoption,cpp,--arg_dep_lookup + # The following options were intended to disable the Intel compiler's + # 'bug-emulation' mode, but were later reported to be causing ICE with + # Intel-Win 9.0. It is not yet clear which options can be safely used. + # -Qoption,cpp,--const_string_literals + # -Qoption,cpp,--new_for_init + # -Qoption,cpp,--no_implicit_typename + # -Qoption,cpp,--no_friend_injection + # -Qoption,cpp,--no_microsoft_bugs + ; + } + + toolset.flags intel-win CFLAGS $(condition) : $(C++FLAGS) ; + # By default, when creating PCH, intel adds 'i' to the explicitly + # specified name of the PCH file. Of course, Boost.Build is not + # happy when compiler produces not the file it was asked for. + # The option below stops this behaviour. + toolset.flags intel-win CFLAGS : -Qpchi- ; + + if ! $(compatibility) + { + # If there's no backend version, assume 10. + compatibility = vc10 ; + } + + local extract-version = [ MATCH ^vc(.*) : $(compatibility) ] ; + if ! $(extract-version) + { + errors.user-error "Invalid value for compatibility option:" + $(compatibility) ; + } + + # Depending on the settings, running of tests require some runtime DLLs. + toolset.flags intel-win RUN_PATH $(condition) : $(root) ; + + msvc.configure-version-specific intel-win : $(extract-version[1]) : $(condition) ; +} + +toolset.flags intel-win.link LIBRARY_OPTION intel : "" ; + +toolset.flags intel-win YLOPTION ; + diff --git a/mosesdecoder/jam-files/boost-build/tools/mpi.jam b/mosesdecoder/jam-files/boost-build/tools/mpi.jam new file mode 100644 index 0000000000000000000000000000000000000000..0fe490becd00754e9170d5b83da78f05f58c4c2c --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/mpi.jam @@ -0,0 +1,583 @@ +# Support for the Message Passing Interface (MPI) +# +# (C) Copyright 2005, 2006 Trustees of Indiana University +# (C) Copyright 2005 Douglas Gregor +# +# 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.) +# +# Authors: Douglas Gregor +# Andrew Lumsdaine +# +# ==== MPI Configuration ==== +# +# For many users, MPI support can be enabled simply by adding the following +# line to your user-config.jam file: +# +# using mpi ; +# +# This should auto-detect MPI settings based on the MPI wrapper compiler in +# your path, e.g., "mpic++". If the wrapper compiler is not in your path, or +# has a different name, you can pass the name of the wrapper compiler as the +# first argument to the mpi module: +# +# using mpi : /opt/mpich2-1.0.4/bin/mpiCC ; +# +# If your MPI implementation does not have a wrapper compiler, or the MPI +# auto-detection code does not work with your MPI's wrapper compiler, +# you can pass MPI-related options explicitly via the second parameter to the +# mpi module: +# +# using mpi : : lammpio lammpi++ +# mpi lam +# dl ; +# +# To see the results of MPI auto-detection, pass "--debug-configuration" on +# the bjam command line. +# +# The (optional) fourth argument configures Boost.MPI for running +# regression tests. These parameters specify the executable used to +# launch jobs (default: "mpirun") followed by any necessary arguments +# to this to run tests and tell the program to expect the number of +# processors to follow (default: "-np"). With the default parameters, +# for instance, the test harness will execute, e.g., +# +# mpirun -np 4 all_gather_test +# +# ==== Linking Against the MPI Libraries === +# +# To link against the MPI libraries, import the "mpi" module and add the +# following requirement to your target: +# +# /mpi//mpi +# +# Since MPI support is not always available, you should check +# "mpi.configured" before trying to link against the MPI libraries. + +import "class" : new ; +import common ; +import feature : feature ; +import generators ; +import os ; +import project ; +import property ; +import testing ; +import toolset ; +import type ; +import path ; + +# Make this module a project +project.initialize $(__name__) ; +project mpi ; + +if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] +{ + .debug-configuration = true ; +} + +# Assuming the first part of the command line is the given prefix +# followed by some non-empty value, remove the first argument. Returns +# either nothing (if there was no prefix or no value) or a pair +# +# value rest-of-cmdline +# +# This is a subroutine of cmdline_to_features +rule add_feature ( prefix name cmdline ) +{ + local match = [ MATCH "^$(prefix)([^\" ]+|\"[^\"]+\") *(.*)$" : $(cmdline) ] ; + + # If there was no value associated with the prefix, abort + if ! $(match) { + return ; + } + + local value = $(match[1]) ; + + if [ MATCH " +" : $(value) ] { + value = "\"$(value)\"" ; + } + + return "<$(name)>$(value)" $(match[2]) ; +} + +# Strip any end-of-line characters off the given string and return the +# result. +rule strip-eol ( string ) +{ + local match = [ MATCH "^(([A-Za-z0-9~`\.!@#$%^&*()_+={};:'\",.<>/?\\| -]|[|])*).*$" : $(string) ] ; + + if $(match) + { + return $(match[1]) ; + } + else + { + return $(string) ; + } +} + +# Split a command-line into a set of features. Certain kinds of +# compiler flags are recognized (e.g., -I, -D, -L, -l) and replaced +# with their Boost.Build equivalents (e.g., , , +# , ). All other arguments are introduced +# using the features in the unknown-features parameter, because we +# don't know how to deal with them. For instance, if your compile and +# correct. The incoming command line should be a string starting with +# an executable (e.g., g++ -I/include/path") and may contain any +# number of command-line arguments thereafter. The result is a list of +# features corresponding to the given command line, ignoring the +# executable. +rule cmdline_to_features ( cmdline : unknown-features ? ) +{ + local executable ; + local features ; + local otherflags ; + local result ; + + unknown-features ?= ; + + # Pull the executable out of the command line. At this point, the + # executable is just thrown away. + local match = [ MATCH "^([^\" ]+|\"[^\"]+\") *(.*)$" : $(cmdline) ] ; + executable = $(match[1]) ; + cmdline = $(match[2]) ; + + # List the prefix/feature pairs that we will be able to transform. + # Every kind of parameter not mentioned here will be placed in both + # cxxflags and linkflags, because we don't know where they should go. + local feature_kinds-D = "define" ; + local feature_kinds-I = "include" ; + local feature_kinds-L = "library-path" ; + local feature_kinds-l = "find-shared-library" ; + + while $(cmdline) { + + # Check for one of the feature prefixes we know about. If we + # find one (and the associated value is nonempty), convert it + # into a feature. + local match = [ MATCH "^(-.)(.*)" : $(cmdline) ] ; + local matched ; + if $(match) && $(match[2]) { + local prefix = $(match[1]) ; + if $(feature_kinds$(prefix)) { + local name = $(feature_kinds$(prefix)) ; + local add = [ add_feature $(prefix) $(name) $(cmdline) ] ; + + if $(add) { + + if $(add[1]) = pthread + { + # Uhm. It's not really nice that this MPI implementation + # uses -lpthread as opposed to -pthread. We do want to + # set multi, instead of -lpthread. + result += "multi" ; + MPI_EXTRA_REQUIREMENTS += "multi" ; + } + else + { + result += $(add[1]) ; + } + + cmdline = $(add[2]) ; + matched = yes ; + } + } + } + + # If we haven't matched a feature prefix, just grab the command-line + # argument itself. If we can map this argument to a feature + # (e.g., -pthread -> multi), then do so; otherwise, + # and add it to the list of "other" flags that we don't + # understand. + if ! $(matched) { + match = [ MATCH "^([^\" ]+|\"[^\"]+\") *(.*)$" : $(cmdline) ] ; + local value = $(match[1]) ; + cmdline = $(match[2]) ; + + # Check for multithreading support + if $(value) = "-pthread" || $(value) = "-pthreads" + { + result += "multi" ; + + # DPG: This is a hack intended to work around a BBv2 bug where + # requirements propagated from libraries are not checked for + # conflicts when BBv2 determines which "common" properties to + # apply to a target. In our case, the single property + # gets propagated from the common properties to Boost.MPI + # targets, even though multi is in the usage + # requirements of /mpi//mpi. + MPI_EXTRA_REQUIREMENTS += "multi" ; + } + else if [ MATCH "(.*[a-zA-Z0-9<>?-].*)" : $(value) ] { + otherflags += $(value) ; + } + } + } + + # If there are other flags that we don't understand, add them to the + # result as both and + if $(otherflags) { + for unknown in $(unknown-features) + { + result += "$(unknown)$(otherflags:J= )" ; + } + } + + return $(result) ; +} + +# Determine if it is safe to execute the given shell command by trying +# to execute it and determining whether the exit code is zero or +# not. Returns true for an exit code of zero, false otherwise. +local rule safe-shell-command ( cmdline ) +{ + local result = [ SHELL "$(cmdline) > /dev/null 2>/dev/null; if [ "$?" -eq "0" ]; then echo SSCOK; fi" ] ; + return [ MATCH ".*(SSCOK).*" : $(result) ] ; +} + +# Initialize the MPI module. +rule init ( mpicxx ? : options * : mpirun-with-options * ) +{ + if ! $(options) && $(.debug-configuration) + { + ECHO "===============MPI Auto-configuration===============" ; + } + + if ! $(mpicxx) && [ os.on-windows ] + { + # Try to auto-configure to the Microsoft Compute Cluster Pack + local cluster_pack_path_native = "C:\\Program Files\\Microsoft Compute Cluster Pack" ; + local cluster_pack_path = [ path.make $(cluster_pack_path_native) ] ; + if [ GLOB $(cluster_pack_path_native)\\Include : mpi.h ] + { + if $(.debug-configuration) + { + ECHO "Found Microsoft Compute Cluster Pack: $(cluster_pack_path_native)" ; + } + + # Pick up either the 32-bit or 64-bit library, depending on which address + # model the user has selected. Default to 32-bit. + options = $(cluster_pack_path)/Include + 64:$(cluster_pack_path)/Lib/amd64 + $(cluster_pack_path)/Lib/i386 + msmpi + msvc:_SECURE_SCL=0 + ; + + # Setup the "mpirun" equivalent (mpiexec) + .mpirun = "\"$(cluster_pack_path_native)\\Bin\\mpiexec.exe"\" ; + .mpirun_flags = -n ; + } + else if $(.debug-configuration) + { + ECHO "Did not find Microsoft Compute Cluster Pack in $(cluster_pack_path_native)." ; + } + } + + if ! $(options) + { + # Try to auto-detect options based on the wrapper compiler + local command = [ common.get-invocation-command mpi : mpic++ : $(mpicxx) ] ; + + if ! $(mpicxx) && ! $(command) + { + # Try "mpiCC", which is used by MPICH + command = [ common.get-invocation-command mpi : mpiCC ] ; + } + + if ! $(mpicxx) && ! $(command) + { + # Try "mpicxx", which is used by OpenMPI and MPICH2 + command = [ common.get-invocation-command mpi : mpicxx ] ; + } + + local result ; + local compile_flags ; + local link_flags ; + + if ! $(command) + { + # Do nothing: we'll complain later + } + # OpenMPI and newer versions of LAM-MPI have -showme:compile and + # -showme:link. + else if [ safe-shell-command "$(command) -showme:compile" ] && + [ safe-shell-command "$(command) -showme:link" ] + { + if $(.debug-configuration) + { + ECHO "Found recent LAM-MPI or Open MPI wrapper compiler: $(command)" ; + } + + compile_flags = [ SHELL "$(command) -showme:compile" ] ; + link_flags = [ SHELL "$(command) -showme:link" ] ; + + # Prepend COMPILER as the executable name, to match the format of + # other compilation commands. + compile_flags = "COMPILER $(compile_flags)" ; + link_flags = "COMPILER $(link_flags)" ; + } + # Look for LAM-MPI's -showme + else if [ safe-shell-command "$(command) -showme" ] + { + if $(.debug-configuration) + { + ECHO "Found older LAM-MPI wrapper compiler: $(command)" ; + } + + result = [ SHELL "$(command) -showme" ] ; + } + # Look for MPICH + else if [ safe-shell-command "$(command) -show" ] + { + if $(.debug-configuration) + { + ECHO "Found MPICH wrapper compiler: $(command)" ; + } + compile_flags = [ SHELL "$(command) -compile_info" ] ; + link_flags = [ SHELL "$(command) -link_info" ] ; + } + # Sun HPC and Ibm POE + else if [ SHELL "$(command) -v 2>/dev/null" ] + { + compile_flags = [ SHELL "$(command) -c -v -xtarget=native64 2>/dev/null" ] ; + + local back = [ MATCH "--------------------(.*)" : $(compile_flags) ] ; + if $(back) + { + # Sun HPC + if $(.debug-configuration) + { + ECHO "Found Sun MPI wrapper compiler: $(command)" ; + } + + compile_flags = [ MATCH "(.*)--------------------" : $(back) ] ; + compile_flags = [ MATCH "(.*)-v" : $(compile_flags) ] ; + link_flags = [ SHELL "$(command) -v -xtarget=native64 2>/dev/null" ] ; + link_flags = [ MATCH "--------------------(.*)" : $(link_flags) ] ; + link_flags = [ MATCH "(.*)--------------------" : $(link_flags) ] ; + + # strip out -v from compile options + local front = [ MATCH "(.*)-v" : $(link_flags) ] ; + local back = [ MATCH "-v(.*)" : $(link_flags) ] ; + link_flags = "$(front) $(back)" ; + front = [ MATCH "(.*)-xtarget=native64" : $(link_flags) ] ; + back = [ MATCH "-xtarget=native64(.*)" : $(link_flags) ] ; + link_flags = "$(front) $(back)" ; + } + else + { + # Ibm POE + if $(.debug-configuration) + { + ECHO "Found IBM MPI wrapper compiler: $(command)" ; + } + + # + compile_flags = [ SHELL "$(command) -c -v 2>/dev/null" ] ; + compile_flags = [ MATCH "(.*)exec: export.*" : $(compile_flags) ] ; + local front = [ MATCH "(.*)-v" : $(compile_flags) ] ; + local back = [ MATCH "-v(.*)" : $(compile_flags) ] ; + compile_flags = "$(front) $(back)" ; + front = [ MATCH "(.*)-c" : $(compile_flags) ] ; + back = [ MATCH "-c(.*)" : $(compile_flags) ] ; + compile_flags = "$(front) $(back)" ; + link_flags = $(compile_flags) ; + + # get location of mpif.h from mpxlf + local f_flags = [ SHELL "mpxlf -v 2>/dev/null" ] ; + f_flags = [ MATCH "(.*)exec: export.*" : $(f_flags) ] ; + front = [ MATCH "(.*)-v" : $(f_flags) ] ; + back = [ MATCH "-v(.*)" : $(f_flags) ] ; + f_flags = "$(front) $(back)" ; + f_flags = [ MATCH "xlf_r(.*)" : $(f_flags) ] ; + f_flags = [ MATCH "-F:mpxlf_r(.*)" : $(f_flags) ] ; + compile_flags = [ strip-eol $(compile_flags) ] ; + compile_flags = "$(compile_flags) $(f_flags)" ; + } + } + + if $(result) || $(compile_flags) && $(link_flags) + { + if $(result) + { + result = [ strip-eol $(result) ] ; + options = [ cmdline_to_features $(result) ] ; + } + else + { + compile_flags = [ strip-eol $(compile_flags) ] ; + link_flags = [ strip-eol $(link_flags) ] ; + + # Separately process compilation and link features, then combine + # them at the end. + local compile_features = [ cmdline_to_features $(compile_flags) + : "" ] ; + local link_features = [ cmdline_to_features $(link_flags) + : "" ] ; + options = $(compile_features) $(link_features) ; + } + + # If requested, display MPI configuration information. + if $(.debug-configuration) + { + if $(result) + { + ECHO " Wrapper compiler command line: $(result)" ; + } + else + { + local match = [ MATCH "^([^\" ]+|\"[^\"]+\") *(.*)$" + : $(compile_flags) ] ; + ECHO "MPI compilation flags: $(match[2])" ; + local match = [ MATCH "^([^\" ]+|\"[^\"]+\") *(.*)$" + : $(link_flags) ] ; + ECHO "MPI link flags: $(match[2])" ; + } + } + } + else + { + if $(command) + { + ECHO "MPI auto-detection failed: unknown wrapper compiler $(command)" ; + ECHO "Please report this error to the Boost mailing list: http://www.boost.org" ; + } + else if $(mpicxx) + { + ECHO "MPI auto-detection failed: unable to find wrapper compiler $(mpicxx)" ; + } + else + { + ECHO "MPI auto-detection failed: unable to find wrapper compiler `mpic++' or `mpiCC'" ; + } + ECHO "You will need to manually configure MPI support." ; + } + + } + + # Find mpirun (or its equivalent) and its flags + if ! $(.mpirun) + { + .mpirun = + [ common.get-invocation-command mpi : mpirun : $(mpirun-with-options[1]) ] ; + .mpirun_flags = $(mpirun-with-options[2-]) ; + .mpirun_flags ?= -np ; + } + + if $(.debug-configuration) + { + if $(options) + { + echo "MPI build features: " ; + ECHO $(options) ; + } + + if $(.mpirun) + { + echo "MPI launcher: $(.mpirun) $(.mpirun_flags)" ; + } + + ECHO "====================================================" ; + } + + if $(options) + { + .configured = true ; + + # Set up the "mpi" alias + alias mpi : : : : $(options) ; + } +} + +# States whether MPI has bee configured +rule configured ( ) +{ + return $(.configured) ; +} + +# Returs the "extra" requirements needed to build MPI. These requirements are +# part of the /mpi//mpi library target, but they need to be added to anything +# that uses MPI directly to work around bugs in BBv2's propagation of +# requirements. +rule extra-requirements ( ) +{ + return $(MPI_EXTRA_REQUIREMENTS) ; +} + +# Support for testing; borrowed from Python +type.register RUN_MPI_OUTPUT ; +type.register RUN_MPI : : TEST ; + +class mpi-test-generator : generator +{ + import property-set ; + + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + self.composing = true ; + } + + rule run ( project name ? : property-set : sources * : multiple ? ) + { + # Generate an executable from the sources. This is the executable we will run. + local executable = + [ generators.construct $(project) $(name) : EXE : $(property-set) : $(sources) ] ; + + result = + [ construct-result $(executable[2-]) : $(project) $(name)-run : $(property-set) ] ; + } +} + +# Use mpi-test-generator to generate MPI tests from sources +generators.register + [ new mpi-test-generator mpi.capture-output : : RUN_MPI_OUTPUT ] ; + +generators.register-standard testing.expect-success + : RUN_MPI_OUTPUT : RUN_MPI ; + +# The number of processes to spawn when executing an MPI test. +feature mpi:processes : : free incidental ; + +# The flag settings on testing.capture-output do not +# apply to mpi.capture output at the moment. +# Redo this explicitly. +toolset.flags mpi.capture-output ARGS ; +rule capture-output ( target : sources * : properties * ) +{ + # Use the standard capture-output rule to run the tests + testing.capture-output $(target) : $(sources[1]) : $(properties) ; + + # Determine the number of processes we should run on. + local num_processes = [ property.select : $(properties) ] ; + num_processes = $(num_processes:G=) ; + + # serialize the MPI tests to avoid overloading systems + JAM_SEMAPHORE on $(target) = mpi-run-semaphore ; + + # We launch MPI processes using the "mpirun" equivalent specified by the user. + LAUNCHER on $(target) = + [ on $(target) return $(.mpirun) $(.mpirun_flags) $(num_processes) ] ; +} + +# Creates a set of test cases to be run through the MPI launcher. The name, sources, +# and requirements are the same as for any other test generator. However, schedule is +# a list of numbers, which indicates how many processes each test run will use. For +# example, passing 1 2 7 will run the test with 1 process, then 2 processes, then 7 +# 7 processes. The name provided is just the base name: the actual tests will be +# the name followed by a hypen, then the number of processes. +rule mpi-test ( name : sources * : requirements * : schedule * ) +{ + sources ?= $(name).cpp ; + schedule ?= 1 2 3 4 7 8 13 17 ; + + local result ; + for processes in $(schedule) + { + result += [ testing.make-test + run-mpi : $(sources) /boost/mpi//boost_mpi + : $(requirements) msvc:static $(processes) : $(name)-$(processes) ] ; + } + return $(result) ; +} diff --git a/mosesdecoder/jam-files/boost-build/tools/msvc.jam b/mosesdecoder/jam-files/boost-build/tools/msvc.jam new file mode 100644 index 0000000000000000000000000000000000000000..22548323ad870281eeab468b3b9262aa96bd6eab --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/msvc.jam @@ -0,0 +1,1398 @@ +# Copyright (c) 2003 David Abrahams. +# Copyright (c) 2005 Vladimir Prus. +# Copyright (c) 2005 Alexey Pakhunov. +# Copyright (c) 2006 Bojan Resnik. +# Copyright (c) 2006 Ilya Sokolov. +# Copyright (c) 2007 Rene Rivera +# Copyright (c) 2008 Jurko Gospodnetic +# +# Use, modification and distribution is subject to the Boost Software +# License Version 1.0. (See accompanying file LICENSE_1_0.txt or +# http://www.boost.org/LICENSE_1_0.txt) + +################################################################################ +# +# MSVC Boost Build toolset module. +# -------------------------------- +# +# All toolset versions need to have their location either auto-detected or +# explicitly specified except for the special 'default' version that expects the +# environment to find the needed tools or report an error. +# +################################################################################ + +import "class" : new ; +import common ; +import errors ; +import feature ; +import generators ; +import mc ; +import midl ; +import os ; +import path ; +import pch ; +import property ; +import rc ; +import toolset ; +import type ; + + +type.register MANIFEST : manifest ; +feature.feature embed-manifest : on off : incidental propagated ; + +type.register PDB : pdb ; + +################################################################################ +# +# Public rules. +# +################################################################################ + +# Initialize a specific toolset version configuration. As the result, path to +# compiler and, possible, program names are set up, and will be used when that +# version of compiler is requested. For example, you might have: +# +# using msvc : 6.5 : cl.exe ; +# using msvc : 7.0 : Y:/foo/bar/cl.exe ; +# +# The version parameter may be ommited: +# +# using msvc : : Z:/foo/bar/cl.exe ; +# +# The following keywords have special meanings when specified as versions: +# - all - all detected but not yet used versions will be marked as used +# with their default options. +# - default - this is an equivalent to an empty version. +# +# Depending on a supplied version, detected configurations and presence 'cl.exe' +# in the path different results may be achieved. The following table describes +# the possible scenarios: +# +# Nothing "x.y" +# Passed Nothing "x.y" detected, detected, +# version detected detected cl.exe in path cl.exe in path +# +# default Error Use "x.y" Create "default" Use "x.y" +# all None Use all None Use all +# x.y - Use "x.y" - Use "x.y" +# a.b Error Error Create "a.b" Create "a.b" +# +# "x.y" - refers to a detected version; +# "a.b" - refers to an undetected version. +# +# FIXME: Currently the command parameter and the property parameter +# seem to overlap in duties. Remove this duplication. This seems to be related +# to why someone started preparing to replace init with configure rules. +# +rule init ( + # The msvc version being configured. When omitted the tools invoked when no + # explicit version is given will be configured. + version ? + + # The command used to invoke the compiler. If not specified: + # - if version is given, default location for that version will be + # searched + # + # - if version is not given, default locations for MSVC 9.0, 8.0, 7.1, 7.0 + # and 6.* will be searched + # + # - if compiler is not found in the default locations, PATH will be + # searched. + : command * + + # Options may include: + # + # All options shared by multiple toolset types as handled by the + # common.handle-options() rule, e.g. , , , + # & . + # + # + # + # + # + # + # + # Exact tool names to be used by this msvc toolset configuration. + # + # + # Command through which to pipe the output of running the compiler. + # For example to pass the output to STLfilt. + # + # + # Global setup command to invoke before running any of the msvc tools. + # It will be passed additional option parameters depending on the actual + # target platform. + # + # + # + # + # Platform specific setup command to invoke before running any of the + # msvc tools used when builing a target for a specific platform, e.g. + # when building a 32 or 64 bit executable. + : options * +) +{ + if $(command) + { + options += $(command) ; + } + configure $(version) : $(options) ; +} + + +# 'configure' is a newer version of 'init'. The parameter 'command' is passed as +# a part of the 'options' list. See the 'init' rule comment for more detailed +# information. +# +rule configure ( version ? : options * ) +{ + switch $(version) + { + case "all" : + if $(options) + { + errors.error "MSVC toolset configuration: options should be" + "empty when '$(version)' is specified." ; + } + + # Configure (i.e. mark as used) all registered versions. + local all-versions = [ $(.versions).all ] ; + if ! $(all-versions) + { + if $(.debug-configuration) + { + ECHO "notice: [msvc-cfg] Asked to configure all registered" + "msvc toolset versions when there are none currently" + "registered." ; + } + } + else + { + for local v in $(all-versions) + { + # Note that there is no need to skip already configured + # versions here as this will request configure-really rule + # to configure the version using default options which will + # in turn cause it to simply do nothing in case the version + # has already been configured. + configure-really $(v) ; + } + } + + case "default" : + configure-really : $(options) ; + + case * : + configure-really $(version) : $(options) ; + } +} + + +# Sets up flag definitions dependent on the compiler version used. +# - 'version' is the version of compiler in N.M format. +# - 'conditions' is the property set to be used as flag conditions. +# - 'toolset' is the toolset for which flag settings are to be defined. +# This makes the rule reusable for other msvc-option-compatible compilers. +# +rule configure-version-specific ( toolset : version : conditions ) +{ + toolset.push-checking-for-flags-module unchecked ; + # Starting with versions 7.0, the msvc compiler have the /Zc:forScope and + # /Zc:wchar_t options that improve C++ standard conformance, but those + # options are off by default. If we are sure that the msvc version is at + # 7.*, add those options explicitly. We can be sure either if user specified + # version 7.* explicitly or if we auto-detected the version ourselves. + if ! [ MATCH ^(6\\.) : $(version) ] + { + toolset.flags $(toolset).compile CFLAGS $(conditions) : /Zc:forScope /Zc:wchar_t ; + toolset.flags $(toolset).compile.c++ C++FLAGS $(conditions) : /wd4675 ; + + # Explicitly disable the 'function is deprecated' warning. Some msvc + # versions have a bug, causing them to emit the deprecation warning even + # with /W0. + toolset.flags $(toolset).compile CFLAGS $(conditions)/off : /wd4996 ; + + if [ MATCH ^([78]\\.) : $(version) ] + { + # 64-bit compatibility warning deprecated since 9.0, see + # http://msdn.microsoft.com/en-us/library/yt4xw8fh.aspx + toolset.flags $(toolset).compile CFLAGS $(conditions)/all : /Wp64 ; + } + } + + # + # Processor-specific optimization. + # + + if [ MATCH ^([67]) : $(version) ] + { + # 8.0 deprecates some of the options. + toolset.flags $(toolset).compile CFLAGS $(conditions)/speed $(conditions)/space : /Ogiy /Gs ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/speed : /Ot ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/space : /Os ; + + toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/ : /GB ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/i386 : /G3 ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/i486 : /G4 ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/$(.cpu-type-g5) : /G5 ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/$(.cpu-type-g6) : /G6 ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-i386)/$(.cpu-type-g7) : /G7 ; + + # Improve floating-point accuracy. Otherwise, some of C++ Boost's "math" + # tests will fail. + toolset.flags $(toolset).compile CFLAGS $(conditions) : /Op ; + + # 7.1 and below have single-threaded static RTL. + toolset.flags $(toolset).compile CFLAGS $(conditions)/off/static/single : /ML ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/on/static/single : /MLd ; + } + else + { + # 8.0 and above adds some more options. + toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-amd64)/ : /favor:blend ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-amd64)/$(.cpu-type-em64t) : /favor:EM64T ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/$(.cpu-arch-amd64)/$(.cpu-type-amd64) : /favor:AMD64 ; + + # 8.0 and above only has multi-threaded static RTL. + toolset.flags $(toolset).compile CFLAGS $(conditions)/off/static/single : /MT ; + toolset.flags $(toolset).compile CFLAGS $(conditions)/on/static/single : /MTd ; + + # Specify target machine type so the linker will not need to guess. + toolset.flags $(toolset).link LINKFLAGS $(conditions)/$(.cpu-arch-amd64) : /MACHINE:X64 ; + toolset.flags $(toolset).link LINKFLAGS $(conditions)/$(.cpu-arch-i386) : /MACHINE:X86 ; + toolset.flags $(toolset).link LINKFLAGS $(conditions)/$(.cpu-arch-ia64) : /MACHINE:IA64 ; + + # Make sure that manifest will be generated even if there is no + # dependencies to put there. + toolset.flags $(toolset).link LINKFLAGS $(conditions)/off : /MANIFEST ; + } + toolset.pop-checking-for-flags-module ; +} + + +# Registers this toolset including all of its flags, features & generators. Does +# nothing on repeated calls. +# +rule register-toolset ( ) +{ + if ! msvc in [ feature.values toolset ] + { + register-toolset-really ; + } +} + + +# Declare action for creating static libraries. If library exists, remove it +# before adding files. See +# http://article.gmane.org/gmane.comp.lib.boost.build/4241 for rationale. +if [ os.name ] in NT +{ + # The 'DEL' command would issue a message to stdout if the file does not + # exist, so need a check. + actions archive + { + if exist "$(<[1])" DEL "$(<[1])" + $(.LD) $(AROPTIONS) /out:"$(<[1])" @"@($(<[1]:W).rsp:E=$(.nl)"$(>)" $(.nl)$(LIBRARIES_MENTIONED_BY_FILE) $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST).lib" $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA).lib")" + } +} +else +{ + actions archive + { + $(.RM) "$(<[1])" + $(.LD) $(AROPTIONS) /out:"$(<[1])" @"@($(<[1]:W).rsp:E=$(.nl)"$(>)" $(.nl)$(LIBRARIES_MENTIONED_BY_FILE) $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST).lib" $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA).lib")" + } +} + + +# For the assembler the following options are turned on by default: +# +# -Zp4 align structures to 4 bytes +# -Cp preserve case of user identifiers +# -Cx preserve case in publics, externs +# +actions compile.asm +{ + $(.ASM) -c -Zp4 -Cp -Cx -D$(DEFINES) $(ASMFLAGS) $(USER_ASMFLAGS) -Fo "$(<:W)" "$(>:W)" +} + + +rule compile.c ( targets + : sources * : properties * ) +{ + C++FLAGS on $(targets[1]) = ; + get-rspline $(targets) : -TC ; + compile-c-c++ $(<) : $(>) [ on $(<) return $(PCH_FILE) ] [ on $(<) return $(PCH_HEADER) ] ; +} + + +rule compile.c.preprocess ( targets + : sources * : properties * ) +{ + C++FLAGS on $(targets[1]) = ; + get-rspline $(targets) : -TC ; + preprocess-c-c++ $(<) : $(>) [ on $(<) return $(PCH_FILE) ] [ on $(<) return $(PCH_HEADER) ] ; +} + + +rule compile.c.pch ( targets + : sources * : properties * ) +{ + C++FLAGS on $(targets[1]) = ; + get-rspline $(targets[1]) : -TC ; + get-rspline $(targets[2]) : -TC ; + local pch-source = [ on $(<) return $(PCH_SOURCE) ] ; + if $(pch-source) + { + DEPENDS $(<) : $(pch-source) ; + compile-c-c++-pch-s $(targets) : $(sources) $(pch-source) ; + } + else + { + compile-c-c++-pch $(targets) : $(sources) ; + } +} + +toolset.flags msvc YLOPTION : "-Yl" ; + +# Action for running the C/C++ compiler without using precompiled headers. +# +# WARNING: Synchronize any changes this in action with intel-win +# +# Notes regarding PDB generation, for when we use on/database +# +# 1. PDB_CFLAG is only set for on/database, ensuring that the /Fd flag is dropped if PDB_CFLAG is empty +# +# 2. When compiling executables's source files, PDB_NAME is set on a per-source file basis by rule compile-c-c++. +# The linker will pull these into the executable's PDB +# +# 3. When compiling library's source files, PDB_NAME is updated to .pdb for each source file by rule archive, +# as in this case the compiler must be used to create a single PDB for our library. +# +actions compile-c-c++ bind PDB_NAME +{ + $(.CC) @"@($(<[1]:W).rsp:E="$(>[1]:W)" -Fo"$(<[1]:W)" $(PDB_CFLAG)"$(PDB_NAME)" -Yu"$(>[3]:D=)" -Fp"$(>[2]:W)" $(CC_RSPLINE))" $(.CC.FILTER) +} + +actions preprocess-c-c++ bind PDB_NAME +{ + $(.CC) @"@($(<[1]:W).rsp:E="$(>[1]:W)" -E $(PDB_CFLAG)"$(PDB_NAME)" -Yu"$(>[3]:D=)" -Fp"$(>[2]:W)" $(CC_RSPLINE))" >"$(<[1]:W)" +} + +rule compile-c-c++ ( targets + : sources * ) +{ + DEPENDS $(<[1]) : [ on $(<[1]) return $(PCH_HEADER) ] ; + DEPENDS $(<[1]) : [ on $(<[1]) return $(PCH_FILE) ] ; + PDB_NAME on $(<) = $(<:S=.pdb) ; +} + +rule preprocess-c-c++ ( targets + : sources * ) +{ + DEPENDS $(<[1]) : [ on $(<[1]) return $(PCH_HEADER) ] ; + DEPENDS $(<[1]) : [ on $(<[1]) return $(PCH_FILE) ] ; + PDB_NAME on $(<) = $(<:S=.pdb) ; +} + +# Action for running the C/C++ compiler using precompiled headers. In addition +# to whatever else it needs to compile, this action also adds a temporary source +# .cpp file used to compile the precompiled headers themselves. +# +# The global .escaped-double-quote variable is used to avoid messing up Emacs +# syntax highlighting in the messy N-quoted code below. +actions compile-c-c++-pch +{ + $(.CC) @"@($(<[1]:W).rsp:E="$(>[2]:W)" -Fo"$(<[2]:W)" -Yc"$(>[1]:D=)" $(YLOPTION)"__bjam_pch_symbol_$(>[1]:D=)" -Fp"$(<[1]:W)" $(CC_RSPLINE))" "@($(<[1]:W).cpp:E=#include $(.escaped-double-quote)$(>[1]:D=)$(.escaped-double-quote)$(.nl))" $(.CC.FILTER) +} + + +# Action for running the C/C++ compiler using precompiled headers. An already +# built source file for compiling the precompiled headers is expected to be +# given as one of the source parameters. +actions compile-c-c++-pch-s +{ + $(.CC) @"@($(<[1]:W).rsp:E="$(>[2]:W)" -Fo"$(<[2]:W)" -Yc"$(>[1]:D=)" $(YLOPTION)"__bjam_pch_symbol_$(>[1]:D=)" -Fp"$(<[1]:W)" $(CC_RSPLINE))" $(.CC.FILTER) +} + + +rule compile.c++ ( targets + : sources * : properties * ) +{ + get-rspline $(targets) : -TP ; + compile-c-c++ $(<) : $(>) [ on $(<) return $(PCH_FILE) ] [ on $(<) return $(PCH_HEADER) ] ; +} + +rule compile.c++.preprocess ( targets + : sources * : properties * ) +{ + get-rspline $(targets) : -TP ; + preprocess-c-c++ $(<) : $(>) [ on $(<) return $(PCH_FILE) ] [ on $(<) return $(PCH_HEADER) ] ; +} + + +rule compile.c++.pch ( targets + : sources * : properties * ) +{ + get-rspline $(targets[1]) : -TP ; + get-rspline $(targets[2]) : -TP ; + local pch-source = [ on $(<) return $(PCH_SOURCE) ] ; + if $(pch-source) + { + DEPENDS $(<) : $(pch-source) ; + compile-c-c++-pch-s $(targets) : $(sources) $(pch-source) ; + } + else + { + compile-c-c++-pch $(targets) : $(sources) ; + } +} + + +# See midl.jam for details. +# +actions compile.idl +{ + $(.IDL) /nologo @"@($(<[1]:W).rsp:E=$(.nl)"$(>:W)" $(.nl)-D$(DEFINES) $(.nl)"-I$(INCLUDES:W)" $(.nl)-U$(UNDEFS) $(.nl)$(MIDLFLAGS) $(.nl)/tlb "$(<[1]:W)" $(.nl)/h "$(<[2]:W)" $(.nl)/iid "$(<[3]:W)" $(.nl)/proxy "$(<[4]:W)" $(.nl)/dlldata "$(<[5]:W)")" + $(.TOUCH_FILE) "$(<[4]:W)" + $(.TOUCH_FILE) "$(<[5]:W)" +} + + +actions compile.mc +{ + $(.MC) $(MCFLAGS) -h "$(<[1]:DW)" -r "$(<[2]:DW)" "$(>:W)" +} + + +actions compile.rc +{ + $(.RC) -l 0x409 -U$(UNDEFS) -D$(DEFINES) -I"$(INCLUDES:W)" -fo "$(<:W)" "$(>:W)" +} + + +rule link ( targets + : sources * : properties * ) +{ + if on in $(properties) + { + msvc.manifest $(targets) : $(sources) : $(properties) ; + } +} + +rule link.dll ( targets + : sources * : properties * ) +{ + DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ; + if on in $(properties) + { + msvc.manifest.dll $(targets) : $(sources) : $(properties) ; + } +} + +# Incremental linking a DLL causes no end of problems: if the actual exports do +# not change, the import .lib file is never updated. Therefore, the .lib is +# always out-of-date and gets rebuilt every time. I am not sure that incremental +# linking is such a great idea in general, but in this case I am sure we do not +# want it. + +# Windows manifest is a new way to specify dependencies on managed DotNet +# assemblies and Windows native DLLs. The manifests are embedded as resources +# and are useful in any PE target (both DLL and EXE). + +if [ os.name ] in NT +{ + actions link bind DEF_FILE LIBRARIES_MENTIONED_BY_FILE + { + $(.LD) $(LINKFLAGS) /out:"$(<[1]:W)" /LIBPATH:"$(LINKPATH:W)" $(OPTIONS) @"@($(<[1]:W).rsp:E=$(.nl)"$(>)" $(.nl)$(LIBRARIES_MENTIONED_BY_FILE) $(.nl)$(LIBRARIES) $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST).lib" $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA).lib")" + if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% + } + + actions manifest + { + if exist "$(<[1]).manifest" ( + $(.MT) -manifest "$(<[1]).manifest" "-outputresource:$(<[1]);1" + ) + } + + actions link.dll bind DEF_FILE LIBRARIES_MENTIONED_BY_FILE + { + $(.LD) /DLL $(LINKFLAGS) /out:"$(<[1]:W)" /IMPLIB:"$(<[2]:W)" /LIBPATH:"$(LINKPATH:W)" /def:"$(DEF_FILE)" $(OPTIONS) @"@($(<[1]:W).rsp:E=$(.nl)"$(>)" $(.nl)$(LIBRARIES_MENTIONED_BY_FILE) $(.nl)$(LIBRARIES) $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST).lib" $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA).lib")" + if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL% + } + + actions manifest.dll + { + if exist "$(<[1]).manifest" ( + $(.MT) -manifest "$(<[1]).manifest" "-outputresource:$(<[1]);2" + ) + } +} +else +{ + actions link bind DEF_FILE LIBRARIES_MENTIONED_BY_FILE + { + $(.LD) $(LINKFLAGS) /out:"$(<[1]:W)" /LIBPATH:"$(LINKPATH:W)" $(OPTIONS) @"@($(<[1]:W).rsp:E=$(.nl)"$(>)" $(.nl)$(LIBRARIES_MENTIONED_BY_FILE) $(.nl)$(LIBRARIES) $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST).lib" $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA).lib")" + } + + actions manifest + { + if test -e "$(<[1]).manifest"; then + $(.MT) -manifest "$(<[1]:W).manifest" "-outputresource:$(<[1]:W);1" + fi + } + + actions link.dll bind DEF_FILE LIBRARIES_MENTIONED_BY_FILE + { + $(.LD) /DLL $(LINKFLAGS) /out:"$(<[1]:W)" /IMPLIB:"$(<[2]:W)" /LIBPATH:"$(LINKPATH:W)" /def:"$(DEF_FILE)" $(OPTIONS) @"@($(<[1]:W).rsp:E=$(.nl)"$(>)" $(.nl)$(LIBRARIES_MENTIONED_BY_FILE) $(.nl)$(LIBRARIES) $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST).lib" $(.nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA).lib")" + } + + actions manifest.dll + { + if test -e "$(<[1]).manifest"; then + $(.MT) -manifest "$(<[1]:W).manifest" "-outputresource:$(<[1]:W);2" + fi + } +} + +# this rule sets up the pdb file that will be used when generating static +# libraries and the debug-store option is database, so that the compiler +# puts all debug info into a single .pdb file named after the library +# +# Poking at source targets this way is probably not clean, but it's the +# easiest approach. +rule archive ( targets + : sources * : properties * ) +{ + PDB_NAME on $(>) = $(<:S=.pdb) ; +} + +################################################################################ +# +# Classes. +# +################################################################################ + +class msvc-pch-generator : pch-generator +{ + import property-set ; + + rule run-pch ( project name ? : property-set : sources * ) + { + # Searching for the header and source file in the sources. + local pch-header ; + local pch-source ; + for local s in $(sources) + { + if [ type.is-derived [ $(s).type ] H ] + { + pch-header = $(s) ; + } + else if + [ type.is-derived [ $(s).type ] CPP ] || + [ type.is-derived [ $(s).type ] C ] + { + pch-source = $(s) ; + } + } + + if ! $(pch-header) + { + errors.user-error "can not build pch without pch-header" ; + } + + # If we do not have the PCH source - that is fine. We will just create a + # temporary .cpp file in the action. + + local generated = [ generator.run $(project) $(name) + : [ property-set.create + # Passing of is a dirty trick, needed because + # non-composing generators with multiple inputs are subtly + # broken. For more detailed information see: + # https://zigzag.cs.msu.su:7813/boost.build/ticket/111 + $(pch-source) + [ $(property-set).raw ] ] + : $(pch-header) ] ; + + local pch-file ; + for local g in $(generated) + { + if [ type.is-derived [ $(g).type ] PCH ] + { + pch-file = $(g) ; + } + } + + return [ property-set.create $(pch-header) + $(pch-file) ] $(generated) ; + } +} + + +################################################################################ +# +# Local rules. +# +################################################################################ + +# Detects versions listed as '.known-versions' by checking registry information, +# environment variables & default paths. Supports both native Windows and +# Cygwin. +# +local rule auto-detect-toolset-versions ( ) +{ + if [ os.name ] in NT CYGWIN + { + # Get installation paths from the registry. + for local i in $(.known-versions) + { + if $(.version-$(i)-reg) + { + local vc-path ; + for local x in "" "Wow6432Node\\" + { + vc-path += [ W32_GETREG + "HKEY_LOCAL_MACHINE\\SOFTWARE\\"$(x)"\\Microsoft\\"$(.version-$(i)-reg) + : "ProductDir" ] ; + } + + if $(vc-path) + { + vc-path = [ path.join [ path.make-NT $(vc-path[1]) ] "bin" ] ; + register-configuration $(i) : [ path.native $(vc-path[1]) ] ; + } + } + } + } + + # Check environment and default installation paths. + for local i in $(.known-versions) + { + if ! $(i) in [ $(.versions).all ] + { + register-configuration $(i) : [ default-path $(i) ] ; + } + } +} + + +# Worker rule for toolset version configuration. Takes an explicit version id or +# nothing in case it should configure the default toolset version (the first +# registered one or a new 'default' one in case no toolset versions have been +# registered yet). +# +local rule configure-really ( version ? : options * ) +{ + local v = $(version) ; + + # Decide what the 'default' version is. + if ! $(v) + { + # Take the first registered (i.e. auto-detected) version. + version = [ $(.versions).all ] ; + version = $(version[1]) ; + v = $(version) ; + + # Note: 'version' can still be empty at this point if no versions have + # been auto-detected. + version ?= "default" ; + } + + # Version alias -> real version number. + if $(.version-alias-$(version)) + { + version = $(.version-alias-$(version)) ; + } + + # Check whether the selected configuration is already in use. + if $(version) in [ $(.versions).used ] + { + # Allow multiple 'toolset.using' calls for the same configuration if the + # identical sets of options are used. + if $(options) && ( $(options) != [ $(.versions).get $(version) : options ] ) + { + errors.error "MSVC toolset configuration: Toolset version" + "'$(version)' already configured." ; + } + } + else + { + # Register a new configuration. + $(.versions).register $(version) ; + + # Add user-supplied to auto-detected options. + options = [ $(.versions).get $(version) : options ] $(options) ; + + # Mark the configuration as 'used'. + $(.versions).use $(version) ; + + # Generate conditions and save them. + local conditions = [ common.check-init-parameters msvc : version $(v) ] + ; + + $(.versions).set $(version) : conditions : $(conditions) ; + + local command = [ feature.get-values : $(options) ] ; + + # If version is specified, we try to search first in default paths, and + # only then in PATH. + command = [ common.get-invocation-command msvc : cl.exe : $(command) : + [ default-paths $(version) ] : $(version) ] ; + + common.handle-options msvc : $(conditions) : $(command) : $(options) ; + + if ! $(version) + { + # Even if version is not explicitly specified, try to detect the + # version from the path. + # FIXME: We currently detect both Microsoft Visual Studio 9.0 and + # 9.0express as 9.0 here. + if [ MATCH "(Microsoft Visual Studio 11)" : $(command) ] + { + version = 11.0 ; + } + else if [ MATCH "(Microsoft Visual Studio 10)" : $(command) ] + { + version = 10.0 ; + } + else if [ MATCH "(Microsoft Visual Studio 9)" : $(command) ] + { + version = 9.0 ; + } + else if [ MATCH "(Microsoft Visual Studio 8)" : $(command) ] + { + version = 8.0 ; + } + else if [ MATCH "(NET 2003[\/\\]VC7)" : $(command) ] + { + version = 7.1 ; + } + else if [ MATCH "(Microsoft Visual C\\+\\+ Toolkit 2003)" : + $(command) ] + { + version = 7.1toolkit ; + } + else if [ MATCH "(.NET[\/\\]VC7)" : $(command) ] + { + version = 7.0 ; + } + else + { + version = 6.0 ; + } + } + + # Generate and register setup command. + + local below-8.0 = [ MATCH ^([67]\\.) : $(version) ] ; + + local cpu = i386 amd64 ia64 ; + if $(below-8.0) + { + cpu = i386 ; + } + + local setup-amd64 ; + local setup-i386 ; + local setup-ia64 ; + + if $(command) + { + # TODO: Note that if we specify a non-existant toolset version then + # this rule may find and use a corresponding compiler executable + # belonging to an incorrect toolset version. For example, if you + # have only MSVC 7.1 installed, have its executable on the path and + # specify you want Boost Build to use MSVC 9.0, then you want Boost + # Build to report an error but this may cause it to silently use the + # MSVC 7.1 compiler even though it thinks it is using the msvc-9.0 + # toolset version. + command = [ common.get-absolute-tool-path $(command[-1]) ] ; + } + + if $(command) + { + local parent = [ path.make $(command) ] ; + parent = [ path.parent $(parent) ] ; + parent = [ path.native $(parent) ] ; + + # Setup will be used if the command name has been specified. If + # setup is not specified explicitly then a default setup script will + # be used instead. Setup scripts may be global or arhitecture/ + # /platform/cpu specific. Setup options are used only in case of + # global setup scripts. + + # Default setup scripts provided with different VC distributions: + # + # VC 7.1 had only the vcvars32.bat script specific to 32 bit i386 + # builds. It was located in the bin folder for the regular version + # and in the root folder for the free VC 7.1 tools. + # + # Later 8.0 & 9.0 versions introduce separate platform specific + # vcvars*.bat scripts (e.g. 32 bit, 64 bit AMD or 64 bit Itanium) + # located in or under the bin folder. Most also include a global + # vcvarsall.bat helper script located in the root folder which runs + # one of the aforementioned vcvars*.bat scripts based on the options + # passed to it. So far only the version coming with some PlatformSDK + # distributions does not include this top level script but to + # support those we need to fall back to using the worker scripts + # directly in case the top level script can not be found. + + local global-setup = [ feature.get-values : $(options) ] ; + global-setup = $(global-setup[1]) ; + if ! $(below-8.0) + { + global-setup ?= [ locate-default-setup $(command) : $(parent) : + vcvarsall.bat ] ; + } + + local default-setup-amd64 = vcvarsx86_amd64.bat ; + local default-setup-i386 = vcvars32.bat ; + local default-setup-ia64 = vcvarsx86_ia64.bat ; + + # http://msdn2.microsoft.com/en-us/library/x4d2c09s(VS.80).aspx and + # http://msdn2.microsoft.com/en-us/library/x4d2c09s(vs.90).aspx + # mention an x86_IPF option, that seems to be a documentation bug + # and x86_ia64 is the correct option. + local default-global-setup-options-amd64 = x86_amd64 ; + local default-global-setup-options-i386 = x86 ; + local default-global-setup-options-ia64 = x86_ia64 ; + + # When using 64-bit Windows, and targeting 64-bit, it is possible to + # use a native 64-bit compiler, selected by the "amd64" & "ia64" + # parameters to vcvarsall.bat. There are two variables we can use -- + # PROCESSOR_ARCHITECTURE and PROCESSOR_IDENTIFIER. The first is + # 'x86' when running 32-bit Windows, no matter which processor is + # used, and 'AMD64' on 64-bit windows on x86 (either AMD64 or EM64T) + # Windows. + # + if [ MATCH ^(AMD64) : [ os.environ PROCESSOR_ARCHITECTURE ] ] + { + default-global-setup-options-amd64 = amd64 ; + } + # TODO: The same 'native compiler usage' should be implemented for + # the Itanium platform by using the "ia64" parameter. For this + # though we need someone with access to this platform who can find + # out how to correctly detect this case. + else if $(somehow-detect-the-itanium-platform) + { + default-global-setup-options-ia64 = ia64 ; + } + + local setup-prefix = "call " ; + local setup-suffix = " >nul"$(.nl) ; + if ! [ os.name ] in NT + { + setup-prefix = "cmd.exe /S /C call " ; + setup-suffix = " \">nul\" \"&&\" " ; + } + + for local c in $(cpu) + { + local setup-options ; + + setup-$(c) = [ feature.get-values : $(options) ] ; + + if ! $(setup-$(c))-is-not-empty + { + if $(global-setup)-is-not-empty + { + setup-$(c) = $(global-setup) ; + + # If needed we can easily add using configuration flags + # here for overriding which options get passed to the + # global setup command for which target platform: + # setup-options = [ feature.get-values : $(options) ] ; + + setup-options ?= $(default-global-setup-options-$(c)) ; + } + else + { + setup-$(c) = [ locate-default-setup $(command) : $(parent) : $(default-setup-$(c)) ] ; + } + } + + # Cygwin to Windows path translation. + setup-$(c) = "\""$(setup-$(c):W)"\"" ; + + # Append setup options to the setup name and add the final setup + # prefix & suffix. + setup-options ?= "" ; + setup-$(c) = $(setup-prefix)$(setup-$(c):J=" ")" "$(setup-options:J=" ")$(setup-suffix) ; + } + } + + # Get tool names (if any) and finish setup. + + compiler = [ feature.get-values : $(options) ] ; + compiler ?= cl ; + + linker = [ feature.get-values : $(options) ] ; + linker ?= link ; + + resource-compiler = [ feature.get-values : $(options) ] ; + resource-compiler ?= rc ; + + # Turn on some options for i386 assembler + # -coff generate COFF format object file (compatible with cl.exe output) + local default-assembler-amd64 = ml64 ; + local default-assembler-i386 = "ml -coff" ; + local default-assembler-ia64 = ias ; + + assembler = [ feature.get-values : $(options) ] ; + + idl-compiler = [ feature.get-values : $(options) ] ; + idl-compiler ?= midl ; + + mc-compiler = [ feature.get-values : $(options) ] ; + mc-compiler ?= mc ; + + manifest-tool = [ feature.get-values : $(options) ] ; + manifest-tool ?= mt ; + + local cc-filter = [ feature.get-values : $(options) ] ; + + for local c in $(cpu) + { + # Setup script is not required in some configurations. + setup-$(c) ?= "" ; + + local cpu-conditions = $(conditions)/$(.cpu-arch-$(c)) ; + + if $(.debug-configuration) + { + for local cpu-condition in $(cpu-conditions) + { + ECHO "notice: [msvc-cfg] condition: '$(cpu-condition)', setup: '$(setup-$(c))'" ; + } + } + + local cpu-assembler = $(assembler) ; + cpu-assembler ?= $(default-assembler-$(c)) ; + + toolset.flags msvc.compile .CC $(cpu-conditions) : $(setup-$(c))$(compiler) /Zm800 -nologo ; + toolset.flags msvc.compile .RC $(cpu-conditions) : $(setup-$(c))$(resource-compiler) ; + toolset.flags msvc.compile .ASM $(cpu-conditions) : $(setup-$(c))$(cpu-assembler) -nologo ; + toolset.flags msvc.link .LD $(cpu-conditions) : $(setup-$(c))$(linker) /NOLOGO /INCREMENTAL:NO ; + toolset.flags msvc.archive .LD $(cpu-conditions) : $(setup-$(c))$(linker) /lib /NOLOGO ; + toolset.flags msvc.compile .IDL $(cpu-conditions) : $(setup-$(c))$(idl-compiler) ; + toolset.flags msvc.compile .MC $(cpu-conditions) : $(setup-$(c))$(mc-compiler) ; + + toolset.flags msvc.link .MT $(cpu-conditions) : $(setup-$(c))$(manifest-tool) -nologo ; + + if $(cc-filter) + { + toolset.flags msvc .CC.FILTER $(cpu-conditions) : "|" $(cc-filter) ; + } + } + + # Set version-specific flags. + configure-version-specific msvc : $(version) : $(conditions) ; + } +} + + +# Returns the default installation path for the given version. +# +local rule default-path ( version ) +{ + # Use auto-detected path if possible. + local path = [ feature.get-values : [ $(.versions).get $(version) + : options ] ] ; + + if $(path) + { + path = $(path:D) ; + } + else + { + # Check environment. + if $(.version-$(version)-env) + { + local vc-path = [ os.environ $(.version-$(version)-env) ] ; + if $(vc-path) + { + vc-path = [ path.make $(vc-path) ] ; + vc-path = [ path.join $(vc-path) $(.version-$(version)-envpath) ] ; + vc-path = [ path.native $(vc-path) ] ; + + path = $(vc-path) ; + } + } + + # Check default path. + if ! $(path) && $(.version-$(version)-path) + { + path = [ path.native [ path.join $(.ProgramFiles) $(.version-$(version)-path) ] ] ; + } + } + + return $(path) ; +} + + +# Returns either the default installation path (if 'version' is not empty) or +# list of all known default paths (if no version is given) +# +local rule default-paths ( version ? ) +{ + local possible-paths ; + + if $(version) + { + possible-paths += [ default-path $(version) ] ; + } + else + { + for local i in $(.known-versions) + { + possible-paths += [ default-path $(i) ] ; + } + } + + return $(possible-paths) ; +} + + +rule get-rspline ( target : lang-opt ) +{ + CC_RSPLINE on $(target) = [ on $(target) return $(lang-opt) -U$(UNDEFS) + $(CFLAGS) $(C++FLAGS) $(OPTIONS) -c $(.nl)-D$(DEFINES) + $(.nl)\"-I$(INCLUDES:W)\" ] ; +} + +class msvc-linking-generator : linking-generator +{ + # Calls the base version. If necessary, also create a target for the + # manifest file.specifying source's name as the name of the created + # target. As result, the PCH will be named whatever.hpp.gch, and not + # whatever.gch. + rule generated-targets ( sources + : property-set : project name ? ) + { + local result = [ linking-generator.generated-targets $(sources) + : $(property-set) : $(project) $(name) ] ; + + if $(result) + { + local name-main = [ $(result[0]).name ] ; + local action = [ $(result[0]).action ] ; + + if [ $(property-set).get ] = "on" + { + # We force exact name on PDB. The reason is tagging -- the tag rule may + # reasonably special case some target types, like SHARED_LIB. The tag rule + # will not catch PDB, and it cannot even easily figure if PDB is paired with + # SHARED_LIB or EXE or something else. Because PDB always get the + # same name as the main target, with .pdb as extension, just force it. + local target = [ class.new file-target $(name-main:S=.pdb) exact : PDB : $(project) : $(action) ] ; + local registered-target = [ virtual-target.register $(target) ] ; + if $(target) != $(registered-target) + { + $(action).replace-targets $(target) : $(registered-target) ; + } + result += $(registered-target) ; + } + + if [ $(property-set).get ] = "off" + { + # Manifest is evil target. It has .manifest appened to the name of + # main target, including extension. E.g. a.exe.manifest. We use 'exact' + # name because to achieve this effect. + local target = [ class.new file-target $(name-main).manifest exact : MANIFEST : $(project) : $(action) ] ; + local registered-target = [ virtual-target.register $(target) ] ; + if $(target) != $(registered-target) + { + $(action).replace-targets $(target) : $(registered-target) ; + } + result += $(registered-target) ; + } + } + return $(result) ; + } +} + + + +# Unsafe worker rule for the register-toolset() rule. Must not be called +# multiple times. +# +local rule register-toolset-really ( ) +{ + feature.extend toolset : msvc ; + + # Intel and msvc supposedly have link-compatible objects. + feature.subfeature toolset msvc : vendor : intel : propagated optional ; + + # Inherit MIDL flags. + toolset.inherit-flags msvc : midl ; + + # Inherit MC flags. + toolset.inherit-flags msvc : mc ; + + # Dynamic runtime comes only in MT flavour. + toolset.add-requirements + msvc,shared:multi ; + + # Declare msvc toolset specific features. + { + feature.feature debug-store : object database : propagated ; + feature.feature pch-source : : dependency free ; + } + + # Declare generators. + { + # TODO: Is it possible to combine these? Make the generators + # non-composing so that they do not convert each source into a separate + # .rsp file. + generators.register [ new msvc-linking-generator + msvc.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : msvc ] ; + generators.register [ new msvc-linking-generator + msvc.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : msvc ] ; + + generators.register-archiver msvc.archive : OBJ : STATIC_LIB : msvc ; + generators.register-c-compiler msvc.compile.c++ : CPP : OBJ : msvc ; + generators.register-c-compiler msvc.compile.c : C : OBJ : msvc ; + generators.register-c-compiler msvc.compile.c++.preprocess : CPP : PREPROCESSED_CPP : msvc ; + generators.register-c-compiler msvc.compile.c.preprocess : C : PREPROCESSED_C : msvc ; + + # Using 'register-c-compiler' adds the build directory to INCLUDES. + generators.register-c-compiler msvc.compile.rc : RC : OBJ(%_res) : msvc ; + generators.override msvc.compile.rc : rc.compile.resource ; + generators.register-standard msvc.compile.asm : ASM : OBJ : msvc ; + + generators.register-c-compiler msvc.compile.idl : IDL : MSTYPELIB H C(%_i) C(%_proxy) C(%_dlldata) : msvc ; + generators.override msvc.compile.idl : midl.compile.idl ; + + generators.register-standard msvc.compile.mc : MC : H RC : msvc ; + generators.override msvc.compile.mc : mc.compile ; + + # Note: the 'H' source type will catch both '.h' and '.hpp' headers as + # the latter have their HPP type derived from H. The type of compilation + # is determined entirely by the destination type. + generators.register [ new msvc-pch-generator msvc.compile.c.pch : H : C_PCH OBJ : on msvc ] ; + generators.register [ new msvc-pch-generator msvc.compile.c++.pch : H : CPP_PCH OBJ : on msvc ] ; + + generators.override msvc.compile.c.pch : pch.default-c-pch-generator ; + generators.override msvc.compile.c++.pch : pch.default-cpp-pch-generator ; + } + + toolset.flags msvc.compile PCH_FILE on : ; + toolset.flags msvc.compile PCH_SOURCE on : ; + toolset.flags msvc.compile PCH_HEADER on : ; + + # + # Declare flags for compilation. + # + + toolset.flags msvc.compile CFLAGS speed : /O2 ; + toolset.flags msvc.compile CFLAGS space : /O1 ; + + toolset.flags msvc.compile CFLAGS $(.cpu-arch-ia64)/$(.cpu-type-itanium) : /G1 ; + toolset.flags msvc.compile CFLAGS $(.cpu-arch-ia64)/$(.cpu-type-itanium2) : /G2 ; + + toolset.flags msvc.compile CFLAGS on/object : /Z7 ; + toolset.flags msvc.compile CFLAGS on/database : /Zi ; + toolset.flags msvc.compile CFLAGS off : /Od ; + toolset.flags msvc.compile CFLAGS off : /Ob0 ; + toolset.flags msvc.compile CFLAGS on : /Ob1 ; + toolset.flags msvc.compile CFLAGS full : /Ob2 ; + + toolset.flags msvc.compile CFLAGS on : /W3 ; + toolset.flags msvc.compile CFLAGS off : /W0 ; + toolset.flags msvc.compile CFLAGS all : /W4 ; + toolset.flags msvc.compile CFLAGS on : /WX ; + + toolset.flags msvc.compile C++FLAGS on/off/off : /EHs ; + toolset.flags msvc.compile C++FLAGS on/off/on : /EHsc ; + toolset.flags msvc.compile C++FLAGS on/on/off : /EHa ; + toolset.flags msvc.compile C++FLAGS on/on/on : /EHac ; + + # By default 8.0 enables rtti support while prior versions disabled it. We + # simply enable or disable it explicitly so we do not have to depend on this + # default behaviour. + toolset.flags msvc.compile CFLAGS on : /GR ; + toolset.flags msvc.compile CFLAGS off : /GR- ; + toolset.flags msvc.compile CFLAGS off/shared : /MD ; + toolset.flags msvc.compile CFLAGS on/shared : /MDd ; + + toolset.flags msvc.compile CFLAGS off/static/multi : /MT ; + toolset.flags msvc.compile CFLAGS on/static/multi : /MTd ; + + toolset.flags msvc.compile OPTIONS : ; + toolset.flags msvc.compile.c++ OPTIONS : ; + + toolset.flags msvc.compile PDB_CFLAG on/database : /Fd ; + + toolset.flags msvc.compile DEFINES ; + toolset.flags msvc.compile UNDEFS ; + toolset.flags msvc.compile INCLUDES ; + + # Declare flags for the assembler. + toolset.flags msvc.compile.asm USER_ASMFLAGS ; + + toolset.flags msvc.compile.asm ASMFLAGS on : "/Zi /Zd" ; + + toolset.flags msvc.compile.asm ASMFLAGS on : /W3 ; + toolset.flags msvc.compile.asm ASMFLAGS off : /W0 ; + toolset.flags msvc.compile.asm ASMFLAGS all : /W4 ; + toolset.flags msvc.compile.asm ASMFLAGS on : /WX ; + + toolset.flags msvc.compile.asm DEFINES ; + + # Declare flags for linking. + { + toolset.flags msvc.link PDB_LINKFLAG on/database : /PDB: ; # not used yet + toolset.flags msvc.link LINKFLAGS on : /DEBUG ; + toolset.flags msvc.link DEF_FILE ; + + # The linker disables the default optimizations when using /DEBUG so we + # have to enable them manually for release builds with debug symbols. + toolset.flags msvc LINKFLAGS on/off : /OPT:REF,ICF ; + + toolset.flags msvc LINKFLAGS console : /subsystem:console ; + toolset.flags msvc LINKFLAGS gui : /subsystem:windows ; + toolset.flags msvc LINKFLAGS wince : /subsystem:windowsce ; + toolset.flags msvc LINKFLAGS native : /subsystem:native ; + toolset.flags msvc LINKFLAGS auto : /subsystem:posix ; + + toolset.flags msvc.link OPTIONS ; + toolset.flags msvc.link LINKPATH ; + + toolset.flags msvc.link FINDLIBS_ST ; + toolset.flags msvc.link FINDLIBS_SA ; + toolset.flags msvc.link LIBRARY_OPTION msvc : "" : unchecked ; + toolset.flags msvc.link LIBRARIES_MENTIONED_BY_FILE : ; + } + + toolset.flags msvc.archive AROPTIONS ; +} + + +# Locates the requested setup script under the given folder and returns its full +# path or nothing in case the script can not be found. In case multiple scripts +# are found only the first one is returned. +# +# TODO: There used to exist a code comment for the msvc.init rule stating that +# we do not correctly detect the location of the vcvars32.bat setup script for +# the free VC7.1 tools in case user explicitly provides a path. This should be +# tested or simply remove this whole comment in case this toolset version is no +# longer important. +# +local rule locate-default-setup ( command : parent : setup-name ) +{ + local result = [ GLOB $(command) $(parent) : $(setup-name) ] ; + if $(result[1]) + { + return $(result[1]) ; + } +} + + +# Validates given path, registers found configuration and prints debug +# information about it. +# +local rule register-configuration ( version : path ? ) +{ + if $(path) + { + local command = [ GLOB $(path) : cl.exe ] ; + + if $(command) + { + if $(.debug-configuration) + { + ECHO "notice: [msvc-cfg] msvc-$(version) detected, command: '$(command)'" ; + } + + $(.versions).register $(version) ; + $(.versions).set $(version) : options : $(command) ; + } + } +} + + +################################################################################ +# +# Startup code executed when loading this module. +# +################################################################################ + +if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] +{ + .debug-configuration = true ; +} + +# Miscellaneous constants. +.RM = [ common.rm-command ] ; +.nl = " +" ; +.ProgramFiles = [ path.make [ common.get-program-files-dir ] ] ; +.escaped-double-quote = "\"" ; +.TOUCH_FILE = [ common.file-touch-command ] ; + +# List of all registered configurations. +.versions = [ new configurations ] ; + +# Supported CPU architectures. +.cpu-arch-i386 = + / + /32 + x86/ + x86/32 ; + +.cpu-arch-amd64 = + /64 + x86/64 ; + +.cpu-arch-ia64 = + ia64/ + ia64/64 ; + + +# Supported CPU types (only Itanium optimization options are supported from +# VC++ 2005 on). See +# http://msdn2.microsoft.com/en-us/library/h66s5s0e(vs.90).aspx for more +# detailed information. +.cpu-type-g5 = i586 pentium pentium-mmx ; +.cpu-type-g6 = i686 pentiumpro pentium2 pentium3 pentium3m pentium-m k6 + k6-2 k6-3 winchip-c6 winchip2 c3 c3-2 ; +.cpu-type-em64t = prescott nocona conroe conroe-xe conroe-l allendale mermon + mermon-xe kentsfield kentsfield-xe penryn wolfdale + yorksfield nehalem ; +.cpu-type-amd64 = k8 opteron athlon64 athlon-fx ; +.cpu-type-g7 = pentium4 pentium4m athlon athlon-tbird athlon-4 athlon-xp + athlon-mp $(.cpu-type-em64t) $(.cpu-type-amd64) ; +.cpu-type-itanium = itanium itanium1 merced ; +.cpu-type-itanium2 = itanium2 mckinley ; + + +# Known toolset versions, in order of preference. +.known-versions = 11.0 10.0 10.0express 9.0 9.0express 8.0 8.0express 7.1 7.1toolkit 7.0 6.0 ; + +# Version aliases. +.version-alias-6 = 6.0 ; +.version-alias-6.5 = 6.0 ; +.version-alias-7 = 7.0 ; +.version-alias-8 = 8.0 ; +.version-alias-9 = 9.0 ; +.version-alias-10 = 10.0 ; +.version-alias-11 = 11.0 ; + +# Names of registry keys containing the Visual C++ installation path (relative +# to "HKEY_LOCAL_MACHINE\SOFTWARE\\Microsoft"). +.version-6.0-reg = "VisualStudio\\6.0\\Setup\\Microsoft Visual C++" ; +.version-7.0-reg = "VisualStudio\\7.0\\Setup\\VC" ; +.version-7.1-reg = "VisualStudio\\7.1\\Setup\\VC" ; +.version-8.0-reg = "VisualStudio\\8.0\\Setup\\VC" ; +.version-8.0express-reg = "VCExpress\\8.0\\Setup\\VC" ; +.version-9.0-reg = "VisualStudio\\9.0\\Setup\\VC" ; +.version-9.0express-reg = "VCExpress\\9.0\\Setup\\VC" ; +.version-10.0-reg = "VisualStudio\\10.0\\Setup\\VC" ; +.version-10.0express-reg = "VCExpress\\10.0\\Setup\\VC" ; +.version-11.0-reg = "VisualStudio\\11.0\\Setup\\VC" ; + +# Visual C++ Toolkit 2003 does not store its installation path in the registry. +# The environment variable 'VCToolkitInstallDir' and the default installation +# path will be checked instead. +.version-7.1toolkit-path = "Microsoft Visual C++ Toolkit 2003" "bin" ; +.version-7.1toolkit-env = VCToolkitInstallDir ; + +# Path to the folder containing "cl.exe" relative to the value of the +# corresponding environment variable. +.version-7.1toolkit-envpath = "bin" ; + + +# Auto-detect all the available msvc installations on the system. +auto-detect-toolset-versions ; + + +# And finally trigger the actual Boost Build toolset registration. +register-toolset ; diff --git a/mosesdecoder/jam-files/boost-build/tools/notfile.jam b/mosesdecoder/jam-files/boost-build/tools/notfile.jam new file mode 100644 index 0000000000000000000000000000000000000000..97a5b0e876acbcb3aaf17373b78ea50bc13531f8 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/notfile.jam @@ -0,0 +1,74 @@ +# Copyright (c) 2005 Vladimir Prus. +# +# Use, modification and distribution is subject to the Boost Software +# License Version 1.0. (See accompanying file LICENSE_1_0.txt or +# http://www.boost.org/LICENSE_1_0.txt) + +import "class" : new ; +import generators ; +import project ; +import targets ; +import toolset ; +import type ; + + +type.register NOTFILE_MAIN ; + + +class notfile-generator : generator +{ + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule run ( project name ? : property-set : sources * : multiple ? ) + { + local action ; + local action-name = [ $(property-set).get ] ; + + local m = [ MATCH ^@(.*) : $(action-name) ] ; + + if $(m) + { + action = [ new action $(sources) : $(m[1]) + : $(property-set) ] ; + } + else + { + action = [ new action $(sources) : notfile.run + : $(property-set) ] ; + } + return [ virtual-target.register + [ new notfile-target $(name) : $(project) : $(action) ] ] ; + } +} + + +generators.register [ new notfile-generator notfile.main : : NOTFILE_MAIN ] ; + + +toolset.flags notfile.run ACTION : ; + + +actions run +{ + $(ACTION) +} + + +rule notfile ( target-name : action + : sources * : requirements * : default-build * ) +{ + local project = [ project.current ] ; + + requirements += $(action) ; + + targets.main-target-alternative + [ new typed-target $(target-name) : $(project) : NOTFILE_MAIN + : [ targets.main-target-sources $(sources) : $(target-name) ] + : [ targets.main-target-requirements $(requirements) : $(project) ] + : [ targets.main-target-default-build $(default-build) : $(project) ] + ] ; +} + +IMPORT $(__name__) : notfile : : notfile ; diff --git a/mosesdecoder/jam-files/boost-build/tools/pathscale.jam b/mosesdecoder/jam-files/boost-build/tools/pathscale.jam new file mode 100644 index 0000000000000000000000000000000000000000..454e34547eddce9a008b48e05439f0c8f278bc6d --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/pathscale.jam @@ -0,0 +1,168 @@ +# Copyright 2006 Noel Belcourt +# 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 property ; +import generators ; +import toolset : flags ; +import feature ; +import type ; +import common ; +import fortran ; + +feature.extend toolset : pathscale ; +toolset.inherit pathscale : unix ; +generators.override pathscale.prebuilt : builtin.prebuilt ; +generators.override pathscale.searched-lib-generator : searched-lib-generator ; + +# Documentation and toolchain description located +# http://www.pathscale.com/docs.html + +rule init ( version ? : command * : options * ) +{ + command = [ common.get-invocation-command pathscale : pathCC : $(command) + : /opt/ekopath/bin ] ; + + # Determine the version + local command-string = $(command:J=" ") ; + if $(command) + { + version ?= [ MATCH "^([0-9.]+)" + : [ SHELL "$(command-string) -dumpversion" ] ] ; + } + + local condition = [ common.check-init-parameters pathscale + : version $(version) ] ; + + common.handle-options pathscale : $(condition) : $(command) : $(options) ; + + toolset.flags pathscale.compile.fortran90 OPTIONS $(condition) : + [ feature.get-values : $(options) ] : unchecked ; + + command_c = $(command_c[1--2]) $(command[-1]:B=pathcc) ; + + toolset.flags pathscale CONFIG_C_COMMAND $(condition) : $(command_c) ; + + # fortran support + local f-command = [ common.get-invocation-command pathscale : pathf90 : $(command) ] ; + local command_f = $(command_f[1--2]) $(f-command[-1]:B=pathf90) ; + local command_f90 = $(command_f[1--2]) $(f-command[-1]:B=pathf90) ; + + toolset.flags pathscale CONFIG_F_COMMAND $(condition) : $(command_f) ; + toolset.flags pathscale CONFIG_F90_COMMAND $(condition) : $(command_f90) ; + + # always link lib rt to resolve clock_gettime() + flags pathscale.link FINDLIBS-SA : rt : unchecked ; +} + +# Declare generators +generators.register-c-compiler pathscale.compile.c : C : OBJ : pathscale ; +generators.register-c-compiler pathscale.compile.c++ : CPP : OBJ : pathscale ; +generators.register-fortran-compiler pathscale.compile.fortran : FORTRAN : OBJ : pathscale ; +generators.register-fortran90-compiler pathscale.compile.fortran90 : FORTRAN90 : OBJ : pathscale ; + +# Declare flags and actions for compilation +flags pathscale.compile OPTIONS off : -O0 ; +flags pathscale.compile OPTIONS speed : -O3 ; +flags pathscale.compile OPTIONS space : -Os ; + +flags pathscale.compile OPTIONS off : -noinline ; +flags pathscale.compile OPTIONS on : -inline ; +flags pathscale.compile OPTIONS full : -inline ; + +flags pathscale.compile OPTIONS off : -woffall ; +flags pathscale.compile OPTIONS on : -Wall ; +flags pathscale.compile OPTIONS all : -Wall -pedantic ; +flags pathscale.compile OPTIONS on : -Werror ; + +flags pathscale.compile OPTIONS on : -ggdb ; +flags pathscale.compile OPTIONS on : -pg ; +flags pathscale.compile OPTIONS shared : -fPIC ; +flags pathscale.compile OPTIONS 32 : -m32 ; +flags pathscale.compile OPTIONS 64 : -m64 ; + +flags pathscale.compile USER_OPTIONS ; +flags pathscale.compile.c++ USER_OPTIONS ; +flags pathscale.compile DEFINES ; +flags pathscale.compile INCLUDES ; + +flags pathscale.compile.fortran USER_OPTIONS ; +flags pathscale.compile.fortran90 USER_OPTIONS ; + +actions compile.c +{ + "$(CONFIG_C_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +actions compile.c++ +{ + "$(CONFIG_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +actions compile.fortran +{ + "$(CONFIG_F_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +rule compile.fortran90 ( targets * : sources * : properties * ) +{ + # the space rule inserts spaces between targets and it's necessary + SPACE on $(targets) = " " ; + # Serialize execution of the compile.fortran90 action + # F90 source must be compiled in a particular order so we + # serialize the build as a parallel F90 compile might fail + JAM_SEMAPHORE on $(targets) = pathscale-f90-semaphore ; +} + +actions compile.fortran90 +{ + "$(CONFIG_F90_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -module $(<[1]:D) -c -o "$(<)" "$(>)" +} + +# Declare flags and actions for linking +flags pathscale.link OPTIONS on : -ggdb -rdynamic ; +# Strip the binary when no debugging is needed +flags pathscale.link OPTIONS off : -g0 ; +flags pathscale.link OPTIONS on : -pg ; +flags pathscale.link USER_OPTIONS ; +flags pathscale.link LINKPATH ; +flags pathscale.link FINDLIBS-ST ; +flags pathscale.link FINDLIBS-SA ; +flags pathscale.link FINDLIBS-SA multi : pthread ; +flags pathscale.link LIBRARIES ; +flags pathscale.link LINK-RUNTIME static : static ; +flags pathscale.link LINK-RUNTIME shared : dynamic ; +flags pathscale.link RPATH ; +# On gcc, there are separate options for dll path at runtime and +# link time. On Solaris, there's only one: -R, so we have to use +# it, even though it's bad idea. +flags pathscale.link RPATH ; + +rule link ( targets * : sources * : properties * ) +{ + SPACE on $(targets) = " " ; +} + +actions link bind LIBRARIES +{ + "$(CONFIG_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) +} + +# Slight mods for dlls +rule link.dll ( targets * : sources * : properties * ) +{ + SPACE on $(targets) = " " ; +} + +actions link.dll bind LIBRARIES +{ + "$(CONFIG_COMMAND)" $(OPTIONS) $(USER_OPTIONS) -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-soname$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) +} + +# Declare action for creating static libraries +# "$(CONFIG_COMMAND)" -ar -o "$(<)" "$(>)" +actions piecemeal archive +{ + ar $(ARFLAGS) ru "$(<)" "$(>)" +} diff --git a/mosesdecoder/jam-files/boost-build/tools/pch.jam b/mosesdecoder/jam-files/boost-build/tools/pch.jam new file mode 100644 index 0000000000000000000000000000000000000000..0c6e98fac747e0ec84eeb4a52bf7881ed687cc20 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/pch.jam @@ -0,0 +1,95 @@ +# Copyright (c) 2005 Reece H. Dunn. +# Copyright 2006 Ilya Sokolov +# +# Use, modification and distribution is subject to the Boost Software +# License Version 1.0. (See accompanying file LICENSE_1_0.txt or +# http://www.boost.org/LICENSE_1_0.txt) + +##### Using Precompiled Headers (Quick Guide) ##### +# +# Make precompiled mypch.hpp: +# +# import pch ; +# +# cpp-pch mypch +# : # sources +# mypch.hpp +# : # requiremnts +# msvc:mypch.cpp +# ; +# +# Add cpp-pch to sources: +# +# exe hello +# : main.cpp hello.cpp mypch +# ; + +import "class" : new ; +import type ; +import feature ; +import generators ; + +type.register PCH : pch ; + +type.register C_PCH : : PCH ; +type.register CPP_PCH : : PCH ; + +# Control precompiled header (PCH) generation. +feature.feature pch : + on + off + : propagated ; + + +feature.feature pch-header : : free dependency ; +feature.feature pch-file : : free dependency ; + +# Base PCH generator. The 'run' method has the logic to prevent this generator +# from being run unless it's being used for a top-level PCH target. +class pch-generator : generator +{ + import property-set ; + + rule action-class ( ) + { + return compile-action ; + } + + rule run ( project name ? : property-set : sources + ) + { + if ! $(name) + { + # Unless this generator is invoked as the top-most generator for a + # main target, fail. This allows using 'H' type as input type for + # this generator, while preventing Boost.Build to try this generator + # when not explicitly asked for. + # + # One bad example is msvc, where pch generator produces both PCH + # target and OBJ target, so if there's any header generated (like by + # bison, or by msidl), we'd try to use pch generator to get OBJ from + # that H, which is completely wrong. By restricting this generator + # only to pch main target, such problem is solved. + } + else + { + local r = [ run-pch $(project) $(name) + : [ $(property-set).add-raw BOOST_BUILD_PCH_ENABLED ] + : $(sources) ] ; + return [ generators.add-usage-requirements $(r) + : BOOST_BUILD_PCH_ENABLED ] ; + } + } + + # This rule must be overridden by the derived classes. + rule run-pch ( project name ? : property-set : sources + ) + { + } +} + + +# NOTE: requirements are empty, default pch generator can be applied when +# pch=off. +generators.register + [ new dummy-generator pch.default-c-pch-generator : : C_PCH ] ; +generators.register + [ new dummy-generator pch.default-cpp-pch-generator : : CPP_PCH ] ; diff --git a/mosesdecoder/jam-files/boost-build/tools/qt.jam b/mosesdecoder/jam-files/boost-build/tools/qt.jam new file mode 100644 index 0000000000000000000000000000000000000000..8aa7ca266c52a5e40d2bcac87c184ed7a67a12ae --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/qt.jam @@ -0,0 +1,17 @@ +# Copyright (c) 2006 Vladimir Prus. +# +# Use, modification and distribution is subject to the Boost Software +# License Version 1.0. (See accompanying file LICENSE_1_0.txt or +# http://www.boost.org/LICENSE_1_0.txt) + +# Forwarning toolset file to Qt GUI library. Forwards to the toolset file +# for the current version of Qt. + +import qt4 ; + +rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : condition * ) +{ + qt4.init $(prefix) : $(full_bin) : $(full_inc) : $(full_lib) : $(version) : $(condition) ; +} + + diff --git a/mosesdecoder/jam-files/boost-build/tools/qt3.jam b/mosesdecoder/jam-files/boost-build/tools/qt3.jam new file mode 100644 index 0000000000000000000000000000000000000000..f82cf0ac3393268e7ddb8cf331372107c7cb73de --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/qt3.jam @@ -0,0 +1,209 @@ +# Copyright 2006 Vladimir Prus +# 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) + +# Support for the Qt GUI library version 3 +# (http://www.trolltech.com/products/qt3/index.html). +# For new developments, it is recommended to use Qt4 via the qt4 Boost.Build +# module. + +import modules ; +import feature ; +import errors ; +import type ; +import "class" : new ; +import generators ; +import project ; +import toolset : flags ; + +# Convert this module into a project, so that we can declare targets here. +project.initialize $(__name__) ; +project qt3 ; + + +# Initialized the QT support module. The 'prefix' parameter tells where QT is +# installed. When not given, environmental variable QTDIR should be set. +# +rule init ( prefix ? ) +{ + if ! $(prefix) + { + prefix = [ modules.peek : QTDIR ] ; + if ! $(prefix) + { + errors.error + "QT installation prefix not given and QTDIR variable is empty" ; + } + } + + if $(.initialized) + { + if $(prefix) != $(.prefix) + { + errors.error + "Attempt the reinitialize QT with different installation prefix" ; + } + } + else + { + .initialized = true ; + .prefix = $(prefix) ; + + generators.register-standard qt3.moc : H : CPP(moc_%) : qt3 ; + # Note: the OBJ target type here is fake, take a look at + # qt4.jam/uic-h-generator for explanations that apply in this case as + # well. + generators.register [ new moc-h-generator-qt3 + qt3.moc.cpp : MOCCABLE_CPP : OBJ : qt3 ] ; + + # The UI type is defined in types/qt.jam, and UIC_H is only used in + # qt.jam, but not in qt4.jam, so define it here. + type.register UIC_H : : H ; + + generators.register-standard qt3.uic-h : UI : UIC_H : qt3 ; + + # The following generator is used to convert UI files to CPP. It creates + # UIC_H from UI, and constructs CPP from UI/UIC_H. In addition, it also + # returns UIC_H target, so that it can be mocced. + class qt::uic-cpp-generator : generator + { + rule __init__ ( ) + { + generator.__init__ qt3.uic-cpp : UI UIC_H : CPP : qt3 ; + } + + rule run ( project name ? : properties * : sources + ) + { + # Consider this: + # obj test : test_a.cpp : off ; + # + # This generator will somehow be called in this case, and, + # will fail -- which is okay. However, if there are + # properties they will be converted to sources, so the size of + # 'sources' will be more than 1. In this case, the base generator + # will just crash -- and that's not good. Just use a quick test + # here. + + local result ; + if ! $(sources[2]) + { + # Construct CPP as usual + result = [ generator.run $(project) $(name) + : $(properties) : $(sources) ] ; + + # If OK, process UIC_H with moc. It's pretty clear that + # the object generated with UIC will have Q_OBJECT macro. + if $(result) + { + local action = [ $(result[1]).action ] ; + local sources = [ $(action).sources ] ; + local mocced = [ generators.construct $(project) $(name) + : CPP : $(properties) : $(sources[2]) ] ; + result += $(mocced[2-]) ; + } + } + + return $(result) ; + } + } + + generators.register [ new qt::uic-cpp-generator ] ; + + # Finally, declare prebuilt target for QT library. + local usage-requirements = + $(.prefix)/include + $(.prefix)/lib + $(.prefix)/lib + qt3 + ; + lib qt : : qt-mt multi : : $(usage-requirements) ; + lib qt : : qt single : : $(usage-requirements) ; + } +} + +class moc-h-generator-qt3 : generator +{ + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule run ( project name ? : property-set : sources * ) + { + if ! $(sources[2]) && [ $(sources[1]).type ] = MOCCABLE_CPP + { + name = [ $(sources[1]).name ] ; + name = $(name:B) ; + + local a = [ new action $(sources[1]) : qt3.moc.cpp : + $(property-set) ] ; + + local target = [ + new file-target $(name) : MOC : $(project) : $(a) ] ; + + local r = [ virtual-target.register $(target) ] ; + + # Since this generator will return a H target, the linking generator + # won't use it at all, and won't set any dependency on it. However, + # we need the target to be seen by bjam, so that the dependency from + # sources to this generated header is detected -- if Jam does not + # know about this target, it won't do anything. + DEPENDS all : [ $(r).actualize ] ; + + return $(r) ; + } + } +} + + +# Query the installation directory. This is needed in at least two scenarios. +# First, when re-using sources from the Qt-Tree. Second, to "install" custom Qt +# plugins to the Qt-Tree. +# +rule directory +{ + return $(.prefix) ; +} + +# -f forces moc to include the processed source file. Without it, it would think +# that .qpp is not a header and would not include it from the generated file. +# +actions moc +{ + $(.prefix)/bin/moc -f $(>) -o $(<) +} + +# When moccing .cpp files, we don't need -f, otherwise generated code will +# include .cpp and we'll get duplicated symbols. +# +actions moc.cpp +{ + $(.prefix)/bin/moc $(>) -o $(<) +} + + +space = " " ; + +# Sometimes it's required to make 'plugins' available during uic invocation. To +# help with this we add paths to all dependency libraries to uic commane line. +# The intention is that it's possible to write +# +# exe a : ... a.ui ... : some_plugin ; +# +# and have everything work. We'd add quite a bunch of unrelated paths but it +# won't hurt. +# +flags qt3.uic-h LIBRARY_PATH ; +actions uic-h +{ + $(.prefix)/bin/uic $(>) -o $(<) -L$(space)$(LIBRARY_PATH) +} + + +flags qt3.uic-cpp LIBRARY_PATH ; +# The second target is uic-generated header name. It's placed in build dir, but +# we want to include it using only basename. +actions uic-cpp +{ + $(.prefix)/bin/uic $(>[1]) -i $(>[2]:D=) -o $(<) -L$(space)$(LIBRARY_PATH) +} diff --git a/mosesdecoder/jam-files/boost-build/tools/qt4.jam b/mosesdecoder/jam-files/boost-build/tools/qt4.jam new file mode 100644 index 0000000000000000000000000000000000000000..71d1b7620718d86ed52ad314b3c94e51d691c67e --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/qt4.jam @@ -0,0 +1,724 @@ +# Copyright 2002-2006 Vladimir Prus +# Copyright 2005 Alo Sarv +# Copyright 2005-2009 Juergen Hunold +# +# 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) + +# Qt4 library support module +# +# The module attempts to auto-detect QT installation location from QTDIR +# environment variable; failing that, installation location can be passed as +# argument: +# +# toolset.using qt4 : /usr/local/Trolltech/Qt-4.0.0 ; +# +# The module supports code generation from .ui and .qrc files, as well as +# running the moc preprocessor on headers. Note that you must list all your +# moc-able headers in sources. +# +# Example: +# +# exe myapp : myapp.cpp myapp.h myapp.ui myapp.qrc +# /qt4//QtGui /qt4//QtNetwork ; +# +# It's also possible to run moc on cpp sources: +# +# import cast ; +# +# exe myapp : myapp.cpp [ cast _ moccable-cpp : myapp.cpp ] /qt4//QtGui ; +# +# When moccing source file myapp.cpp you need to include "myapp.moc" from +# myapp.cpp. When moccing .h files, the output of moc will be automatically +# compiled and linked in, you don't need any includes. +# +# This is consistent with Qt guidelines: +# http://doc.trolltech.com/4.0/moc.html + +import modules ; +import feature ; +import errors ; +import type ; +import "class" : new ; +import generators ; +import project ; +import toolset : flags ; +import os ; +import virtual-target ; +import scanner ; + +# Qt3Support control feature +# +# Qt4 configure defaults to build Qt4 libraries with Qt3Support. +# The autodetection is missing, so we default to disable Qt3Support. +# This prevents the user from inadvertedly using a deprecated API. +# +# The Qt3Support library can be activated by adding +# "on" to requirements +# +# Use "on:QT3_SUPPORT_WARNINGS" +# to get warnings about deprecated Qt3 support funtions and classes. +# Files ported by the "qt3to4" conversion tool contain _tons_ of +# warnings, so this define is not set as default. +# +# Todo: Detect Qt3Support from Qt's configure data. +# Or add more auto-configuration (like python). +feature.feature qt3support : off on : propagated link-incompatible ; + +# The Qt version used for requirements +# Valid are 4.4 or 4.5.0 +# Auto-detection via qmake sets 'major.minor.patch' +feature.feature qt : : propagated ; + +project.initialize $(__name__) ; +project qt ; + +# Save the project so that we tolerate 'import + using' combo. +.project = [ project.current ] ; + +# Helper utils for easy debug output +if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] +{ + .debug-configuration = TRUE ; +} + +local rule debug-message ( message * ) +{ + if $(.debug-configuration) = TRUE + { + ECHO notice: [qt4-cfg] $(message) ; + } +} + +# Capture qmake output line by line +local rule read-output ( content ) +{ + local lines ; + local nl = " +" ; + local << = "([^$(nl)]*)[$(nl)](.*)" ; + local line+ = [ MATCH "$(<<)" : "$(content)" ] ; + while $(line+) + { + lines += $(line+[1]) ; + line+ = [ MATCH "$(<<)" : "$(line+[2])" ] ; + } + return $(lines) ; +} + +# Capture Qt version from qmake +local rule check-version ( bin_prefix ) +{ + full-cmd = $(bin_prefix)"/qmake -v" ; + debug-message Running '$(full-cmd)' ; + local output = [ SHELL $(full-cmd) ] ; + for line in [ read-output $(output) ] + { + # Parse the output to get all the results. + if [ MATCH "QMake" : $(line) ] + { + # Skip first line of output + } + else + { + temp = [ MATCH "([0-9]*)\\.([0-9]*)\\.([0-9]*)" : $(line) ] ; + } + } + return $(temp) ; +} + +# Validate the version string and extract the major/minor part we care about. +# +local rule split-version ( version ) +{ + local major-minor = [ MATCH ^([0-9]+)\.([0-9]+)(.*)$ : $(version) : 1 2 3 ] ; + if ! $(major-minor[2]) || $(major-minor[3]) + { + ECHO "Warning: 'using qt' expects a two part (major, minor) version number; got" $(version) instead ; + + # Add a zero to account for the missing digit if necessary. + major-minor += 0 ; + } + + return $(major-minor[1]) $(major-minor[2]) ; +} + +# Initialize the QT support module. +# Parameters: +# - 'prefix' parameter tells where Qt is installed. +# - 'full_bin' optional full path to Qt binaries (qmake,moc,uic,rcc) +# - 'full_inc' optional full path to Qt top-level include directory +# - 'full_lib' optional full path to Qt library directory +# - 'version' optional version of Qt, else autodetected via 'qmake -v' +# - 'condition' optional requirements +rule init ( prefix : full_bin ? : full_inc ? : full_lib ? : version ? : condition * ) +{ + project.push-current $(.project) ; + + debug-message "==== Configuring Qt ... ====" ; + for local v in version cmd-or-prefix includes libraries condition + { + if $($(v)) + { + debug-message " user-specified "$(v): '$($(v))' ; + } + } + + # Needed as default value + .prefix = $(prefix) ; + + # pre-build paths to detect reinitializations changes + local inc_prefix lib_prefix bin_prefix ; + if $(full_inc) + { + inc_prefix = $(full_inc) ; + } + else + { + inc_prefix = $(prefix)/include ; + } + if $(full_lib) + { + lib_prefix = $(full_lib) ; + } + else + { + lib_prefix = $(prefix)/lib ; + } + if $(full_bin) + { + bin_prefix = $(full_bin) ; + } + else + { + bin_prefix = $(prefix)/bin ; + } + + # Globally needed variables + .incprefix = $(inc_prefix) ; + .libprefix = $(lib_prefix) ; + .binprefix = $(bin_prefix) ; + + if ! $(.initialized) + { + # Make sure this is initialised only once + .initialized = true ; + + # Generates cpp files from header files using "moc" tool + generators.register-standard qt4.moc : H : CPP(moc_%) : qt4 ; + + # The OBJ result type is a fake, 'H' will be really produced. See + # comments on the generator class, defined below the 'init' function. + generators.register [ new uic-generator qt4.uic : UI : OBJ : + qt4 ] ; + + # The OBJ result type is a fake here too. + generators.register [ new moc-h-generator + qt4.moc.inc : MOCCABLE_CPP : OBJ : qt4 ] ; + + generators.register [ new moc-inc-generator + qt4.moc.inc : MOCCABLE_H : OBJ : qt4 ] ; + + # Generates .cpp files from .qrc files. + generators.register-standard qt4.rcc : QRC : CPP(qrc_%) ; + + # dependency scanner for wrapped files. + type.set-scanner QRC : qrc-scanner ; + + # Save value of first occuring prefix + .PREFIX = $(prefix) ; + } + + if $(version) + { + major-minor = [ split-version $(version) ] ; + version = $(major-minor:J=.) ; + } + else + { + version = [ check-version $(bin_prefix) ] ; + if $(version) + { + version = $(version:J=.) ; + } + debug-message Detected version '$(version)' ; + } + + local target-requirements = $(condition) ; + + # Add the version, if any, to the target requirements. + if $(version) + { + if ! $(version) in [ feature.values qt ] + { + feature.extend qt : $(version) ; + } + target-requirements += $(version:E=default) ; + } + + local target-os = [ feature.get-values target-os : $(condition) ] ; + if ! $(target-os) + { + target-os ?= [ feature.defaults target-os ] ; + target-os = $(target-os:G=) ; + target-requirements += $(target-os) ; + } + + # Build exact requirements for the tools + local tools-requirements = $(target-requirements:J=/) ; + + debug-message "Details of this Qt configuration:" ; + debug-message " prefix: " '$(prefix:E=)' ; + debug-message " binary path: " '$(bin_prefix:E=)' ; + debug-message " include path:" '$(inc_prefix:E=)' ; + debug-message " library path:" '$(lib_prefix:E=)' ; + debug-message " target requirements:" '$(target-requirements)' ; + debug-message " tool requirements: " '$(tools-requirements)' ; + + # setup the paths for the tools + toolset.flags qt4.moc .BINPREFIX $(tools-requirements) : $(bin_prefix) ; + toolset.flags qt4.rcc .BINPREFIX $(tools-requirements) : $(bin_prefix) ; + toolset.flags qt4.uic .BINPREFIX $(tools-requirements) : $(bin_prefix) ; + + # TODO: 2009-02-12: Better support for directories + # Most likely needed are separate getters for: include,libraries,binaries and sources. + toolset.flags qt4.directory .PREFIX $(tools-requirements) : $(prefix) ; + + # Test for a buildable Qt. + if [ glob $(.prefix)/Jamroot ] + { + .bjam-qt = true + + # this will declare QtCore (and qtmain on windows) + add-shared-library QtCore ; + } + else + # Setup common pre-built Qt. + # Special setup for QtCore on which everything depends + { + local usage-requirements = + $(.incprefix) + $(.libprefix) + $(.libprefix) + multi + qt4 ; + + local suffix ; + + # Since Qt-4.2, debug versions on unix have to be built + # separately and therefore have no suffix. + .suffix_version = "" ; + .suffix_debug = "" ; + + # Control flag for auto-configuration of the debug libraries. + # This setup requires Qt 'configure -debug-and-release'. + # Only available on some platforms. + # ToDo: 2009-02-12: Maybe throw this away and + # require separate setup with debug as condition. + .have_separate_debug = FALSE ; + + # Setup other platforms + if $(target-os) in windows cygwin + { + .have_separate_debug = TRUE ; + + # On NT, the libs have "4" suffix, and "d" suffix in debug builds. + .suffix_version = "4" ; + .suffix_debug = "d" ; + + # On Windows we must link against the qtmain library + lib qtmain + : # sources + : # requirements + qtmain$(.suffix_debug) + debug + $(target-requirements) + ; + + lib qtmain + : # sources + : # requirements + qtmain + $(target-requirements) + ; + } + else if $(target-os) = darwin + { + # On MacOS X, both debug and release libraries are available. + .suffix_debug = "_debug" ; + + .have_separate_debug = TRUE ; + + alias qtmain ; + } + else + { + alias qtmain : : $(target-requirements) ; + } + + lib QtCore : qtmain + : # requirements + QtCore$(.suffix_version) + $(target-requirements) + : # default-build + : # usage-requirements + QT_CORE_LIB + QT_NO_DEBUG + $(.incprefix)/QtCore + $(usage-requirements) + ; + + if $(.have_separate_debug) = TRUE + { + debug-message Configure debug libraries with suffix '$(.suffix_debug)' ; + + lib QtCore : $(main) + : # requirements + QtCore$(.suffix_debug)$(.suffix_version) + debug + $(target-requirements) + : # default-build + : # usage-requirements + QT_CORE_LIB + $(.incprefix)/QtCore + $(usage-requirements) + ; + } + } + + # Initialising the remaining libraries is canonical + # parameters 'module' : 'depends-on' : 'usage-define' : 'requirements' : 'include' + # 'include' only for non-canonical include paths. + add-shared-library QtGui : QtCore : QT_GUI_LIB : $(target-requirements) ; + add-shared-library QtNetwork : QtCore : QT_NETWORK_LIB : $(target-requirements) ; + add-shared-library QtSql : QtCore : QT_SQL_LIB : $(target-requirements) ; + add-shared-library QtXml : QtCore : QT_XML_LIB : $(target-requirements) ; + + add-shared-library Qt3Support : QtGui QtNetwork QtXml QtSql + : QT_QT3SUPPORT_LIB QT3_SUPPORT + : on $(target-requirements) ; + + # Dummy target to enable "off" and + # "/qt//Qt3Support" at the same time. This enables quick + # switching from one to the other for test/porting purposes. + alias Qt3Support : : off $(target-requirements) ; + + # OpenGl Support + add-shared-library QtOpenGL : QtGui : QT_OPENGL_LIB : $(target-requirements) ; + + # SVG-Support (Qt 4.1) + add-shared-library QtSvg : QtXml QtOpenGL : QT_SVG_LIB : $(target-requirements) ; + + # Test-Support (Qt 4.1) + add-shared-library QtTest : QtCore : : $(target-requirements) ; + + # Qt designer library + add-shared-library QtDesigner : QtGui QtXml : : $(target-requirements) ; + add-shared-library QtDesignerComponents : QtGui QtXml : : $(target-requirements) ; + + # Support for dynamic Widgets (Qt 4.1) + add-static-library QtUiTools : QtGui QtXml : $(target-requirements) ; + + # DBus-Support (Qt 4.2) + add-shared-library QtDBus : QtXml : : $(target-requirements) ; + + # Script-Engine (Qt 4.3) + add-shared-library QtScript : QtGui QtXml : QT_SCRIPT_LIB : $(target-requirements) ; + + # Tools for the Script-Engine (Qt 4.5) + add-shared-library QtScriptTools : QtScript : QT_SCRIPTTOOLS_LIB : $(target-requirements) ; + + # WebKit (Qt 4.4) + add-shared-library QtWebKit : QtGui : QT_WEBKIT_LIB : $(target-requirements) ; + + # Phonon Multimedia (Qt 4.4) + add-shared-library phonon : QtGui QtXml : QT_PHONON_LIB : $(target-requirements) ; + + # Multimedia engine (Qt 4.6) + add-shared-library QtMultimedia : QtGui : QT_MULTIMEDIA_LIB : $(target-requirements) ; + + # XmlPatterns-Engine (Qt 4.4) + add-shared-library QtXmlPatterns : QtNetwork : QT_XMLPATTERNS_LIB : $(target-requirements) ; + + # Help-Engine (Qt 4.4) + add-shared-library QtHelp : QtGui QtSql QtXml : : $(target-requirements) ; + add-shared-library QtCLucene : QCore QtSql QtXml : : $(target-requirements) ; + + # QML-Engine (Qt 4.7) + add-shared-library QtDeclarative : QtGui QtXml : : $(target-requirements) ; + + # AssistantClient Support + # Compat library removed in 4.7.0 + # Pre-4.4 help system, use QtHelp for new programs + if $(version) < "4.7" + { + add-shared-library QtAssistantClient : QtGui : : $(target-requirements) : QtAssistant ; + } + debug-message "==== Configured Qt-$(version) ====" ; + + project.pop-current ; +} + +rule initialized ( ) +{ + return $(.initialized) ; +} + + + +# This custom generator is needed because in QT4, UI files are translated only +# into H files, and no C++ files are created. Further, the H files need not be +# passed via MOC. The header is used only via inclusion. If we define a standard +# UI -> H generator, Boost.Build will run MOC on H, and then compile the +# resulting cpp. It will give a warning, since output from moc will be empty. +# +# This generator is declared with a UI -> OBJ signature, so it gets invoked when +# linking generator tries to convert sources to OBJ, but it produces target of +# type H. This is non-standard, but allowed. That header won't be mocced. +# +class uic-generator : generator +{ + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule run ( project name ? : property-set : sources * ) + { + if ! $(name) + { + name = [ $(sources[0]).name ] ; + name = $(name:B) ; + } + + local a = [ new action $(sources[1]) : qt4.uic : $(property-set) ] ; + + # The 'ui_' prefix is to match qmake's default behavior. + local target = [ new file-target ui_$(name) : H : $(project) : $(a) ] ; + + local r = [ virtual-target.register $(target) ] ; + + # Since this generator will return a H target, the linking generator + # won't use it at all, and won't set any dependency on it. However, we + # need the target to be seen by bjam, so that dependency from sources to + # this generated header is detected -- if jam does not know about this + # target, it won't do anything. + DEPENDS all : [ $(r).actualize ] ; + + return $(r) ; + } +} + + +class moc-h-generator : generator +{ + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule run ( project name ? : property-set : sources * ) + { + if ! $(sources[2]) && [ $(sources[1]).type ] = MOCCABLE_CPP + { + name = [ $(sources[0]).name ] ; + name = $(name:B) ; + + local a = [ new action $(sources[1]) : qt4.moc.inc : + $(property-set) ] ; + + local target = [ new file-target $(name) : MOC : $(project) : $(a) + ] ; + + local r = [ virtual-target.register $(target) ] ; + + # Since this generator will return a H target, the linking generator + # won't use it at all, and won't set any dependency on it. However, + # we need the target to be seen by bjam, so that dependency from + # sources to this generated header is detected -- if jam does not + # know about this target, it won't do anything. + DEPENDS all : [ $(r).actualize ] ; + + return $(r) ; + } + } +} + + +class moc-inc-generator : generator +{ + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule run ( project name ? : property-set : sources * ) + { + if ! $(sources[2]) && [ $(sources[1]).type ] = MOCCABLE_H + { + name = [ $(sources[0]).name ] ; + name = $(name:B) ; + + local a = [ new action $(sources[1]) : qt4.moc.inc : + $(property-set) ] ; + + local target = [ new file-target moc_$(name) : CPP : $(project) : + $(a) ] ; + + # Since this generator will return a H target, the linking generator + # won't use it at all, and won't set any dependency on it. However, + # we need the target to be seen by bjam, so that dependency from + # sources to this generated header is detected -- if jam does not + # know about this target, it won't do anything. + DEPENDS all : [ $(target).actualize ] ; + + return [ virtual-target.register $(target) ] ; + } + } +} + + +# Query the installation directory. This is needed in at least two scenarios. +# First, when re-using sources from the Qt-Tree. Second, to "install" custom Qt +# plugins to the Qt-Tree. +# +rule directory +{ + return $(.PREFIX) ; +} + +# Add a shared Qt library. +rule add-shared-library ( lib-name : depends-on * : usage-defines * : requirements * : include ? ) +{ + add-library $(lib-name) : $(.suffix_version) : $(depends-on) : $(usage-defines) : $(requirements) : $(include) ; +} + +# Add a static Qt library. +rule add-static-library ( lib-name : depends-on * : usage-defines * : requirements * : include ? ) +{ + add-library $(lib-name) : : $(depends-on) : $(usage-defines) : $(requirements) : $(include) ; +} + +# Add a Qt library. +# Static libs are unversioned, whereas shared libs have the major number as suffix. +# Creates both release and debug versions on platforms where both are enabled by Qt configure. +# Flags: +# - lib-name Qt library Name +# - version Qt major number used as shared library suffix (QtCore4.so) +# - depends-on other Qt libraries +# - usage-defines those are set by qmake, so set them when using this library +# - requirements addional requirements +# - include non-canonical include path. The canonical path is $(.incprefix)/$(lib-name). +rule add-library ( lib-name : version ? : depends-on * : usage-defines * : requirements * : include ? ) +{ + if $(.bjam-qt) + { + # Import Qt module + # Eveything will be setup there + alias $(lib-name) + : $(.prefix)//$(lib-name) + : + : + : qt4 ; + } + else + { + local real_include ; + real_include ?= $(include) ; + real_include ?= $(lib-name) ; + + lib $(lib-name) + : # sources + $(depends-on) + : # requirements + $(lib-name)$(version) + $(requirements) + : # default-build + : # usage-requirements + $(usage-defines) + $(.incprefix)/$(real_include) + ; + + if $(.have_separate_debug) = TRUE + { + lib $(lib-name) + : # sources + $(depends-on) + : # requirements + $(lib-name)$(.suffix_debug)$(version) + $(requirements) + debug + : # default-build + : # usage-requirements + $(usage-defines) + $(.incprefix)/$(real_include) + ; + } + } + + # Make library explicit so that a simple qt4 will not bring in everything. + # And some components like QtDBus/Phonon may not be available on all platforms. + explicit $(lib-name) ; +} + +# Use $(.BINPREFIX[-1]) for the paths as several tools-requirements can match. +# The exact match is the last one. + +# Get and from current toolset. +flags qt4.moc INCLUDES ; +flags qt4.moc DEFINES ; + +# need a newline for expansion of DEFINES and INCLUDES in the response file. +.nl = " +" ; + +# Processes headers to create Qt MetaObject information. Qt4-moc has its +# c++-parser, so pass INCLUDES and DEFINES. +# We use response file with one INCLUDE/DEFINE per line +# +actions moc +{ + $(.BINPREFIX[-1])/moc -f $(>) -o $(<) @"@($(<).rsp:E=-D$(DEFINES)$(.nl) -I$(INCLUDES:T)$(.nl))" +} + +# When moccing files for include only, we don't need -f, otherwise the generated +# code will include the .cpp and we'll get duplicated symbols. +# +actions moc.inc +{ + $(.BINPREFIX[-1])/moc $(>) -o $(<) @"@($(<).rsp:E=-D$(DEFINES)$(.nl) -I$(INCLUDES:T)$(.nl))" +} + + +# Generates source files from resource files. +# +actions rcc +{ + $(.BINPREFIX[-1])/rcc $(>) -name $(>:B) -o $(<) +} + + +# Generates user-interface source from .ui files. +# +actions uic +{ + $(.BINPREFIX[-1])/uic $(>) -o $(<) +} + + +# Scanner for .qrc files. Look for the CDATA section of the tag. Ignore +# the "alias" attribute. See http://doc.trolltech.com/qt/resources.html for +# detailed documentation of the Qt Resource System. +# +class qrc-scanner : common-scanner +{ + rule pattern ( ) + { + return "(.*)" ; + } +} + + +# Wrapped files are "included". +scanner.register qrc-scanner : include ; diff --git a/mosesdecoder/jam-files/boost-build/tools/sun.jam b/mosesdecoder/jam-files/boost-build/tools/sun.jam new file mode 100644 index 0000000000000000000000000000000000000000..0ca927d3e4ab7cdfe8bdd41c0680ee9f091fba87 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/sun.jam @@ -0,0 +1,142 @@ +# Copyright (C) Christopher Currie 2003. Permission to copy, use, +# modify, sell and distribute this software is granted provided this +# copyright notice appears in all copies. This software is provided +# "as is" without express or implied warranty, and with no claim as +# to its suitability for any purpose. + +import property ; +import generators ; +import os ; +import toolset : flags ; +import feature ; +import type ; +import common ; + +feature.extend toolset : sun ; +toolset.inherit sun : unix ; +generators.override sun.prebuilt : builtin.lib-generator ; +generators.override sun.prebuilt : builtin.prebuilt ; +generators.override sun.searched-lib-generator : searched-lib-generator ; + +feature.extend stdlib : sun-stlport ; +feature.compose sun-stlport + : -library=stlport4 -library=stlport4 + ; + +rule init ( version ? : command * : options * ) +{ + local condition = [ + common.check-init-parameters sun : version $(version) ] ; + + command = [ common.get-invocation-command sun : CC + : $(command) : "/opt/SUNWspro/bin" ] ; + + # Even if the real compiler is not found, put CC to + # command line so that user see command line that would have being executed. + command ?= CC ; + + common.handle-options sun : $(condition) : $(command) : $(options) ; + + command_c = $(command[1--2]) $(command[-1]:B=cc) ; + + toolset.flags sun CONFIG_C_COMMAND $(condition) : $(command_c) ; +} + +# Declare generators +generators.register-c-compiler sun.compile.c : C : OBJ : sun ; +generators.register-c-compiler sun.compile.c++ : CPP : OBJ : sun ; + +# Declare flags and actions for compilation +flags sun.compile OPTIONS on : -g ; +flags sun.compile OPTIONS on : -xprofile=tcov ; +flags sun.compile OPTIONS speed : -xO4 ; +flags sun.compile OPTIONS space : -xO2 -xspace ; +flags sun.compile OPTIONS multi : -mt ; +flags sun.compile OPTIONS off : -erroff ; +flags sun.compile OPTIONS on : -erroff=%none ; +flags sun.compile OPTIONS all : -erroff=%none ; +flags sun.compile OPTIONS on : -errwarn ; + +flags sun.compile.c++ OPTIONS off : +d ; + +# The -m32 and -m64 options are supported starting +# with Sun Studio 12. On earlier compilers, the +# 'address-model' feature is not supported and should not +# be used. Instead, use -xarch=generic64 command line +# option. +# See http://svn.boost.org/trac/boost/ticket/1186 +# for details. +flags sun OPTIONS 32 : -m32 ; +flags sun OPTIONS 64 : -m64 ; +# On sparc, there's a difference between -Kpic +# and -KPIC. The first is slightly more efficient, +# but has the limits on the size of GOT table. +# For minimal fuss on user side, we use -KPIC here. +# See http://svn.boost.org/trac/boost/ticket/1186#comment:6 +# for detailed explanation. +flags sun OPTIONS shared : -KPIC ; + +flags sun.compile OPTIONS ; +flags sun.compile.c++ OPTIONS ; +flags sun.compile DEFINES ; +flags sun.compile INCLUDES ; + +actions compile.c +{ + "$(CONFIG_C_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +actions compile.c++ +{ + "$(CONFIG_COMMAND)" $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +# Declare flags and actions for linking +flags sun.link OPTIONS on : -g ; +# Strip the binary when no debugging is needed +flags sun.link OPTIONS off : -s ; +flags sun.link OPTIONS on : -xprofile=tcov ; +flags sun.link OPTIONS multi : -mt ; +flags sun.link OPTIONS ; +flags sun.link LINKPATH ; +flags sun.link FINDLIBS-ST ; +flags sun.link FINDLIBS-SA ; +flags sun.link LIBRARIES ; +flags sun.link LINK-RUNTIME static : static ; +flags sun.link LINK-RUNTIME shared : dynamic ; +flags sun.link RPATH ; +# On gcc, there are separate options for dll path at runtime and +# link time. On Solaris, there's only one: -R, so we have to use +# it, even though it's bad idea. +flags sun.link RPATH ; + +# The POSIX real-time library is always needed (nanosleep, clock_gettime etc.) +flags sun.link FINDLIBS-SA : rt ; + +rule link ( targets * : sources * : properties * ) +{ + SPACE on $(targets) = " " ; +} + +actions link bind LIBRARIES +{ + "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -Bdynamic -l$(FINDLIBS-SA) -Bstatic -l$(FINDLIBS-ST) -B$(LINK-RUNTIME) +} + +# Slight mods for dlls +rule link.dll ( targets * : sources * : properties * ) +{ + SPACE on $(targets) = " " ; +} + +actions link.dll bind LIBRARIES +{ + "$(CONFIG_COMMAND)" $(OPTIONS) -L"$(LINKPATH)" -R"$(RPATH)" -o "$(<)" -h$(<[1]:D=) -G "$(>)" "$(LIBRARIES)" -Bdynamic -l$(FINDLIBS-SA) -Bstatic -l$(FINDLIBS-ST) -B$(LINK-RUNTIME) +} + +# Declare action for creating static libraries +actions piecemeal archive +{ + "$(CONFIG_COMMAND)" -xar -o "$(<)" "$(>)" +} + diff --git a/mosesdecoder/jam-files/boost-build/tools/testing.jam b/mosesdecoder/jam-files/boost-build/tools/testing.jam new file mode 100644 index 0000000000000000000000000000000000000000..c42075b78a48215264ced86e42034a70d1f36ffd --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/testing.jam @@ -0,0 +1,581 @@ +# Copyright 2005 Dave Abrahams +# Copyright 2002, 2003, 2004, 2005, 2006 Vladimir Prus +# 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) + +# This module implements regression testing framework. It declares a number of +# main target rules which perform some action and, if the results are OK, +# creates an output file. +# +# The exact list of rules is: +# 'compile' -- creates .test file if compilation of sources was +# successful. +# 'compile-fail' -- creates .test file if compilation of sources failed. +# 'run' -- creates .test file is running of executable produced from +# sources was successful. Also leaves behind .output file +# with the output from program run. +# 'run-fail' -- same as above, but .test file is created if running fails. +# +# In all cases, presence of .test file is an indication that the test passed. +# For more convenient reporting, you might want to use C++ Boost regression +# testing utilities (see http://www.boost.org/more/regression.html). +# +# For historical reason, a 'unit-test' rule is available which has the same +# syntax as 'exe' and behaves just like 'run'. + +# Things to do: +# - Teach compiler_status handle Jamfile.v2. +# Notes: +# - is not implemented, since it is Como-specific, and it is not +# clear how to implement it +# - std::locale-support is not implemented (it is used in one test). + + +import alias ; +import "class" ; +import common ; +import errors ; +import feature ; +import generators ; +import os ; +import path ; +import project ; +import property ; +import property-set ; +import regex ; +import sequence ; +import targets ; +import toolset ; +import type ; +import virtual-target ; + + +rule init ( ) +{ +} + + +# Feature controling the command used to lanch test programs. +feature.feature testing.launcher : : free optional ; + +feature.feature test-info : : free incidental ; +feature.feature testing.arg : : free incidental ; +feature.feature testing.input-file : : free dependency ; + +feature.feature preserve-test-targets : on off : incidental propagated ; + +# Register target types. +type.register TEST : test ; +type.register COMPILE : : TEST ; +type.register COMPILE_FAIL : : TEST ; +type.register RUN_OUTPUT : run ; +type.register RUN : : TEST ; +type.register RUN_FAIL : : TEST ; +type.register LINK_FAIL : : TEST ; +type.register LINK : : TEST ; +type.register UNIT_TEST : passed : TEST ; + + +# Declare the rules which create main targets. While the 'type' module already +# creates rules with the same names for us, we need extra convenience: default +# name of main target, so write our own versions. + +# Helper rule. Create a test target, using basename of first source if no target +# name is explicitly passed. Remembers the created target in a global variable. +# +rule make-test ( target-type : sources + : requirements * : target-name ? ) +{ + target-name ?= $(sources[1]:D=:S=) ; + + # Having periods (".") in the target name is problematic because the typed + # generator will strip the suffix and use the bare name for the file + # targets. Even though the location-prefix averts problems most times it + # does not prevent ambiguity issues when referring to the test targets. For + # example when using the XML log output. So we rename the target to remove + # the periods, and provide an alias for users. + local real-name = [ regex.replace $(target-name) "[.]" "~" ] ; + + local project = [ project.current ] ; + # The forces the build system for generate paths in the + # form '$build_dir/array1.test/gcc/debug'. This is necessary to allow + # post-processing tools to work. + local t = [ targets.create-typed-target [ type.type-from-rule-name + $(target-type) ] : $(project) : $(real-name) : $(sources) : + $(requirements) $(real-name).test ] ; + + # The alias to the real target, per period replacement above. + if $(real-name) != $(target-name) + { + alias $(target-name) : $(t) ; + } + + # Remember the test (for --dump-tests). A good way would be to collect all + # given a project. This has some technical problems: e.g. we can not call + # this dump from a Jamfile since projects referred by 'build-project' are + # not available until the whole Jamfile has been loaded. + .all-tests += $(t) ; + return $(t) ; +} + + +# Note: passing more that one cpp file here is known to fail. Passing a cpp file +# and a library target works. +# +rule compile ( sources + : requirements * : target-name ? ) +{ + return [ make-test compile : $(sources) : $(requirements) : $(target-name) ] + ; +} + + +rule compile-fail ( sources + : requirements * : target-name ? ) +{ + return [ make-test compile-fail : $(sources) : $(requirements) : + $(target-name) ] ; +} + + +rule link ( sources + : requirements * : target-name ? ) +{ + return [ make-test link : $(sources) : $(requirements) : $(target-name) ] ; +} + + +rule link-fail ( sources + : requirements * : target-name ? ) +{ + return [ make-test link-fail : $(sources) : $(requirements) : $(target-name) + ] ; +} + + +rule handle-input-files ( input-files * ) +{ + if $(input-files[2]) + { + # Check that sorting made when creating property-set instance will not + # change the ordering. + if [ sequence.insertion-sort $(input-files) ] != $(input-files) + { + errors.user-error "Names of input files must be sorted alphabetically" + : "due to internal limitations" ; + } + } + return $(input-files) ; +} + + +rule run ( sources + : args * : input-files * : requirements * : target-name ? : + default-build * ) +{ + requirements += $(args:J=" ") ; + requirements += [ handle-input-files $(input-files) ] ; + return [ make-test run : $(sources) : $(requirements) : $(target-name) ] ; +} + + +rule run-fail ( sources + : args * : input-files * : requirements * : + target-name ? : default-build * ) +{ + requirements += $(args:J=" ") ; + requirements += [ handle-input-files $(input-files) ] ; + return [ make-test run-fail : $(sources) : $(requirements) : $(target-name) + ] ; +} + + +# Use 'test-suite' as a synonym for 'alias', for backward compatibility. +IMPORT : alias : : test-suite ; + + +# For all main targets in 'project-module', which are typed targets with type +# derived from 'TEST', produce some interesting information. +# +rule dump-tests +{ + for local t in $(.all-tests) + { + dump-test $(t) ; + } +} + + +# Given a project location in normalized form (slashes are forward), compute the +# name of the Boost library. +# +local rule get-library-name ( path ) +{ + # Path is in normalized form, so all slashes are forward. + local match1 = [ MATCH /(tools|libs)/(.*)/(test|example) : $(path) ] ; + local match2 = [ MATCH /(tools|libs)/(.*)$ : $(path) ] ; + local match3 = [ MATCH (/status$) : $(path) ] ; + + if $(match1) { return $(match1[2]) ; } + else if $(match2) { return $(match2[2]) ; } + else if $(match3) { return "" ; } + else if --dump-tests in [ modules.peek : ARGV ] + { + # The 'run' rule and others might be used outside boost. In that case, + # just return the path, since the 'library name' makes no sense. + return $(path) ; + } +} + + +# Was an XML dump requested? +.out-xml = [ MATCH --out-xml=(.*) : [ modules.peek : ARGV ] ] ; + + +# Takes a target (instance of 'basic-target') and prints +# - its type +# - its name +# - comments specified via the property +# - relative location of all source from the project root. +# +rule dump-test ( target ) +{ + local type = [ $(target).type ] ; + local name = [ $(target).name ] ; + local project = [ $(target).project ] ; + + local project-root = [ $(project).get project-root ] ; + local library = [ get-library-name [ path.root [ $(project).get location ] + [ path.pwd ] ] ] ; + if $(library) + { + name = $(library)/$(name) ; + } + + local sources = [ $(target).sources ] ; + local source-files ; + for local s in $(sources) + { + if [ class.is-a $(s) : file-reference ] + { + local location = [ path.root [ path.root [ $(s).name ] + [ $(s).location ] ] [ path.pwd ] ] ; + + source-files += [ path.relative-to [ path.root $(project-root) + [ path.pwd ] ] $(location) ] ; + } + } + + local target-name = [ $(project).get location ] // [ $(target).name ] .test + ; + target-name = $(target-name:J=) ; + + local r = [ $(target).requirements ] ; + # Extract values of the feature. + local test-info = [ $(r).get ] ; + + # If the user requested XML output on the command-line, add the test info to + # that XML file rather than dumping them to stdout. + if $(.out-xml) + { + local nl = " +" ; + .contents on $(.out-xml) += + "$(nl) " + "$(nl) " + "$(nl) " + "$(nl) " + "$(nl) " + ; + } + else + { + # Format them into a single string of quoted strings. + test-info = \"$(test-info:J=\"\ \")\" ; + + ECHO boost-test($(type)) \"$(name)\" [$(test-info)] ":" + \"$(source-files)\" ; + } +} + + +# Register generators. Depending on target type, either 'expect-success' or +# 'expect-failure' rule will be used. +generators.register-standard testing.expect-success : OBJ : COMPILE ; +generators.register-standard testing.expect-failure : OBJ : COMPILE_FAIL ; +generators.register-standard testing.expect-success : RUN_OUTPUT : RUN ; +generators.register-standard testing.expect-failure : RUN_OUTPUT : RUN_FAIL ; +generators.register-standard testing.expect-failure : EXE : LINK_FAIL ; +generators.register-standard testing.expect-success : EXE : LINK ; + +# Generator which runs an EXE and captures output. +generators.register-standard testing.capture-output : EXE : RUN_OUTPUT ; + +# Generator which creates a target if sources run successfully. Differs from RUN +# in that run output is not captured. The reason why it exists is that the 'run' +# rule is much better for automated testing, but is not user-friendly (see +# http://article.gmane.org/gmane.comp.lib.boost.build/6353). +generators.register-standard testing.unit-test : EXE : UNIT_TEST ; + + +# The action rules called by generators. + +# Causes the 'target' to exist after bjam invocation if and only if all the +# dependencies were successfully built. +# +rule expect-success ( target : dependency + : requirements * ) +{ + **passed** $(target) : $(sources) ; +} + + +# Causes the 'target' to exist after bjam invocation if and only if all some of +# the dependencies were not successfully built. +# +rule expect-failure ( target : dependency + : properties * ) +{ + local grist = [ MATCH ^<(.*)> : $(dependency:G) ] ; + local marker = $(dependency:G=$(grist)*fail) ; + (failed-as-expected) $(marker) ; + FAIL_EXPECTED $(dependency) ; + LOCATE on $(marker) = [ on $(dependency) return $(LOCATE) ] ; + RMOLD $(marker) ; + DEPENDS $(marker) : $(dependency) ; + DEPENDS $(target) : $(marker) ; + **passed** $(target) : $(marker) ; +} + + +# The rule/action combination used to report successful passing of a test. +# +rule **passed** +{ + # Dump all the tests, if needed. We do it here, since dump should happen + # only after all Jamfiles have been read, and there is no such place + # currently defined (but there should be). + if ! $(.dumped-tests) && ( --dump-tests in [ modules.peek : ARGV ] ) + { + .dumped-tests = true ; + dump-tests ; + } + + # Force deletion of the target, in case any dependencies failed to build. + RMOLD $(<) ; +} + + +# Used to create test files signifying passed tests. +# +actions **passed** +{ + echo passed > "$(<)" +} + + +# Used to create replacement object files that do not get created during tests +# that are expected to fail. +# +actions (failed-as-expected) +{ + echo failed as expected > "$(<)" +} + + +rule run-path-setup ( target : source : properties * ) +{ + # For testing, we need to make sure that all dynamic libraries needed by the + # test are found. So, we collect all paths from dependency libraries (via + # xdll-path property) and add whatever explicit dll-path user has specified. + # The resulting paths are added to the environment on each test invocation. + local dll-paths = [ feature.get-values : $(properties) ] ; + dll-paths += [ feature.get-values : $(properties) ] ; + dll-paths += [ on $(source) return $(RUN_PATH) ] ; + dll-paths = [ sequence.unique $(dll-paths) ] ; + if $(dll-paths) + { + dll-paths = [ sequence.transform path.native : $(dll-paths) ] ; + PATH_SETUP on $(target) = [ common.prepend-path-variable-command + [ os.shared-library-path-variable ] : $(dll-paths) ] ; + } +} + + +local argv = [ modules.peek : ARGV ] ; + +toolset.flags testing.capture-output ARGS ; +toolset.flags testing.capture-output INPUT_FILES ; +toolset.flags testing.capture-output LAUNCHER ; + + +# Runs executable 'sources' and stores stdout in file 'target'. Unless +# --preserve-test-targets command line option has been specified, removes the +# executable. The 'target-to-remove' parameter controls what should be removed: +# - if 'none', does not remove anything, ever +# - if empty, removes 'source' +# - if non-empty and not 'none', contains a list of sources to remove. +# +rule capture-output ( target : source : properties * : targets-to-remove * ) +{ + output-file on $(target) = $(target:S=.output) ; + LOCATE on $(target:S=.output) = [ on $(target) return $(LOCATE) ] ; + + # The INCLUDES kill a warning about independent target... + INCLUDES $(target) : $(target:S=.output) ; + # but it also puts .output into dependency graph, so we must tell jam it is + # OK if it cannot find the target or updating rule. + NOCARE $(target:S=.output) ; + + # This has two-fold effect. First it adds input files to the dependendency + # graph, preventing a warning. Second, it causes input files to be bound + # before target is created. Therefore, they are bound using SEARCH setting + # on them and not LOCATE setting of $(target), as in other case (due to jam + # bug). + DEPENDS $(target) : [ on $(target) return $(INPUT_FILES) ] ; + + if $(targets-to-remove) = none + { + targets-to-remove = ; + } + else if ! $(targets-to-remove) + { + targets-to-remove = $(source) ; + } + + run-path-setup $(target) : $(source) : $(properties) ; + + if [ feature.get-values preserve-test-targets : $(properties) ] = off + { + TEMPORARY $(targets-to-remove) ; + # Set a second action on target that will be executed after capture + # output action. The 'RmTemps' rule has the 'ignore' modifier so it is + # always considered succeeded. This is needed for 'run-fail' test. For + # that test the target will be marked with FAIL_EXPECTED, and without + # 'ignore' successful execution will be negated and be reported as + # failure. With 'ignore' we do not detect a case where removing files + # fails, but it is not likely to happen. + RmTemps $(target) : $(targets-to-remove) ; + } +} + + +if [ os.name ] = NT +{ + .STATUS = %status% ; + .SET_STATUS = "set status=%ERRORLEVEL%" ; + .RUN_OUTPUT_NL = "echo." ; + .STATUS_0 = "%status% EQU 0 (" ; + .STATUS_NOT_0 = "%status% NEQ 0 (" ; + .VERBOSE = "%verbose% EQU 1 (" ; + .ENDIF = ")" ; + .SHELL_SET = "set " ; + .CATENATE = type ; + .CP = copy ; +} +else +{ + .STATUS = "$status" ; + .SET_STATUS = "status=$?" ; + .RUN_OUTPUT_NL = "echo" ; + .STATUS_0 = "test $status -eq 0 ; then" ; + .STATUS_NOT_0 = "test $status -ne 0 ; then" ; + .VERBOSE = "test $verbose -eq 1 ; then" ; + .ENDIF = "fi" ; + .SHELL_SET = "" ; + .CATENATE = cat ; + .CP = cp ; +} + + +.VERBOSE_TEST = 0 ; +if --verbose-test in [ modules.peek : ARGV ] +{ + .VERBOSE_TEST = 1 ; +} + + +.RM = [ common.rm-command ] ; + + +actions capture-output bind INPUT_FILES output-file +{ + $(PATH_SETUP) + $(LAUNCHER) "$(>)" $(ARGS) "$(INPUT_FILES)" > "$(output-file)" 2>&1 + $(.SET_STATUS) + $(.RUN_OUTPUT_NL) >> "$(output-file)" + echo EXIT STATUS: $(.STATUS) >> "$(output-file)" + if $(.STATUS_0) + $(.CP) "$(output-file)" "$(<)" + $(.ENDIF) + $(.SHELL_SET)verbose=$(.VERBOSE_TEST) + if $(.STATUS_NOT_0) + $(.SHELL_SET)verbose=1 + $(.ENDIF) + if $(.VERBOSE) + echo ====== BEGIN OUTPUT ====== + $(.CATENATE) "$(output-file)" + echo ====== END OUTPUT ====== + $(.ENDIF) + exit $(.STATUS) +} + + +actions quietly updated ignore piecemeal together RmTemps +{ + $(.RM) "$(>)" +} + + +.MAKE_FILE = [ common.file-creation-command ] ; + +toolset.flags testing.unit-test LAUNCHER ; +toolset.flags testing.unit-test ARGS ; + + +rule unit-test ( target : source : properties * ) +{ + run-path-setup $(target) : $(source) : $(properties) ; +} + + +actions unit-test +{ + $(PATH_SETUP) + $(LAUNCHER) $(>) $(ARGS) && $(.MAKE_FILE) $(<) +} + + +IMPORT $(__name__) : compile compile-fail run run-fail link link-fail + : : compile compile-fail run run-fail link link-fail ; + + +type.register TIME : time ; +generators.register-standard testing.time : : TIME ; + + +rule record-time ( target : source : start end user system ) +{ + local src-string = [$(source:G=:J=",")"] " ; + USER_TIME on $(target) += $(src-string)$(user) ; + SYSTEM_TIME on $(target) += $(src-string)$(system) ; +} + + +IMPORT testing : record-time : : testing.record-time ; + + +# Calling this rule requests that Boost Build time how long it taks to build the +# 'source' target and display the results both on the standard output and in the +# 'target' file. +# +rule time ( target : source : properties * ) +{ + # Set up rule for recording timing information. + __TIMING_RULE__ on $(source) = testing.record-time $(target) ; + + # Make sure that the source is rebuilt any time we need to retrieve that + # information. + REBUILDS $(target) : $(source) ; +} + + +actions time +{ + echo user: $(USER_TIME) + echo system: $(SYSTEM_TIME) + + echo user: $(USER_TIME)" seconds" > "$(<)" + echo system: $(SYSTEM_TIME)" seconds" >> "$(<)" +} diff --git a/mosesdecoder/jam-files/boost-build/tools/types/html.jam b/mosesdecoder/jam-files/boost-build/tools/types/html.jam new file mode 100644 index 0000000000000000000000000000000000000000..5cd337d09402b8a6c2b8c584fd8df7133d26dfa8 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/types/html.jam @@ -0,0 +1,4 @@ +# Copyright David Abrahams 2004. 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) +type HTML : html ; diff --git a/mosesdecoder/jam-files/boost-build/tools/types/obj.jam b/mosesdecoder/jam-files/boost-build/tools/types/obj.jam new file mode 100644 index 0000000000000000000000000000000000000000..6afbcaa6f3113bc2badcc1fac4e3c0eb256ff19a --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/types/obj.jam @@ -0,0 +1,9 @@ +# Copyright David Abrahams 2004. 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 type ; + +type.register OBJ : o obj ; +type.set-generated-target-suffix OBJ : windows : obj ; +type.set-generated-target-suffix OBJ : cygwin : obj ; diff --git a/mosesdecoder/jam-files/boost-build/tools/types/objc.jam b/mosesdecoder/jam-files/boost-build/tools/types/objc.jam new file mode 100644 index 0000000000000000000000000000000000000000..709cbd0c7d2145d6d82a8005497c2f091c32bc80 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/types/objc.jam @@ -0,0 +1,26 @@ +# Copyright Rene Rivera 2008, 2010. +# 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 type ; +import scanner ; +import types/cpp ; + +class objc-scanner : c-scanner +{ + rule __init__ ( includes * ) + { + c-scanner.__init__ $(includes) ; + } + + rule pattern ( ) + { + return "#[ \t]*include|import[ ]*(<(.*)>|\"(.*)\")" ; + } +} + +scanner.register objc-scanner : include ; + +type.register OBJECTIVE_C : m ; +type.register OBJECTIVE_CPP : mm ; +type.set-scanner OBJECTIVE_C : objc-scanner ; +type.set-scanner OBJECTIVE_CPP : objc-scanner ; diff --git a/mosesdecoder/jam-files/boost-build/tools/types/preprocessed.jam b/mosesdecoder/jam-files/boost-build/tools/types/preprocessed.jam new file mode 100644 index 0000000000000000000000000000000000000000..c9187ba671084997c8412b751975ee8dd73811ed --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/types/preprocessed.jam @@ -0,0 +1,9 @@ +# Copyright Steven Watanabe 2011 +# 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 type ; + +type.register PREPROCESSED_C : i : C ; +type.register PREPROCESSED_CPP : ii : CPP ; diff --git a/mosesdecoder/jam-files/boost-build/tools/types/qt.jam b/mosesdecoder/jam-files/boost-build/tools/types/qt.jam new file mode 100644 index 0000000000000000000000000000000000000000..6d1dfbd42f4a1ee6d84211c186f358f040223239 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/types/qt.jam @@ -0,0 +1,10 @@ +# Copyright Vladimir Prus 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) + +type UI : ui ; +type QRC : qrc ; +type MOCCABLE_CPP ; +type MOCCABLE_H ; +# Result of running moc. +type MOC : moc : H ; diff --git a/mosesdecoder/jam-files/boost-build/tools/types/register.jam b/mosesdecoder/jam-files/boost-build/tools/types/register.jam new file mode 100644 index 0000000000000000000000000000000000000000..203992ca9255914a45f860e17b477a6f6b03c8b1 --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/types/register.jam @@ -0,0 +1,39 @@ +# Copyright David Abrahams 2004. 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 module's job is to automatically import all the type +# registration modules in its directory. +import type os path modules ; + +# Register the given type on the specified OSes, or on remaining OSes +# if os is not specified. This rule is injected into each of the type +# modules for the sake of convenience. +local rule type ( type : suffixes * : base-type ? : os * ) +{ + if ! [ type.registered $(type) ] + { + if ( ! $(os) ) || [ os.name ] in $(os) + { + type.register $(type) : $(suffixes) : $(base-type) ; + } + } +} + +.this-module's-file = [ modules.binding $(__name__) ] ; +.this-module's-dir = [ path.parent $(.this-module's-file) ] ; +.sibling-jamfiles = [ path.glob $(.this-module's-dir) : *.jam ] ; +.sibling-modules = [ MATCH ^(.*)\.jam$ : $(.sibling-jamfiles) ] ; + +# A loop over all modules in this directory +for m in $(.sibling-modules) +{ + m = [ path.basename $(m) ] ; + m = types/$(m) ; + + # Inject the type rule into the new module + IMPORT $(__name__) : type : $(m) : type ; + import $(m) ; +} + + diff --git a/mosesdecoder/jam-files/boost-build/tools/unix.jam b/mosesdecoder/jam-files/boost-build/tools/unix.jam new file mode 100644 index 0000000000000000000000000000000000000000..75949851a0cb9b453a404df0d27ed4272cc5601a --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/unix.jam @@ -0,0 +1,224 @@ +# Copyright (c) 2004 Vladimir Prus. +# +# Use, modification and distribution is subject to the Boost Software +# License Version 1.0. (See accompanying file LICENSE_1_0.txt or +# http://www.boost.org/LICENSE_1_0.txt) + +# This file implements linking semantic common to all unixes. On unix, static +# libraries must be specified in a fixed order on the linker command line. Generators +# declared there store information about the order and use it property. + +import feature ; +import "class" : new ; +import generators ; +import type ; +import set ; +import order ; +import builtin ; + +class unix-linking-generator : linking-generator +{ + import property-set ; + import type ; + import unix ; + + rule __init__ ( id + composing ? : # Specify if generator is composing. The generator will be + # composing if non-empty string is passed, or parameter is + # not given. To make generator non-composing, pass empty + # string ("") + source-types + : target-types + : + requirements * ) + { + composing ?= true ; + generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) : + $(requirements) ; + } + + rule run ( project name ? : property-set : sources + ) + { + local result = [ linking-generator.run $(project) $(name) : $(property-set) + : $(sources) ] ; + + unix.set-library-order $(sources) : $(property-set) : $(result[2-]) ; + + return $(result) ; + } + + rule generated-targets ( sources + : property-set : project name ? ) + { + local sources2 ; + local libraries ; + for local l in $(sources) + { + if [ type.is-derived [ $(l).type ] LIB ] + { + libraries += $(l) ; + } + else + { + sources2 += $(l) ; + } + } + + sources = $(sources2) [ unix.order-libraries $(libraries) ] ; + + return [ linking-generator.generated-targets $(sources) : $(property-set) + : $(project) $(name) ] ; + } + +} + +class unix-archive-generator : archive-generator +{ + import unix ; + + rule __init__ ( id composing ? : source-types + : target-types + : + requirements * ) + { + composing ?= true ; + archive-generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) : + $(requirements) ; + } + + rule run ( project name ? : property-set : sources + ) + { + local result = [ archive-generator.run $(project) $(name) : $(property-set) + : $(sources) ] ; + + unix.set-library-order $(sources) : $(property-set) : $(result[2-]) ; + + return $(result) ; + + } +} + +class unix-searched-lib-generator : searched-lib-generator +{ + import unix ; + rule __init__ ( * : * ) + { + generator.__init__ + $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule optional-properties ( ) + { + return $(self.requirements) ; + } + + rule run ( project name ? : property-set : sources * ) + { + local result = [ searched-lib-generator.run $(project) $(name) + : $(property-set) : $(sources) ] ; + + unix.set-library-order $(sources) : $(property-set) : $(result[2-]) ; + + return $(result) ; + } +} + +class unix-prebuilt-lib-generator : generator +{ + import unix ; + rule __init__ ( * : * ) + { + generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } + + rule run ( project name ? : property-set : sources * ) + { + local f = [ $(property-set).get ] ; + unix.set-library-order-aux $(f) : $(sources) ; + return $(f) $(sources) ; + } +} + +generators.register + [ new unix-prebuilt-lib-generator unix.prebuilt : : LIB + : unix ] ; + +generators.override unix.prebuilt : builtin.lib-generator ; + + +# Declare generators +generators.register [ new unix-linking-generator unix.link : LIB OBJ : EXE + : unix ] ; + +generators.register [ new unix-archive-generator unix.archive : OBJ : STATIC_LIB + : unix ] ; + +generators.register [ new unix-linking-generator unix.link.dll : LIB OBJ : SHARED_LIB + : unix ] ; + +generators.register [ new unix-searched-lib-generator + unix.searched-lib-generator : : SEARCHED_LIB : unix ] ; + + +# The derived toolset must specify their own actions. +actions link { +} + +actions link.dll { +} + +actions archive { +} + +actions searched-lib-generator { +} + +actions prebuilt { +} + + + + + +.order = [ new order ] ; + +rule set-library-order-aux ( from * : to * ) +{ + for local f in $(from) + { + for local t in $(to) + { + if $(f) != $(t) + { + $(.order).add-pair $(f) $(t) ; + } + } + } +} + +rule set-library-order ( sources * : property-set : result * ) +{ + local used-libraries ; + local deps = [ $(property-set).dependency ] ; + for local l in $(sources) $(deps:G=) + { + if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ] + { + used-libraries += $(l) ; + } + } + + local created-libraries ; + for local l in $(result) + { + if [ $(l).type ] && [ type.is-derived [ $(l).type ] LIB ] + { + created-libraries += $(l) ; + } + } + + created-libraries = [ set.difference $(created-libraries) : $(used-libraries) ] ; + set-library-order-aux $(created-libraries) : $(used-libraries) ; +} + +rule order-libraries ( libraries * ) +{ + local r = [ $(.order).order $(libraries) ] ; + return $(r) ; +} + \ No newline at end of file diff --git a/mosesdecoder/jam-files/boost-build/tools/xsltproc.jam b/mosesdecoder/jam-files/boost-build/tools/xsltproc.jam new file mode 100644 index 0000000000000000000000000000000000000000..96f5170bed4fbf972509331729a5b3c8e749055e --- /dev/null +++ b/mosesdecoder/jam-files/boost-build/tools/xsltproc.jam @@ -0,0 +1,194 @@ +# Copyright (C) 2003 Doug Gregor. Permission to copy, use, modify, sell and +# distribute this software is granted provided this copyright notice appears in +# all copies. This software is provided "as is" without express or implied +# warranty, and with no claim as to its suitability for any purpose. + +# This module defines rules to apply an XSLT stylesheet to an XML file using the +# xsltproc driver, part of libxslt. +# +# Note: except for 'init', this modules does not provide any rules for end +# users. + +import feature ; +import regex ; +import sequence ; +import common ; +import os ; +import modules ; +import path ; +import errors ; + +feature.feature xsl:param : : free ; +feature.feature xsl:path : : free ; +feature.feature catalog : : free ; + + +# Initialize xsltproc support. The parameters are: +# xsltproc: The xsltproc executable +# +rule init ( xsltproc ? ) +{ + if $(xsltproc) + { + modify-config ; + .xsltproc = $(xsltproc) ; + check-xsltproc ; + } +} + +rule freeze-config ( ) +{ + if ! $(.config-frozen) + { + .config-frozen = true ; + .xsltproc ?= [ modules.peek : XSLTPROC ] ; + .xsltproc ?= xsltproc ; + check-xsltproc ; + .is-cygwin = [ .is-cygwin $(.xsltproc) ] ; + } +} + +rule modify-config +{ + if $(.config-frozen) + { + errors.user-error "xsltproc: Cannot change xsltproc command after it has been used." ; + } +} + +rule check-xsltproc ( ) +{ + if $(.xsltproc) + { + local status = [ SHELL "\"$(.xsltproc)\" -V" : no-output : exit-status ] ; + if $(status[2]) != "0" + { + errors.user-error "xsltproc: Could not run \"$(.xsltproc)\" -V." ; + } + } +} + +# Returns a non-empty string if a cygwin xsltproc binary was specified. +rule is-cygwin ( ) +{ + freeze-config ; + return $(.is-cygwin) ; +} + +rule .is-cygwin ( xsltproc ) +{ + if [ os.on-windows ] + { + local file = [ path.make [ modules.binding $(__name__) ] ] ; + local dir = [ path.native + [ path.join [ path.parent $(file) ] xsltproc ] ] ; + if [ os.name ] = CYGWIN + { + dir = $(dir:W) ; + } + local command = + "\"$(xsltproc)\" \"$(dir)\\test.xsl\" \"$(dir)\\test.xml\" 2>&1" ; + local status = [ SHELL $(command) : no-output : exit-status ] ; + if $(status[2]) != "0" + { + return true ; + } + } +} + +rule compute-xslt-flags ( target : properties * ) +{ + local flags ; + + # Raw flags. + flags += [ feature.get-values : $(properties) ] ; + + # Translate into command line flags. + for local param in [ feature.get-values : $(properties) ] + { + local namevalue = [ regex.split $(param) "=" ] ; + flags += --stringparam $(namevalue[1]) \"$(namevalue[2])\" ; + } + + # Translate . + for local path in [ feature.get-values : $(properties) ] + { + flags += --path \"$(path:G=)\" ; + } + + # Take care of implicit dependencies. + local other-deps ; + for local dep in [ feature.get-values : $(properties) ] + { + other-deps += [ $(dep:G=).creating-subvariant ] ; + } + + local implicit-target-directories ; + for local dep in [ sequence.unique $(other-deps) ] + { + implicit-target-directories += [ $(dep).all-target-directories ] ; + } + + for local dir in $(implicit-target-directories) + { + flags += --path \"$(dir:T)\" ; + } + + return $(flags) ; +} + + +local rule .xsltproc ( target : source stylesheet : properties * : dirname ? : action ) +{ + freeze-config ; + STYLESHEET on $(target) = $(stylesheet) ; + FLAGS on $(target) += [ compute-xslt-flags $(target) : $(properties) ] ; + NAME on $(target) = $(.xsltproc) ; + + for local catalog in [ feature.get-values : $(properties) ] + { + CATALOG = [ common.variable-setting-command XML_CATALOG_FILES : $(catalog:T) ] ; + } + + if [ os.on-windows ] && ! [ is-cygwin ] + { + action = $(action).windows ; + } + + $(action) $(target) : $(source) ; +} + + +rule xslt ( target : source stylesheet : properties * ) +{ + return [ .xsltproc $(target) : $(source) $(stylesheet) : $(properties) : : xslt-xsltproc ] ; +} + + +rule xslt-dir ( target : source stylesheet : properties * : dirname ) +{ + return [ .xsltproc $(target) : $(source) $(stylesheet) : $(properties) : $(dirname) : xslt-xsltproc-dir ] ; +} + +actions xslt-xsltproc.windows +{ + $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<)" "$(STYLESHEET:W)" "$(>:W)" +} + + +actions xslt-xsltproc bind STYLESHEET +{ + $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<)" "$(STYLESHEET:T)" "$(>:T)" +} + + +actions xslt-xsltproc-dir.windows bind STYLESHEET +{ + $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<:D)/" "$(STYLESHEET:W)" "$(>:W)" +} + + +actions xslt-xsltproc-dir bind STYLESHEET +{ + $(CATALOG) "$(NAME:E=xsltproc)" $(FLAGS) --xinclude -o "$(<:D)/" "$(STYLESHEET:T)" "$(>:T)" +} diff --git a/mosesdecoder/jam-files/empty_test_main.cc b/mosesdecoder/jam-files/empty_test_main.cc new file mode 100644 index 0000000000000000000000000000000000000000..a3971f820a3aae1312ddb353d44d85e9ae6ba0f8 --- /dev/null +++ b/mosesdecoder/jam-files/empty_test_main.cc @@ -0,0 +1,8 @@ +/* Program to verify compilation against the unit test framework */ + +#define BOOST_TEST_MODULE EmptyTest +#include + +namespace { +BOOST_AUTO_TEST_CASE(Empty) {} +} // namespace diff --git a/mosesdecoder/jam-files/engine/class.h b/mosesdecoder/jam-files/engine/class.h new file mode 100644 index 0000000000000000000000000000000000000000..256d298b53242985247c3791a7ecad3a262187d4 --- /dev/null +++ b/mosesdecoder/jam-files/engine/class.h @@ -0,0 +1,14 @@ +/* Copyright Vladimir Prus 2003. 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) */ + +#ifndef CLASS_H_VP_2003_08_01 +#define CLASS_H_VP_2003_08_01 + +#include "lists.h" +#include "frames.h" + +OBJECT * make_class_module( LIST * xname, LIST * bases, FRAME * frame ); +void class_done( void ); + +#endif diff --git a/mosesdecoder/jam-files/engine/command.c b/mosesdecoder/jam-files/engine/command.c new file mode 100644 index 0000000000000000000000000000000000000000..571b8b6d072691945595ceab7048dda527164970 --- /dev/null +++ b/mosesdecoder/jam-files/engine/command.c @@ -0,0 +1,84 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* This file is ALSO: + * Copyright 2001-2004 David Abrahams. + * 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) + */ + +/* + * command.c - maintain lists of commands + */ + +#include "jam.h" +#include "command.h" + +#include "lists.h" +#include "rules.h" + +#include + + +/* + * cmd_new() - return a new CMD. + */ + +CMD * cmd_new( RULE * rule, LIST * targets, LIST * sources, LIST * shell ) +{ + CMD * cmd = (CMD *)BJAM_MALLOC( sizeof( CMD ) ); + FRAME frame[ 1 ]; + + assert( cmd ); + cmd->rule = rule; + cmd->shell = shell; + cmd->next = 0; + cmd->noop = 0; + + lol_init( &cmd->args ); + lol_add( &cmd->args, targets ); + lol_add( &cmd->args, sources ); + string_new( cmd->buf ); + + frame_init( frame ); + frame->module = rule->module; + lol_init( frame->args ); + lol_add( frame->args, list_copy( targets ) ); + lol_add( frame->args, list_copy( sources ) ); + function_run_actions( rule->actions->command, frame, stack_global(), + cmd->buf ); + frame_free( frame ); + + return cmd; +} + + +/* + * cmd_free() - free a CMD + */ + +void cmd_free( CMD * cmd ) +{ + lol_free( &cmd->args ); + list_free( cmd->shell ); + string_free( cmd->buf ); + BJAM_FREE( (void *)cmd ); +} + + +/* + * cmd_release_targets_and_shell() + * + * Makes the CMD release its hold on its targets & shell lists and forget + * about them. Useful in case caller still has references to those lists and + * wants to reuse them after freeing the CMD object. + */ + +void cmd_release_targets_and_shell( CMD * cmd ) +{ + cmd->args.list[ 0 ] = L0; /* targets */ + cmd->shell = L0; /* shell */ +} diff --git a/mosesdecoder/jam-files/engine/compile.c b/mosesdecoder/jam-files/engine/compile.c new file mode 100644 index 0000000000000000000000000000000000000000..db46937ca499d00f56af3a228f8bad36a5382ade --- /dev/null +++ b/mosesdecoder/jam-files/engine/compile.c @@ -0,0 +1,271 @@ +/* + * Copyright 1993, 2000 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* This file is ALSO: + * Copyright 2001-2004 David Abrahams. + * 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) + */ + +/* + * compile.c - compile parsed jam statements + * + * External routines: + * evaluate_rule() - execute a rule invocation + * + * Internal routines: + * debug_compile() - printf with indent to show rule expansion + */ + +#include "jam.h" +#include "compile.h" + +#include "builtins.h" +#include "class.h" +#include "constants.h" +#include "hash.h" +#include "hdrmacro.h" +#include "make.h" +#include "modules.h" +#include "parse.h" +#include "rules.h" +#include "search.h" +#include "strings.h" +#include "variable.h" + +#include +#include +#include + + +static void debug_compile( int which, char const * s, FRAME * ); + +/* Internal functions from builtins.c */ +void backtrace( FRAME * ); +void backtrace_line( FRAME * ); +void print_source_line( FRAME * ); +void unknown_rule( FRAME *, char const * key, module_t *, OBJECT * rule_name ); + + +/* + * evaluate_rule() - execute a rule invocation + */ + +LIST * evaluate_rule( RULE * rule, OBJECT * rulename, FRAME * frame ) +{ + LIST * result = L0; + profile_frame prof[ 1 ]; + module_t * prev_module = frame->module; + + if ( DEBUG_COMPILE ) + { + /* Try hard to indicate in which module the rule is going to execute. */ + char buf[ 256 ] = ""; + if ( rule->module->name ) + { + strncat( buf, object_str( rule->module->name ), sizeof( buf ) - + 1 ); + strncat( buf, ".", sizeof( buf ) - 1 ); + if ( strncmp( buf, object_str( rule->name ), strlen( buf ) ) == 0 ) + { + buf[ 0 ] = 0; + } + } + strncat( buf, object_str( rule->name ), sizeof( buf ) - 1 ); + debug_compile( 1, buf, frame ); + + lol_print( frame->args ); + printf( "\n" ); + } + + if ( rule->procedure && rule->module != prev_module ) + { + /* Propagate current module to nested rule invocations. */ + frame->module = rule->module; + } + + /* Record current rule name in frame. */ + if ( rule->procedure ) + { + frame->rulename = object_str( rulename ); + /* And enter record profile info. */ + if ( DEBUG_PROFILE ) + profile_enter( function_rulename( rule->procedure ), prof ); + } + + /* Check traditional targets $(<) and sources $(>). */ + if ( !rule->actions && !rule->procedure ) + unknown_rule( frame, NULL, frame->module, rule->name ); + + /* If this rule will be executed for updating the targets then construct the + * action for make(). + */ + if ( rule->actions ) + { + TARGETS * t; + + /* The action is associated with this instance of this rule. */ + ACTION * const action = (ACTION *)BJAM_MALLOC( sizeof( ACTION ) ); + memset( (char *)action, '\0', sizeof( *action ) ); + + action->rule = rule; + action->targets = targetlist( (TARGETS *)0, lol_get( frame->args, 0 ) ); + action->sources = targetlist( (TARGETS *)0, lol_get( frame->args, 1 ) ); + action->refs = 1; + + /* If we have a group of targets all being built using the same action + * then we must not allow any of them to be used as sources unless they + * are all up to date and their action does not need to be run or their + * action has had a chance to finish its work and build all of them + * anew. + * + * Without this it might be possible, in case of a multi-process build, + * for their action, triggered to building one of the targets, to still + * be running when another target in the group reports as done in order + * to avoid triggering the same action again and gets used prematurely. + * + * As a quick-fix to achieve this effect we make all the targets list + * each other as 'included targets'. More precisely, we mark the first + * listed target as including all the other targets in the list and vice + * versa. This makes anyone depending on any of those targets implicitly + * depend on all of them, thus making sure none of those targets can be + * used as sources until all of them have been built. Note that direct + * dependencies could not have been used due to the 'circular + * dependency' issue. + * + * TODO: Although the current implementation solves the problem of one + * of the targets getting used before its action completes its work, it + * also forces the action to run whenever any of the targets in the + * group is not up to date even though some of them might not actually + * be used by the targets being built. We should see how we can + * correctly recognize such cases and use that to avoid running the + * action if possible and not rebuild targets not actually depending on + * targets that are not up to date. + * + * TODO: Current solution using fake INCLUDES relations may cause + * actions to be run when the affected targets are built by multiple + * actions. E.g. if we have the following actions registered in the + * order specified: + * (I) builds targets A & B + * (II) builds target B + * and we want to build a target depending on target A, then both + * actions (I) & (II) will be run, even though the second one does not + * have any direct relationship to target A. Consider whether this is + * desired behaviour or not. It could be that Boost Build should (or + * possibly already does) run all actions registered for a given target + * if any of them needs to be run in which case our INCLUDES relations + * are not actually causing any actions to be run that would not have + * been run without them. + */ + if ( action->targets ) + { + TARGET * const t0 = action->targets->target; + for ( t = action->targets->next; t; t = t->next ) + { + target_include( t->target, t0 ); + target_include( t0, t->target ); + } + } + + /* Append this action to the actions of each target. */ + for ( t = action->targets; t; t = t->next ) + t->target->actions = actionlist( t->target->actions, action ); + + action_free( action ); + } + + /* Now recursively compile any parse tree associated with this rule. + * function_refer()/function_free() call pair added to ensure the rule does + * not get freed while in use. + */ + if ( rule->procedure ) + { + FUNCTION * const function = rule->procedure; + function_refer( function ); + result = function_run( function, frame, stack_global() ); + function_free( function ); + } + + if ( DEBUG_PROFILE && rule->procedure ) + profile_exit( prof ); + + if ( DEBUG_COMPILE ) + debug_compile( -1, 0, frame ); + + return result; +} + + +/* + * Call the given rule with the specified parameters. The parameters should be + * of type LIST* and end with a NULL pointer. This differs from 'evaluate_rule' + * in that frame for the called rule is prepared inside 'call_rule'. + * + * This function is useful when a builtin rule (in C) wants to call another rule + * which might be implemented in Jam. + */ + +LIST * call_rule( OBJECT * rulename, FRAME * caller_frame, ... ) +{ + va_list va; + LIST * result; + + FRAME inner[ 1 ]; + frame_init( inner ); + inner->prev = caller_frame; + inner->prev_user = caller_frame->module->user_module + ? caller_frame + : caller_frame->prev_user; + inner->module = caller_frame->module; + + va_start( va, caller_frame ); + for ( ; ; ) + { + LIST * const l = va_arg( va, LIST * ); + if ( !l ) + break; + lol_add( inner->args, l ); + } + va_end( va ); + + result = evaluate_rule( bindrule( rulename, inner->module ), rulename, inner ); + + frame_free( inner ); + + return result; +} + + +/* + * debug_compile() - printf with indent to show rule expansion + */ + +static void debug_compile( int which, char const * s, FRAME * frame ) +{ + static int level = 0; + static char indent[ 36 ] = ">>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|"; + + if ( which >= 0 ) + { + int i; + + print_source_line( frame ); + + i = ( level + 1 ) * 2; + while ( i > 35 ) + { + fputs( indent, stdout ); + i -= 35; + } + + printf( "%*.*s ", i, i, indent ); + } + + if ( s ) + printf( "%s ", s ); + + level += which; +} diff --git a/mosesdecoder/jam-files/engine/cwd.h b/mosesdecoder/jam-files/engine/cwd.h new file mode 100644 index 0000000000000000000000000000000000000000..886714a8fd75e0b9a8e05adaa0b9350a7678e778 --- /dev/null +++ b/mosesdecoder/jam-files/engine/cwd.h @@ -0,0 +1,35 @@ +/* + * Copyright 2002. Vladimir Prus + * 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) + */ + +/* + * cwd.h - manages the current working folder information + */ + +#ifndef CWD_H +#define CWD_H + +#include "object.h" + + +/* cwd() - returns the current working folder */ +OBJECT * cwd( void ); + +/* cwd_init() - initialize the cwd module functionality + * + * The current working folder can not change in Boost Jam so this function + * gets the current working folder information from the OS and stores it + * internally. + * + * Expected to be called at program startup before the program's current + * working folder has been changed + */ +void cwd_init( void ); + +/* cwd_done() - cleans up the cwd module functionality */ +void cwd_done( void ); + +#endif diff --git a/mosesdecoder/jam-files/engine/debug.c b/mosesdecoder/jam-files/engine/debug.c new file mode 100644 index 0000000000000000000000000000000000000000..2a656551bfca77b145a108aaaab17f3bf8faf483 --- /dev/null +++ b/mosesdecoder/jam-files/engine/debug.c @@ -0,0 +1,145 @@ +/* + * Copyright 2005. 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) + */ + +#include "jam.h" +#include "debug.h" + +#include "hash.h" + + +static profile_frame * profile_stack = 0; +static struct hash * profile_hash = 0; +static profile_info profile_other = { 0 }; +static profile_info profile_total = { 0 }; + + +profile_frame * profile_init( OBJECT * rulename, profile_frame * frame ) +{ + if ( DEBUG_PROFILE ) profile_enter( rulename, frame ); + return frame; +} + + +void profile_enter( OBJECT * rulename, profile_frame * frame ) +{ + if ( DEBUG_PROFILE ) + { + clock_t start = clock(); + profile_info * p; + + if ( !profile_hash && rulename ) + profile_hash = hashinit( sizeof( profile_info ), "profile" ); + + if ( rulename ) + { + int found; + p = (profile_info *)hash_insert( profile_hash, rulename, &found ); + if ( !found ) + { + p->name = rulename; + p->cumulative = 0; + p->net = 0; + p->num_entries = 0; + p->stack_count = 0; + p->memory = 0; + } + } + else + { + p = &profile_other; + } + + ++p->num_entries; + ++p->stack_count; + + frame->info = p; + + frame->caller = profile_stack; + profile_stack = frame; + + frame->entry_time = clock(); + frame->overhead = 0; + frame->subrules = 0; + + /* caller pays for the time it takes to play with the hash table */ + if ( frame->caller ) + frame->caller->overhead += frame->entry_time - start; + } +} + + +void profile_memory( long mem ) +{ + if ( DEBUG_PROFILE ) + if ( profile_stack && profile_stack->info ) + profile_stack->info->memory += mem; +} + + +void profile_exit( profile_frame * frame ) +{ + if ( DEBUG_PROFILE ) + { + /* Cumulative time for this call. */ + clock_t const t = clock() - frame->entry_time - frame->overhead; + /* If this rule is already present on the stack, do not add the time for + * this instance. + */ + if ( frame->info->stack_count == 1 ) + frame->info->cumulative += t; + /* Net time does not depend on presense of the same rule in call stack. + */ + frame->info->net += t - frame->subrules; + + if ( frame->caller ) + { + /* Caller's cumulative time must account for this overhead. */ + frame->caller->overhead += frame->overhead; + frame->caller->subrules += t; + } + /* Pop this stack frame. */ + --frame->info->stack_count; + profile_stack = frame->caller; + } +} + + +static void dump_profile_entry( void * p_, void * ignored ) +{ + profile_info * p = (profile_info *)p_; + unsigned long mem_each = ( p->memory / ( p->num_entries ? p->num_entries : 1 + ) ); + double cumulative = p->cumulative; + double net = p->net; + double q = p->net; + q /= ( p->num_entries ? p->num_entries : 1 ); + cumulative /= CLOCKS_PER_SEC; + net /= CLOCKS_PER_SEC; + q /= CLOCKS_PER_SEC; + if ( !ignored ) + { + profile_total.cumulative += p->net; + profile_total.memory += p->memory; + } + printf( "%10ld %12.6f %12.6f %12.8f %10ld %10ld %s\n", p->num_entries, + cumulative, net, q, p->memory, mem_each, object_str( p->name ) ); +} + + +void profile_dump() +{ + if ( profile_hash ) + { + printf( "%10s %12s %12s %12s %10s %10s %s\n", "--count--", "--gross--", + "--net--", "--each--", "--mem--", "--each--", "--name--" ); + hashenumerate( profile_hash, dump_profile_entry, 0 ); + profile_other.name = constant_other; + dump_profile_entry( &profile_other, 0 ); + profile_total.name = constant_total; + dump_profile_entry( &profile_total, (void *)1 ); + } +} diff --git a/mosesdecoder/jam-files/engine/debug.h b/mosesdecoder/jam-files/engine/debug.h new file mode 100644 index 0000000000000000000000000000000000000000..4151d27fabd92f8abdb5831a35ff04e8c7b1c2a9 --- /dev/null +++ b/mosesdecoder/jam-files/engine/debug.h @@ -0,0 +1,55 @@ +/* + * Copyright 2005. 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) + */ + +#ifndef BJAM_DEBUG_H +#define BJAM_DEBUG_H + +#include "constants.h" +#include "object.h" +#include + + +typedef struct profile_info +{ + /* name of rule being called */ + OBJECT * name; + /* cumulative time spent in rule */ + clock_t cumulative; + /* time spent in rule proper */ + clock_t net; + /* number of time rule was entered */ + unsigned long num_entries; + /* number of the times this function is present in stack */ + unsigned long stack_count; + /* bytes of memory allocated by the call */ + unsigned long memory; +} profile_info; + +typedef struct profile_frame +{ + /* permanent storage where data accumulates */ + profile_info * info; + /* overhead for profiling in this call */ + clock_t overhead; + /* time of last entry to rule */ + clock_t entry_time; + /* stack frame of caller */ + struct profile_frame * caller; + /* time spent in subrules */ + clock_t subrules; +} profile_frame; + +profile_frame * profile_init( OBJECT * rulename, profile_frame * ); +void profile_enter( OBJECT * rulename, profile_frame * ); +void profile_memory( long mem ); +void profile_exit( profile_frame * ); +void profile_dump(); + +#define PROFILE_ENTER( scope ) profile_frame PROF_ ## scope, *PROF_ ## scope ## _p = profile_init( constant_ ## scope, &PROF_ ## scope ) +#define PROFILE_EXIT( scope ) profile_exit( PROF_ ## scope ## _p ) + +#endif diff --git a/mosesdecoder/jam-files/engine/execcmd.c b/mosesdecoder/jam-files/engine/execcmd.c new file mode 100644 index 0000000000000000000000000000000000000000..f751cbff3369a5adcfe4831e6738c00ab24ad1f2 --- /dev/null +++ b/mosesdecoder/jam-files/engine/execcmd.c @@ -0,0 +1,121 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * Copyright 2007 Noel Belcourt. + * + * Utility functions shared between different exec*.c platform specific + * implementation modules. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +#include "jam.h" +#include "execcmd.h" + +#include +#include +#include + + +/* Internal interrupt counter. */ +static int intr; + + +/* Constructs a list of command-line elements using the format specified by the + * given shell list. + * + * Given argv array should have at least MAXARGC + 1 elements. + * Slot numbers may be between 0 and 998 (inclusive). + * + * Constructed argv list will be zero terminated. Character arrays referenced by + * the argv structure elements will be either elements from the give shell list, + * internal static buffers or the given command string and should thus not + * considered owned by or released via the argv structure and should be + * considered invalidated by the next argv_from_shell() call. + * + * Shell list elements: + * - Starting with '%' - represent the command string. + * - Starting with '!' - represent the slot number (increased by one). + * - Anything else - used as a literal. + * - If no '%' element is found, the command string is appended as an extra. + */ + +void argv_from_shell( char const * * argv, LIST * shell, char const * command, + int const slot ) +{ + static char jobno[ 4 ]; + + int i; + int gotpercent = 0; + LISTITER iter = list_begin( shell ); + LISTITER end = list_end( shell ); + + assert( 0 <= slot ); + assert( slot < 999 ); + sprintf( jobno, "%d", slot + 1 ); + + for ( i = 0; iter != end && i < MAXARGC; ++i, iter = list_next( iter ) ) + { + switch ( object_str( list_item( iter ) )[ 0 ] ) + { + case '%': argv[ i ] = command; ++gotpercent; break; + case '!': argv[ i ] = jobno; break; + default : argv[ i ] = object_str( list_item( iter ) ); + } + } + + if ( !gotpercent ) + argv[ i++ ] = command; + + argv[ i ] = NULL; +} + + +/* Returns whether the given command string contains lines longer than the given + * maximum. + */ +int check_cmd_for_too_long_lines( char const * command, int const max, + int * const error_length, int * const error_max_length ) +{ + while ( *command ) + { + size_t const l = strcspn( command, "\n" ); + if ( l > max ) + { + *error_length = l; + *error_max_length = max; + return EXEC_CHECK_LINE_TOO_LONG; + } + command += l; + if ( *command ) + ++command; + } + return EXEC_CHECK_OK; +} + + +/* Checks whether the given shell list is actually a request to execute raw + * commands without an external shell. + */ +int is_raw_command_request( LIST * shell ) +{ + return !list_empty( shell ) && + !strcmp( object_str( list_front( shell ) ), "%" ) && + list_next( list_begin( shell ) ) == list_end( shell ); +} + + +/* Returns whether an interrupt has been detected so far. */ + +int interrupted( void ) +{ + return intr != 0; +} + + +/* Internal interrupt handler. */ + +void onintr( int disp ) +{ + ++intr; + printf( "...interrupted\n" ); +} diff --git a/mosesdecoder/jam-files/engine/execnt.c b/mosesdecoder/jam-files/engine/execnt.c new file mode 100644 index 0000000000000000000000000000000000000000..ca89bd0f01ef163d862f208c7712169a7cde6aee --- /dev/null +++ b/mosesdecoder/jam-files/engine/execnt.c @@ -0,0 +1,1232 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* This file is ALSO: + * Copyright 2001-2004 David Abrahams. + * Copyright 2007 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) + */ + +/* + * execnt.c - execute a shell command on Windows NT + * + * If $(JAMSHELL) is defined, uses that to formulate the actual command. The + * default is: cmd.exe /Q/C + * + * In $(JAMSHELL), % expands to the command string and ! expands to the slot + * number (starting at 1) for multiprocess (-j) invocations. If $(JAMSHELL) does + * not include a %, it is tacked on as the last argument. + * + * Each $(JAMSHELL) placeholder must be specified as a separate individual + * element in a jam variable value. + * + * Do not just set JAMSHELL to cmd.exe - it will not work! + * + * External routines: + * exec_check() - preprocess and validate the command + * exec_cmd() - launch an async command execution + * exec_wait() - wait for any of the async command processes to terminate + * + * Internal routines: + * filetime_to_seconds() - Windows FILETIME --> number of seconds conversion + */ + +#include "jam.h" +#ifdef USE_EXECNT +#include "execcmd.h" + +#include "lists.h" +#include "output.h" +#include "pathsys.h" +#include "string.h" + +#include +#include +#include +#include + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include + + +/* get the maximum shell command line length according to the OS */ +static int maxline(); +/* valid raw command string length */ +static long raw_command_length( char const * command ); +/* add two 64-bit unsigned numbers, h1l1 and h2l2 */ +static FILETIME add_64( + unsigned long h1, unsigned long l1, + unsigned long h2, unsigned long l2 ); +/* */ +static FILETIME add_FILETIME( FILETIME t1, FILETIME t2 ); +/* */ +static FILETIME negate_FILETIME( FILETIME t ); +/* record the timing info for the process */ +static void record_times( HANDLE const, timing_info * const ); +/* calc the current running time of an *active* process */ +static double running_time( HANDLE const ); +/* terminate the given process, after terminating all its children first */ +static void kill_process_tree( DWORD const procesdId, HANDLE const ); +/* waits for a command to complete or time out */ +static int try_wait( int const timeoutMillis ); +/* reads any pending output for running commands */ +static void read_output(); +/* checks if a command ran out of time, and kills it */ +static int try_kill_one(); +/* is the first process a parent (direct or indirect) to the second one */ +static int is_parent_child( DWORD const parent, DWORD const child ); +/* */ +static void close_alert( PROCESS_INFORMATION const * const ); +/* close any alerts hanging around */ +static void close_alerts(); +/* prepare a command file to be executed using an external shell */ +static char const * prepare_command_file( string const * command, int slot ); +/* invoke the actual external process using the given command line */ +static void invoke_cmd( char const * const command, int const slot ); +/* find a free slot in the running commands table */ +static int get_free_cmdtab_slot(); +/* put together the final command string we are to run */ +static void string_new_from_argv( string * result, char const * const * argv ); +/* frees and renews the given string */ +static void string_renew( string * const ); +/* reports the last failed Windows API related error message */ +static void reportWindowsError( char const * const apiName ); +/* closes a Windows HANDLE and resets its variable to 0. */ +static void closeWinHandle( HANDLE * const handle ); + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +/* CreateProcessA() Windows API places a limit of 32768 characters (bytes) on + * the allowed command-line length, including a trailing Unicode (2-byte) + * nul-terminator character. + */ +#define MAX_RAW_COMMAND_LENGTH 32766 + +/* We hold handles for pipes used to communicate with child processes in two + * element arrays indexed as follows. + */ +#define EXECCMD_PIPE_READ 0 +#define EXECCMD_PIPE_WRITE 1 + +static int intr_installed; + + +/* The list of commands we run. */ +static struct +{ + /* Temporary command file used to execute the action when needed. */ + string command_file[ 1 ]; + + /* Pipes for communicating with the child process. Parent reads from (0), + * child writes to (1). + */ + HANDLE pipe_out[ 2 ]; + HANDLE pipe_err[ 2 ]; + + string buffer_out[ 1 ]; /* buffer to hold stdout, if any */ + string buffer_err[ 1 ]; /* buffer to hold stderr, if any */ + + PROCESS_INFORMATION pi; /* running process information */ + + /* Function called when the command completes. */ + ExecCmdCallback func; + + /* Opaque data passed back to the 'func' callback. */ + void * closure; +} +cmdtab[ MAXJOBS ] = { { 0 } }; + + +/* + * Execution unit tests. + */ + +void execnt_unit_test() +{ +#if !defined( NDEBUG ) + /* vc6 preprocessor is broken, so assert with these strings gets confused. + * Use a table instead. + */ + { + typedef struct test { char * command; int result; } test; + test tests[] = { + { "", 0 }, + { " ", 0 }, + { "x", 1 }, + { "\nx", 1 }, + { "x\n", 1 }, + { "\nx\n", 1 }, + { "\nx \n", 2 }, + { "\nx \n ", 2 }, + { " \n\t\t\v\r\r\n \t x \v \t\t\r\n\n\n \n\n\v\t", 8 }, + { "x\ny", -1 }, + { "x\n\n y", -1 }, + { "echo x > foo.bar", -1 }, + { "echo x < foo.bar", -1 }, + { "echo x | foo.bar", -1 }, + { "echo x \">\" foo.bar", 18 }, + { "echo x '<' foo.bar", 18 }, + { "echo x \"|\" foo.bar", 18 }, + { "echo x \\\">\\\" foo.bar", -1 }, + { "echo x \\\"<\\\" foo.bar", -1 }, + { "echo x \\\"|\\\" foo.bar", -1 }, + { "\"echo x > foo.bar\"", 18 }, + { "echo x \"'\"<' foo.bar", -1 }, + { "echo x \\\\\"<\\\\\" foo.bar", 22 }, + { "echo x \\x\\\"<\\\\\" foo.bar", -1 }, + { 0 } }; + test const * t; + for ( t = tests; t->command; ++t ) + assert( raw_command_length( t->command ) == t->result ); + } + + { + int const length = maxline() + 9; + char * const cmd = (char *)BJAM_MALLOC_ATOMIC( length + 1 ); + memset( cmd, 'x', length ); + cmd[ length ] = 0; + assert( raw_command_length( cmd ) == length ); + BJAM_FREE( cmd ); + } +#endif +} + + +/* + * exec_check() - preprocess and validate the command + */ + +int exec_check +( + string const * command, + LIST * * pShell, + int * error_length, + int * error_max_length +) +{ + /* Default shell does nothing when triggered with an empty or a + * whitespace-only command so we simply skip running it in that case. We + * still pass them on to non-default shells as we do not really know what + * they are going to do with such commands. + */ + if ( list_empty( *pShell ) ) + { + char const * s = command->value; + while ( isspace( *s ) ) ++s; + if ( !*s ) + return EXEC_CHECK_NOOP; + } + + /* Check prerequisites for executing raw commands. */ + if ( is_raw_command_request( *pShell ) ) + { + int const raw_cmd_length = raw_command_length( command->value ); + if ( raw_cmd_length < 0 ) + { + /* Invalid characters detected - fallback to default shell. */ + list_free( *pShell ); + *pShell = L0; + } + else if ( raw_cmd_length > MAX_RAW_COMMAND_LENGTH ) + { + *error_length = raw_cmd_length; + *error_max_length = MAX_RAW_COMMAND_LENGTH; + return EXEC_CHECK_TOO_LONG; + } + else + return raw_cmd_length ? EXEC_CHECK_OK : EXEC_CHECK_NOOP; + } + + /* Now we know we are using an external shell. Note that there is no need to + * check for too long command strings when using an external shell since we + * use a command file and assume no one is going to set up a JAMSHELL format + * string longer than a few hundred bytes at most which should be well under + * the total command string limit. Should someone actually construct such a + * JAMSHELL value it will get reported as an 'invalid parameter' + * CreateProcessA() Windows API failure which seems like a good enough + * result for such intentional mischief. + */ + + /* Check for too long command lines. */ + return check_cmd_for_too_long_lines( command->value, maxline(), + error_length, error_max_length ); +} + + +/* + * exec_cmd() - launch an async command execution + * + * We assume exec_check() already verified that the given command can have its + * command string constructed as requested. + */ + +void exec_cmd +( + string const * cmd_orig, + ExecCmdCallback func, + void * closure, + LIST * shell +) +{ + int const slot = get_free_cmdtab_slot(); + int const is_raw_cmd = is_raw_command_request( shell ); + string cmd_local[ 1 ]; + + /* Initialize default shell - anything more than /Q/C is non-portable. */ + static LIST * default_shell; + if ( !default_shell ) + default_shell = list_new( object_new( "cmd.exe /Q/C" ) ); + + /* Specifying no shell means requesting the default shell. */ + if ( list_empty( shell ) ) + shell = default_shell; + + if ( DEBUG_EXECCMD ) + if ( is_raw_cmd ) + printf( "Executing raw command directly\n" ); + else + { + printf( "Executing using a command file and the shell: " ); + list_print( shell ); + printf( "\n" ); + } + + /* If we are running a raw command directly - trim its leading whitespaces + * as well as any trailing all-whitespace lines but keep any trailing + * whitespace in the final/only line containing something other than + * whitespace). + */ + if ( is_raw_cmd ) + { + char const * start = cmd_orig->value; + char const * p = cmd_orig->value + cmd_orig->size; + char const * end = p; + while ( isspace( *start ) ) ++start; + while ( p > start && isspace( p[ -1 ] ) ) + if ( *--p == '\n' ) + end = p; + string_new( cmd_local ); + string_append_range( cmd_local, start, end ); + assert( cmd_local->size == raw_command_length( cmd_orig->value ) ); + } + /* If we are not running a raw command directly, prepare a command file to + * be executed using an external shell and the actual command string using + * that command file. + */ + else + { + char const * const cmd_file = prepare_command_file( cmd_orig, slot ); + char const * argv[ MAXARGC + 1 ]; /* +1 for NULL */ + argv_from_shell( argv, shell, cmd_file, slot ); + string_new_from_argv( cmd_local, argv ); + } + + /* Catch interrupts whenever commands are running. */ + if ( !intr_installed ) + { + intr_installed = 1; + signal( SIGINT, onintr ); + } + + /* Save input data into the selected running commands table slot. */ + cmdtab[ slot ].func = func; + cmdtab[ slot ].closure = closure; + + /* Invoke the actual external process using the constructed command line. */ + invoke_cmd( cmd_local->value, slot ); + + /* Free our local command string copy. */ + string_free( cmd_local ); +} + + +/* + * exec_wait() - wait for any of the async command processes to terminate + * + * Wait and drive at most one execution completion, while processing the I/O for + * all ongoing commands. + */ + +void exec_wait() +{ + int i = -1; + int exit_reason; /* reason why a command completed */ + + /* Wait for a command to complete, while snarfing up any output. */ + while ( 1 ) + { + /* Check for a complete command, briefly. */ + i = try_wait( 500 ); + /* Read in the output of all running commands. */ + read_output(); + /* Close out pending debug style dialogs. */ + close_alerts(); + /* Process the completed command we found. */ + if ( i >= 0 ) { exit_reason = EXIT_OK; break; } + /* Check if a command ran out of time. */ + i = try_kill_one(); + if ( i >= 0 ) { exit_reason = EXIT_TIMEOUT; break; } + } + + /* We have a command... process it. */ + { + DWORD exit_code; + timing_info time; + int rstat; + + /* The time data for the command. */ + record_times( cmdtab[ i ].pi.hProcess, &time ); + + /* Removed the used temporary command file. */ + if ( cmdtab[ i ].command_file->size ) + unlink( cmdtab[ i ].command_file->value ); + + /* Find out the process exit code. */ + GetExitCodeProcess( cmdtab[ i ].pi.hProcess, &exit_code ); + + /* The dispossition of the command. */ + if ( interrupted() ) + rstat = EXEC_CMD_INTR; + else if ( exit_code ) + rstat = EXEC_CMD_FAIL; + else + rstat = EXEC_CMD_OK; + + /* Call the callback, may call back to jam rule land. */ + (*cmdtab[ i ].func)( cmdtab[ i ].closure, rstat, &time, + cmdtab[ i ].buffer_out->value, cmdtab[ i ].buffer_err->value, + exit_reason ); + + /* Clean up our child process tracking data. No need to clear the + * temporary command file name as it gets reused. + */ + closeWinHandle( &cmdtab[ i ].pi.hProcess ); + closeWinHandle( &cmdtab[ i ].pi.hThread ); + closeWinHandle( &cmdtab[ i ].pipe_out[ EXECCMD_PIPE_READ ] ); + closeWinHandle( &cmdtab[ i ].pipe_out[ EXECCMD_PIPE_WRITE ] ); + closeWinHandle( &cmdtab[ i ].pipe_err[ EXECCMD_PIPE_READ ] ); + closeWinHandle( &cmdtab[ i ].pipe_err[ EXECCMD_PIPE_WRITE ] ); + string_renew( cmdtab[ i ].buffer_out ); + string_renew( cmdtab[ i ].buffer_err ); + } +} + + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +/* + * Invoke the actual external process using the given command line. Track the + * process in our running commands table. + */ + +static void invoke_cmd( char const * const command, int const slot ) +{ + SECURITY_ATTRIBUTES sa = { sizeof( SECURITY_ATTRIBUTES ), 0, 0 }; + SECURITY_DESCRIPTOR sd; + STARTUPINFO si = { sizeof( STARTUPINFO ), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 }; + + /* Init the security data. */ + InitializeSecurityDescriptor( &sd, SECURITY_DESCRIPTOR_REVISION ); + SetSecurityDescriptorDacl( &sd, TRUE, NULL, FALSE ); + sa.lpSecurityDescriptor = &sd; + sa.bInheritHandle = TRUE; + + /* Create pipes for communicating with the child process. */ + if ( !CreatePipe( &cmdtab[ slot ].pipe_out[ EXECCMD_PIPE_READ ], + &cmdtab[ slot ].pipe_out[ EXECCMD_PIPE_WRITE ], &sa, 0 ) ) + { + reportWindowsError( "CreatePipe" ); + exit( EXITBAD ); + } + if ( globs.pipe_action && !CreatePipe( &cmdtab[ slot ].pipe_err[ + EXECCMD_PIPE_READ ], &cmdtab[ slot ].pipe_err[ EXECCMD_PIPE_WRITE ], + &sa, 0 ) ) + { + reportWindowsError( "CreatePipe" ); + exit( EXITBAD ); + } + + /* Set handle inheritance off for the pipe ends the parent reads from. */ + SetHandleInformation( cmdtab[ slot ].pipe_out[ EXECCMD_PIPE_READ ], + HANDLE_FLAG_INHERIT, 0 ); + if ( globs.pipe_action ) + SetHandleInformation( cmdtab[ slot ].pipe_err[ EXECCMD_PIPE_READ ], + HANDLE_FLAG_INHERIT, 0 ); + + /* Hide the child window, if any. */ + si.dwFlags |= STARTF_USESHOWWINDOW; + si.wShowWindow = SW_HIDE; + + /* Redirect the child's output streams to our pipes. */ + si.dwFlags |= STARTF_USESTDHANDLES; + si.hStdOutput = cmdtab[ slot ].pipe_out[ EXECCMD_PIPE_WRITE ]; + si.hStdError = globs.pipe_action + ? cmdtab[ slot ].pipe_err[ EXECCMD_PIPE_WRITE ] + : cmdtab[ slot ].pipe_out[ EXECCMD_PIPE_WRITE ]; + + /* Let the child inherit stdin, as some commands assume it is available. */ + si.hStdInput = GetStdHandle( STD_INPUT_HANDLE ); + + /* Create output buffers. */ + string_new( cmdtab[ slot ].buffer_out ); + string_new( cmdtab[ slot ].buffer_err ); + + if ( DEBUG_EXECCMD ) + printf( "Command string for CreateProcessA(): '%s'\n", command ); + + /* Run the command by creating a sub-process for it. */ + if ( !CreateProcessA( + NULL , /* application name */ + (char *)command , /* command line */ + NULL , /* process attributes */ + NULL , /* thread attributes */ + TRUE , /* inherit handles */ + CREATE_NEW_PROCESS_GROUP, /* create flags */ + NULL , /* env vars, null inherits env */ + NULL , /* current dir, null is our current dir */ + &si , /* startup info */ + &cmdtab[ slot ].pi ) ) /* child process info, if created */ + { + reportWindowsError( "CreateProcessA" ); + exit( EXITBAD ); + } +} + + +/* + * For more details on Windows cmd.exe shell command-line length limitations see + * the following MSDN article: + * http://support.microsoft.com/default.aspx?scid=kb;en-us;830473 + */ + +static int raw_maxline() +{ + OSVERSIONINFO os_info; + os_info.dwOSVersionInfoSize = sizeof( os_info ); + GetVersionEx( &os_info ); + + if ( os_info.dwMajorVersion >= 5 ) return 8191; /* XP */ + if ( os_info.dwMajorVersion == 4 ) return 2047; /* NT 4.x */ + return 996; /* NT 3.5.1 */ +} + +static int maxline() +{ + static result; + if ( !result ) result = raw_maxline(); + return result; +} + + +/* + * Closes a Windows HANDLE and resets its variable to 0. + */ + +static void closeWinHandle( HANDLE * const handle ) +{ + if ( *handle ) + { + CloseHandle( *handle ); + *handle = 0; + } +} + + +/* + * Frees and renews the given string. + */ + +static void string_renew( string * const s ) +{ + string_free( s ); + string_new( s ); +} + + +/* + * raw_command_length() - valid raw command string length + * + * Checks whether the given command may be executed as a raw command. If yes, + * returns the corresponding command string length. If not, returns -1. + * + * Rules for constructing raw command strings: + * - Command may not contain unquoted shell I/O redirection characters. + * - May have at most one command line with non-whitespace content. + * - Leading whitespace trimmed. + * - Trailing all-whitespace lines trimmed. + * - Trailing whitespace on the sole command line kept (may theoretically + * affect the executed command). + */ + +static long raw_command_length( char const * command ) +{ + char const * p; + char const * escape = 0; + char inquote = 0; + char const * newline = 0; + + /* Skip leading whitespace. */ + while ( isspace( *command ) ) + ++command; + + p = command; + + /* Look for newlines and unquoted I/O redirection. */ + do + { + p += strcspn( p, "\n\"'<>|\\" ); + switch ( *p ) + { + case '\n': + /* If our command contains non-whitespace content split over + * multiple lines we can not execute it directly. + */ + newline = p; + while ( isspace( *++p ) ); + if ( *p ) return -1; + break; + + case '\\': + escape = escape && escape == p - 1 ? 0 : p; + ++p; + break; + + case '"': + case '\'': + if ( escape && escape == p - 1 ) + escape = 0; + else if ( inquote == *p ) + inquote = 0; + else if ( !inquote ) + inquote = *p; + ++p; + break; + + case '<': + case '>': + case '|': + if ( !inquote ) + return -1; + ++p; + break; + } + } + while ( *p ); + + /* Return the number of characters the command will occupy. */ + return ( newline ? newline : p ) - command; +} + + +/* 64-bit arithmetic helpers. */ + +/* Compute the carry bit from the addition of two 32-bit unsigned numbers. */ +#define add_carry_bit( a, b ) ((((a) | (b)) >> 31) & (~((a) + (b)) >> 31) & 0x1) + +/* Compute the high 32 bits of the addition of two 64-bit unsigned numbers, h1l1 + * and h2l2. + */ +#define add_64_hi( h1, l1, h2, l2 ) ((h1) + (h2) + add_carry_bit(l1, l2)) + + +/* + * Add two 64-bit unsigned numbers, h1l1 and h2l2. + */ + +static FILETIME add_64 +( + unsigned long h1, unsigned long l1, + unsigned long h2, unsigned long l2 +) +{ + FILETIME result; + result.dwLowDateTime = l1 + l2; + result.dwHighDateTime = add_64_hi( h1, l1, h2, l2 ); + return result; +} + + +static FILETIME add_FILETIME( FILETIME t1, FILETIME t2 ) +{ + return add_64( t1.dwHighDateTime, t1.dwLowDateTime, t2.dwHighDateTime, + t2.dwLowDateTime ); +} + + +static FILETIME negate_FILETIME( FILETIME t ) +{ + /* 2s complement negation */ + return add_64( ~t.dwHighDateTime, ~t.dwLowDateTime, 0, 1 ); +} + + +/* + * filetime_to_seconds() - Windows FILETIME --> number of seconds conversion + */ + +static double filetime_to_seconds( FILETIME const ft ) +{ + return ft.dwHighDateTime * ( (double)( 1UL << 31 ) * 2.0 * 1.0e-7 ) + + ft.dwLowDateTime * 1.0e-7; +} + + +static void record_times( HANDLE const process, timing_info * const time ) +{ + FILETIME creation; + FILETIME exit; + FILETIME kernel; + FILETIME user; + if ( GetProcessTimes( process, &creation, &exit, &kernel, &user ) ) + { + time->system = filetime_to_seconds( kernel ); + time->user = filetime_to_seconds( user ); + timestamp_from_filetime( &time->start, &creation ); + timestamp_from_filetime( &time->end, &exit ); + } +} + + +#define IO_BUFFER_SIZE ( 16 * 1024 ) + +static char ioBuffer[ IO_BUFFER_SIZE + 1 ]; + + +static void read_pipe +( + HANDLE in, /* the pipe to read from */ + string * out +) +{ + DWORD bytesInBuffer = 0; + DWORD bytesAvailable = 0; + + do + { + /* check if we have any data to read */ + if ( !PeekNamedPipe( in, ioBuffer, IO_BUFFER_SIZE, &bytesInBuffer, + &bytesAvailable, NULL ) ) + bytesAvailable = 0; + + /* read in the available data */ + if ( bytesAvailable > 0 ) + { + /* we only read in the available bytes, to avoid blocking */ + if ( ReadFile( in, ioBuffer, bytesAvailable <= IO_BUFFER_SIZE ? + bytesAvailable : IO_BUFFER_SIZE, &bytesInBuffer, NULL ) ) + { + if ( bytesInBuffer > 0 ) + { + /* Clean up some illegal chars. */ + int i; + for ( i = 0; i < bytesInBuffer; ++i ) + { + if ( ( (unsigned char)ioBuffer[ i ] < 1 ) ) + ioBuffer[ i ] = '?'; + } + /* Null, terminate. */ + ioBuffer[ bytesInBuffer ] = '\0'; + /* Append to the output. */ + string_append( out, ioBuffer ); + /* Subtract what we read in. */ + bytesAvailable -= bytesInBuffer; + } + else + { + /* Likely read a error, bail out. */ + bytesAvailable = 0; + } + } + else + { + /* Definitely read a error, bail out. */ + bytesAvailable = 0; + } + } + } + while ( bytesAvailable > 0 ); +} + + +static void read_output() +{ + int i; + for ( i = 0; i < globs.jobs; ++i ) + if ( cmdtab[ i ].pi.hProcess ) + { + /* Read stdout data. */ + if ( cmdtab[ i ].pipe_out[ EXECCMD_PIPE_READ ] ) + read_pipe( cmdtab[ i ].pipe_out[ EXECCMD_PIPE_READ ], + cmdtab[ i ].buffer_out ); + /* Read stderr data. */ + if ( cmdtab[ i ].pipe_err[ EXECCMD_PIPE_READ ] ) + read_pipe( cmdtab[ i ].pipe_err[ EXECCMD_PIPE_READ ], + cmdtab[ i ].buffer_err ); + } +} + + +/* + * Waits for a single child process command to complete, or the timeout, + * whichever comes first. Returns the index of the completed command in the + * cmdtab array, or -1. + */ + +static int try_wait( int const timeoutMillis ) +{ + int i; + int num_active; + int wait_api_result; + HANDLE active_handles[ MAXJOBS ]; + int active_procs[ MAXJOBS ]; + + /* Prepare a list of all active processes to wait for. */ + for ( num_active = 0, i = 0; i < globs.jobs; ++i ) + if ( cmdtab[ i ].pi.hProcess ) + { + active_handles[ num_active ] = cmdtab[ i ].pi.hProcess; + active_procs[ num_active ] = i; + ++num_active; + } + + /* Wait for a child to complete, or for our timeout window to expire. */ + wait_api_result = WaitForMultipleObjects( num_active, active_handles, + FALSE, timeoutMillis ); + if ( ( WAIT_OBJECT_0 <= wait_api_result ) && + ( wait_api_result < WAIT_OBJECT_0 + num_active ) ) + { + /* Terminated process detected - return its index. */ + return active_procs[ wait_api_result - WAIT_OBJECT_0 ]; + } + + /* Timeout. */ + return -1; +} + + +static int try_kill_one() +{ + /* Only need to check if a timeout was specified with the -l option. */ + if ( globs.timeout > 0 ) + { + int i; + for ( i = 0; i < globs.jobs; ++i ) + if ( cmdtab[ i ].pi.hProcess ) + { + double const t = running_time( cmdtab[ i ].pi.hProcess ); + if ( t > (double)globs.timeout ) + { + /* The job may have left an alert dialog around, try and get + * rid of it before killing the job itself. + */ + close_alert( &cmdtab[ i ].pi ); + /* We have a "runaway" job, kill it. */ + kill_process_tree( cmdtab[ i ].pi.dwProcessId, + cmdtab[ i ].pi.hProcess ); + /* And return its running commands table slot. */ + return i; + } + } + } + return -1; +} + + +static void close_alerts() +{ + /* We only attempt this every 5 seconds or so, because it is not a cheap + * operation, and we will catch the alerts eventually. This check uses + * floats as some compilers define CLOCKS_PER_SEC as a float or double. + */ + if ( ( (float)clock() / (float)( CLOCKS_PER_SEC * 5 ) ) < ( 1.0 / 5.0 ) ) + { + int i; + for ( i = 0; i < globs.jobs; ++i ) + if ( cmdtab[ i ].pi.hProcess ) + close_alert( &cmdtab[ i ].pi ); + } +} + + +/* + * Calc the current running time of an *active* process. + */ + +static double running_time( HANDLE const process ) +{ + FILETIME creation; + FILETIME exit; + FILETIME kernel; + FILETIME user; + if ( GetProcessTimes( process, &creation, &exit, &kernel, &user ) ) + { + /* Compute the elapsed time. */ + FILETIME current; + GetSystemTimeAsFileTime( ¤t ); + return filetime_to_seconds( add_FILETIME( current, + negate_FILETIME( creation ) ) ); + } + return 0.0; +} + + +/* + * Not really optimal, or efficient, but it is easier this way, and it is not + * like we are going to be killing thousands, or even tens of processes. + */ + +static void kill_process_tree( DWORD const pid, HANDLE const process ) +{ + HANDLE const process_snapshot_h = CreateToolhelp32Snapshot( + TH32CS_SNAPPROCESS, 0 ); + if ( INVALID_HANDLE_VALUE != process_snapshot_h ) + { + BOOL ok = TRUE; + PROCESSENTRY32 pinfo; + pinfo.dwSize = sizeof( PROCESSENTRY32 ); + for ( + ok = Process32First( process_snapshot_h, &pinfo ); + ok == TRUE; + ok = Process32Next( process_snapshot_h, &pinfo ) ) + { + if ( pinfo.th32ParentProcessID == pid ) + { + /* Found a child, recurse to kill it and anything else below it. + */ + HANDLE const ph = OpenProcess( PROCESS_ALL_ACCESS, FALSE, + pinfo.th32ProcessID ); + if ( ph ) + { + kill_process_tree( pinfo.th32ProcessID, ph ); + CloseHandle( ph ); + } + } + } + CloseHandle( process_snapshot_h ); + } + /* Now that the children are all dead, kill the root. */ + TerminateProcess( process, -2 ); +} + + +static double creation_time( HANDLE const process ) +{ + FILETIME creation; + FILETIME exit; + FILETIME kernel; + FILETIME user; + return GetProcessTimes( process, &creation, &exit, &kernel, &user ) + ? filetime_to_seconds( creation ) + : 0.0; +} + + +/* + * Recursive check if first process is parent (directly or indirectly) of the + * second one. Both processes are passed as process ids, not handles. Special + * return value 2 means that the second process is smss.exe and its parent + * process is System (first argument is ignored). + */ + +static int is_parent_child( DWORD const parent, DWORD const child ) +{ + HANDLE process_snapshot_h = INVALID_HANDLE_VALUE; + + if ( !child ) + return 0; + if ( parent == child ) + return 1; + + process_snapshot_h = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); + if ( INVALID_HANDLE_VALUE != process_snapshot_h ) + { + BOOL ok = TRUE; + PROCESSENTRY32 pinfo; + pinfo.dwSize = sizeof( PROCESSENTRY32 ); + for ( + ok = Process32First( process_snapshot_h, &pinfo ); + ok == TRUE; + ok = Process32Next( process_snapshot_h, &pinfo ) ) + { + if ( pinfo.th32ProcessID == child ) + { + /* Unfortunately, process ids are not really unique. There might + * be spurious "parent and child" relationship match between two + * non-related processes if real parent process of a given + * process has exited (while child process kept running as an + * "orphan") and the process id of such parent process has been + * reused by internals of the operating system when creating + * another process. + * + * Thus an additional check is needed - process creation time. + * This check may fail (i.e. return 0) for system processes due + * to insufficient privileges, and that is OK. + */ + double tchild = 0.0; + double tparent = 0.0; + HANDLE const hchild = OpenProcess( PROCESS_QUERY_INFORMATION, + FALSE, pinfo.th32ProcessID ); + CloseHandle( process_snapshot_h ); + + /* csrss.exe may display message box like following: + * xyz.exe - Unable To Locate Component + * This application has failed to start because + * boost_foo-bar.dll was not found. Re-installing the + * application may fix the problem + * This actually happens when starting a test process that + * depends on a dynamic library which failed to build. We want + * to automatically close these message boxes even though + * csrss.exe is not our child process. We may depend on the fact + * that (in all current versions of Windows) csrss.exe is a + * direct child of the smss.exe process, which in turn is a + * direct child of the System process, which always has process + * id == 4. This check must be performed before comparing + * process creation times. + */ + if ( !stricmp( pinfo.szExeFile, "csrss.exe" ) && + is_parent_child( parent, pinfo.th32ParentProcessID ) == 2 ) + return 1; + if ( !stricmp( pinfo.szExeFile, "smss.exe" ) && + ( pinfo.th32ParentProcessID == 4 ) ) + return 2; + + if ( hchild ) + { + HANDLE hparent = OpenProcess( PROCESS_QUERY_INFORMATION, + FALSE, pinfo.th32ParentProcessID ); + if ( hparent ) + { + tchild = creation_time( hchild ); + tparent = creation_time( hparent ); + CloseHandle( hparent ); + } + CloseHandle( hchild ); + } + + /* Return 0 if one of the following is true: + * 1. we failed to read process creation time + * 2. child was created before alleged parent + */ + if ( ( tchild == 0.0 ) || ( tparent == 0.0 ) || + ( tchild < tparent ) ) + return 0; + + return is_parent_child( parent, pinfo.th32ParentProcessID ) & 1; + } + } + + CloseHandle( process_snapshot_h ); + } + + return 0; +} + + +/* + * Called by the OS for each topmost window. + */ + +BOOL CALLBACK close_alert_window_enum( HWND hwnd, LPARAM lParam ) +{ + char buf[ 7 ] = { 0 }; + PROCESS_INFORMATION const * const pi = (PROCESS_INFORMATION *)lParam; + DWORD pid; + DWORD tid; + + /* We want to find and close any window that: + * 1. is visible and + * 2. is a dialog and + * 3. is displayed by any of our child processes + */ + if ( + /* We assume hidden windows do not require user interaction. */ + !IsWindowVisible( hwnd ) + /* Failed to read class name; presume it is not a dialog. */ + || !GetClassNameA( hwnd, buf, sizeof( buf ) ) + /* All Windows system dialogs use the same Window class name. */ + || strcmp( buf, "#32770" ) ) + return TRUE; + + /* GetWindowThreadProcessId() returns 0 on error, otherwise thread id of + * the window's message pump thread. + */ + tid = GetWindowThreadProcessId( hwnd, &pid ); + if ( !tid || !is_parent_child( pi->dwProcessId, pid ) ) + return TRUE; + + /* Ask real nice. */ + PostMessageA( hwnd, WM_CLOSE, 0, 0 ); + + /* Wait and see if it worked. If not, insist. */ + if ( WaitForSingleObject( pi->hProcess, 200 ) == WAIT_TIMEOUT ) + { + PostThreadMessageA( tid, WM_QUIT, 0, 0 ); + WaitForSingleObject( pi->hProcess, 300 ); + } + + /* Done, we do not want to check any other windows now. */ + return FALSE; +} + + +static void close_alert( PROCESS_INFORMATION const * const pi ) +{ + EnumWindows( &close_alert_window_enum, (LPARAM)pi ); +} + + +/* + * Open a command file to store the command into for executing using an external + * shell. Returns a pointer to a FILE open for writing or 0 in case such a file + * could not be opened. The file name used is stored back in the corresponding + * running commands table slot. + * + * Expects the running commands table slot's command_file attribute to contain + * either a zeroed out string object or one prepared previously by this same + * function. + */ + +static FILE * open_command_file( int const slot ) +{ + string * const command_file = cmdtab[ slot ].command_file; + + /* If the temporary command file name has not already been prepared for this + * slot number, prepare a new one containing a '##' place holder that will + * be changed later and needs to be located at a fixed distance from the + * end. + */ + if ( !command_file->value ) + { + DWORD const procID = GetCurrentProcessId(); + string const * const tmpdir = path_tmpdir(); + string_new( command_file ); + string_reserve( command_file, tmpdir->size + 64 ); + command_file->size = sprintf( command_file->value, + "%s\\jam%d-%02d-##.bat", tmpdir->value, procID, slot ); + } + + /* For some reason opening a command file can fail intermittently. But doing + * some retries works. Most likely this is due to a previously existing file + * of the same name that happens to still be opened by an active virus + * scanner. Originally pointed out and fixed by Bronek Kozicki. + * + * We first try to open several differently named files to avoid having to + * wait idly if not absolutely necessary. Our temporary command file names + * contain a fixed position place holder we use for generating different + * file names. + */ + { + char * const index1 = command_file->value + command_file->size - 6; + char * const index2 = index1 + 1; + int waits_remaining; + assert( command_file->value < index1 ); + assert( index2 + 1 < command_file->value + command_file->size ); + assert( index2[ 1 ] == '.' ); + for ( waits_remaining = 3; ; --waits_remaining ) + { + int index; + for ( index = 0; index != 20; ++index ) + { + FILE * f; + *index1 = '0' + index / 10; + *index2 = '0' + index % 10; + f = fopen( command_file->value, "w" ); + if ( f ) return f; + } + if ( !waits_remaining ) break; + Sleep( 250 ); + } + } + + return 0; +} + + +/* + * Prepare a command file to be executed using an external shell. + */ + +static char const * prepare_command_file( string const * command, int slot ) +{ + FILE * const f = open_command_file( slot ); + if ( !f ) + { + printf( "failed to write command file!\n" ); + exit( EXITBAD ); + } + fputs( command->value, f ); + fclose( f ); + return cmdtab[ slot ].command_file->value; +} + + +/* + * Find a free slot in the running commands table. + */ + +static int get_free_cmdtab_slot() +{ + int slot; + for ( slot = 0; slot < MAXJOBS; ++slot ) + if ( !cmdtab[ slot ].pi.hProcess ) + return slot; + printf( "no slots for child!\n" ); + exit( EXITBAD ); +} + + +/* + * Put together the final command string we are to run. + */ + +static void string_new_from_argv( string * result, char const * const * argv ) +{ + assert( argv ); + assert( argv[ 0 ] ); + string_copy( result, *(argv++) ); + while ( *argv ) + { + string_push_back( result, ' ' ); + string_append( result, *(argv++) ); + } +} + + +/* + * Reports the last failed Windows API related error message. + */ + +static void reportWindowsError( char const * const apiName ) +{ + char * errorMessage; + DWORD const errorCode = GetLastError(); + DWORD apiResult = FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | /* __in DWORD dwFlags */ + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, /* __in_opt LPCVOID lpSource */ + errorCode, /* __in DWORD dwMessageId */ + 0, /* __in DWORD dwLanguageId */ + (LPSTR)&errorMessage, /* __out LPTSTR lpBuffer */ + 0, /* __in DWORD nSize */ + 0 ); /* __in_opt va_list * Arguments */ + if ( !apiResult ) + printf( "%s() Windows API failed: %d.\n", apiName, errorCode ); + else + { + printf( "%s() Windows API failed: %d - %s\n", apiName, errorCode, + errorMessage ); + LocalFree( errorMessage ); + } +} + + +#endif /* USE_EXECNT */ diff --git a/mosesdecoder/jam-files/engine/execunix.c b/mosesdecoder/jam-files/engine/execunix.c new file mode 100644 index 0000000000000000000000000000000000000000..965e58011621162a0bc0e0a535f4d8a364d6aa7e --- /dev/null +++ b/mosesdecoder/jam-files/engine/execunix.c @@ -0,0 +1,559 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * Copyright 2007 Noel Belcourt. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +#include "jam.h" +#include "execcmd.h" + +#include "lists.h" +#include "output.h" +#include "strings.h" + +#include +#include +#include +#include +#include /* vfork(), _exit(), STDOUT_FILENO and such */ +#include +#include +#include + +#if defined(sun) || defined(__sun) + #include +#endif + +#ifdef USE_EXECUNIX + +#include + +#if defined(__APPLE__) + #define NO_VFORK +#endif + +#ifdef NO_VFORK + #define vfork() fork() +#endif + + +/* + * execunix.c - execute a shell script on UNIX/OS2/AmigaOS + * + * If $(JAMSHELL) is defined, uses that to formulate execvp()/spawnvp(). The + * default is: /bin/sh -c + * + * In $(JAMSHELL), % expands to the command string and ! expands to the slot + * number (starting at 1) for multiprocess (-j) invocations. If $(JAMSHELL) does + * not include a %, it is tacked on as the last argument. + * + * Each word must be an individual element in a jam variable value. + * + * Do not just set JAMSHELL to /bin/sh - it will not work! + * + * External routines: + * exec_check() - preprocess and validate the command. + * exec_cmd() - launch an async command execution. + * exec_wait() - wait for any of the async command processes to terminate. + */ + +/* find a free slot in the running commands table */ +static int get_free_cmdtab_slot(); + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +static clock_t tps; +static int old_time_initialized; +static struct tms old_time; + +/* We hold stdout & stderr child process information in two element arrays + * indexed as follows. + */ +#define OUT 0 +#define ERR 1 + +static struct +{ + int pid; /* on win32, a real process handle */ + int fd[ 2 ]; /* file descriptors for stdout and stderr */ + FILE * stream[ 2 ]; /* child's stdout and stderr file streams */ + clock_t start_time; /* start time of child process */ + int exit_reason; /* termination status */ + char * buffer[ 2 ]; /* buffers to hold stdout and stderr, if any */ + int buf_size[ 2 ]; /* buffer sizes in bytes */ + timestamp start_dt; /* start of command timestamp */ + + /* Function called when the command completes. */ + ExecCmdCallback func; + + /* Opaque data passed back to the 'func' callback. */ + void * closure; +} cmdtab[ MAXJOBS ] = { { 0 } }; + + +/* + * exec_check() - preprocess and validate the command. + */ + +int exec_check +( + string const * command, + LIST * * pShell, + int * error_length, + int * error_max_length +) +{ + int const is_raw_cmd = is_raw_command_request( *pShell ); + + /* We allow empty commands for non-default shells since we do not really + * know what they are going to do with such commands. + */ + if ( !command->size && ( is_raw_cmd || list_empty( *pShell ) ) ) + return EXEC_CHECK_NOOP; + + return is_raw_cmd + ? EXEC_CHECK_OK + : check_cmd_for_too_long_lines( command->value, MAXLINE, error_length, + error_max_length ); +} + + +/* + * exec_cmd() - launch an async command execution. + */ + +/* We hold file descriptors for pipes used to communicate with child processes + * in two element arrays indexed as follows. + */ +#define EXECCMD_PIPE_READ 0 +#define EXECCMD_PIPE_WRITE 1 + +void exec_cmd +( + string const * command, + ExecCmdCallback func, + void * closure, + LIST * shell +) +{ + int const slot = get_free_cmdtab_slot(); + int out[ 2 ]; + int err[ 2 ]; + int len; + char const * argv[ MAXARGC + 1 ]; /* +1 for NULL */ + + /* Initialize default shell. */ + static LIST * default_shell; + if ( !default_shell ) + default_shell = list_push_back( list_new( + object_new( "/bin/sh" ) ), + object_new( "-c" ) ); + + if ( list_empty( shell ) ) + shell = default_shell; + + /* Forumulate argv. If shell was defined, be prepared for % and ! subs. + * Otherwise, use stock /bin/sh. + */ + argv_from_shell( argv, shell, command->value, slot ); + + if ( DEBUG_EXECCMD ) + { + int i; + printf( "Using shell: " ); + list_print( shell ); + printf( "\n" ); + for ( i = 0; argv[ i ]; ++i ) + printf( " argv[%d] = '%s'\n", i, argv[ i ] ); + } + + /* Create pipes for collecting child output. */ + if ( pipe( out ) < 0 || ( globs.pipe_action && pipe( err ) < 0 ) ) + { + perror( "pipe" ); + exit( EXITBAD ); + } + + /* Initialize old_time only once. */ + if ( !old_time_initialized ) + { + times( &old_time ); + old_time_initialized = 1; + } + + /* Start the command */ + + timestamp_current( &cmdtab[ slot ].start_dt ); + + if ( 0 < globs.timeout ) + { + /* Handle hung processes by manually tracking elapsed time and signal + * process when time limit expires. + */ + struct tms buf; + cmdtab[ slot ].start_time = times( &buf ); + + /* Make a global, only do this once. */ + if ( !tps ) tps = sysconf( _SC_CLK_TCK ); + } + + /* Child does not need the read pipe ends used by the parent. */ + fcntl( out[ EXECCMD_PIPE_READ ], F_SETFD, FD_CLOEXEC ); + if ( globs.pipe_action ) + fcntl( err[ EXECCMD_PIPE_READ ], F_SETFD, FD_CLOEXEC ); + + if ( ( cmdtab[ slot ].pid = vfork() ) == -1 ) + { + perror( "vfork" ); + exit( EXITBAD ); + } + + if ( cmdtab[ slot ].pid == 0 ) + { + /*****************/ + /* Child process */ + /*****************/ + int const pid = getpid(); + + /* Redirect stdout and stderr to pipes inherited from the parent. */ + dup2( out[ EXECCMD_PIPE_WRITE ], STDOUT_FILENO ); + dup2( globs.pipe_action ? err[ EXECCMD_PIPE_WRITE ] : + out[ EXECCMD_PIPE_WRITE ], STDERR_FILENO ); + close( out[ EXECCMD_PIPE_WRITE ] ); + if ( globs.pipe_action ) + close( err[ EXECCMD_PIPE_WRITE ] ); + + /* Make this process a process group leader so that when we kill it, all + * child processes of this process are terminated as well. We use + * killpg( pid, SIGKILL ) to kill the process group leader and all its + * children. + */ + if ( 0 < globs.timeout ) + { + struct rlimit r_limit; + r_limit.rlim_cur = globs.timeout; + r_limit.rlim_max = globs.timeout; + setrlimit( RLIMIT_CPU, &r_limit ); + } + setpgid( pid, pid ); + execvp( argv[ 0 ], (char * *)argv ); + perror( "execvp" ); + _exit( 127 ); + } + + /******************/ + /* Parent process */ + /******************/ + setpgid( cmdtab[ slot ].pid, cmdtab[ slot ].pid ); + + /* Parent not need the write pipe ends used by the child. */ + close( out[ EXECCMD_PIPE_WRITE ] ); + if ( globs.pipe_action ) + close( err[ EXECCMD_PIPE_WRITE ] ); + + /* Set both pipe read file descriptors to non-blocking. */ + fcntl( out[ EXECCMD_PIPE_READ ], F_SETFL, O_NONBLOCK ); + if ( globs.pipe_action ) + fcntl( err[ EXECCMD_PIPE_READ ], F_SETFL, O_NONBLOCK ); + + /* Parent reads from out[ EXECCMD_PIPE_READ ]. */ + cmdtab[ slot ].fd[ OUT ] = out[ EXECCMD_PIPE_READ ]; + cmdtab[ slot ].stream[ OUT ] = fdopen( cmdtab[ slot ].fd[ OUT ], "rb" ); + if ( !cmdtab[ slot ].stream[ OUT ] ) + { + perror( "fdopen" ); + exit( EXITBAD ); + } + + /* Parent reads from err[ EXECCMD_PIPE_READ ]. */ + if ( globs.pipe_action ) + { + cmdtab[ slot ].fd[ ERR ] = err[ EXECCMD_PIPE_READ ]; + cmdtab[ slot ].stream[ ERR ] = fdopen( cmdtab[ slot ].fd[ ERR ], "rb" ); + if ( !cmdtab[ slot ].stream[ ERR ] ) + { + perror( "fdopen" ); + exit( EXITBAD ); + } + } + + /* Save input data into the selected running commands table slot. */ + cmdtab[ slot ].func = func; + cmdtab[ slot ].closure = closure; +} + +#undef EXECCMD_PIPE_READ +#undef EXECCMD_PIPE_WRITE + + +/* Returns 1 if file descriptor is closed, or 0 if it is still alive. + * + * i is index into cmdtab + * + * s (stream) indexes: + * - cmdtab[ i ].stream[ s ] + * - cmdtab[ i ].buffer[ s ] + * - cmdtab[ i ].fd [ s ] + */ + +static int read_descriptor( int i, int s ) +{ + int ret; + char buffer[ BUFSIZ ]; + + while ( 0 < ( ret = fread( buffer, sizeof( char ), BUFSIZ - 1, + cmdtab[ i ].stream[ s ] ) ) ) + { + buffer[ ret ] = 0; + if ( !cmdtab[ i ].buffer[ s ] ) + { + /* Never been allocated. */ + if ( globs.max_buf && ret > globs.max_buf ) + { + ret = globs.max_buf; + buffer[ ret ] = 0; + } + cmdtab[ i ].buf_size[ s ] = ret + 1; + cmdtab[ i ].buffer[ s ] = (char*)BJAM_MALLOC_ATOMIC( ret + 1 ); + memcpy( cmdtab[ i ].buffer[ s ], buffer, ret + 1 ); + } + else + { + /* Previously allocated. */ + if ( cmdtab[ i ].buf_size[ s ] < globs.max_buf || !globs.max_buf ) + { + char * tmp = cmdtab[ i ].buffer[ s ]; + int const old_len = cmdtab[ i ].buf_size[ s ] - 1; + int const new_len = old_len + ret + 1; + cmdtab[ i ].buf_size[ s ] = new_len; + cmdtab[ i ].buffer[ s ] = (char*)BJAM_MALLOC_ATOMIC( new_len ); + memcpy( cmdtab[ i ].buffer[ s ], tmp, old_len ); + memcpy( cmdtab[ i ].buffer[ s ] + old_len, buffer, ret + 1 ); + BJAM_FREE( tmp ); + } + } + } + + /* If buffer full, ensure last buffer char is newline so that jam log + * contains the command status at beginning of it own line instead of + * appended to end of the previous output. + */ + if ( globs.max_buf && globs.max_buf <= cmdtab[ i ].buf_size[ s ] ) + cmdtab[ i ].buffer[ s ][ cmdtab[ i ].buf_size[ s ] - 2 ] = '\n'; + + return feof( cmdtab[ i ].stream[ s ] ); +} + + +/* + * close_streams() - Close the stream and pipe descriptor. + */ + +static void close_streams( int const i, int const s ) +{ + fclose( cmdtab[ i ].stream[ s ] ); + cmdtab[ i ].stream[ s ] = 0; + + close( cmdtab[ i ].fd[ s ] ); + cmdtab[ i ].fd[ s ] = 0; +} + + +/* + * Populate the file descriptors collection for use in select() and return the + * maximal included file descriptor value. + */ + +static int populate_file_descriptors( fd_set * const fds ) +{ + int i; + int fd_max = 0; + + FD_ZERO( fds ); + for ( i = 0; i < globs.jobs; ++i ) + { + int fd; + if ( ( fd = cmdtab[ i ].fd[ OUT ] ) > 0 ) + { + if ( fd > fd_max ) fd_max = fd; + FD_SET( fd, fds ); + } + if ( globs.pipe_action ) + { + if ( ( fd = cmdtab[ i ].fd[ ERR ] ) > 0 ) + { + if ( fd > fd_max ) fd_max = fd; + FD_SET( fd, fds ); + } + } + } + return fd_max; +} + + +/* + * exec_wait() - wait for any of the async command processes to terminate. + * + * May register more than one terminated child process but will exit as soon as + * at least one has been registered. + */ + +void exec_wait() +{ + int finished = 0; + + /* Process children that signaled. */ + while ( !finished ) + { + int i; + struct timeval tv; + struct timeval * ptv = NULL; + int select_timeout = globs.timeout; + + /* Prepare file descriptor information for use in select(). */ + fd_set fds; + int const fd_max = populate_file_descriptors( &fds ); + + /* Check for timeouts: + * - kill children that already timed out + * - decide how long until the next one times out + */ + if ( globs.timeout > 0 ) + { + struct tms buf; + clock_t const current = times( &buf ); + for ( i = 0; i < globs.jobs; ++i ) + if ( cmdtab[ i ].pid ) + { + clock_t const consumed = + ( current - cmdtab[ i ].start_time ) / tps; + if ( consumed >= globs.timeout ) + { + killpg( cmdtab[ i ].pid, SIGKILL ); + cmdtab[ i ].exit_reason = EXIT_TIMEOUT; + } + else if ( globs.timeout - consumed < select_timeout ) + select_timeout = globs.timeout - consumed; + } + + /* If nothing else causes our select() call to exit, force it after + * however long it takes for the next one of our child processes to + * crossed its alloted processing time so we can terminate it. + */ + tv.tv_sec = select_timeout; + tv.tv_usec = 0; + ptv = &tv; + } + + /* select() will wait for I/O on a descriptor, a signal, or timeout. */ + { + int ret; + while ( ( ret = select( fd_max + 1, &fds, 0, 0, ptv ) ) == -1 ) + if ( errno != EINTR ) + break; + if ( ret <= 0 ) + continue; + } + + for ( i = 0; i < globs.jobs; ++i ) + { + int out_done = 0; + int err_done = 0; + if ( FD_ISSET( cmdtab[ i ].fd[ OUT ], &fds ) ) + out_done = read_descriptor( i, OUT ); + + if ( globs.pipe_action && FD_ISSET( cmdtab[ i ].fd[ ERR ], &fds ) ) + err_done = read_descriptor( i, ERR ); + + /* If feof on either descriptor, we are done. */ + if ( out_done || err_done ) + { + int pid; + int status; + int rstat; + timing_info time_info; + + /* We found a terminated child process - our search is done. */ + finished = 1; + + /* Close the stream and pipe descriptors. */ + close_streams( i, OUT ); + if ( globs.pipe_action ) + close_streams( i, ERR ); + + /* Reap the child and release resources. */ + while ( ( pid = waitpid( cmdtab[ i ].pid, &status, 0 ) ) == -1 ) + if ( errno != EINTR ) + break; + if ( pid != cmdtab[ i ].pid ) + { + printf( "unknown pid %d with errno = %d\n", pid, errno ); + exit( EXITBAD ); + } + + /* Set reason for exit if not timed out. */ + if ( WIFEXITED( status ) ) + cmdtab[ i ].exit_reason = WEXITSTATUS( status ) + ? EXIT_FAIL + : EXIT_OK; + + { + struct tms new_time; + times( &new_time ); + time_info.system = (double)( new_time.tms_cstime - + old_time.tms_cstime ) / CLOCKS_PER_SEC; + time_info.user = (double)( new_time.tms_cutime - + old_time.tms_cutime ) / CLOCKS_PER_SEC; + timestamp_copy( &time_info.start, &cmdtab[ i ].start_dt ); + timestamp_current( &time_info.end ); + old_time = new_time; + } + + /* Drive the completion. */ + if ( interrupted() ) + rstat = EXEC_CMD_INTR; + else if ( status ) + rstat = EXEC_CMD_FAIL; + else + rstat = EXEC_CMD_OK; + + /* Call the callback, may call back to jam rule land. */ + (*cmdtab[ i ].func)( cmdtab[ i ].closure, rstat, &time_info, + cmdtab[ i ].buffer[ OUT ], cmdtab[ i ].buffer[ ERR ], + cmdtab[ i ].exit_reason ); + + /* Clean up the command's running commands table slot. */ + BJAM_FREE( cmdtab[ i ].buffer[ OUT ] ); + cmdtab[ i ].buffer[ OUT ] = 0; + cmdtab[ i ].buf_size[ OUT ] = 0; + + BJAM_FREE( cmdtab[ i ].buffer[ ERR ] ); + cmdtab[ i ].buffer[ ERR ] = 0; + cmdtab[ i ].buf_size[ ERR ] = 0; + + cmdtab[ i ].pid = 0; + cmdtab[ i ].func = 0; + cmdtab[ i ].closure = 0; + cmdtab[ i ].start_time = 0; + } + } + } +} + + +/* + * Find a free slot in the running commands table. + */ + +static int get_free_cmdtab_slot() +{ + int slot; + for ( slot = 0; slot < MAXJOBS; ++slot ) + if ( !cmdtab[ slot ].pid ) + return slot; + printf( "no slots for child!\n" ); + exit( EXITBAD ); +} + +# endif /* USE_EXECUNIX */ diff --git a/mosesdecoder/jam-files/engine/filesys.h b/mosesdecoder/jam-files/engine/filesys.h new file mode 100644 index 0000000000000000000000000000000000000000..f7469bece22dd83e61d99a5bbfdaf3fbf61d14a2 --- /dev/null +++ b/mosesdecoder/jam-files/engine/filesys.h @@ -0,0 +1,56 @@ +/* + * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* This file is ALSO: + * Copyright 2001-2004 David Abrahams. + * 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) + */ + +/* + * filesys.h - OS specific file routines + */ + +#ifndef FILESYS_DWA20011025_H +#define FILESYS_DWA20011025_H + +#include "hash.h" +#include "lists.h" +#include "object.h" +#include "pathsys.h" +#include "timestamp.h" + + +typedef struct file_info_t +{ + OBJECT * name; + char is_file; + char is_dir; + char exists; + timestamp time; + LIST * files; +} file_info_t; + +typedef void (*scanback)( void * closure, OBJECT * path, int found, + timestamp const * const ); + + +void file_build1( PATHNAME * const f, string * file ) ; +void file_dirscan( OBJECT * dir, scanback func, void * closure ); +file_info_t * file_info( OBJECT * const path, int * found ); +int file_is_file( OBJECT * const path ); +int file_mkdir( char const * const path ); +file_info_t * file_query( OBJECT * const path ); +void file_remove_atexit( OBJECT * const path ); +void file_supported_fmt_resolution( timestamp * const ); +int file_time( OBJECT * const path, timestamp * const ); + +/* Internal utility worker functions. */ +void file_query_posix_( file_info_t * const ); + +void file_done(); + +#endif diff --git a/mosesdecoder/jam-files/engine/frames.h b/mosesdecoder/jam-files/engine/frames.h new file mode 100644 index 0000000000000000000000000000000000000000..2e99f17370e90d6438398cb4f4524e2326216789 --- /dev/null +++ b/mosesdecoder/jam-files/engine/frames.h @@ -0,0 +1,42 @@ +/* + * Copyright 2001-2004 David Abrahams. + * 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) + */ + +#ifndef FRAMES_DWA20011021_H +#define FRAMES_DWA20011021_H + +#include "lists.h" +#include "modules.h" +#include "object.h" + + +typedef struct frame FRAME; + +struct frame +{ + FRAME * prev; + FRAME * prev_user; /* The nearest enclosing frame for which + module->user_module is true. */ + LOL args[ 1 ]; + module_t * module; + OBJECT * file; + int line; + char const * rulename; +}; + + +/* When a call into Python is in progress, this variable points to the bjam + * frame that was current at the moment of the call. When the call completes, + * the variable is not defined. Furthermore, if Jam calls Python which calls Jam + * and so on, this variable only keeps the most recent Jam frame. + */ +extern FRAME * frame_before_python_call; + + +void frame_init( FRAME * ); +void frame_free( FRAME * ); + +#endif diff --git a/mosesdecoder/jam-files/engine/hash.c b/mosesdecoder/jam-files/engine/hash.c new file mode 100644 index 0000000000000000000000000000000000000000..36f8366685805aa3f32e0af88a3fe11677ee8137 --- /dev/null +++ b/mosesdecoder/jam-files/engine/hash.c @@ -0,0 +1,387 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* + * hash.c - simple in-memory hashing routines + * + * External routines: + * hashinit() - initialize a hash table, returning a handle + * hashitem() - find a record in the table, and optionally enter a new one + * hashdone() - free a hash table, given its handle + * + * Internal routines: + * hashrehash() - resize and rebuild hp->tab, the hash table + */ + +#include "jam.h" +#include "hash.h" + +#include "compile.h" + +#include + +/* */ +#define HASH_DEBUG_PROFILE 1 +/* */ + +/* Header attached to all hash table data items. */ + +typedef struct item ITEM; +struct item +{ + ITEM * next; +}; + +#define MAX_LISTS 32 + +struct hash +{ + /* + * the hash table, just an array of item pointers + */ + struct + { + int nel; + ITEM * * base; + } tab; + + int bloat; /* tab.nel / items.nel */ + int inel; /* initial number of elements */ + + /* + * the array of records, maintained by these routines - essentially a + * microallocator + */ + struct + { + int more; /* how many more ITEMs fit in lists[ list ] */ + ITEM * free; /* free list of items */ + char * next; /* where to put more ITEMs in lists[ list ] */ + int size; /* sizeof( ITEM ) + aligned datalen */ + int nel; /* total ITEMs held by all lists[] */ + int list; /* index into lists[] */ + + struct + { + int nel; /* total ITEMs held by this list */ + char * base; /* base of ITEMs array */ + } lists[ MAX_LISTS ]; + } items; + + char const * name; /* just for hashstats() */ +}; + +static void hashrehash( struct hash * ); +static void hashstat( struct hash * ); + +static unsigned int hash_keyval( OBJECT * key ) +{ + return object_hash( key ); +} + +#define hash_bucket(hp, keyval) ((hp)->tab.base + ((keyval) % (hp)->tab.nel)) + +#define hash_data_key(data) (*(OBJECT * *)(data)) +#define hash_item_data(item) ((HASHDATA *)((char *)item + sizeof(ITEM))) +#define hash_item_key(item) (hash_data_key(hash_item_data(item))) + + +#define ALIGNED(x) ((x + sizeof(ITEM) - 1) & ~(sizeof(ITEM) - 1)) + +/* + * hashinit() - initialize a hash table, returning a handle + */ + +struct hash * hashinit( int datalen, char const * name ) +{ + struct hash * hp = (struct hash *)BJAM_MALLOC( sizeof( *hp ) ); + + hp->bloat = 3; + hp->tab.nel = 0; + hp->tab.base = 0; + hp->items.more = 0; + hp->items.free = 0; + hp->items.size = sizeof( ITEM ) + ALIGNED( datalen ); + hp->items.list = -1; + hp->items.nel = 0; + hp->inel = 11; /* 47 */ + hp->name = name; + + return hp; +} + + +/* + * hash_search() - Find the hash item for the given data. + * + * Returns a pointer to a hashed item with the given key. If given a 'previous' + * pointer, makes it point to the item prior to the found item in the same + * bucket or to 0 if our item is the first item in its bucket. + */ + +static ITEM * hash_search( struct hash * hp, unsigned int keyval, + OBJECT * keydata, ITEM * * previous ) +{ + ITEM * i = *hash_bucket( hp, keyval ); + ITEM * p = 0; + for ( ; i; i = i->next ) + { + if ( object_equal( hash_item_key( i ), keydata ) ) + { + if ( previous ) + *previous = p; + return i; + } + p = i; + } + return 0; +} + + +/* + * hash_insert() - insert a record in the table or return the existing one + */ + +HASHDATA * hash_insert( struct hash * hp, OBJECT * key, int * found ) +{ + ITEM * i; + unsigned int keyval = hash_keyval( key ); + + #ifdef HASH_DEBUG_PROFILE + profile_frame prof[ 1 ]; + if ( DEBUG_PROFILE ) + profile_enter( 0, prof ); + #endif + + if ( !hp->items.more ) + hashrehash( hp ); + + i = hash_search( hp, keyval, key, 0 ); + if ( i ) + *found = 1; + else + { + ITEM * * base = hash_bucket( hp, keyval ); + + /* Try to grab one from the free list. */ + if ( hp->items.free ) + { + i = hp->items.free; + hp->items.free = i->next; + assert( !hash_item_key( i ) ); + } + else + { + i = (ITEM *)hp->items.next; + hp->items.next += hp->items.size; + } + --hp->items.more; + i->next = *base; + *base = i; + *found = 0; + } + + #ifdef HASH_DEBUG_PROFILE + if ( DEBUG_PROFILE ) + profile_exit( prof ); + #endif + + return hash_item_data( i ); +} + + +/* + * hash_find() - find a record in the table or NULL if none exists + */ + +HASHDATA * hash_find( struct hash * hp, OBJECT * key ) +{ + ITEM * i; + unsigned int keyval = hash_keyval( key ); + + #ifdef HASH_DEBUG_PROFILE + profile_frame prof[ 1 ]; + if ( DEBUG_PROFILE ) + profile_enter( 0, prof ); + #endif + + if ( !hp->items.nel ) + { + #ifdef HASH_DEBUG_PROFILE + if ( DEBUG_PROFILE ) + profile_exit( prof ); + #endif + return 0; + } + + i = hash_search( hp, keyval, key, 0 ); + + #ifdef HASH_DEBUG_PROFILE + if ( DEBUG_PROFILE ) + profile_exit( prof ); + #endif + + return i ? hash_item_data( i ) : 0; +} + + +/* + * hashrehash() - resize and rebuild hp->tab, the hash table + */ + +static void hashrehash( struct hash * hp ) +{ + int i = ++hp->items.list; + hp->items.more = i ? 2 * hp->items.nel : hp->inel; + hp->items.next = (char *)BJAM_MALLOC( hp->items.more * hp->items.size ); + hp->items.free = 0; + + hp->items.lists[ i ].nel = hp->items.more; + hp->items.lists[ i ].base = hp->items.next; + hp->items.nel += hp->items.more; + + if ( hp->tab.base ) + BJAM_FREE( (char *)hp->tab.base ); + + hp->tab.nel = hp->items.nel * hp->bloat; + hp->tab.base = (ITEM * *)BJAM_MALLOC( hp->tab.nel * sizeof( ITEM * * ) ); + + memset( (char *)hp->tab.base, '\0', hp->tab.nel * sizeof( ITEM * ) ); + + for ( i = 0; i < hp->items.list; ++i ) + { + int nel = hp->items.lists[ i ].nel; + char * next = hp->items.lists[ i ].base; + + for ( ; nel--; next += hp->items.size ) + { + ITEM * i = (ITEM *)next; + ITEM * * ip = hp->tab.base + object_hash( hash_item_key( i ) ) % + hp->tab.nel; + /* code currently assumes rehashing only when there are no free + * items + */ + assert( hash_item_key( i ) ); + + i->next = *ip; + *ip = i; + } + } +} + + +void hashenumerate( struct hash * hp, void (* f)( void *, void * ), void * data + ) +{ + int i; + for ( i = 0; i <= hp->items.list; ++i ) + { + char * next = hp->items.lists[ i ].base; + int nel = hp->items.lists[ i ].nel; + if ( i == hp->items.list ) + nel -= hp->items.more; + + for ( ; nel--; next += hp->items.size ) + { + ITEM * const i = (ITEM *)next; + if ( hash_item_key( i ) != 0 ) /* Do not enumerate freed items. */ + f( hash_item_data( i ), data ); + } + } +} + + +/* + * hash_free() - free a hash table, given its handle + */ + +void hash_free( struct hash * hp ) +{ + int i; + if ( !hp ) + return; + if ( hp->tab.base ) + BJAM_FREE( (char *)hp->tab.base ); + for ( i = 0; i <= hp->items.list; ++i ) + BJAM_FREE( hp->items.lists[ i ].base ); + BJAM_FREE( (char *)hp ); +} + + +static void hashstat( struct hash * hp ) +{ + struct hashstats stats[ 1 ]; + hashstats_init( stats ); + hashstats_add( stats, hp ); + hashstats_print( stats, hp->name ); +} + + +void hashstats_init( struct hashstats * stats ) +{ + stats->count = 0; + stats->num_items = 0; + stats->tab_size = 0; + stats->item_size = 0; + stats->sets = 0; + stats->num_hashes = 0; +} + + +void hashstats_add( struct hashstats * stats, struct hash * hp ) +{ + if ( hp ) + { + ITEM * * tab = hp->tab.base; + int nel = hp->tab.nel; + int count = 0; + int sets = 0; + int i; + + for ( i = 0; i < nel; ++i ) + { + ITEM * item; + int here = 0; + for ( item = tab[ i ]; item; item = item->next ) + ++here; + + count += here; + if ( here > 0 ) + ++sets; + } + + stats->count += count; + stats->sets += sets; + stats->num_items += hp->items.nel; + stats->tab_size += hp->tab.nel; + stats->item_size = hp->items.size; + ++stats->num_hashes; + } +} + + +void hashstats_print( struct hashstats * stats, char const * name ) +{ + printf( "%s table: %d+%d+%d (%dK+%luK+%luK) items+table+hash, %f density\n", + name, + stats->count, + stats->num_items, + stats->tab_size, + stats->num_items * stats->item_size / 1024, + (long unsigned)stats->tab_size * sizeof( ITEM * * ) / 1024, + (long unsigned)stats->num_hashes * sizeof( struct hash ) / 1024, + (float)stats->count / (float)stats->sets ); +} + + +void hashdone( struct hash * hp ) +{ + if ( !hp ) + return; + if ( DEBUG_MEM || DEBUG_PROFILE ) + hashstat( hp ); + hash_free( hp ); +} diff --git a/mosesdecoder/jam-files/engine/hdrmacro.c b/mosesdecoder/jam-files/engine/hdrmacro.c new file mode 100644 index 0000000000000000000000000000000000000000..eb4fe90f4b67241cedd37d705a898a50039fa262 --- /dev/null +++ b/mosesdecoder/jam-files/engine/hdrmacro.c @@ -0,0 +1,139 @@ +/* + * Copyright 1993, 2000 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* This file is ALSO: + * Copyright 2001-2004 David Abrahams. + * 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) + */ + +/* + * hdrmacro.c - handle header files that define macros used in #include + * statements. + * + * we look for lines like "#define MACRO <....>" or '#define MACRO " "' in + * the target file. When found, we then phony up a rule invocation like: + * + * $(HDRRULE) : ; + * + * External routines: + * headers1() - scan a target for "#include MACRO" lines and try to resolve + * them when needed + * + * Internal routines: + * headers1() - using regexp, scan a file and build include LIST + */ + +#include "jam.h" +#include "hdrmacro.h" + +#include "compile.h" +#include "hash.h" +#include "lists.h" +#include "object.h" +#include "parse.h" +#include "rules.h" +#include "strings.h" +#include "subst.h" +#include "variable.h" + + +/* this type is used to store a dictionary of file header macros */ +typedef struct header_macro +{ + OBJECT * symbol; + OBJECT * filename; /* we could maybe use a LIST here ?? */ +} HEADER_MACRO; + +static struct hash * header_macros_hash = 0; + + +/* + * headers() - scan a target for include files and call HDRRULE + */ + +#define MAXINC 10 + +void macro_headers( TARGET * t ) +{ + static regexp * re = 0; + FILE * f; + char buf[ 1024 ]; + + if ( DEBUG_HEADER ) + printf( "macro header scan for %s\n", object_str( t->name ) ); + + /* This regexp is used to detect lines of the form + * "#define MACRO <....>" or "#define MACRO "....." + * in the header macro files. + */ + if ( !re ) + { + OBJECT * const re_str = object_new( + "^[ ]*#[ ]*define[ ]*([A-Za-z][A-Za-z0-9_]*)[ ]*" + "[<\"]([^\">]*)[\">].*$" ); + re = regex_compile( re_str ); + object_free( re_str ); + } + + if ( !( f = fopen( object_str( t->boundname ), "r" ) ) ) + return; + + while ( fgets( buf, sizeof( buf ), f ) ) + { + HEADER_MACRO var; + HEADER_MACRO * v = &var; + + if ( regexec( re, buf ) && re->startp[ 1 ] ) + { + OBJECT * symbol; + int found; + /* we detected a line that looks like "#define MACRO filename */ + ( (char *)re->endp[ 1 ] )[ 0 ] = '\0'; + ( (char *)re->endp[ 2 ] )[ 0 ] = '\0'; + + if ( DEBUG_HEADER ) + printf( "macro '%s' used to define filename '%s' in '%s'\n", + re->startp[ 1 ], re->startp[ 2 ], object_str( t->boundname ) + ); + + /* add macro definition to hash table */ + if ( !header_macros_hash ) + header_macros_hash = hashinit( sizeof( HEADER_MACRO ), + "hdrmacros" ); + + symbol = object_new( re->startp[ 1 ] ); + v = (HEADER_MACRO *)hash_insert( header_macros_hash, symbol, &found + ); + if ( !found ) + { + v->symbol = symbol; + v->filename = object_new( re->startp[ 2 ] ); /* never freed */ + } + else + object_free( symbol ); + /* XXXX: FOR NOW, WE IGNORE MULTIPLE MACRO DEFINITIONS !! */ + /* WE MIGHT AS WELL USE A LIST TO STORE THEM.. */ + } + } + + fclose( f ); +} + + +OBJECT * macro_header_get( OBJECT * macro_name ) +{ + HEADER_MACRO * v; + if ( header_macros_hash && ( v = (HEADER_MACRO *)hash_find( + header_macros_hash, macro_name ) ) ) + { + if ( DEBUG_HEADER ) + printf( "### macro '%s' evaluated to '%s'\n", object_str( macro_name + ), object_str( v->filename ) ); + return v->filename; + } + return 0; +} diff --git a/mosesdecoder/jam-files/engine/jambase.c b/mosesdecoder/jam-files/engine/jambase.c new file mode 100644 index 0000000000000000000000000000000000000000..b15282bc32cfa57e933610ebe77a69b8f773094e --- /dev/null +++ b/mosesdecoder/jam-files/engine/jambase.c @@ -0,0 +1,1691 @@ +/* Generated by mkjambase from Jambase */ +char *jambase[] = { +/* Jambase */ +"if $(NT)\n", +"{\n", +"SLASH ?= \\\\ ;\n", +"}\n", +"SLASH ?= / ;\n", +"rule find-to-root ( dir : patterns + )\n", +"{\n", +"local globs = [ GLOB $(dir) : $(patterns) ] ;\n", +"while ! $(globs) && $(dir:P) != $(dir)\n", +"{\n", +"dir = $(dir:P) ;\n", +"globs = [ GLOB $(dir) : $(patterns) ] ;\n", +"}\n", +"return $(globs) ;\n", +"}\n", +".boost-build-file = ;\n", +".bootstrap-file = ;\n", +"BOOST_BUILD_PATH.user-value = $(BOOST_BUILD_PATH) ;\n", +"if ! $(BOOST_BUILD_PATH) && $(UNIX)\n", +"{\n", +"BOOST_BUILD_PATH = /usr/share/boost-build ;\n", +"}\n", +"rule _poke ( module-name ? : variables + : value * )\n", +"{\n", +"module $(<)\n", +"{\n", +"$(>) = $(3) ;\n", +"}\n", +"}\n", +"rule boost-build ( dir ? )\n", +"{\n", +"if $(.bootstrap-file)\n", +"{\n", +"ECHO \"Error: Illegal attempt to re-bootstrap the build system by invoking\" ;\n", +"ECHO ;\n", +"ECHO \" 'boost-build\" $(dir) \";'\" ;\n", +"ECHO ;\n", +"EXIT \"Please consult the documentation at 'http://www.boost.org'.\" ;\n", +"}\n", +"BOOST_BUILD_PATH = $(dir:R=$(.boost-build-file:D)) $(BOOST_BUILD_PATH) ;\n", +"_poke .ENVIRON : BOOST_BUILD_PATH : $(BOOST_BUILD_PATH) ;\n", +"local bootstrap-file = [ GLOB $(BOOST_BUILD_PATH) : bootstrap.jam ] ;\n", +".bootstrap-file = $(bootstrap-file[1]) ;\n", +"if ! $(.bootstrap-file)\n", +"{\n", +"ECHO \"Unable to load Boost.Build: could not find build system.\" ;\n", +"ECHO --------------------------------------------------------- ;\n", +"ECHO \"$(.boost-build-file) attempted to load the build system by invoking\" ;\n", +"ECHO ;\n", +"ECHO \" 'boost-build\" $(dir) \";'\" ;\n", +"ECHO ;\n", +"ECHO \"but we were unable to find \\\"bootstrap.jam\\\" in the specified directory\" ;\n", +"ECHO \"or in BOOST_BUILD_PATH (searching \"$(BOOST_BUILD_PATH:J=\", \")\").\" ;\n", +"ECHO ;\n", +"EXIT \"Please consult the documentation at 'http://www.boost.org'.\" ;\n", +"}\n", +"if [ MATCH .*(--debug-configuration).* : $(ARGV) ]\n", +"{\n", +"ECHO \"notice: loading Boost.Build from\"\n", +"[ NORMALIZE_PATH $(.bootstrap-file:D) ] ;\n", +"}\n", +"include $(.bootstrap-file) ;\n", +"}\n", +"if [ MATCH .*(b2).* : $(ARGV[1]:BL) ] \n", +"|| [ MATCH .*(bjam).* : $(ARGV[1]:BL) ]\n", +"|| $(BOOST_ROOT) # A temporary measure so Jam works with Boost.Build v1.\n", +"{\n", +"local search-path = $(BOOST_BUILD_PATH) $(BOOST_ROOT) ;\n", +"local self = [ SELF_PATH ] ;\n", +"local boost-build-relative = ../../share/boost-build ;\n", +"local self-based-path = [ NORMALIZE_PATH $(boost-build-relative:R=$(self)) ] ;\n", +"local boost-build-files =\n", +"[ find-to-root [ PWD ] : boost-build.jam ]\n", +"[ GLOB $(self-based-path) : boost-build.jam ]\n", +"[ GLOB $(search-path) : boost-build.jam ] ;\n", +".boost-build-file = $(boost-build-files[1]) ;\n", +"if ! $(.boost-build-file)\n", +"{\n", +"ECHO \"Unable to load Boost.Build: could not find \\\"boost-build.jam\\\"\" ;\n", +"ECHO --------------------------------------------------------------- ;\n", +"if ! [ MATCH .*(bjam).* : $(ARGV[1]:BL) ]\n", +"{\n", +"ECHO \"BOOST_ROOT must be set, either in the environment, or \" ;\n", +"ECHO \"on the command-line with -sBOOST_ROOT=..., to the root\" ;\n", +"ECHO \"of the boost installation.\" ;\n", +"ECHO ;\n", +"}\n", +"ECHO \"Attempted search from\" [ PWD ] \"up to the root\" ;\n", +"ECHO \"at\" $(self-based-path) ;\n", +"ECHO \"and in these directories from BOOST_BUILD_PATH and BOOST_ROOT: \"$(search-path:J=\", \")\".\" ;\n", +"EXIT \"Please consult the documentation at 'http://www.boost.org'.\" ;\n", +"}\n", +"if [ MATCH .*(--debug-configuration).* : $(ARGV) ]\n", +"{\n", +"ECHO \"notice: found boost-build.jam at\"\n", +"[ NORMALIZE_PATH $(.boost-build-file) ] ;\n", +"}\n", +"include $(.boost-build-file) ;\n", +"if ! $(.bootstrap-file)\n", +"{\n", +"ECHO \"Unable to load Boost.Build\" ;\n", +"ECHO -------------------------- ;\n", +"ECHO \"\\\"$(.boost-build-file)\\\" was found by searching from\" [ PWD ] \"up to the root\" ;\n", +"ECHO \"and in these directories from BOOST_BUILD_PATH and BOOST_ROOT: \"$(search-path:J=\", \")\".\" ;\n", +"ECHO ;\n", +"ECHO \"However, it failed to call the \\\"boost-build\\\" rule to indicate\" ;\n", +"ECHO \"the location of the build system.\" ;\n", +"ECHO ;\n", +"EXIT \"Please consult the documentation at 'http://www.boost.org'.\" ;\n", +"}\n", +"}\n", +"else\n", +"{\n", +"if $(NT)\n", +"{\n", +"local SUPPORTED_TOOLSETS = \"BORLANDC\" \"VC7\" \"VISUALC\" \"VISUALC16\" \"INTELC\" \"WATCOM\"\n", +"\"MINGW\" \"LCC\" ;\n", +"TOOLSET = \"\" ;\n", +"if $(JAM_TOOLSET)\n", +"{\n", +"local t ;\n", +"for t in $(SUPPORTED_TOOLSETS)\n", +"{\n", +"$(t) = $($(t):J=\" \") ; # reconstitute paths with spaces in them\n", +"if $(t) = $(JAM_TOOLSET) { TOOLSET = $(t) ; }\n", +"}\n", +"if ! $(TOOLSET)\n", +"{\n", +"ECHO \"The JAM_TOOLSET environment variable is defined but its value\" ;\n", +"ECHO \"is invalid, please use one of the following:\" ;\n", +"ECHO ;\n", +"for t in $(SUPPORTED_TOOLSETS) { ECHO \" \" $(t) ; }\n", +"EXIT ;\n", +"}\n", +"}\n", +"if ! $(TOOLSET)\n", +"{\n", +"if $(BCCROOT)\n", +"{\n", +"TOOLSET = BORLANDC ;\n", +"BORLANDC = $(BCCROOT:J=\" \") ;\n", +"}\n", +"else if $(MSVC)\n", +"{\n", +"TOOLSET = VISUALC16 ;\n", +"VISUALC16 = $(MSVC:J=\" \") ;\n", +"}\n", +"else if $(MSVCNT)\n", +"{\n", +"TOOLSET = VISUALC ;\n", +"VISUALC = $(MSVCNT:J=\" \") ;\n", +"}\n", +"else if $(MSVCDir)\n", +"{\n", +"TOOLSET = VISUALC ;\n", +"VISUALC = $(MSVCDir:J=\" \") ;\n", +"}\n", +"else if $(MINGW)\n", +"{\n", +"TOOLSET = MINGW ;\n", +"}\n", +"else\n", +"{\n", +"ECHO \"Jam cannot be run because, either:\" ;\n", +"ECHO \" a. You didn't set BOOST_ROOT to indicate the root of your\" ;\n", +"ECHO \" Boost installation.\" ;\n", +"ECHO \" b. You are trying to use stock Jam but didn't indicate which\" ;\n", +"ECHO \" compilation toolset to use. To do so, follow these simple\" ;\n", +"ECHO \" instructions:\" ;\n", +"ECHO ;\n", +"ECHO \" - define one of the following environment variable, with the\" ;\n", +"ECHO \" appropriate value according to this list:\" ;\n", +"ECHO ;\n", +"ECHO \" Variable Toolset Description\" ;\n", +"ECHO ;\n", +"ECHO \" BORLANDC Borland C++ BC++ install path\" ;\n", +"ECHO \" VISUALC Microsoft Visual C++ VC++ install path\" ;\n", +"ECHO \" VISUALC16 Microsoft Visual C++ 16 bit VC++ 16 bit install\" ;\n", +"ECHO \" INTELC Intel C/C++ IC++ install path\" ;\n", +"ECHO \" WATCOM Watcom C/C++ Watcom install path\" ;\n", +"ECHO \" MINGW MinGW (gcc) MinGW install path\" ;\n", +"ECHO \" LCC Win32-LCC LCC-Win32 install path\" ;\n", +"ECHO ;\n", +"ECHO \" - define the JAM_TOOLSET environment variable with the *name*\" ;\n", +"ECHO \" of the toolset variable you want to use.\" ;\n", +"ECHO ;\n", +"ECHO \" e.g.: set VISUALC=C:\\\\Visual6\" ;\n", +"ECHO \" set JAM_TOOLSET=VISUALC\" ;\n", +"EXIT ;\n", +"}\n", +"}\n", +"CP ?= copy ;\n", +"RM ?= del /f/q ;\n", +"SLASH ?= \\\\ ;\n", +"SUFLIB ?= .lib ;\n", +"SUFOBJ ?= .obj ;\n", +"SUFEXE ?= .exe ;\n", +"if $(TOOLSET) = BORLANDC\n", +"{\n", +"ECHO \"Compiler is Borland C++\" ;\n", +"AR ?= tlib /C /P64 ;\n", +"CC ?= bcc32 ;\n", +"CCFLAGS ?= -q -y -d -v -w-par -w-ccc -w-rch -w-pro -w-aus ;\n", +"C++ ?= bcc32 ;\n", +"C++FLAGS ?= -q -y -d -v -w-par -w-ccc -w-rch -w-pro -w-aus -P ;\n", +"LINK ?= $(CC) ;\n", +"LINKFLAGS ?= $(CCFLAGS) ;\n", +"STDLIBPATH ?= $(BORLANDC)\\\\lib ;\n", +"STDHDRS ?= $(BORLANDC)\\\\include ;\n", +"NOARSCAN ?= true ;\n", +"}\n", +"else if $(TOOLSET) = VISUALC16\n", +"{\n", +"ECHO \"Compiler is Microsoft Visual C++ 16 bit\" ;\n", +"AR ?= lib /nologo ;\n", +"CC ?= cl /nologo ;\n", +"CCFLAGS ?= /D \\\"WIN\\\" ;\n", +"C++ ?= $(CC) ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"LINK ?= $(CC) ;\n", +"LINKFLAGS ?= $(CCFLAGS) ;\n", +"LINKLIBS ?=\n", +"\\\"$(VISUALC16)\\\\lib\\\\mlibce.lib\\\"\n", +"\\\"$(VISUALC16)\\\\lib\\\\oldnames.lib\\\"\n", +";\n", +"LINKLIBS ?= ;\n", +"NOARSCAN ?= true ;\n", +"OPTIM ?= \"\" ;\n", +"STDHDRS ?= $(VISUALC16)\\\\include ;\n", +"UNDEFFLAG ?= \"/u _\" ;\n", +"}\n", +"else if $(TOOLSET) = VISUALC\n", +"{\n", +"ECHO \"Compiler is Microsoft Visual C++\" ;\n", +"AR ?= lib ;\n", +"AS ?= masm386 ;\n", +"CC ?= cl /nologo ;\n", +"CCFLAGS ?= \"\" ;\n", +"C++ ?= $(CC) ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"LINK ?= link /nologo ;\n", +"LINKFLAGS ?= \"\" ;\n", +"LINKLIBS ?= \\\"$(VISUALC)\\\\lib\\\\advapi32.lib\\\"\n", +"\\\"$(VISUALC)\\\\lib\\\\gdi32.lib\\\"\n", +"\\\"$(VISUALC)\\\\lib\\\\user32.lib\\\"\n", +"\\\"$(VISUALC)\\\\lib\\\\kernel32.lib\\\" ;\n", +"OPTIM ?= \"\" ;\n", +"STDHDRS ?= $(VISUALC)\\\\include ;\n", +"UNDEFFLAG ?= \"/u _\" ;\n", +"}\n", +"else if $(TOOLSET) = VC7\n", +"{\n", +"ECHO \"Compiler is Microsoft Visual C++ .NET\" ;\n", +"AR ?= lib ;\n", +"AS ?= masm386 ;\n", +"CC ?= cl /nologo ;\n", +"CCFLAGS ?= \"\" ;\n", +"C++ ?= $(CC) ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"LINK ?= link /nologo ;\n", +"LINKFLAGS ?= \"\" ;\n", +"LINKLIBS ?= \\\"$(VISUALC)\\\\PlatformSDK\\\\lib\\\\advapi32.lib\\\"\n", +"\\\"$(VISUALC)\\\\PlatformSDK\\\\lib\\\\gdi32.lib\\\"\n", +"\\\"$(VISUALC)\\\\PlatformSDK\\\\lib\\\\user32.lib\\\"\n", +"\\\"$(VISUALC)\\\\PlatformSDK\\\\lib\\\\kernel32.lib\\\" ;\n", +"OPTIM ?= \"\" ;\n", +"STDHDRS ?= \\\"$(VISUALC)\\\\include\\\"\n", +"\\\"$(VISUALC)\\\\PlatformSDK\\\\include\\\" ;\n", +"UNDEFFLAG ?= \"/u _\" ;\n", +"}\n", +"else if $(TOOLSET) = INTELC\n", +"{\n", +"ECHO \"Compiler is Intel C/C++\" ;\n", +"if ! $(VISUALC)\n", +"{\n", +"ECHO \"As a special exception, when using the Intel C++ compiler, you need\" ;\n", +"ECHO \"to define the VISUALC environment variable to indicate the location\" ;\n", +"ECHO \"of your Visual C++ installation. Aborting..\" ;\n", +"EXIT ;\n", +"}\n", +"AR ?= lib ;\n", +"AS ?= masm386 ;\n", +"CC ?= icl /nologo ;\n", +"CCFLAGS ?= \"\" ;\n", +"C++ ?= $(CC) ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"LINK ?= link /nologo ;\n", +"LINKFLAGS ?= \"\" ;\n", +"LINKLIBS ?= $(VISUALC)\\\\lib\\\\advapi32.lib\n", +"$(VISUALC)\\\\lib\\\\kernel32.lib\n", +";\n", +"OPTIM ?= \"\" ;\n", +"STDHDRS ?= $(INTELC)\\include $(VISUALC)\\\\include ;\n", +"UNDEFFLAG ?= \"/u _\" ;\n", +"}\n", +"else if $(TOOLSET) = WATCOM\n", +"{\n", +"ECHO \"Compiler is Watcom C/C++\" ;\n", +"AR ?= wlib ;\n", +"CC ?= wcc386 ;\n", +"CCFLAGS ?= /zq /DWIN32 /I$(WATCOM)\\\\h ; # zq=quiet\n", +"C++ ?= wpp386 ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"CP ?= copy ;\n", +"DOT ?= . ;\n", +"DOTDOT ?= .. ;\n", +"LINK ?= wcl386 ;\n", +"LINKFLAGS ?= /zq ; # zq=quiet\n", +"LINKLIBS ?= ;\n", +"MV ?= move ;\n", +"NOARSCAN ?= true ;\n", +"OPTIM ?= ;\n", +"RM ?= del /f ;\n", +"SLASH ?= \\\\ ;\n", +"STDHDRS ?= $(WATCOM)\\\\h $(WATCOM)\\\\h\\\\nt ;\n", +"SUFEXE ?= .exe ;\n", +"SUFLIB ?= .lib ;\n", +"SUFOBJ ?= .obj ;\n", +"UNDEFFLAG ?= \"/u _\" ;\n", +"}\n", +"else if $(TOOLSET) = MINGW\n", +"{\n", +"ECHO \"Compiler is GCC with Mingw\" ;\n", +"AR ?= ar -ru ;\n", +"CC ?= gcc ;\n", +"CCFLAGS ?= \"\" ;\n", +"C++ ?= $(CC) ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"LINK ?= $(CC) ;\n", +"LINKFLAGS ?= \"\" ;\n", +"LINKLIBS ?= \"\" ;\n", +"OPTIM ?= ;\n", +"SUFOBJ = .o ;\n", +"SUFLIB = .a ;\n", +"SLASH = / ;\n", +"}\n", +"else if $(TOOLSET) = LCC\n", +"{\n", +"ECHO \"Compiler is Win32-LCC\" ;\n", +"AR ?= lcclib ;\n", +"CC ?= lcc ;\n", +"CCFLAGS ?= \"\" ;\n", +"C++ ?= $(CC) ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"LINK ?= lcclnk ;\n", +"LINKFLAGS ?= \"\" ;\n", +"LINKLIBS ?= \"\" ;\n", +"OPTIM ?= ;\n", +"NOARSCAN = true ;\n", +"}\n", +"else\n", +"{\n", +"EXIT On NT, set BCCROOT, MSVCNT, MINGW or MSVC to the root of the\n", +"Borland or Microsoft directories. ;\n", +"}\n", +"}\n", +"else if $(OS2)\n", +"{\n", +"local SUPPORTED_TOOLSETS = \"EMX\" \"WATCOM\" ;\n", +"TOOLSET = \"\" ;\n", +"if $(JAM_TOOLSET)\n", +"{\n", +"local t ;\n", +"for t in $(SUPPORTED_TOOLSETS)\n", +"{\n", +"$(t) = $($(t):J=\" \") ; # reconstitute paths with spaces in them\n", +"if $(t) = $(JAM_TOOLSET) { TOOLSET = $(t) ; }\n", +"}\n", +"if ! $(TOOLSET)\n", +"{\n", +"ECHO \"The JAM_TOOLSET environment variable is defined but its value\" ;\n", +"ECHO \"is invalid, please use one of the following:\" ;\n", +"ECHO ;\n", +"for t in $(SUPPORTED_TOOLSETS) { ECHO \" \" $(t) ; }\n", +"EXIT ;\n", +"}\n", +"}\n", +"if ! $(TOOLSET)\n", +"{\n", +"if $(watcom)\n", +"{\n", +"WATCOM = $(watcom:J=\" \") ;\n", +"TOOLSET = WATCOM ;\n", +"}\n", +"else\n", +"{\n", +"ECHO \"Jam cannot be run because you didn't indicate which compilation toolset\" ;\n", +"ECHO \"to use. To do so, follow these simple instructions:\" ;\n", +"ECHO ;\n", +"ECHO \" - define one of the following environment variable, with the\" ;\n", +"ECHO \" appropriate value according to this list:\" ;\n", +"ECHO ;\n", +"ECHO \" Variable Toolset Description\" ;\n", +"ECHO ;\n", +"ECHO \" WATCOM Watcom C/C++ Watcom install path\" ;\n", +"ECHO \" EMX EMX (gcc) EMX install path\" ;\n", +"ECHO \" VISUALAGE IBM Visual Age C/C++ VisualAge install path\" ;\n", +"ECHO ;\n", +"ECHO \" - define the JAM_TOOLSET environment variable with the *name*\" ;\n", +"ECHO \" of the toolset variable you want to use.\" ;\n", +"ECHO ;\n", +"ECHO \" e.g.: set WATCOM=C:\\WATCOM\" ;\n", +"ECHO \" set JAM_TOOLSET=WATCOM\" ;\n", +"ECHO ;\n", +"EXIT ;\n", +"}\n", +"}\n", +"RM = del /f ;\n", +"CP = copy ;\n", +"MV ?= move ;\n", +"DOT ?= . ;\n", +"DOTDOT ?= .. ;\n", +"SUFLIB ?= .lib ;\n", +"SUFOBJ ?= .obj ;\n", +"SUFEXE ?= .exe ;\n", +"if $(TOOLSET) = WATCOM\n", +"{\n", +"AR ?= wlib ;\n", +"BINDIR ?= \\\\os2\\\\apps ;\n", +"CC ?= wcc386 ;\n", +"CCFLAGS ?= /zq /DOS2 /I$(WATCOM)\\\\h ; # zq=quiet\n", +"C++ ?= wpp386 ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"LINK ?= wcl386 ;\n", +"LINKFLAGS ?= /zq ; # zq=quiet\n", +"LINKLIBS ?= ;\n", +"NOARSCAN ?= true ;\n", +"OPTIM ?= ;\n", +"SLASH ?= \\\\ ;\n", +"STDHDRS ?= $(WATCOM)\\\\h ;\n", +"UNDEFFLAG ?= \"/u _\" ;\n", +"}\n", +"else if $(TOOLSET) = EMX\n", +"{\n", +"ECHO \"Compiler is GCC-EMX\" ;\n", +"AR ?= ar -ru ;\n", +"CC ?= gcc ;\n", +"CCFLAGS ?= \"\" ;\n", +"C++ ?= $(CC) ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"LINK ?= $(CC) ;\n", +"LINKFLAGS ?= \"\" ;\n", +"LINKLIBS ?= \"\" ;\n", +"OPTIM ?= ;\n", +"SUFOBJ = .o ;\n", +"SUFLIB = .a ;\n", +"UNDEFFLAG ?= \"-U\" ;\n", +"SLASH = / ;\n", +"}\n", +"else\n", +"{\n", +"EXIT \"Sorry, but the $(JAM_TOOLSET) toolset isn't supported for now\" ;\n", +"}\n", +"}\n", +"else if $(VMS)\n", +"{\n", +"C++ ?= cxx ;\n", +"C++FLAGS ?= ;\n", +"CC ?= cc ;\n", +"CCFLAGS ?= ;\n", +"CHMOD ?= set file/prot= ;\n", +"CP ?= copy/replace ;\n", +"CRELIB ?= true ;\n", +"DOT ?= [] ;\n", +"DOTDOT ?= [-] ;\n", +"EXEMODE ?= (w:e) ;\n", +"FILEMODE ?= (w:r) ;\n", +"HDRS ?= ;\n", +"LINK ?= link ;\n", +"LINKFLAGS ?= \"\" ;\n", +"LINKLIBS ?= ;\n", +"MKDIR ?= create/dir ;\n", +"MV ?= rename ;\n", +"OPTIM ?= \"\" ;\n", +"RM ?= delete ;\n", +"RUNVMS ?= mcr ;\n", +"SHELLMODE ?= (w:er) ;\n", +"SLASH ?= . ;\n", +"STDHDRS ?= decc$library_include ;\n", +"SUFEXE ?= .exe ;\n", +"SUFLIB ?= .olb ;\n", +"SUFOBJ ?= .obj ;\n", +"switch $(OS)\n", +"{\n", +"case OPENVMS : CCFLAGS ?= /stand=vaxc ;\n", +"case VMS : LINKLIBS ?= sys$library:vaxcrtl.olb/lib ;\n", +"}\n", +"}\n", +"else if $(MAC)\n", +"{\n", +"local OPT ;\n", +"CW ?= \"{CW}\" ;\n", +"MACHDRS ?=\n", +"\"$(UMACHDRS):Universal:Interfaces:CIncludes\"\n", +"\"$(CW):MSL:MSL_C:MSL_Common:Include\"\n", +"\"$(CW):MSL:MSL_C:MSL_MacOS:Include\" ;\n", +"MACLIBS ?=\n", +"\"$(CW):MacOS Support:Universal:Libraries:StubLibraries:Interfacelib\"\n", +"\"$(CW):MacOS Support:Universal:Libraries:StubLibraries:Mathlib\" ;\n", +"MPWLIBS ?=\n", +"\"$(CW):MacOS Support:Libraries:Runtime:Runtime PPC:MSL MPWCRuntime.lib\"\n", +"\"$(CW):MSL:MSL_C:MSL_MacOS:Lib:PPC:MSL C.PPC MPW.Lib\" ;\n", +"MPWNLLIBS ?=\n", +"\"$(CW):MacOS Support:Libraries:Runtime:Runtime PPC:MSL MPWCRuntime.lib\"\n", +"\"$(CW):MSL:MSL_C:MSL_MacOS:Lib:PPC:MSL C.PPC MPW(NL).Lib\" ;\n", +"SIOUXHDRS ?= ;\n", +"SIOUXLIBS ?=\n", +"\"$(CW):MacOS Support:Libraries:Runtime:Runtime PPC:MSL RuntimePPC.lib\"\n", +"\"$(CW):MSL:MSL_C:MSL_MacOS:Lib:PPC:MSL SIOUX.PPC.Lib\"\n", +"\"$(CW):MSL:MSL_C:MSL_MacOS:Lib:PPC:MSL C.PPC.Lib\" ;\n", +"C++ ?= mwcppc ;\n", +"C++FLAGS ?= -w off -nomapcr ;\n", +"CC ?= mwcppc ;\n", +"CCFLAGS ?= -w off -nomapcr ;\n", +"CP ?= duplicate -y ;\n", +"DOT ?= \":\" ;\n", +"DOTDOT ?= \"::\" ;\n", +"HDRS ?= $(MACHDRS) $(MPWHDRS) ;\n", +"LINK ?= mwlinkppc ;\n", +"LINKFLAGS ?= -mpwtool -warn ;\n", +"LINKLIBS ?= $(MACLIBS) $(MPWLIBS) ;\n", +"MKDIR ?= newfolder ;\n", +"MV ?= rename -y ;\n", +"NOARSCAN ?= true ;\n", +"OPTIM ?= ;\n", +"RM ?= delete -y ;\n", +"SLASH ?= \":\" ;\n", +"STDHDRS ?= ;\n", +"SUFLIB ?= .lib ;\n", +"SUFOBJ ?= .o ;\n", +"}\n", +"else if $(OS) = BEOS && $(METROWERKS)\n", +"{\n", +"AR ?= mwld -xml -o ;\n", +"BINDIR ?= /boot/apps ;\n", +"CC ?= mwcc ;\n", +"CCFLAGS ?= -nosyspath ;\n", +"C++ ?= $(CC) ;\n", +"C++FLAGS ?= -nosyspath ;\n", +"FORTRAN ?= \"\" ;\n", +"LIBDIR ?= /boot/develop/libraries ;\n", +"LINK ?= mwld ;\n", +"LINKFLAGS ?= \"\" ;\n", +"MANDIR ?= /boot/documentation/\"Shell Tools\"/HTML ;\n", +"NOARSCAN ?= true ;\n", +"STDHDRS ?= /boot/develop/headers/posix ;\n", +"}\n", +"else if $(OS) = BEOS\n", +"{\n", +"BINDIR ?= /boot/apps ;\n", +"CC ?= gcc ;\n", +"C++ ?= $(CC) ;\n", +"FORTRAN ?= \"\" ;\n", +"LIBDIR ?= /boot/develop/libraries ;\n", +"LINK ?= gcc ;\n", +"LINKLIBS ?= -lnet ;\n", +"NOARSCAN ?= true ;\n", +"STDHDRS ?= /boot/develop/headers/posix ;\n", +"}\n", +"else if $(UNIX)\n", +"{\n", +"switch $(OS)\n", +"{\n", +"case AIX :\n", +"LINKLIBS ?= -lbsd ;\n", +"case AMIGA :\n", +"CC ?= gcc ;\n", +"YACC ?= \"bison -y\" ;\n", +"case CYGWIN :\n", +"CC ?= gcc ;\n", +"CCFLAGS += -D__cygwin__ ;\n", +"LEX ?= flex ;\n", +"RANLIB ?= \"\" ;\n", +"SUFEXE ?= .exe ;\n", +"YACC ?= \"bison -y\" ;\n", +"case DGUX :\n", +"RANLIB ?= \"\" ;\n", +"RELOCATE ?= true ;\n", +"case HPUX :\n", +"YACC = ;\n", +"CFLAGS += -Ae ;\n", +"CCFLAGS += -Ae ;\n", +"RANLIB ?= \"\" ;\n", +"case INTERIX :\n", +"CC ?= gcc ;\n", +"RANLIB ?= \"\" ;\n", +"case IRIX :\n", +"RANLIB ?= \"\" ;\n", +"case MPEIX :\n", +"CC ?= gcc ;\n", +"C++ ?= gcc ;\n", +"CCFLAGS += -D_POSIX_SOURCE ;\n", +"HDRS += /usr/include ;\n", +"RANLIB ?= \"\" ;\n", +"NOARSCAN ?= true ;\n", +"NOARUPDATE ?= true ;\n", +"case MVS :\n", +"RANLIB ?= \"\" ;\n", +"case NEXT :\n", +"AR ?= libtool -o ;\n", +"RANLIB ?= \"\" ;\n", +"case MACOSX :\n", +"AR ?= libtool -o ;\n", +"C++ ?= c++ ;\n", +"MANDIR ?= /usr/local/share/man ;\n", +"RANLIB ?= \"\" ;\n", +"case NCR :\n", +"RANLIB ?= \"\" ;\n", +"case PTX :\n", +"RANLIB ?= \"\" ;\n", +"case QNX :\n", +"AR ?= wlib ;\n", +"CC ?= cc ;\n", +"CCFLAGS ?= -Q ; # quiet\n", +"C++ ?= $(CC) ;\n", +"C++FLAGS ?= -Q ; # quiet\n", +"LINK ?= $(CC) ;\n", +"LINKFLAGS ?= -Q ; # quiet\n", +"NOARSCAN ?= true ;\n", +"RANLIB ?= \"\" ;\n", +"case SCO :\n", +"RANLIB ?= \"\" ;\n", +"RELOCATE ?= true ;\n", +"case SINIX :\n", +"RANLIB ?= \"\" ;\n", +"case SOLARIS :\n", +"RANLIB ?= \"\" ;\n", +"AR ?= \"/usr/ccs/bin/ar ru\" ;\n", +"case UNICOS :\n", +"NOARSCAN ?= true ;\n", +"OPTIM ?= -O0 ;\n", +"case UNIXWARE :\n", +"RANLIB ?= \"\" ;\n", +"RELOCATE ?= true ;\n", +"}\n", +"CCFLAGS ?= ;\n", +"C++FLAGS ?= $(CCFLAGS) ;\n", +"CHMOD ?= chmod ;\n", +"CHGRP ?= chgrp ;\n", +"CHOWN ?= chown ;\n", +"LEX ?= lex ;\n", +"LINKFLAGS ?= $(CCFLAGS) ;\n", +"LINKLIBS ?= ;\n", +"OPTIM ?= -O ;\n", +"RANLIB ?= ranlib ;\n", +"YACC ?= yacc ;\n", +"YACCFILES ?= y.tab ;\n", +"YACCFLAGS ?= -d ;\n", +"}\n", +"AR ?= ar ru ;\n", +"AS ?= as ;\n", +"ASFLAGS ?= ;\n", +"AWK ?= awk ;\n", +"BINDIR ?= /usr/local/bin ;\n", +"C++ ?= cc ;\n", +"C++FLAGS ?= ;\n", +"CC ?= cc ;\n", +"CCFLAGS ?= ;\n", +"CP ?= cp -f ;\n", +"CRELIB ?= ;\n", +"DOT ?= . ;\n", +"DOTDOT ?= .. ;\n", +"EXEMODE ?= 711 ;\n", +"FILEMODE ?= 644 ;\n", +"FORTRAN ?= f77 ;\n", +"FORTRANFLAGS ?= ;\n", +"HDRS ?= ;\n", +"INSTALLGRIST ?= installed ;\n", +"JAMFILE ?= Jamfile ;\n", +"JAMRULES ?= Jamrules ;\n", +"LEX ?= ;\n", +"LIBDIR ?= /usr/local/lib ;\n", +"LINK ?= $(CC) ;\n", +"LINKFLAGS ?= ;\n", +"LINKLIBS ?= ;\n", +"LN ?= ln ;\n", +"MANDIR ?= /usr/local/man ;\n", +"MKDIR ?= mkdir ;\n", +"MV ?= mv -f ;\n", +"OPTIM ?= ;\n", +"RCP ?= rcp ;\n", +"RM ?= rm -f ;\n", +"RSH ?= rsh ;\n", +"SED ?= sed ;\n", +"SHELLHEADER ?= \"#!/bin/sh\" ;\n", +"SHELLMODE ?= 755 ;\n", +"SLASH ?= / ;\n", +"STDHDRS ?= /usr/include ;\n", +"SUFEXE ?= \"\" ;\n", +"SUFLIB ?= .a ;\n", +"SUFOBJ ?= .o ;\n", +"UNDEFFLAG ?= \"-u _\" ;\n", +"YACC ?= ;\n", +"YACCFILES ?= ;\n", +"YACCFLAGS ?= ;\n", +"HDRPATTERN =\n", +"\"^[ ]*#[ ]*include[ ]*[<\\\"]([^\\\">]*)[\\\">].*$\" ;\n", +"OSFULL = $(OS)$(OSVER)$(OSPLAT) $(OS)$(OSPLAT) $(OS)$(OSVER) $(OS) ;\n", +"DEPENDS all : shell files lib exe obj ;\n", +"DEPENDS all shell files lib exe obj : first ;\n", +"NOTFILE all first shell files lib exe obj dirs clean uninstall ;\n", +"ALWAYS clean uninstall ;\n", +"rule As\n", +"{\n", +"DEPENDS $(<) : $(>) ;\n", +"ASFLAGS on $(<) += $(ASFLAGS) $(SUBDIRASFLAGS) ;\n", +"}\n", +"rule Bulk\n", +"{\n", +"local i ;\n", +"for i in $(>)\n", +"{\n", +"File $(i:D=$(<)) : $(i) ;\n", +"}\n", +"}\n", +"rule Cc\n", +"{\n", +"local _h ;\n", +"DEPENDS $(<) : $(>) ;\n", +"CCFLAGS on $(<) += $(CCFLAGS) $(SUBDIRCCFLAGS) ;\n", +"if $(RELOCATE)\n", +"{\n", +"CcMv $(<) : $(>) ;\n", +"}\n", +"_h = $(SEARCH_SOURCE) $(HDRS) $(SUBDIRHDRS) ;\n", +"if $(VMS) && $(_h)\n", +"{\n", +"SLASHINC on $(<) = \"/inc=(\" $(_h[1]) ,$(_h[2-]) \")\" ;\n", +"}\n", +"else if $(MAC) && $(_h)\n", +"{\n", +"local _i _j ;\n", +"_j = $(_h[1]) ;\n", +"for _i in $(_h[2-])\n", +"{\n", +"_j = $(_j),$(_i) ;\n", +"}\n", +"MACINC on $(<) = \\\"$(_j)\\\" ;\n", +"}\n", +"}\n", +"rule C++\n", +"{\n", +"local _h ;\n", +"DEPENDS $(<) : $(>) ;\n", +"C++FLAGS on $(<) += $(C++FLAGS) $(SUBDIRC++FLAGS) ;\n", +"if $(RELOCATE)\n", +"{\n", +"CcMv $(<) : $(>) ;\n", +"}\n", +"_h = $(SEARCH_SOURCE) $(HDRS) $(SUBDIRHDRS) ;\n", +"if $(VMS) && $(_h)\n", +"{\n", +"SLASHINC on $(<) = \"/inc=(\" $(_h[1]) ,$(_h[2-]) \")\" ;\n", +"}\n", +"else if $(MAC) && $(_h)\n", +"{\n", +"local _i _j ;\n", +"_j = $(_h[1]) ;\n", +"for _i in $(_h[2-])\n", +"{\n", +"_j = $(_j),$(_i) ;\n", +"}\n", +"MACINC on $(<) = \\\"$(_j)\\\" ;\n", +"}\n", +"}\n", +"rule Chmod\n", +"{\n", +"if $(CHMOD) { Chmod1 $(<) ; }\n", +"}\n", +"rule File\n", +"{\n", +"DEPENDS files : $(<) ;\n", +"DEPENDS $(<) : $(>) ;\n", +"SEARCH on $(>) = $(SEARCH_SOURCE) ;\n", +"MODE on $(<) = $(FILEMODE) ;\n", +"Chmod $(<) ;\n", +"}\n", +"rule Fortran\n", +"{\n", +"DEPENDS $(<) : $(>) ;\n", +"}\n", +"rule GenFile\n", +"{\n", +"local _t = [ FGristSourceFiles $(<) ] ;\n", +"local _s = [ FAppendSuffix $(>[1]) : $(SUFEXE) ] ;\n", +"Depends $(_t) : $(_s) $(>[2-]) ;\n", +"GenFile1 $(_t) : $(_s) $(>[2-]) ;\n", +"Clean clean : $(_t) ;\n", +"}\n", +"rule GenFile1\n", +"{\n", +"MakeLocate $(<) : $(LOCATE_SOURCE) ;\n", +"SEARCH on $(>) = $(SEARCH_SOURCE) ;\n", +"}\n", +"rule HardLink\n", +"{\n", +"DEPENDS files : $(<) ;\n", +"DEPENDS $(<) : $(>) ;\n", +"SEARCH on $(>) = $(SEARCH_SOURCE) ;\n", +"}\n", +"rule HdrMacroFile\n", +"{\n", +"HDRMACRO $(<) ;\n", +"}\n", +"rule HdrRule\n", +"{\n", +"local s ;\n", +"if $(HDRGRIST)\n", +"{\n", +"s = $(>:G=$(HDRGRIST)) ;\n", +"} else {\n", +"s = $(>) ;\n", +"}\n", +"INCLUDES $(<) : $(s) ;\n", +"SEARCH on $(s) = $(HDRSEARCH) ;\n", +"NOCARE $(s) ;\n", +"HDRSEARCH on $(s) = $(HDRSEARCH) ;\n", +"HDRSCAN on $(s) = $(HDRSCAN) ;\n", +"HDRRULE on $(s) = $(HDRRULE) ;\n", +"HDRGRIST on $(s) = $(HDRGRIST) ;\n", +"}\n", +"rule InstallInto\n", +"{\n", +"local i t ;\n", +"t = $(>:G=$(INSTALLGRIST)) ;\n", +"Depends install : $(t) ;\n", +"Clean uninstall : $(t) ;\n", +"SEARCH on $(>) = $(SEARCH_SOURCE) ;\n", +"MakeLocate $(t) : $(<) ;\n", +"for i in $(>)\n", +"{\n", +"local tt = $(i:G=$(INSTALLGRIST)) ;\n", +"Depends $(tt) : $(i) ;\n", +"Install $(tt) : $(i) ;\n", +"Chmod $(tt) ;\n", +"if $(OWNER) && $(CHOWN)\n", +"{\n", +"Chown $(tt) ;\n", +"OWNER on $(tt) = $(OWNER) ;\n", +"}\n", +"if $(GROUP) && $(CHGRP)\n", +"{\n", +"Chgrp $(tt) ;\n", +"GROUP on $(tt) = $(GROUP) ;\n", +"}\n", +"}\n", +"}\n", +"rule InstallBin\n", +"{\n", +"local _t = [ FAppendSuffix $(>) : $(SUFEXE) ] ;\n", +"InstallInto $(<) : $(_t) ;\n", +"MODE on $(_t:G=installed) = $(EXEMODE) ;\n", +"}\n", +"rule InstallFile\n", +"{\n", +"InstallInto $(<) : $(>) ;\n", +"MODE on $(>:G=installed) = $(FILEMODE) ;\n", +"}\n", +"rule InstallLib\n", +"{\n", +"InstallInto $(<) : $(>) ;\n", +"MODE on $(>:G=installed) = $(FILEMODE) ;\n", +"}\n", +"rule InstallMan\n", +"{\n", +"local i s d ;\n", +"for i in $(>)\n", +"{\n", +"switch $(i:S)\n", +"{\n", +"case .1 : s = 1 ; case .2 : s = 2 ; case .3 : s = 3 ;\n", +"case .4 : s = 4 ; case .5 : s = 5 ; case .6 : s = 6 ;\n", +"case .7 : s = 7 ; case .8 : s = 8 ; case .l : s = l ;\n", +"case .n : s = n ; case .man : s = 1 ;\n", +"}\n", +"d = man$(s) ;\n", +"InstallInto $(d:R=$(<)) : $(i) ;\n", +"}\n", +"MODE on $(>:G=installed) = $(FILEMODE) ;\n", +"}\n", +"rule InstallShell\n", +"{\n", +"InstallInto $(<) : $(>) ;\n", +"MODE on $(>:G=installed) = $(SHELLMODE) ;\n", +"}\n", +"rule Lex\n", +"{\n", +"LexMv $(<) : $(>) ;\n", +"DEPENDS $(<) : $(>) ;\n", +"MakeLocate $(<) : $(LOCATE_SOURCE) ;\n", +"Clean clean : $(<) ;\n", +"}\n", +"rule Library\n", +"{\n", +"LibraryFromObjects $(<) : $(>:S=$(SUFOBJ)) ;\n", +"Objects $(>) ;\n", +"}\n", +"rule LibraryFromObjects\n", +"{\n", +"local _i _l _s ;\n", +"_s = [ FGristFiles $(>) ] ;\n", +"_l = $(<:S=$(SUFLIB)) ;\n", +"if $(KEEPOBJS)\n", +"{\n", +"DEPENDS obj : $(_s) ;\n", +"}\n", +"else\n", +"{\n", +"DEPENDS lib : $(_l) ;\n", +"}\n", +"if ! $(_l:D)\n", +"{\n", +"MakeLocate $(_l) $(_l)($(_s:BS)) : $(LOCATE_TARGET) ;\n", +"}\n", +"if $(NOARSCAN)\n", +"{\n", +"DEPENDS $(_l) : $(_s) ;\n", +"}\n", +"else\n", +"{\n", +"DEPENDS $(_l) : $(_l)($(_s:BS)) ;\n", +"for _i in $(_s)\n", +"{\n", +"DEPENDS $(_l)($(_i:BS)) : $(_i) ;\n", +"}\n", +"}\n", +"Clean clean : $(_l) ;\n", +"if $(CRELIB) { CreLib $(_l) : $(_s[1]) ; }\n", +"Archive $(_l) : $(_s) ;\n", +"if $(RANLIB) { Ranlib $(_l) ; }\n", +"if ! ( $(NOARSCAN) || $(KEEPOBJS) ) { RmTemps $(_l) : $(_s) ; }\n", +"}\n", +"rule Link\n", +"{\n", +"MODE on $(<) = $(EXEMODE) ;\n", +"Chmod $(<) ;\n", +"}\n", +"rule LinkLibraries\n", +"{\n", +"local _t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;\n", +"DEPENDS $(_t) : $(>:S=$(SUFLIB)) ;\n", +"NEEDLIBS on $(_t) += $(>:S=$(SUFLIB)) ;\n", +"}\n", +"rule Main\n", +"{\n", +"MainFromObjects $(<) : $(>:S=$(SUFOBJ)) ;\n", +"Objects $(>) ;\n", +"}\n", +"rule MainFromObjects\n", +"{\n", +"local _s _t ;\n", +"_s = [ FGristFiles $(>) ] ;\n", +"_t = [ FAppendSuffix $(<) : $(SUFEXE) ] ;\n", +"if $(_t) != $(<)\n", +"{\n", +"DEPENDS $(<) : $(_t) ;\n", +"NOTFILE $(<) ;\n", +"}\n", +"DEPENDS exe : $(_t) ;\n", +"DEPENDS $(_t) : $(_s) ;\n", +"MakeLocate $(_t) : $(LOCATE_TARGET) ;\n", +"Clean clean : $(_t) ;\n", +"Link $(_t) : $(_s) ;\n", +"}\n", +"rule MakeLocate\n", +"{\n", +"if $(>)\n", +"{\n", +"LOCATE on $(<) = $(>) ;\n", +"Depends $(<) : $(>[1]) ;\n", +"MkDir $(>[1]) ;\n", +"}\n", +"}\n", +"rule MkDir\n", +"{\n", +"NOUPDATE $(<) ;\n", +"if $(<) != $(DOT) && ! $($(<)-mkdir)\n", +"{\n", +"local s ;\n", +"$(<)-mkdir = true ;\n", +"MkDir1 $(<) ;\n", +"Depends dirs : $(<) ;\n", +"s = $(<:P) ;\n", +"if $(NT)\n", +"{\n", +"switch $(s)\n", +"{\n", +"case *: : s = ;\n", +"case *:\\\\ : s = ;\n", +"}\n", +"}\n", +"if $(s) && $(s) != $(<)\n", +"{\n", +"Depends $(<) : $(s) ;\n", +"MkDir $(s) ;\n", +"}\n", +"else if $(s)\n", +"{\n", +"NOTFILE $(s) ;\n", +"}\n", +"}\n", +"}\n", +"rule Object\n", +"{\n", +"local h ;\n", +"Clean clean : $(<) ;\n", +"MakeLocate $(<) : $(LOCATE_TARGET) ;\n", +"SEARCH on $(>) = $(SEARCH_SOURCE) ;\n", +"HDRS on $(<) = $(SEARCH_SOURCE) $(HDRS) $(SUBDIRHDRS) ;\n", +"if $(SEARCH_SOURCE)\n", +"{\n", +"h = $(SEARCH_SOURCE) ;\n", +"}\n", +"else\n", +"{\n", +"h = \"\" ;\n", +"}\n", +"HDRRULE on $(>) = HdrRule ;\n", +"HDRSCAN on $(>) = $(HDRPATTERN) ;\n", +"HDRSEARCH on $(>) = $(HDRS) $(SUBDIRHDRS) $(h) $(STDHDRS) ;\n", +"HDRGRIST on $(>) = $(HDRGRIST) ;\n", +"switch $(>:S)\n", +"{\n", +"case .asm : As $(<) : $(>) ;\n", +"case .c : Cc $(<) : $(>) ;\n", +"case .C : C++ $(<) : $(>) ;\n", +"case .cc : C++ $(<) : $(>) ;\n", +"case .cpp : C++ $(<) : $(>) ;\n", +"case .f : Fortran $(<) : $(>) ;\n", +"case .l : Cc $(<) : $(<:S=.c) ;\n", +"Lex $(<:S=.c) : $(>) ;\n", +"case .s : As $(<) : $(>) ;\n", +"case .y : Cc $(<) : $(<:S=.c) ;\n", +"Yacc $(<:S=.c) : $(>) ;\n", +"case * : UserObject $(<) : $(>) ;\n", +"}\n", +"}\n", +"rule ObjectCcFlags\n", +"{\n", +"CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;\n", +"}\n", +"rule ObjectC++Flags\n", +"{\n", +"C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;\n", +"}\n", +"rule ObjectHdrs\n", +"{\n", +"HDRS on [ FGristFiles $(<:S=$(SUFOBJ)) ] += $(>) ;\n", +"}\n", +"rule Objects\n", +"{\n", +"local _i ;\n", +"for _i in [ FGristFiles $(<) ]\n", +"{\n", +"Object $(_i:S=$(SUFOBJ)) : $(_i) ;\n", +"DEPENDS obj : $(_i:S=$(SUFOBJ)) ;\n", +"}\n", +"}\n", +"rule RmTemps\n", +"{\n", +"TEMPORARY $(>) ;\n", +"}\n", +"rule Setuid\n", +"{\n", +"MODE on [ FAppendSuffix $(<) : $(SUFEXE) ] = 4711 ;\n", +"}\n", +"rule Shell\n", +"{\n", +"DEPENDS shell : $(<) ;\n", +"DEPENDS $(<) : $(>) ;\n", +"SEARCH on $(>) = $(SEARCH_SOURCE) ;\n", +"MODE on $(<) = $(SHELLMODE) ;\n", +"Clean clean : $(<) ;\n", +"Chmod $(<) ;\n", +"}\n", +"rule SubDir\n", +"{\n", +"local _r _s ;\n", +"if ! $($(<[1]))\n", +"{\n", +"if ! $(<[1])\n", +"{\n", +"EXIT SubDir syntax error ;\n", +"}\n", +"$(<[1]) = [ FSubDir $(<[2-]) ] ;\n", +"}\n", +"if ! $($(<[1])-included)\n", +"{\n", +"$(<[1])-included = TRUE ;\n", +"_r = $($(<[1])RULES) ;\n", +"if ! $(_r)\n", +"{\n", +"_r = $(JAMRULES:R=$($(<[1]))) ;\n", +"}\n", +"include $(_r) ;\n", +"}\n", +"_s = [ FDirName $(<[2-]) ] ;\n", +"SUBDIR = $(_s:R=$($(<[1]))) ;\n", +"SUBDIR_TOKENS = $(<[2-]) ;\n", +"SEARCH_SOURCE = $(SUBDIR) ;\n", +"LOCATE_SOURCE = $(ALL_LOCATE_TARGET) $(SUBDIR) ;\n", +"LOCATE_TARGET = $(ALL_LOCATE_TARGET) $(SUBDIR) ;\n", +"SOURCE_GRIST = [ FGrist $(<[2-]) ] ;\n", +"SUBDIRCCFLAGS = ;\n", +"SUBDIRC++FLAGS = ;\n", +"SUBDIRHDRS = ;\n", +"}\n", +"rule SubDirCcFlags\n", +"{\n", +"SUBDIRCCFLAGS += $(<) ;\n", +"}\n", +"rule SubDirC++Flags\n", +"{\n", +"SUBDIRC++FLAGS += $(<) ;\n", +"}\n", +"rule SubDirHdrs\n", +"{\n", +"SUBDIRHDRS += $(<) ;\n", +"}\n", +"rule SubInclude\n", +"{\n", +"local _s ;\n", +"if ! $($(<[1]))\n", +"{\n", +"EXIT Top level of source tree has not been set with $(<[1]) ;\n", +"}\n", +"_s = [ FDirName $(<[2-]) ] ;\n", +"include $(JAMFILE:D=$(_s):R=$($(<[1]))) ;\n", +"}\n", +"rule Undefines\n", +"{\n", +"UNDEFS on [ FAppendSuffix $(<) : $(SUFEXE) ] += $(UNDEFFLAG)$(>) ;\n", +"}\n", +"rule UserObject\n", +"{\n", +"EXIT \"Unknown suffix on\" $(>) \"- see UserObject rule in Jamfile(5).\" ;\n", +"}\n", +"rule Yacc\n", +"{\n", +"local _h ;\n", +"_h = $(<:BS=.h) ;\n", +"MakeLocate $(<) $(_h) : $(LOCATE_SOURCE) ;\n", +"if $(YACC)\n", +"{\n", +"DEPENDS $(<) $(_h) : $(>) ;\n", +"Yacc1 $(<) $(_h) : $(>) ;\n", +"YaccMv $(<) $(_h) : $(>) ;\n", +"Clean clean : $(<) $(_h) ;\n", +"}\n", +"INCLUDES $(<) : $(_h) ;\n", +"}\n", +"rule FGrist\n", +"{\n", +"local _g _i ;\n", +"_g = $(<[1]) ;\n", +"for _i in $(<[2-])\n", +"{\n", +"_g = $(_g)!$(_i) ;\n", +"}\n", +"return $(_g) ;\n", +"}\n", +"rule FGristFiles\n", +"{\n", +"if ! $(SOURCE_GRIST)\n", +"{\n", +"return $(<) ;\n", +"}\n", +"else\n", +"{\n", +"return $(<:G=$(SOURCE_GRIST)) ;\n", +"}\n", +"}\n", +"rule FGristSourceFiles\n", +"{\n", +"if ! $(SOURCE_GRIST)\n", +"{\n", +"return $(<) ;\n", +"}\n", +"else\n", +"{\n", +"local _i _o ;\n", +"for _i in $(<)\n", +"{\n", +"switch $(_i)\n", +"{\n", +"case *.h : _o += $(_i) ;\n", +"case * : _o += $(_i:G=$(SOURCE_GRIST)) ;\n", +"}\n", +"}\n", +"return $(_o) ;\n", +"}\n", +"}\n", +"rule FConcat\n", +"{\n", +"local _t _r ;\n", +"$(_r) = $(<[1]) ;\n", +"for _t in $(<[2-])\n", +"{\n", +"$(_r) = $(_r)$(_t) ;\n", +"}\n", +"return $(_r) ;\n", +"}\n", +"rule FSubDir\n", +"{\n", +"local _i _d ;\n", +"if ! $(<[1])\n", +"{\n", +"_d = $(DOT) ;\n", +"}\n", +"else\n", +"{\n", +"_d = $(DOTDOT) ;\n", +"for _i in $(<[2-])\n", +"{\n", +"_d = $(_d:R=$(DOTDOT)) ;\n", +"}\n", +"}\n", +"return $(_d) ;\n", +"}\n", +"rule FDirName\n", +"{\n", +"local _s _i ;\n", +"if ! $(<)\n", +"{\n", +"_s = $(DOT) ;\n", +"}\n", +"else if $(VMS)\n", +"{\n", +"switch $(<[1])\n", +"{\n", +"case *:* : _s = $(<[1]) ;\n", +"case \\\\[*\\\\] : _s = $(<[1]) ;\n", +"case * : _s = [.$(<[1])] ;\n", +"}\n", +"for _i in [.$(<[2-])]\n", +"{\n", +"_s = $(_i:R=$(_s)) ;\n", +"}\n", +"}\n", +"else if $(MAC)\n", +"{\n", +"_s = $(DOT) ;\n", +"for _i in $(<)\n", +"{\n", +"_s = $(_i:R=$(_s)) ;\n", +"}\n", +"}\n", +"else\n", +"{\n", +"_s = $(<[1]) ;\n", +"for _i in $(<[2-])\n", +"{\n", +"_s = $(_i:R=$(_s)) ;\n", +"}\n", +"}\n", +"return $(_s) ;\n", +"}\n", +"rule _makeCommon\n", +"{\n", +"if $($(<)[1]) && $($(<)[1]) = $($(>)[1])\n", +"{\n", +"$(<) = $($(<)[2-]) ;\n", +"$(>) = $($(>)[2-]) ;\n", +"_makeCommon $(<) : $(>) ;\n", +"}\n", +"}\n", +"rule FRelPath\n", +"{\n", +"local _l _r ;\n", +"_l = $(<) ;\n", +"_r = $(>) ;\n", +"_makeCommon _l : _r ;\n", +"_l = [ FSubDir $(_l) ] ;\n", +"_r = [ FDirName $(_r) ] ;\n", +"if $(_r) = $(DOT) {\n", +"return $(_l) ;\n", +"} else {\n", +"return $(_r:R=$(_l)) ;\n", +"}\n", +"}\n", +"rule FAppendSuffix\n", +"{\n", +"if $(>)\n", +"{\n", +"local _i _o ;\n", +"for _i in $(<)\n", +"{\n", +"if $(_i:S)\n", +"{\n", +"_o += $(_i) ;\n", +"}\n", +"else\n", +"{\n", +"_o += $(_i:S=$(>)) ;\n", +"}\n", +"}\n", +"return $(_o) ;\n", +"}\n", +"else\n", +"{\n", +"return $(<) ;\n", +"}\n", +"}\n", +"rule unmakeDir\n", +"{\n", +"if $(>[1]:D) && $(>[1]:D) != $(>[1]) && $(>[1]:D) != \\\\\\\\\n", +"{\n", +"unmakeDir $(<) : $(>[1]:D) $(>[1]:BS) $(>[2-]) ;\n", +"}\n", +"else\n", +"{\n", +"$(<) = $(>) ;\n", +"}\n", +"}\n", +"rule FConvertToSlashes\n", +"{\n", +"local _d, _s, _i ;\n", +"unmakeDir _d : $(<) ;\n", +"_s = $(_d[1]) ;\n", +"for _i in $(_d[2-])\n", +"{\n", +"_s = $(_s)/$(_i) ;\n", +"}\n", +"return $(_s) ;\n", +"}\n", +"actions updated together piecemeal Archive\n", +"{\n", +"$(AR) $(<) $(>)\n", +"}\n", +"actions As\n", +"{\n", +"$(AS) $(ASFLAGS) -I$(HDRS) -o $(<) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"$(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) -o $(<) $(>)\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) -o $(<) $(>)\n", +"}\n", +"actions Chgrp\n", +"{\n", +"$(CHGRP) $(GROUP) $(<)\n", +"}\n", +"actions Chmod1\n", +"{\n", +"$(CHMOD) $(MODE) $(<)\n", +"}\n", +"actions Chown\n", +"{\n", +"$(CHOWN) $(OWNER) $(<)\n", +"}\n", +"actions piecemeal together existing Clean\n", +"{\n", +"$(RM) $(>)\n", +"}\n", +"actions File\n", +"{\n", +"$(CP) $(>) $(<)\n", +"}\n", +"actions GenFile1\n", +"{\n", +"$(>[1]) $(<) $(>[2-])\n", +"}\n", +"actions Fortran\n", +"{\n", +"$(FORTRAN) $(FORTRANFLAGS) -o $(<) $(>)\n", +"}\n", +"actions HardLink\n", +"{\n", +"$(RM) $(<) && $(LN) $(>) $(<)\n", +"}\n", +"actions Install\n", +"{\n", +"$(CP) $(>) $(<)\n", +"}\n", +"actions Lex\n", +"{\n", +"$(LEX) $(>)\n", +"}\n", +"actions LexMv\n", +"{\n", +"$(MV) lex.yy.c $(<)\n", +"}\n", +"actions Link bind NEEDLIBS\n", +"{\n", +"$(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)\n", +"}\n", +"actions MkDir1\n", +"{\n", +"$(MKDIR) $(<)\n", +"}\n", +"actions together Ranlib\n", +"{\n", +"$(RANLIB) $(<)\n", +"}\n", +"actions quietly updated piecemeal together RmTemps\n", +"{\n", +"$(RM) $(>)\n", +"}\n", +"actions Shell\n", +"{\n", +"$(AWK) '\n", +"NR == 1 { print \"$(SHELLHEADER)\" }\n", +"NR == 1 && /^[#:]/ { next }\n", +"/^##/ { next }\n", +"{ print }\n", +"' < $(>) > $(<)\n", +"}\n", +"actions Yacc1\n", +"{\n", +"$(YACC) $(YACCFLAGS) $(>)\n", +"}\n", +"actions YaccMv\n", +"{\n", +"$(MV) $(YACCFILES).c $(<[1])\n", +"$(MV) $(YACCFILES).h $(<[2])\n", +"}\n", +"if $(RELOCATE)\n", +"{\n", +"actions C++\n", +"{\n", +"$(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) $(>)\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) $(>)\n", +"}\n", +"actions ignore CcMv\n", +"{\n", +"[ $(<) != $(>:BS=$(SUFOBJ)) ] && $(MV) $(>:BS=$(SUFOBJ)) $(<)\n", +"}\n", +"}\n", +"if $(NOARUPDATE)\n", +"{\n", +"actions Archive\n", +"{\n", +"$(AR) $(<) $(>)\n", +"}\n", +"}\n", +"if $(NT)\n", +"{\n", +"if $(TOOLSET) = VISUALC || $(TOOLSET) = VC7 || $(TOOLSET) = INTELC\n", +"{\n", +"actions updated together piecemeal Archive\n", +"{\n", +"if exist $(<) set _$(<:B)_=$(<)\n", +"$(AR) /out:$(<) %_$(<:B)_% $(>)\n", +"}\n", +"actions As\n", +"{\n", +"$(AS) /Ml /p /v /w2 $(>) $(<) ,nul,nul;\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) /c $(CCFLAGS) $(OPTIM) /Fo$(<) /I$(HDRS) /I$(STDHDRS) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"$(C++) /c $(C++FLAGS) $(OPTIM) /Fo$(<) /I$(HDRS) /I$(STDHDRS) /Tp$(>)\n", +"}\n", +"actions Link bind NEEDLIBS\n", +"{\n", +"$(LINK) $(LINKFLAGS) /out:$(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)\n", +"}\n", +"}\n", +"else if $(TOOLSET) = VISUALC16\n", +"{\n", +"actions updated together piecemeal Archive\n", +"{\n", +"$(AR) $(<) -+$(>)\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) /c $(CCFLAGS) $(OPTIM) /Fo$(<) /I$(HDRS) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"$(C++) /c $(C++FLAGS) $(OPTIM) /Fo$(<) /I$(HDRS) /Tp$(>)\n", +"}\n", +"actions Link bind NEEDLIBS\n", +"{\n", +"$(LINK) $(LINKFLAGS) /out:$(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)\n", +"}\n", +"}\n", +"else if $(TOOLSET) = BORLANDC\n", +"{\n", +"actions updated together piecemeal Archive\n", +"{\n", +"$(AR) $(<) -+$(>)\n", +"}\n", +"actions Link bind NEEDLIBS\n", +"{\n", +"$(LINK) -e$(<) $(LINKFLAGS) $(UNDEFS) -L$(LINKLIBS) $(NEEDLIBS) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"$(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)\n", +"}\n", +"}\n", +"else if $(TOOLSET) = MINGW\n", +"{\n", +"actions together piecemeal Archive\n", +"{\n", +"$(AR) $(<) $(>:T)\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"$(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)\n", +"}\n", +"}\n", +"else if $(TOOLSET) = WATCOM\n", +"{\n", +"actions together piecemeal Archive\n", +"{\n", +"$(AR) $(<) +-$(>)\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) $(CCFLAGS) $(OPTIM) /Fo=$(<) /I$(HDRS) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"$(C++) $(C++FLAGS) $(OPTIM) /Fo=$(<) /I$(HDRS) $(>)\n", +"}\n", +"actions Link bind NEEDLIBS\n", +"{\n", +"$(LINK) $(LINKFLAGS) /Fe=$(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)\n", +"}\n", +"actions Shell\n", +"{\n", +"$(CP) $(>) $(<)\n", +"}\n", +"}\n", +"else if $(TOOLSET) = LCC\n", +"{\n", +"actions together piecemeal Archive\n", +"{\n", +"$(AR) /out:$(<) $(>)\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) $(CCFLAGS) $(OPTIM) -Fo$(<) -I$(HDRS) $(>)\n", +"}\n", +"actions Link bind NEEDLIBS\n", +"{\n", +"$(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)\n", +"}\n", +"actions Shell\n", +"{\n", +"$(CP) $(>) $(<)\n", +"}\n", +"}\n", +"}\n", +"else if $(OS2)\n", +"{\n", +"if $(TOOLSET) = WATCOM\n", +"{\n", +"actions together piecemeal Archive\n", +"{\n", +"$(AR) $(<) +-$(>)\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) $(CCFLAGS) $(OPTIM) /Fo=$(<) /I$(HDRS) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"$(C++) $(C++FLAGS) $(OPTIM) /Fo=$(<) /I$(HDRS) $(>)\n", +"}\n", +"actions Link bind NEEDLIBS\n", +"{\n", +"$(LINK) $(LINKFLAGS) /Fe=$(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)\n", +"}\n", +"actions Shell\n", +"{\n", +"$(CP) $(>) $(<)\n", +"}\n", +"}\n", +"else if $(TOOLSET) = EMX\n", +"{\n", +"actions together piecemeal Archive\n", +"{\n", +"$(AR) $(<) $(>:T)\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC) -c $(CCFLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"$(C++) -c $(C++FLAGS) $(OPTIM) -I$(HDRS) -o$(<) $(>)\n", +"}\n", +"}\n", +"}\n", +"else if $(VMS)\n", +"{\n", +"actions updated together piecemeal Archive\n", +"{\n", +"lib/replace $(<) $(>[1]) ,$(>[2-])\n", +"}\n", +"actions Cc\n", +"{\n", +"$(CC)/obj=$(<) $(CCFLAGS) $(OPTIM) $(SLASHINC) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"$(C++)/obj=$(<) $(C++FLAGS) $(OPTIM) $(SLASHINC) $(>)\n", +"}\n", +"actions piecemeal together existing Clean\n", +"{\n", +"$(RM) $(>[1]);* ,$(>[2-]);*\n", +"}\n", +"actions together quietly CreLib\n", +"{\n", +"if f$search(\"$(<)\") .eqs. \"\" then lib/create $(<)\n", +"}\n", +"actions GenFile1\n", +"{\n", +"mcr $(>[1]) $(<) $(>[2-])\n", +"}\n", +"actions Link bind NEEDLIBS\n", +"{\n", +"$(LINK)/exe=$(<) $(LINKFLAGS) $(>[1]) ,$(>[2-]) ,$(NEEDLIBS)/lib ,$(LINKLIBS)\n", +"}\n", +"actions quietly updated piecemeal together RmTemps\n", +"{\n", +"$(RM) $(>[1]);* ,$(>[2-]);*\n", +"}\n", +"actions Shell\n", +"{\n", +"$(CP) $(>) $(<)\n", +"}\n", +"}\n", +"else if $(MAC)\n", +"{\n", +"actions together Archive\n", +"{\n", +"$(LINK) -library -o $(<) $(>)\n", +"}\n", +"actions Cc\n", +"{\n", +"set -e MWCincludes $(MACINC)\n", +"$(CC) -o $(<) $(CCFLAGS) $(OPTIM) $(>)\n", +"}\n", +"actions C++\n", +"{\n", +"set -e MWCincludes $(MACINC)\n", +"$(CC) -o $(<) $(C++FLAGS) $(OPTIM) $(>)\n", +"}\n", +"actions Link bind NEEDLIBS\n", +"{\n", +"$(LINK) -o $(<) $(LINKFLAGS) $(>) $(NEEDLIBS) \"$(LINKLIBS)\"\n", +"}\n", +"}\n", +"rule BULK { Bulk $(<) : $(>) ; }\n", +"rule FILE { File $(<) : $(>) ; }\n", +"rule HDRRULE { HdrRule $(<) : $(>) ; }\n", +"rule INSTALL { Install $(<) : $(>) ; }\n", +"rule LIBRARY { Library $(<) : $(>) ; }\n", +"rule LIBS { LinkLibraries $(<) : $(>) ; }\n", +"rule LINK { Link $(<) : $(>) ; }\n", +"rule MAIN { Main $(<) : $(>) ; }\n", +"rule SETUID { Setuid $(<) ; }\n", +"rule SHELL { Shell $(<) : $(>) ; }\n", +"rule UNDEFINES { Undefines $(<) : $(>) ; }\n", +"rule INSTALLBIN { InstallBin $(BINDIR) : $(<) ; }\n", +"rule INSTALLLIB { InstallLib $(LIBDIR) : $(<) ; }\n", +"rule INSTALLMAN { InstallMan $(MANDIR) : $(<) ; }\n", +"rule addDirName { $(<) += [ FDirName $(>) ] ; }\n", +"rule makeDirName { $(<) = [ FDirName $(>) ] ; }\n", +"rule makeGristedName { $(<) = [ FGristSourceFiles $(>) ] ; }\n", +"rule makeRelPath { $(<[1]) = [ FRelPath $(<[2-]) : $(>) ] ; }\n", +"rule makeSuffixed { $(<[1]) = [ FAppendSuffix $(>) : $(<[2]) ] ; }\n", +"{\n", +"if $(JAMFILE) { include $(JAMFILE) ; }\n", +"}\n", +"}\n", +0 }; diff --git a/mosesdecoder/jam-files/engine/jamgram.c b/mosesdecoder/jam-files/engine/jamgram.c new file mode 100644 index 0000000000000000000000000000000000000000..48c85228e82b7e0b65bae72d9c601994ecdc2f07 --- /dev/null +++ b/mosesdecoder/jam-files/engine/jamgram.c @@ -0,0 +1,2327 @@ +/* A Bison parser, made by GNU Bison 2.4.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.4.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ +#line 96 "jamgram.y" + +#include "jam.h" + +#include "lists.h" +#include "parse.h" +#include "scan.h" +#include "compile.h" +#include "object.h" +#include "rules.h" + +# define YYMAXDEPTH 10000 /* for OSF and other less endowed yaccs */ + +# define F0 -1 +# define P0 (PARSE *)0 +# define S0 (OBJECT *)0 + +# define pappend( l,r ) parse_make( PARSE_APPEND,l,r,P0,S0,S0,0 ) +# define peval( c,l,r ) parse_make( PARSE_EVAL,l,r,P0,S0,S0,c ) +# define pfor( s,l,r,x ) parse_make( PARSE_FOREACH,l,r,P0,s,S0,x ) +# define pif( l,r,t ) parse_make( PARSE_IF,l,r,t,S0,S0,0 ) +# define pincl( l ) parse_make( PARSE_INCLUDE,l,P0,P0,S0,S0,0 ) +# define plist( s ) parse_make( PARSE_LIST,P0,P0,P0,s,S0,0 ) +# define plocal( l,r,t ) parse_make( PARSE_LOCAL,l,r,t,S0,S0,0 ) +# define pmodule( l,r ) parse_make( PARSE_MODULE,l,r,P0,S0,S0,0 ) +# define pclass( l,r ) parse_make( PARSE_CLASS,l,r,P0,S0,S0,0 ) +# define pnull() parse_make( PARSE_NULL,P0,P0,P0,S0,S0,0 ) +# define pon( l,r ) parse_make( PARSE_ON,l,r,P0,S0,S0,0 ) +# define prule( s,p ) parse_make( PARSE_RULE,p,P0,P0,s,S0,0 ) +# define prules( l,r ) parse_make( PARSE_RULES,l,r,P0,S0,S0,0 ) +# define pset( l,r,a ) parse_make( PARSE_SET,l,r,P0,S0,S0,a ) +# define pset1( l,r,t,a ) parse_make( PARSE_SETTINGS,l,r,t,S0,S0,a ) +# define psetc( s,p,a,l ) parse_make( PARSE_SETCOMP,p,a,P0,s,S0,l ) +# define psete( s,l,s1,f ) parse_make( PARSE_SETEXEC,l,P0,P0,s,s1,f ) +# define pswitch( l,r ) parse_make( PARSE_SWITCH,l,r,P0,S0,S0,0 ) +# define pwhile( l,r ) parse_make( PARSE_WHILE,l,r,P0,S0,S0,0 ) + +# define pnode( l,r ) parse_make( F0,l,r,P0,S0,S0,0 ) +# define psnode( s,l ) parse_make( F0,l,P0,P0,s,S0,0 ) + + + +/* Line 189 of yacc.c */ +#line 114 "y.tab.c" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + _BANG_t = 258, + _BANG_EQUALS_t = 259, + _AMPER_t = 260, + _AMPERAMPER_t = 261, + _LPAREN_t = 262, + _RPAREN_t = 263, + _PLUS_EQUALS_t = 264, + _COLON_t = 265, + _SEMIC_t = 266, + _LANGLE_t = 267, + _LANGLE_EQUALS_t = 268, + _EQUALS_t = 269, + _RANGLE_t = 270, + _RANGLE_EQUALS_t = 271, + _QUESTION_EQUALS_t = 272, + _LBRACKET_t = 273, + _RBRACKET_t = 274, + ACTIONS_t = 275, + BIND_t = 276, + CASE_t = 277, + CLASS_t = 278, + DEFAULT_t = 279, + ELSE_t = 280, + EXISTING_t = 281, + FOR_t = 282, + IF_t = 283, + IGNORE_t = 284, + IN_t = 285, + INCLUDE_t = 286, + LOCAL_t = 287, + MODULE_t = 288, + ON_t = 289, + PIECEMEAL_t = 290, + QUIETLY_t = 291, + RETURN_t = 292, + RULE_t = 293, + SWITCH_t = 294, + TOGETHER_t = 295, + UPDATED_t = 296, + WHILE_t = 297, + _LBRACE_t = 298, + _BAR_t = 299, + _BARBAR_t = 300, + _RBRACE_t = 301, + ARG = 302, + STRING = 303 + }; +#endif +/* Tokens. */ +#define _BANG_t 258 +#define _BANG_EQUALS_t 259 +#define _AMPER_t 260 +#define _AMPERAMPER_t 261 +#define _LPAREN_t 262 +#define _RPAREN_t 263 +#define _PLUS_EQUALS_t 264 +#define _COLON_t 265 +#define _SEMIC_t 266 +#define _LANGLE_t 267 +#define _LANGLE_EQUALS_t 268 +#define _EQUALS_t 269 +#define _RANGLE_t 270 +#define _RANGLE_EQUALS_t 271 +#define _QUESTION_EQUALS_t 272 +#define _LBRACKET_t 273 +#define _RBRACKET_t 274 +#define ACTIONS_t 275 +#define BIND_t 276 +#define CASE_t 277 +#define CLASS_t 278 +#define DEFAULT_t 279 +#define ELSE_t 280 +#define EXISTING_t 281 +#define FOR_t 282 +#define IF_t 283 +#define IGNORE_t 284 +#define IN_t 285 +#define INCLUDE_t 286 +#define LOCAL_t 287 +#define MODULE_t 288 +#define ON_t 289 +#define PIECEMEAL_t 290 +#define QUIETLY_t 291 +#define RETURN_t 292 +#define RULE_t 293 +#define SWITCH_t 294 +#define TOGETHER_t 295 +#define UPDATED_t 296 +#define WHILE_t 297 +#define _LBRACE_t 298 +#define _BAR_t 299 +#define _BARBAR_t 300 +#define _RBRACE_t 301 +#define ARG 302 +#define STRING 303 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 264 of yacc.c */ +#line 252 "y.tab.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 43 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 243 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 49 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 24 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 75 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 159 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 303 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 4, 6, 8, 10, 12, 15, 21, + 22, 25, 27, 31, 32, 34, 35, 39, 43, 47, + 52, 59, 63, 72, 78, 84, 90, 96, 102, 110, + 116, 120, 121, 122, 132, 134, 136, 138, 141, 143, + 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, + 187, 190, 194, 195, 198, 203, 205, 209, 211, 212, + 215, 217, 218, 223, 226, 231, 236, 237, 240, 242, + 244, 246, 248, 250, 252, 253 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 50, 0, -1, -1, 52, -1, 53, -1, 52, -1, + 57, -1, 57, 52, -1, 32, 65, 54, 11, 51, + -1, -1, 14, 65, -1, 53, -1, 7, 64, 8, + -1, -1, 32, -1, -1, 43, 51, 46, -1, 31, + 65, 11, -1, 47, 64, 11, -1, 67, 60, 65, + 11, -1, 67, 34, 65, 60, 65, 11, -1, 37, + 65, 11, -1, 27, 56, 47, 30, 65, 43, 51, + 46, -1, 39, 65, 43, 62, 46, -1, 28, 61, + 43, 51, 46, -1, 33, 65, 43, 51, 46, -1, + 23, 64, 43, 51, 46, -1, 42, 61, 43, 51, + 46, -1, 28, 61, 43, 51, 46, 25, 57, -1, + 56, 38, 47, 55, 57, -1, 34, 67, 57, -1, + -1, -1, 20, 70, 47, 72, 43, 58, 48, 59, + 46, -1, 14, -1, 9, -1, 17, -1, 24, 14, + -1, 67, -1, 61, 14, 61, -1, 61, 4, 61, + -1, 61, 12, 61, -1, 61, 13, 61, -1, 61, + 15, 61, -1, 61, 16, 61, -1, 61, 5, 61, + -1, 61, 6, 61, -1, 61, 44, 61, -1, 61, + 45, 61, -1, 67, 30, 65, -1, 3, 61, -1, + 7, 61, 8, -1, -1, 63, 62, -1, 22, 47, + 10, 51, -1, 65, -1, 65, 10, 64, -1, 66, + -1, -1, 66, 67, -1, 47, -1, -1, 18, 68, + 69, 19, -1, 47, 64, -1, 34, 67, 47, 64, + -1, 34, 67, 37, 65, -1, -1, 70, 71, -1, + 41, -1, 40, -1, 29, -1, 36, -1, 35, -1, + 26, -1, -1, 21, 65, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 139, 139, 141, 152, 154, 158, 160, 162, 167, + 170, 172, 176, 179, 182, 185, 188, 190, 192, 194, + 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, + 216, 219, 221, 218, 230, 232, 234, 236, 243, 245, + 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, + 267, 269, 281, 282, 286, 295, 297, 307, 312, 313, + 317, 319, 319, 328, 330, 332, 343, 344, 348, 350, + 352, 354, 356, 358, 368, 369 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "_BANG_t", "_BANG_EQUALS_t", "_AMPER_t", + "_AMPERAMPER_t", "_LPAREN_t", "_RPAREN_t", "_PLUS_EQUALS_t", "_COLON_t", + "_SEMIC_t", "_LANGLE_t", "_LANGLE_EQUALS_t", "_EQUALS_t", "_RANGLE_t", + "_RANGLE_EQUALS_t", "_QUESTION_EQUALS_t", "_LBRACKET_t", "_RBRACKET_t", + "ACTIONS_t", "BIND_t", "CASE_t", "CLASS_t", "DEFAULT_t", "ELSE_t", + "EXISTING_t", "FOR_t", "IF_t", "IGNORE_t", "IN_t", "INCLUDE_t", + "LOCAL_t", "MODULE_t", "ON_t", "PIECEMEAL_t", "QUIETLY_t", "RETURN_t", + "RULE_t", "SWITCH_t", "TOGETHER_t", "UPDATED_t", "WHILE_t", "_LBRACE_t", + "_BAR_t", "_BARBAR_t", "_RBRACE_t", "ARG", "STRING", "$accept", "run", + "block", "rules", "null", "assign_list_opt", "arglist_opt", "local_opt", + "rule", "$@1", "$@2", "assign", "expr", "cases", "case", "lol", "list", + "listp", "arg", "$@3", "func", "eflags", "eflag", "bindlist", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 49, 50, 50, 51, 51, 52, 52, 52, 53, + 54, 54, 55, 55, 56, 56, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 57, 58, 59, 57, 60, 60, 60, 60, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 62, 62, 63, 64, 64, 65, 66, 66, + 67, 68, 67, 69, 69, 69, 70, 70, 71, 71, + 71, 71, 71, 71, 72, 72 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 1, 1, 1, 1, 2, 5, 0, + 2, 1, 3, 0, 1, 0, 3, 3, 3, 4, + 6, 3, 8, 5, 5, 5, 5, 5, 7, 5, + 3, 0, 0, 9, 1, 1, 1, 2, 1, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 2, 3, 0, 2, 4, 1, 3, 1, 0, 2, + 1, 0, 4, 2, 4, 4, 0, 2, 1, 1, + 1, 1, 1, 1, 0, 2 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 61, 66, 58, 15, 0, 58, 58, 58, 0, + 58, 58, 0, 9, 60, 0, 3, 0, 6, 0, + 0, 0, 0, 55, 57, 14, 0, 0, 0, 60, + 0, 38, 0, 9, 0, 15, 0, 0, 0, 0, + 5, 4, 0, 1, 0, 7, 35, 34, 36, 0, + 58, 58, 0, 58, 0, 73, 70, 72, 71, 69, + 68, 74, 67, 9, 58, 59, 0, 50, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, + 58, 17, 58, 11, 0, 9, 30, 21, 52, 9, + 16, 18, 13, 37, 0, 0, 0, 63, 62, 58, + 0, 0, 56, 58, 51, 40, 45, 46, 41, 42, + 39, 43, 44, 0, 47, 48, 49, 10, 9, 0, + 0, 0, 52, 0, 58, 15, 58, 19, 58, 58, + 75, 31, 26, 0, 24, 8, 25, 0, 23, 53, + 27, 0, 29, 0, 65, 64, 0, 9, 15, 9, + 12, 20, 32, 0, 28, 54, 0, 22, 33 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 15, 39, 40, 41, 84, 125, 17, 18, 146, + 156, 51, 30, 121, 122, 22, 23, 24, 31, 20, + 54, 21, 62, 100 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -48 +static const yytype_int16 yypact[] = +{ + 170, -48, -48, -48, -12, 7, -48, -17, -48, -3, + -48, -48, 7, 170, 1, 22, -48, -9, 170, 19, + -2, 79, -6, 29, -3, -48, 2, 7, 7, -48, + 138, 20, 44, 45, 18, 196, 51, 26, 151, 24, + -48, -48, 62, -48, 27, -48, -48, -48, -48, 61, + -48, -48, -3, -48, 67, -48, -48, -48, -48, -48, + -48, 58, -48, 170, -48, -48, 50, -48, 52, 7, + 7, 7, 7, 7, 7, 7, 7, 170, 7, 7, + -48, -48, -48, -48, 70, 170, -48, -48, 87, 170, + -48, -48, 94, -48, 17, 99, -20, -48, -48, -48, + 69, 71, -48, -48, -48, 91, 156, 156, -48, -48, + 91, -48, -48, 77, 78, 78, -48, -48, 170, 81, + 66, 82, 87, 95, -48, 196, -48, -48, -48, -48, + -48, -48, -48, 97, 112, -48, -48, 135, -48, -48, + -48, 150, -48, 148, -48, -48, 98, 170, 196, 170, + -48, -48, -48, 115, -48, -48, 116, -48, -48 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -48, -48, -47, 5, 140, -48, -48, 171, -27, -48, + -48, 80, 60, 54, -48, -13, -4, -48, 0, -48, + -48, -48, -48, -48 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -59 +static const yytype_int16 yytable[] = +{ + 19, 42, 32, 33, 34, 16, 36, 37, 86, 35, + 27, -58, -58, 19, 28, 1, 101, 128, 19, -58, + 25, -14, 43, 45, 65, 1, 46, 129, 46, 44, + 113, 47, 52, 47, 48, 19, 48, 63, 119, 64, + 97, 49, 123, 49, 29, 53, 94, 95, -58, 66, + 80, 102, 96, 50, 29, 81, 69, 70, 71, 82, + 104, 85, 87, 19, 72, 73, 74, 75, 76, 88, + 90, 135, 38, 91, 92, 93, 116, 19, 117, 99, + 103, 118, 69, 70, 71, 19, 98, 67, 68, 19, + 72, 73, 74, 75, 76, 130, 78, 79, 142, 133, + 153, 124, 155, 72, 73, 55, 75, 76, 56, 120, + 127, 141, 131, 137, 57, 58, 145, 132, 19, 59, + 60, 154, 143, 134, 144, 19, 61, 136, 138, 105, + 106, 107, 108, 109, 110, 111, 112, 148, 114, 115, + 147, 140, 69, 70, 71, 149, 152, 19, 19, 19, + 72, 73, 74, 75, 76, 69, 70, 71, 150, 151, + 69, 157, 158, 72, 73, 74, 75, 76, 72, 73, + 74, 75, 76, 83, 126, 26, 139, 0, 0, 0, + 0, 77, 78, 79, 0, 0, 0, 0, 1, 0, + 2, 0, 0, 3, 89, 78, 79, 4, 5, 0, + 0, 6, 7, 8, 9, 0, 0, 10, -15, 11, + 0, 0, 12, 13, 1, 0, 2, 14, 0, 3, + 0, 0, 0, 4, 5, 0, 0, 6, 25, 8, + 9, 0, 0, 10, 0, 11, 0, 0, 12, 13, + 0, 0, 0, 14 +}; + +static const yytype_int16 yycheck[] = +{ + 0, 14, 6, 7, 8, 0, 10, 11, 35, 9, + 3, 10, 11, 13, 7, 18, 63, 37, 18, 18, + 32, 38, 0, 18, 24, 18, 9, 47, 9, 38, + 77, 14, 34, 14, 17, 35, 17, 43, 85, 10, + 53, 24, 89, 24, 47, 47, 50, 51, 47, 47, + 30, 64, 52, 34, 47, 11, 4, 5, 6, 14, + 8, 43, 11, 63, 12, 13, 14, 15, 16, 43, + 46, 118, 12, 11, 47, 14, 80, 77, 82, 21, + 30, 11, 4, 5, 6, 85, 19, 27, 28, 89, + 12, 13, 14, 15, 16, 99, 44, 45, 125, 103, + 147, 7, 149, 12, 13, 26, 15, 16, 29, 22, + 11, 124, 43, 47, 35, 36, 129, 46, 118, 40, + 41, 148, 126, 46, 128, 125, 47, 46, 46, 69, + 70, 71, 72, 73, 74, 75, 76, 25, 78, 79, + 43, 46, 4, 5, 6, 10, 48, 147, 148, 149, + 12, 13, 14, 15, 16, 4, 5, 6, 8, 11, + 4, 46, 46, 12, 13, 14, 15, 16, 12, 13, + 14, 15, 16, 33, 94, 4, 122, -1, -1, -1, + -1, 43, 44, 45, -1, -1, -1, -1, 18, -1, + 20, -1, -1, 23, 43, 44, 45, 27, 28, -1, + -1, 31, 32, 33, 34, -1, -1, 37, 38, 39, + -1, -1, 42, 43, 18, -1, 20, 47, -1, 23, + -1, -1, -1, 27, 28, -1, -1, 31, 32, 33, + 34, -1, -1, 37, -1, 39, -1, -1, 42, 43, + -1, -1, -1, 47 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 18, 20, 23, 27, 28, 31, 32, 33, 34, + 37, 39, 42, 43, 47, 50, 52, 56, 57, 67, + 68, 70, 64, 65, 66, 32, 56, 3, 7, 47, + 61, 67, 65, 65, 65, 67, 65, 65, 61, 51, + 52, 53, 64, 0, 38, 52, 9, 14, 17, 24, + 34, 60, 34, 47, 69, 26, 29, 35, 36, 40, + 41, 47, 71, 43, 10, 67, 47, 61, 61, 4, + 5, 6, 12, 13, 14, 15, 16, 43, 44, 45, + 30, 11, 14, 53, 54, 43, 57, 11, 43, 43, + 46, 11, 47, 14, 65, 65, 67, 64, 19, 21, + 72, 51, 64, 30, 8, 61, 61, 61, 61, 61, + 61, 61, 61, 51, 61, 61, 65, 65, 11, 51, + 22, 62, 63, 51, 7, 55, 60, 11, 37, 47, + 65, 43, 46, 65, 46, 51, 46, 47, 46, 62, + 46, 64, 57, 65, 65, 64, 58, 43, 25, 10, + 8, 11, 48, 51, 57, 51, 59, 46, 46 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ + +#define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 3: + +/* Line 1464 of yacc.c */ +#line 142 "jamgram.y" + { parse_save( (yyvsp[(1) - (1)]).parse ); } + break; + + case 4: + +/* Line 1464 of yacc.c */ +#line 153 "jamgram.y" + { (yyval).parse = (yyvsp[(1) - (1)]).parse; } + break; + + case 5: + +/* Line 1464 of yacc.c */ +#line 155 "jamgram.y" + { (yyval).parse = (yyvsp[(1) - (1)]).parse; } + break; + + case 6: + +/* Line 1464 of yacc.c */ +#line 159 "jamgram.y" + { (yyval).parse = (yyvsp[(1) - (1)]).parse; } + break; + + case 7: + +/* Line 1464 of yacc.c */ +#line 161 "jamgram.y" + { (yyval).parse = prules( (yyvsp[(1) - (2)]).parse, (yyvsp[(2) - (2)]).parse ); } + break; + + case 8: + +/* Line 1464 of yacc.c */ +#line 163 "jamgram.y" + { (yyval).parse = plocal( (yyvsp[(2) - (5)]).parse, (yyvsp[(3) - (5)]).parse, (yyvsp[(5) - (5)]).parse ); } + break; + + case 9: + +/* Line 1464 of yacc.c */ +#line 167 "jamgram.y" + { (yyval).parse = pnull(); } + break; + + case 10: + +/* Line 1464 of yacc.c */ +#line 171 "jamgram.y" + { (yyval).parse = (yyvsp[(2) - (2)]).parse; (yyval).number = ASSIGN_SET; } + break; + + case 11: + +/* Line 1464 of yacc.c */ +#line 173 "jamgram.y" + { (yyval).parse = (yyvsp[(1) - (1)]).parse; (yyval).number = ASSIGN_APPEND; } + break; + + case 12: + +/* Line 1464 of yacc.c */ +#line 177 "jamgram.y" + { (yyval).parse = (yyvsp[(2) - (3)]).parse; } + break; + + case 13: + +/* Line 1464 of yacc.c */ +#line 179 "jamgram.y" + { (yyval).parse = P0; } + break; + + case 14: + +/* Line 1464 of yacc.c */ +#line 183 "jamgram.y" + { (yyval).number = 1; } + break; + + case 15: + +/* Line 1464 of yacc.c */ +#line 185 "jamgram.y" + { (yyval).number = 0; } + break; + + case 16: + +/* Line 1464 of yacc.c */ +#line 189 "jamgram.y" + { (yyval).parse = (yyvsp[(2) - (3)]).parse; } + break; + + case 17: + +/* Line 1464 of yacc.c */ +#line 191 "jamgram.y" + { (yyval).parse = pincl( (yyvsp[(2) - (3)]).parse ); } + break; + + case 18: + +/* Line 1464 of yacc.c */ +#line 193 "jamgram.y" + { (yyval).parse = prule( (yyvsp[(1) - (3)]).string, (yyvsp[(2) - (3)]).parse ); } + break; + + case 19: + +/* Line 1464 of yacc.c */ +#line 195 "jamgram.y" + { (yyval).parse = pset( (yyvsp[(1) - (4)]).parse, (yyvsp[(3) - (4)]).parse, (yyvsp[(2) - (4)]).number ); } + break; + + case 20: + +/* Line 1464 of yacc.c */ +#line 197 "jamgram.y" + { (yyval).parse = pset1( (yyvsp[(1) - (6)]).parse, (yyvsp[(3) - (6)]).parse, (yyvsp[(5) - (6)]).parse, (yyvsp[(4) - (6)]).number ); } + break; + + case 21: + +/* Line 1464 of yacc.c */ +#line 199 "jamgram.y" + { (yyval).parse = (yyvsp[(2) - (3)]).parse; } + break; + + case 22: + +/* Line 1464 of yacc.c */ +#line 201 "jamgram.y" + { (yyval).parse = pfor( (yyvsp[(3) - (8)]).string, (yyvsp[(5) - (8)]).parse, (yyvsp[(7) - (8)]).parse, (yyvsp[(2) - (8)]).number ); } + break; + + case 23: + +/* Line 1464 of yacc.c */ +#line 203 "jamgram.y" + { (yyval).parse = pswitch( (yyvsp[(2) - (5)]).parse, (yyvsp[(4) - (5)]).parse ); } + break; + + case 24: + +/* Line 1464 of yacc.c */ +#line 205 "jamgram.y" + { (yyval).parse = pif( (yyvsp[(2) - (5)]).parse, (yyvsp[(4) - (5)]).parse, pnull() ); } + break; + + case 25: + +/* Line 1464 of yacc.c */ +#line 207 "jamgram.y" + { (yyval).parse = pmodule( (yyvsp[(2) - (5)]).parse, (yyvsp[(4) - (5)]).parse ); } + break; + + case 26: + +/* Line 1464 of yacc.c */ +#line 209 "jamgram.y" + { (yyval).parse = pclass( (yyvsp[(2) - (5)]).parse, (yyvsp[(4) - (5)]).parse ); } + break; + + case 27: + +/* Line 1464 of yacc.c */ +#line 211 "jamgram.y" + { (yyval).parse = pwhile( (yyvsp[(2) - (5)]).parse, (yyvsp[(4) - (5)]).parse ); } + break; + + case 28: + +/* Line 1464 of yacc.c */ +#line 213 "jamgram.y" + { (yyval).parse = pif( (yyvsp[(2) - (7)]).parse, (yyvsp[(4) - (7)]).parse, (yyvsp[(7) - (7)]).parse ); } + break; + + case 29: + +/* Line 1464 of yacc.c */ +#line 215 "jamgram.y" + { (yyval).parse = psetc( (yyvsp[(3) - (5)]).string, (yyvsp[(5) - (5)]).parse, (yyvsp[(4) - (5)]).parse, (yyvsp[(1) - (5)]).number ); } + break; + + case 30: + +/* Line 1464 of yacc.c */ +#line 217 "jamgram.y" + { (yyval).parse = pon( (yyvsp[(2) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 31: + +/* Line 1464 of yacc.c */ +#line 219 "jamgram.y" + { yymode( SCAN_STRING ); } + break; + + case 32: + +/* Line 1464 of yacc.c */ +#line 221 "jamgram.y" + { yymode( SCAN_NORMAL ); } + break; + + case 33: + +/* Line 1464 of yacc.c */ +#line 223 "jamgram.y" + { (yyval).parse = psete( (yyvsp[(3) - (9)]).string,(yyvsp[(4) - (9)]).parse,(yyvsp[(7) - (9)]).string,(yyvsp[(2) - (9)]).number ); } + break; + + case 34: + +/* Line 1464 of yacc.c */ +#line 231 "jamgram.y" + { (yyval).number = ASSIGN_SET; } + break; + + case 35: + +/* Line 1464 of yacc.c */ +#line 233 "jamgram.y" + { (yyval).number = ASSIGN_APPEND; } + break; + + case 36: + +/* Line 1464 of yacc.c */ +#line 235 "jamgram.y" + { (yyval).number = ASSIGN_DEFAULT; } + break; + + case 37: + +/* Line 1464 of yacc.c */ +#line 237 "jamgram.y" + { (yyval).number = ASSIGN_DEFAULT; } + break; + + case 38: + +/* Line 1464 of yacc.c */ +#line 244 "jamgram.y" + { (yyval).parse = peval( EXPR_EXISTS, (yyvsp[(1) - (1)]).parse, pnull() ); } + break; + + case 39: + +/* Line 1464 of yacc.c */ +#line 246 "jamgram.y" + { (yyval).parse = peval( EXPR_EQUALS, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 40: + +/* Line 1464 of yacc.c */ +#line 248 "jamgram.y" + { (yyval).parse = peval( EXPR_NOTEQ, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 41: + +/* Line 1464 of yacc.c */ +#line 250 "jamgram.y" + { (yyval).parse = peval( EXPR_LESS, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 42: + +/* Line 1464 of yacc.c */ +#line 252 "jamgram.y" + { (yyval).parse = peval( EXPR_LESSEQ, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 43: + +/* Line 1464 of yacc.c */ +#line 254 "jamgram.y" + { (yyval).parse = peval( EXPR_MORE, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 44: + +/* Line 1464 of yacc.c */ +#line 256 "jamgram.y" + { (yyval).parse = peval( EXPR_MOREEQ, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 45: + +/* Line 1464 of yacc.c */ +#line 258 "jamgram.y" + { (yyval).parse = peval( EXPR_AND, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 46: + +/* Line 1464 of yacc.c */ +#line 260 "jamgram.y" + { (yyval).parse = peval( EXPR_AND, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 47: + +/* Line 1464 of yacc.c */ +#line 262 "jamgram.y" + { (yyval).parse = peval( EXPR_OR, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 48: + +/* Line 1464 of yacc.c */ +#line 264 "jamgram.y" + { (yyval).parse = peval( EXPR_OR, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 49: + +/* Line 1464 of yacc.c */ +#line 266 "jamgram.y" + { (yyval).parse = peval( EXPR_IN, (yyvsp[(1) - (3)]).parse, (yyvsp[(3) - (3)]).parse ); } + break; + + case 50: + +/* Line 1464 of yacc.c */ +#line 268 "jamgram.y" + { (yyval).parse = peval( EXPR_NOT, (yyvsp[(2) - (2)]).parse, pnull() ); } + break; + + case 51: + +/* Line 1464 of yacc.c */ +#line 270 "jamgram.y" + { (yyval).parse = (yyvsp[(2) - (3)]).parse; } + break; + + case 52: + +/* Line 1464 of yacc.c */ +#line 281 "jamgram.y" + { (yyval).parse = P0; } + break; + + case 53: + +/* Line 1464 of yacc.c */ +#line 283 "jamgram.y" + { (yyval).parse = pnode( (yyvsp[(1) - (2)]).parse, (yyvsp[(2) - (2)]).parse ); } + break; + + case 54: + +/* Line 1464 of yacc.c */ +#line 287 "jamgram.y" + { (yyval).parse = psnode( (yyvsp[(2) - (4)]).string, (yyvsp[(4) - (4)]).parse ); } + break; + + case 55: + +/* Line 1464 of yacc.c */ +#line 296 "jamgram.y" + { (yyval).parse = pnode( P0, (yyvsp[(1) - (1)]).parse ); } + break; + + case 56: + +/* Line 1464 of yacc.c */ +#line 298 "jamgram.y" + { (yyval).parse = pnode( (yyvsp[(3) - (3)]).parse, (yyvsp[(1) - (3)]).parse ); } + break; + + case 57: + +/* Line 1464 of yacc.c */ +#line 308 "jamgram.y" + { (yyval).parse = (yyvsp[(1) - (1)]).parse; yymode( SCAN_NORMAL ); } + break; + + case 58: + +/* Line 1464 of yacc.c */ +#line 312 "jamgram.y" + { (yyval).parse = pnull(); yymode( SCAN_PUNCT ); } + break; + + case 59: + +/* Line 1464 of yacc.c */ +#line 314 "jamgram.y" + { (yyval).parse = pappend( (yyvsp[(1) - (2)]).parse, (yyvsp[(2) - (2)]).parse ); } + break; + + case 60: + +/* Line 1464 of yacc.c */ +#line 318 "jamgram.y" + { (yyval).parse = plist( (yyvsp[(1) - (1)]).string ); } + break; + + case 61: + +/* Line 1464 of yacc.c */ +#line 319 "jamgram.y" + { yymode( SCAN_NORMAL ); } + break; + + case 62: + +/* Line 1464 of yacc.c */ +#line 320 "jamgram.y" + { (yyval).parse = (yyvsp[(3) - (4)]).parse; } + break; + + case 63: + +/* Line 1464 of yacc.c */ +#line 329 "jamgram.y" + { (yyval).parse = prule( (yyvsp[(1) - (2)]).string, (yyvsp[(2) - (2)]).parse ); } + break; + + case 64: + +/* Line 1464 of yacc.c */ +#line 331 "jamgram.y" + { (yyval).parse = pon( (yyvsp[(2) - (4)]).parse, prule( (yyvsp[(3) - (4)]).string, (yyvsp[(4) - (4)]).parse ) ); } + break; + + case 65: + +/* Line 1464 of yacc.c */ +#line 333 "jamgram.y" + { (yyval).parse = pon( (yyvsp[(2) - (4)]).parse, (yyvsp[(4) - (4)]).parse ); } + break; + + case 66: + +/* Line 1464 of yacc.c */ +#line 343 "jamgram.y" + { (yyval).number = 0; } + break; + + case 67: + +/* Line 1464 of yacc.c */ +#line 345 "jamgram.y" + { (yyval).number = (yyvsp[(1) - (2)]).number | (yyvsp[(2) - (2)]).number; } + break; + + case 68: + +/* Line 1464 of yacc.c */ +#line 349 "jamgram.y" + { (yyval).number = EXEC_UPDATED; } + break; + + case 69: + +/* Line 1464 of yacc.c */ +#line 351 "jamgram.y" + { (yyval).number = EXEC_TOGETHER; } + break; + + case 70: + +/* Line 1464 of yacc.c */ +#line 353 "jamgram.y" + { (yyval).number = EXEC_IGNORE; } + break; + + case 71: + +/* Line 1464 of yacc.c */ +#line 355 "jamgram.y" + { (yyval).number = EXEC_QUIETLY; } + break; + + case 72: + +/* Line 1464 of yacc.c */ +#line 357 "jamgram.y" + { (yyval).number = EXEC_PIECEMEAL; } + break; + + case 73: + +/* Line 1464 of yacc.c */ +#line 359 "jamgram.y" + { (yyval).number = EXEC_EXISTING; } + break; + + case 74: + +/* Line 1464 of yacc.c */ +#line 368 "jamgram.y" + { (yyval).parse = pnull(); } + break; + + case 75: + +/* Line 1464 of yacc.c */ +#line 370 "jamgram.y" + { (yyval).parse = (yyvsp[(2) - (2)]).parse; } + break; + + + +/* Line 1464 of yacc.c */ +#line 2118 "y.tab.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + diff --git a/mosesdecoder/jam-files/engine/jamgram.h b/mosesdecoder/jam-files/engine/jamgram.h new file mode 100644 index 0000000000000000000000000000000000000000..97f117535d46b50b7ba3b6084f4950233c162b11 --- /dev/null +++ b/mosesdecoder/jam-files/engine/jamgram.h @@ -0,0 +1,149 @@ +/* A Bison parser, made by GNU Bison 2.4.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2009, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + _BANG_t = 258, + _BANG_EQUALS_t = 259, + _AMPER_t = 260, + _AMPERAMPER_t = 261, + _LPAREN_t = 262, + _RPAREN_t = 263, + _PLUS_EQUALS_t = 264, + _COLON_t = 265, + _SEMIC_t = 266, + _LANGLE_t = 267, + _LANGLE_EQUALS_t = 268, + _EQUALS_t = 269, + _RANGLE_t = 270, + _RANGLE_EQUALS_t = 271, + _QUESTION_EQUALS_t = 272, + _LBRACKET_t = 273, + _RBRACKET_t = 274, + ACTIONS_t = 275, + BIND_t = 276, + CASE_t = 277, + CLASS_t = 278, + DEFAULT_t = 279, + ELSE_t = 280, + EXISTING_t = 281, + FOR_t = 282, + IF_t = 283, + IGNORE_t = 284, + IN_t = 285, + INCLUDE_t = 286, + LOCAL_t = 287, + MODULE_t = 288, + ON_t = 289, + PIECEMEAL_t = 290, + QUIETLY_t = 291, + RETURN_t = 292, + RULE_t = 293, + SWITCH_t = 294, + TOGETHER_t = 295, + UPDATED_t = 296, + WHILE_t = 297, + _LBRACE_t = 298, + _BAR_t = 299, + _BARBAR_t = 300, + _RBRACE_t = 301, + ARG = 302, + STRING = 303 + }; +#endif +/* Tokens. */ +#define _BANG_t 258 +#define _BANG_EQUALS_t 259 +#define _AMPER_t 260 +#define _AMPERAMPER_t 261 +#define _LPAREN_t 262 +#define _RPAREN_t 263 +#define _PLUS_EQUALS_t 264 +#define _COLON_t 265 +#define _SEMIC_t 266 +#define _LANGLE_t 267 +#define _LANGLE_EQUALS_t 268 +#define _EQUALS_t 269 +#define _RANGLE_t 270 +#define _RANGLE_EQUALS_t 271 +#define _QUESTION_EQUALS_t 272 +#define _LBRACKET_t 273 +#define _RBRACKET_t 274 +#define ACTIONS_t 275 +#define BIND_t 276 +#define CASE_t 277 +#define CLASS_t 278 +#define DEFAULT_t 279 +#define ELSE_t 280 +#define EXISTING_t 281 +#define FOR_t 282 +#define IF_t 283 +#define IGNORE_t 284 +#define IN_t 285 +#define INCLUDE_t 286 +#define LOCAL_t 287 +#define MODULE_t 288 +#define ON_t 289 +#define PIECEMEAL_t 290 +#define QUIETLY_t 291 +#define RETURN_t 292 +#define RULE_t 293 +#define SWITCH_t 294 +#define TOGETHER_t 295 +#define UPDATED_t 296 +#define WHILE_t 297 +#define _LBRACE_t 298 +#define _BAR_t 299 +#define _BARBAR_t 300 +#define _RBRACE_t 301 +#define ARG 302 +#define STRING 303 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + +extern YYSTYPE yylval; + + diff --git a/mosesdecoder/jam-files/engine/jamgramtab.h b/mosesdecoder/jam-files/engine/jamgramtab.h new file mode 100644 index 0000000000000000000000000000000000000000..a0fd43f6aa5c9a0db86e262f760707ddd7d51165 --- /dev/null +++ b/mosesdecoder/jam-files/engine/jamgramtab.h @@ -0,0 +1,44 @@ + { "!", _BANG_t }, + { "!=", _BANG_EQUALS_t }, + { "&", _AMPER_t }, + { "&&", _AMPERAMPER_t }, + { "(", _LPAREN_t }, + { ")", _RPAREN_t }, + { "+=", _PLUS_EQUALS_t }, + { ":", _COLON_t }, + { ";", _SEMIC_t }, + { "<", _LANGLE_t }, + { "<=", _LANGLE_EQUALS_t }, + { "=", _EQUALS_t }, + { ">", _RANGLE_t }, + { ">=", _RANGLE_EQUALS_t }, + { "?=", _QUESTION_EQUALS_t }, + { "[", _LBRACKET_t }, + { "]", _RBRACKET_t }, + { "actions", ACTIONS_t }, + { "bind", BIND_t }, + { "case", CASE_t }, + { "class", CLASS_t }, + { "default", DEFAULT_t }, + { "else", ELSE_t }, + { "existing", EXISTING_t }, + { "for", FOR_t }, + { "if", IF_t }, + { "ignore", IGNORE_t }, + { "in", IN_t }, + { "include", INCLUDE_t }, + { "local", LOCAL_t }, + { "module", MODULE_t }, + { "on", ON_t }, + { "piecemeal", PIECEMEAL_t }, + { "quietly", QUIETLY_t }, + { "return", RETURN_t }, + { "rule", RULE_t }, + { "switch", SWITCH_t }, + { "together", TOGETHER_t }, + { "updated", UPDATED_t }, + { "while", WHILE_t }, + { "{", _LBRACE_t }, + { "|", _BAR_t }, + { "||", _BARBAR_t }, + { "}", _RBRACE_t }, diff --git a/mosesdecoder/jam-files/engine/lists.h b/mosesdecoder/jam-files/engine/lists.h new file mode 100644 index 0000000000000000000000000000000000000000..3dd8fe873cb4a2c76fa7cd19f687c0f70ec0afbf --- /dev/null +++ b/mosesdecoder/jam-files/engine/lists.h @@ -0,0 +1,113 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* This file is ALSO: + * Copyright 2001-2004 David Abrahams. + * 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) + */ + +/* + * lists.h - the LIST structure and routines to manipulate them + * + * The whole of jam relies on lists of objects as a datatype. This module, in + * conjunction with object.c, handles these relatively efficiently. + * + * Structures defined: + * + * LIST - list of OBJECTs + * LOL - list of LISTs + * + * External routines: + * + * list_append() - append a list onto another one, returning total + * list_new() - tack an object onto the end of a list of objects + * list_copy() - copy a whole list of objects + * list_sublist() - copy a subset of a list of objects + * list_free() - free a list of objects + * list_print() - print a list of objects to stdout + * list_length() - return the number of items in the list + * + * lol_init() - initialize a LOL (list of lists) + * lol_add() - append a LIST onto an LOL + * lol_free() - free the LOL and its LISTs + * lol_get() - return one of the LISTs in the LOL + * lol_print() - debug print LISTS separated by ":" + */ + +#ifndef LISTS_DWA20011022_H +#define LISTS_DWA20011022_H + +#include "object.h" + +#ifdef HAVE_PYTHON +# include +#endif + +/* + * LIST - list of strings + */ + +typedef struct _list { + union { + int size; + struct _list * next; + OBJECT * align; + } impl; +} LIST; + +typedef OBJECT * * LISTITER; + +/* + * LOL - list of LISTs + */ + +#define LOL_MAX 19 +typedef struct _lol { + int count; + LIST * list[ LOL_MAX ]; +} LOL; + +LIST * list_new( OBJECT * value ); +LIST * list_append( LIST * destination, LIST * source ); +LIST * list_copy( LIST * ); +LIST * list_copy_range( LIST * destination, LISTITER first, LISTITER last ); +void list_free( LIST * head ); +LIST * list_push_back( LIST * head, OBJECT * value ); +void list_print( LIST * ); +int list_length( LIST * ); +LIST * list_sublist( LIST *, int start, int count ); +LIST * list_pop_front( LIST * ); +LIST * list_sort( LIST * ); +LIST * list_unique( LIST * sorted_list ); +int list_in( LIST *, OBJECT * value ); +LIST * list_reverse( LIST * ); +int list_cmp( LIST * lhs, LIST * rhs ); +int list_is_sublist( LIST * sub, LIST * l ); +void list_done(); + +LISTITER list_begin( LIST * ); +LISTITER list_end( LIST * ); +#define list_next( it ) ((it) + 1) +#define list_item( it ) (*(it)) +#define list_empty( l ) ((l) == L0) +#define list_front( l ) list_item( list_begin( l ) ) + +#define L0 ((LIST *)0) + +void lol_add( LOL *, LIST * ); +void lol_init( LOL * ); +void lol_free( LOL * ); +LIST * lol_get( LOL *, int i ); +void lol_print( LOL * ); +void lol_build( LOL *, char const * * elements ); + +#ifdef HAVE_PYTHON +PyObject * list_to_python( LIST * ); +LIST * list_from_python( PyObject * ); +#endif + +#endif diff --git a/mosesdecoder/jam-files/engine/make.h b/mosesdecoder/jam-files/engine/make.h new file mode 100644 index 0000000000000000000000000000000000000000..2c3ba16789f139db1c92fd99f35816b15ccef1c3 --- /dev/null +++ b/mosesdecoder/jam-files/engine/make.h @@ -0,0 +1,44 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* + * make.h - bring a target up to date, once rules are in place + */ + +#ifndef MAKE_SW20111118_H +#define MAKE_SW20111118_H + +#include "lists.h" +#include "object.h" +#include "rules.h" + +int make( LIST * targets, int anyhow ); +int make1( LIST * t ); + +typedef struct { + int temp; + int updating; + int cantfind; + int cantmake; + int targets; + int made; +} COUNTS ; + + +void make0( TARGET * t, TARGET * p, int depth, COUNTS * counts, int anyhow, + TARGET * rescanning ); + + +/* Specifies that the target should be updated. */ +void mark_target_for_updating( OBJECT * target ); + +/* Returns targets previously passed to mark_target_for_updating(). */ +LIST * targets_to_update(); + +/* Clears/unmarks all targets currently marked for update. */ +void clear_targets_to_update(); + +#endif diff --git a/mosesdecoder/jam-files/engine/md5.c b/mosesdecoder/jam-files/engine/md5.c new file mode 100644 index 0000000000000000000000000000000000000000..c35d96c5ef54848f670132e6660c0f9b58e291a2 --- /dev/null +++ b/mosesdecoder/jam-files/engine/md5.c @@ -0,0 +1,381 @@ +/* + Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + L. Peter Deutsch + ghost@aladdin.com + + */ +/* $Id: md5.c,v 1.6 2002/04/13 19:20:28 lpd Exp $ */ +/* + Independent implementation of MD5 (RFC 1321). + + This code implements the MD5 Algorithm defined in RFC 1321, whose + text is available at + http://www.ietf.org/rfc/rfc1321.txt + The code is derived from the text of the RFC, including the test suite + (section A.5) but excluding the rest of Appendix A. It does not include + any code or documentation that is identified in the RFC as being + copyrighted. + + The original and principal author of md5.c is L. Peter Deutsch + . Other authors are noted in the change history + that follows (in reverse chronological order): + + 2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order + either statically or dynamically; added missing #include + in library. + 2002-03-11 lpd Corrected argument list for main(), and added int return + type, in test program and T value program. + 2002-02-21 lpd Added missing #include in test program. + 2000-07-03 lpd Patched to eliminate warnings about "constant is + unsigned in ANSI C, signed in traditional"; made test program + self-checking. + 1999-11-04 lpd Edited comments slightly for automatic TOC extraction. + 1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5). + 1999-05-03 lpd Original version. + */ + +#include "md5.h" +#include + +#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ +#ifdef ARCH_IS_BIG_ENDIAN +# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1) +#else +# define BYTE_ORDER 0 +#endif + +#define T_MASK ((md5_word_t)~0) +#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) +#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) +#define T3 0x242070db +#define T4 /* 0xc1bdceee */ (T_MASK ^ 0x3e423111) +#define T5 /* 0xf57c0faf */ (T_MASK ^ 0x0a83f050) +#define T6 0x4787c62a +#define T7 /* 0xa8304613 */ (T_MASK ^ 0x57cfb9ec) +#define T8 /* 0xfd469501 */ (T_MASK ^ 0x02b96afe) +#define T9 0x698098d8 +#define T10 /* 0x8b44f7af */ (T_MASK ^ 0x74bb0850) +#define T11 /* 0xffff5bb1 */ (T_MASK ^ 0x0000a44e) +#define T12 /* 0x895cd7be */ (T_MASK ^ 0x76a32841) +#define T13 0x6b901122 +#define T14 /* 0xfd987193 */ (T_MASK ^ 0x02678e6c) +#define T15 /* 0xa679438e */ (T_MASK ^ 0x5986bc71) +#define T16 0x49b40821 +#define T17 /* 0xf61e2562 */ (T_MASK ^ 0x09e1da9d) +#define T18 /* 0xc040b340 */ (T_MASK ^ 0x3fbf4cbf) +#define T19 0x265e5a51 +#define T20 /* 0xe9b6c7aa */ (T_MASK ^ 0x16493855) +#define T21 /* 0xd62f105d */ (T_MASK ^ 0x29d0efa2) +#define T22 0x02441453 +#define T23 /* 0xd8a1e681 */ (T_MASK ^ 0x275e197e) +#define T24 /* 0xe7d3fbc8 */ (T_MASK ^ 0x182c0437) +#define T25 0x21e1cde6 +#define T26 /* 0xc33707d6 */ (T_MASK ^ 0x3cc8f829) +#define T27 /* 0xf4d50d87 */ (T_MASK ^ 0x0b2af278) +#define T28 0x455a14ed +#define T29 /* 0xa9e3e905 */ (T_MASK ^ 0x561c16fa) +#define T30 /* 0xfcefa3f8 */ (T_MASK ^ 0x03105c07) +#define T31 0x676f02d9 +#define T32 /* 0x8d2a4c8a */ (T_MASK ^ 0x72d5b375) +#define T33 /* 0xfffa3942 */ (T_MASK ^ 0x0005c6bd) +#define T34 /* 0x8771f681 */ (T_MASK ^ 0x788e097e) +#define T35 0x6d9d6122 +#define T36 /* 0xfde5380c */ (T_MASK ^ 0x021ac7f3) +#define T37 /* 0xa4beea44 */ (T_MASK ^ 0x5b4115bb) +#define T38 0x4bdecfa9 +#define T39 /* 0xf6bb4b60 */ (T_MASK ^ 0x0944b49f) +#define T40 /* 0xbebfbc70 */ (T_MASK ^ 0x4140438f) +#define T41 0x289b7ec6 +#define T42 /* 0xeaa127fa */ (T_MASK ^ 0x155ed805) +#define T43 /* 0xd4ef3085 */ (T_MASK ^ 0x2b10cf7a) +#define T44 0x04881d05 +#define T45 /* 0xd9d4d039 */ (T_MASK ^ 0x262b2fc6) +#define T46 /* 0xe6db99e5 */ (T_MASK ^ 0x1924661a) +#define T47 0x1fa27cf8 +#define T48 /* 0xc4ac5665 */ (T_MASK ^ 0x3b53a99a) +#define T49 /* 0xf4292244 */ (T_MASK ^ 0x0bd6ddbb) +#define T50 0x432aff97 +#define T51 /* 0xab9423a7 */ (T_MASK ^ 0x546bdc58) +#define T52 /* 0xfc93a039 */ (T_MASK ^ 0x036c5fc6) +#define T53 0x655b59c3 +#define T54 /* 0x8f0ccc92 */ (T_MASK ^ 0x70f3336d) +#define T55 /* 0xffeff47d */ (T_MASK ^ 0x00100b82) +#define T56 /* 0x85845dd1 */ (T_MASK ^ 0x7a7ba22e) +#define T57 0x6fa87e4f +#define T58 /* 0xfe2ce6e0 */ (T_MASK ^ 0x01d3191f) +#define T59 /* 0xa3014314 */ (T_MASK ^ 0x5cfebceb) +#define T60 0x4e0811a1 +#define T61 /* 0xf7537e82 */ (T_MASK ^ 0x08ac817d) +#define T62 /* 0xbd3af235 */ (T_MASK ^ 0x42c50dca) +#define T63 0x2ad7d2bb +#define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) + + +static void +md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) +{ + md5_word_t + a = pms->abcd[0], b = pms->abcd[1], + c = pms->abcd[2], d = pms->abcd[3]; + md5_word_t t; +#if BYTE_ORDER > 0 + /* Define storage only for big-endian CPUs. */ + md5_word_t X[16]; +#else + /* Define storage for little-endian or both types of CPUs. */ + md5_word_t xbuf[16]; + const md5_word_t *X; +#endif + + { +#if BYTE_ORDER == 0 + /* + * Determine dynamically whether this is a big-endian or + * little-endian machine, since we can use a more efficient + * algorithm on the latter. + */ + static const int w = 1; + + if (*((const md5_byte_t *)&w)) /* dynamic little-endian */ +#endif +#if BYTE_ORDER <= 0 /* little-endian */ + { + /* + * On little-endian machines, we can process properly aligned + * data without copying it. + */ + if (!((data - (const md5_byte_t *)0) & 3)) { + /* data are properly aligned */ + X = (const md5_word_t *)data; + } else { + /* not aligned */ + memcpy(xbuf, data, 64); + X = xbuf; + } + } +#endif +#if BYTE_ORDER == 0 + else /* dynamic big-endian */ +#endif +#if BYTE_ORDER >= 0 /* big-endian */ + { + /* + * On big-endian machines, we must arrange the bytes in the + * right order. + */ + const md5_byte_t *xp = data; + int i; + +# if BYTE_ORDER == 0 + X = xbuf; /* (dynamic only) */ +# else +# define xbuf X /* (static only) */ +# endif + for (i = 0; i < 16; ++i, xp += 4) + xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24); + } +#endif + } + +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n)))) + + /* Round 1. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */ +#define F(x, y, z) (((x) & (y)) | (~(x) & (z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + F(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 0, 7, T1); + SET(d, a, b, c, 1, 12, T2); + SET(c, d, a, b, 2, 17, T3); + SET(b, c, d, a, 3, 22, T4); + SET(a, b, c, d, 4, 7, T5); + SET(d, a, b, c, 5, 12, T6); + SET(c, d, a, b, 6, 17, T7); + SET(b, c, d, a, 7, 22, T8); + SET(a, b, c, d, 8, 7, T9); + SET(d, a, b, c, 9, 12, T10); + SET(c, d, a, b, 10, 17, T11); + SET(b, c, d, a, 11, 22, T12); + SET(a, b, c, d, 12, 7, T13); + SET(d, a, b, c, 13, 12, T14); + SET(c, d, a, b, 14, 17, T15); + SET(b, c, d, a, 15, 22, T16); +#undef SET + + /* Round 2. */ + /* Let [abcd k s i] denote the operation + a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */ +#define G(x, y, z) (((x) & (z)) | ((y) & ~(z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + G(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 1, 5, T17); + SET(d, a, b, c, 6, 9, T18); + SET(c, d, a, b, 11, 14, T19); + SET(b, c, d, a, 0, 20, T20); + SET(a, b, c, d, 5, 5, T21); + SET(d, a, b, c, 10, 9, T22); + SET(c, d, a, b, 15, 14, T23); + SET(b, c, d, a, 4, 20, T24); + SET(a, b, c, d, 9, 5, T25); + SET(d, a, b, c, 14, 9, T26); + SET(c, d, a, b, 3, 14, T27); + SET(b, c, d, a, 8, 20, T28); + SET(a, b, c, d, 13, 5, T29); + SET(d, a, b, c, 2, 9, T30); + SET(c, d, a, b, 7, 14, T31); + SET(b, c, d, a, 12, 20, T32); +#undef SET + + /* Round 3. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */ +#define H(x, y, z) ((x) ^ (y) ^ (z)) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + H(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 5, 4, T33); + SET(d, a, b, c, 8, 11, T34); + SET(c, d, a, b, 11, 16, T35); + SET(b, c, d, a, 14, 23, T36); + SET(a, b, c, d, 1, 4, T37); + SET(d, a, b, c, 4, 11, T38); + SET(c, d, a, b, 7, 16, T39); + SET(b, c, d, a, 10, 23, T40); + SET(a, b, c, d, 13, 4, T41); + SET(d, a, b, c, 0, 11, T42); + SET(c, d, a, b, 3, 16, T43); + SET(b, c, d, a, 6, 23, T44); + SET(a, b, c, d, 9, 4, T45); + SET(d, a, b, c, 12, 11, T46); + SET(c, d, a, b, 15, 16, T47); + SET(b, c, d, a, 2, 23, T48); +#undef SET + + /* Round 4. */ + /* Let [abcd k s t] denote the operation + a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */ +#define I(x, y, z) ((y) ^ ((x) | ~(z))) +#define SET(a, b, c, d, k, s, Ti)\ + t = a + I(b,c,d) + X[k] + Ti;\ + a = ROTATE_LEFT(t, s) + b + /* Do the following 16 operations. */ + SET(a, b, c, d, 0, 6, T49); + SET(d, a, b, c, 7, 10, T50); + SET(c, d, a, b, 14, 15, T51); + SET(b, c, d, a, 5, 21, T52); + SET(a, b, c, d, 12, 6, T53); + SET(d, a, b, c, 3, 10, T54); + SET(c, d, a, b, 10, 15, T55); + SET(b, c, d, a, 1, 21, T56); + SET(a, b, c, d, 8, 6, T57); + SET(d, a, b, c, 15, 10, T58); + SET(c, d, a, b, 6, 15, T59); + SET(b, c, d, a, 13, 21, T60); + SET(a, b, c, d, 4, 6, T61); + SET(d, a, b, c, 11, 10, T62); + SET(c, d, a, b, 2, 15, T63); + SET(b, c, d, a, 9, 21, T64); +#undef SET + + /* Then perform the following additions. (That is increment each + of the four registers by the value it had before this block + was started.) */ + pms->abcd[0] += a; + pms->abcd[1] += b; + pms->abcd[2] += c; + pms->abcd[3] += d; +} + +void +md5_init(md5_state_t *pms) +{ + pms->count[0] = pms->count[1] = 0; + pms->abcd[0] = 0x67452301; + pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476; + pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301; + pms->abcd[3] = 0x10325476; +} + +void +md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes) +{ + const md5_byte_t *p = data; + int left = nbytes; + int offset = (pms->count[0] >> 3) & 63; + md5_word_t nbits = (md5_word_t)(nbytes << 3); + + if (nbytes <= 0) + return; + + /* Update the message length. */ + pms->count[1] += nbytes >> 29; + pms->count[0] += nbits; + if (pms->count[0] < nbits) + pms->count[1]++; + + /* Process an initial partial block. */ + if (offset) { + int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); + + memcpy(pms->buf + offset, p, copy); + if (offset + copy < 64) + return; + p += copy; + left -= copy; + md5_process(pms, pms->buf); + } + + /* Process full blocks. */ + for (; left >= 64; p += 64, left -= 64) + md5_process(pms, p); + + /* Process a final partial block. */ + if (left) + memcpy(pms->buf, p, left); +} + +void +md5_finish(md5_state_t *pms, md5_byte_t digest[16]) +{ + static const md5_byte_t pad[64] = { + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + md5_byte_t data[8]; + int i; + + /* Save the length before padding. */ + for (i = 0; i < 8; ++i) + data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3)); + /* Pad to 56 bytes mod 64. */ + md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1); + /* Append the length. */ + md5_append(pms, data, 8); + for (i = 0; i < 16; ++i) + digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); +} diff --git a/mosesdecoder/jam-files/engine/mem.c b/mosesdecoder/jam-files/engine/mem.c new file mode 100644 index 0000000000000000000000000000000000000000..6a11fb38a5f8ce1f25b3ef40e8cb3dafe3f54181 --- /dev/null +++ b/mosesdecoder/jam-files/engine/mem.c @@ -0,0 +1,75 @@ +/* +Copyright Rene Rivera 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) +*/ + +#include "jam.h" + +#ifdef OPT_BOEHM_GC + + /* Compile the Boehm GC as one big chunk of code. It's much easier + this way, than trying to make radical changes to the bjam build + scripts. */ + + #define ATOMIC_UNCOLLECTABLE + #define NO_EXECUTE_PERMISSION + #define ALL_INTERIOR_POINTERS + + #define LARGE_CONFIG + /* + #define NO_SIGNALS + #define SILENT + */ + #ifndef GC_DEBUG + #define NO_DEBUGGING + #endif + + #ifdef __GLIBC__ + #define __USE_GNU + #endif + + #include "boehm_gc/reclaim.c" + #include "boehm_gc/allchblk.c" + #include "boehm_gc/misc.c" + #include "boehm_gc/alloc.c" + #include "boehm_gc/mach_dep.c" + #include "boehm_gc/os_dep.c" + #include "boehm_gc/mark_rts.c" + #include "boehm_gc/headers.c" + #include "boehm_gc/mark.c" + #include "boehm_gc/obj_map.c" + #include "boehm_gc/pcr_interface.c" + #include "boehm_gc/blacklst.c" + #include "boehm_gc/new_hblk.c" + #include "boehm_gc/real_malloc.c" + #include "boehm_gc/dyn_load.c" + #include "boehm_gc/dbg_mlc.c" + #include "boehm_gc/malloc.c" + #include "boehm_gc/stubborn.c" + #include "boehm_gc/checksums.c" + #include "boehm_gc/pthread_support.c" + #include "boehm_gc/pthread_stop_world.c" + #include "boehm_gc/darwin_stop_world.c" + #include "boehm_gc/typd_mlc.c" + #include "boehm_gc/ptr_chck.c" + #include "boehm_gc/mallocx.c" + #include "boehm_gc/gcj_mlc.c" + #include "boehm_gc/specific.c" + #include "boehm_gc/gc_dlopen.c" + #include "boehm_gc/backgraph.c" + #include "boehm_gc/win32_threads.c" + + /* Needs to be last. */ + #include "boehm_gc/finalize.c" + +#elif defined(OPT_DUMA) + + #ifdef OS_NT + #define WIN32 + #endif + #include "duma/duma.c" + #include "duma/print.c" + +#endif diff --git a/mosesdecoder/jam-files/engine/native.c b/mosesdecoder/jam-files/engine/native.c new file mode 100644 index 0000000000000000000000000000000000000000..68828aa315788501ff0b221248253334035b3371 --- /dev/null +++ b/mosesdecoder/jam-files/engine/native.c @@ -0,0 +1,34 @@ +/* Copyright 2003. Vladimir Prus + * 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) + */ + +#include "native.h" + +#include "hash.h" + +#include + + +void declare_native_rule( char const * module, char const * rule, + char const * * args, LIST * (*f)( FRAME *, int ), int version ) +{ + OBJECT * const module_obj = module ? object_new( module ) : 0 ; + module_t * m = bindmodule( module_obj ); + if ( module_obj ) + object_free( module_obj ); + if ( !m->native_rules ) + m->native_rules = hashinit( sizeof( native_rule_t ), "native rules" ); + + { + OBJECT * const name = object_new( rule ); + int found; + native_rule_t * const np = (native_rule_t *)hash_insert( + m->native_rules, name, &found ); + np->name = name; + assert( !found ); + np->procedure = function_builtin( f, 0, args ); + np->version = version; + } +} diff --git a/mosesdecoder/jam-files/engine/object.c b/mosesdecoder/jam-files/engine/object.c new file mode 100644 index 0000000000000000000000000000000000000000..ef46e4ae460fd7e55f64cb15dcd3a2e968d0222e --- /dev/null +++ b/mosesdecoder/jam-files/engine/object.c @@ -0,0 +1,394 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * Copyright 2011 Steven Watanabe + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* + * object.c - object manipulation routines + * + * External functions: + * object_new() - create an object from a string + * object_new_range() - create an object from a string of given length + * object_copy() - return a copy of an object + * object_free() - free an object + * object_str() - get the string value of an object + * object_done() - free string tables + * + * This implementation builds a hash table of all strings, so that multiple + * calls of object_new() on the same string allocate memory for the string once. + * Strings are never actually freed. + */ + +#include "jam.h" +#include "object.h" + +#include +#include +#include + + +#define OBJECT_MAGIC 0xa762e0e3u + +#ifndef object_copy + +struct hash_header +{ +#ifndef NDEBUG + unsigned int magic; +#endif + unsigned int hash; + struct hash_item * next; +}; + +#endif + +struct hash_item +{ + struct hash_header header; + char data[ 1 ]; +}; + +#define ALLOC_ALIGNMENT (sizeof(struct hash_item) - sizeof(struct hash_header)) + +typedef struct string_set +{ + unsigned int num; + unsigned int size; + struct hash_item * * data; +} string_set; + +static string_set strhash; +static int strtotal = 0; +static int strcount_in = 0; +static int strcount_out = 0; + + +/* + * Immortal string allocator implementation speeds string allocation and cuts + * down on internal fragmentation. + */ + +#define STRING_BLOCK 4096 +typedef struct strblock +{ + struct strblock * next; + char data[ STRING_BLOCK ]; +} strblock; + +static strblock * strblock_chain = 0; + +/* Storage remaining in the current strblock */ +static char * storage_start = 0; +static char * storage_finish = 0; + + +/* + * allocate() - Allocate n bytes of immortal string storage. + */ + +static char * allocate( size_t n ) +{ +#ifdef BJAM_NEWSTR_NO_ALLOCATE + return (char *)BJAM_MALLOC( n ); +#else + /* See if we can grab storage from an existing block. */ + size_t remaining = storage_finish - storage_start; + n = ( ( n + ALLOC_ALIGNMENT - 1 ) / ALLOC_ALIGNMENT ) * ALLOC_ALIGNMENT; + if ( remaining >= n ) + { + char * result = storage_start; + storage_start += n; + return result; + } + else /* Must allocate a new block. */ + { + strblock * new_block; + size_t nalloc = n; + if ( nalloc < STRING_BLOCK ) + nalloc = STRING_BLOCK; + + /* Allocate a new block and link into the chain. */ + new_block = (strblock *)BJAM_MALLOC( offsetof( strblock, data[ 0 ] ) + + nalloc * sizeof( new_block->data[ 0 ] ) ); + if ( new_block == 0 ) + return 0; + new_block->next = strblock_chain; + strblock_chain = new_block; + + /* Take future allocations out of the larger remaining space. */ + if ( remaining < nalloc - n ) + { + storage_start = new_block->data + n; + storage_finish = new_block->data + nalloc; + } + return new_block->data; + } +#endif +} + + +static unsigned int hash_keyval( char const * key, int const size ) +{ + unsigned int const magic = 2147059363; + unsigned int hash = 0; + + unsigned int i; + for ( i = 0; i < size / sizeof( unsigned int ); ++i ) + { + unsigned int val; + memcpy( &val, key, sizeof( unsigned int ) ); + hash = hash * magic + val; + key += sizeof( unsigned int ); + } + + { + unsigned int val = 0; + memcpy( &val, key, size % sizeof( unsigned int ) ); + hash = hash * magic + val; + } + + return hash + ( hash >> 17 ); +} + + +static void string_set_init( string_set * set ) +{ + set->size = 0; + set->num = 4; + set->data = (struct hash_item * *)BJAM_MALLOC( set->num * sizeof( struct hash_item * ) ); + memset( set->data, 0, set->num * sizeof( struct hash_item * ) ); +} + + +static void string_set_done( string_set * set ) +{ + BJAM_FREE( set->data ); +} + + +static void string_set_resize( string_set * set ) +{ + unsigned i; + string_set new_set; + new_set.num = set->num * 2; + new_set.size = set->size; + new_set.data = (struct hash_item * *)BJAM_MALLOC( sizeof( struct hash_item * + ) * new_set.num ); + memset( new_set.data, 0, sizeof( struct hash_item * ) * new_set.num ); + for ( i = 0; i < set->num; ++i ) + { + while ( set->data[ i ] ) + { + struct hash_item * temp = set->data[ i ]; + unsigned pos = temp->header.hash % new_set.num; + set->data[ i ] = temp->header.next; + temp->header.next = new_set.data[ pos ]; + new_set.data[ pos ] = temp; + } + } + BJAM_FREE( set->data ); + *set = new_set; +} + + +static char const * string_set_insert( string_set * set, char const * string, + int const size ) +{ + unsigned hash = hash_keyval( string, size ); + unsigned pos = hash % set->num; + + struct hash_item * result; + + for ( result = set->data[ pos ]; result; result = result->header.next ) + if ( !strncmp( result->data, string, size ) && !result->data[ size ] ) + return result->data; + + if ( set->size >= set->num ) + { + string_set_resize( set ); + pos = hash % set->num; + } + + result = (struct hash_item *)allocate( sizeof( struct hash_header ) + size + + 1 ); + result->header.hash = hash; + result->header.next = set->data[ pos ]; +#ifndef NDEBUG + result->header.magic = OBJECT_MAGIC; +#endif + memcpy( result->data, string, size ); + result->data[ size ] = '\0'; + assert( hash_keyval( result->data, size ) == result->header.hash ); + set->data[ pos ] = result; + strtotal += size + 1; + ++set->size; + + return result->data; +} + + +static struct hash_item * object_get_item( OBJECT * obj ) +{ + return (struct hash_item *)( (char *)obj - offsetof( struct hash_item, data + ) ); +} + + +static void object_validate( OBJECT * obj ) +{ + assert( obj ); + assert( object_get_item( obj )->header.magic == OBJECT_MAGIC ); +} + + +/* + * object_new_range() - create an object from a string of given length + */ + +OBJECT * object_new_range( char const * const string, int const size ) +{ + ++strcount_in; + +#ifdef BJAM_NO_MEM_CACHE + { + struct hash_item * const m = (struct hash_item *)BJAM_MALLOC( sizeof( + struct hash_header ) + size + 1 ); + strtotal += size + 1; + memcpy( m->data, string, size ); + m->data[ size ] = '\0'; + m->header.magic = OBJECT_MAGIC; + return (OBJECT *)m->data; + } +#else + if ( !strhash.data ) + string_set_init( &strhash ); + return (OBJECT *)string_set_insert( &strhash, string, size ); +#endif +} + + +/* + * object_new() - create an object from a string + */ + +OBJECT * object_new( char const * const string ) +{ + return object_new_range( string, strlen( string ) ); +} + + +#ifndef object_copy + +/* + * object_copy() - return a copy of an object + */ + +OBJECT * object_copy( OBJECT * obj ) +{ + object_validate( obj ); +#ifdef BJAM_NO_MEM_CACHE + return object_new( object_str( obj ) ); +#else + ++strcount_in; + return obj; +#endif +} + + +/* + * object_free() - free an object + */ + +void object_free( OBJECT * obj ) +{ + object_validate( obj ); +#ifdef BJAM_NO_MEM_CACHE + BJAM_FREE( object_get_item( obj ) ); +#endif + ++strcount_out; +} + + +/* + * object_str() - return the OBJECT's internal C string + */ + +char const * object_str( OBJECT * obj ) +{ + object_validate( obj ); + return (char const *)obj; +} + + +/* + * object_equal() - compare two objects + */ + +int object_equal( OBJECT * lhs, OBJECT * rhs ) +{ + object_validate( lhs ); + object_validate( rhs ); +#ifdef BJAM_NO_MEM_CACHE + return !strcmp( object_str( lhs ), object_str( rhs ) ); +#else + assert( ( lhs == rhs ) == !strcmp( object_str( lhs ), object_str( rhs ) ) ); + return lhs == rhs; +#endif +} + + +/* + * object_hash() - returns the hash value of an object + */ + +unsigned int object_hash( OBJECT * obj ) +{ + object_validate( obj ); +#ifdef BJAM_NO_MEM_CACHE + return hash_keyval( object_str( obj ), strlen( object_str( obj ) ) ); +#else + return object_get_item( obj )->header.hash; +#endif +} + +#endif + +/* + * object_done() - free string tables. + */ + +void object_done() +{ +#ifdef BJAM_NEWSTR_NO_ALLOCATE + unsigned i; + for ( i = 0; i < strhash.num; ++i ) + { + while ( strhash.data[ i ] ) + { + struct hash_item * item = strhash.data[ i ]; + strhash.data[ i ] = item->header.next; + BJAM_FREE( item ); + } + } +#else + /* Reclaim string blocks. */ + while ( strblock_chain ) + { + strblock * const n = strblock_chain->next; + BJAM_FREE( strblock_chain ); + strblock_chain = n; + } +#endif + + string_set_done( &strhash ); + + if ( DEBUG_MEM ) + { + printf( "%dK in strings\n", strtotal / 1024 ); + if ( strcount_in != strcount_out ) + printf( "--- %d strings of %d dangling\n", strcount_in - + strcount_out, strcount_in ); + } +} diff --git a/mosesdecoder/jam-files/engine/output.h b/mosesdecoder/jam-files/engine/output.h new file mode 100644 index 0000000000000000000000000000000000000000..186e867f69bc419bfba0f6ecf8ea7dd7d655ffde --- /dev/null +++ b/mosesdecoder/jam-files/engine/output.h @@ -0,0 +1,30 @@ +/* + Copyright 2007 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) +*/ + +#ifndef BJAM_OUTPUT_H +#define BJAM_OUTPUT_H + +#include "object.h" +#include "timestamp.h" + +#define EXIT_OK 0 +#define EXIT_FAIL 1 +#define EXIT_TIMEOUT 2 + +void out_action( + char const * const action, + char const * const target, + char const * const command, + char const * const out_data, + char const * const err_data, + int const exit_reason +); + +OBJECT * outf_int( int const value ); +OBJECT * outf_double( double const value ); +OBJECT * outf_time( timestamp const * const value ); + +#endif diff --git a/mosesdecoder/jam-files/engine/pathsys.c b/mosesdecoder/jam-files/engine/pathsys.c new file mode 100644 index 0000000000000000000000000000000000000000..ae4e6e052aebdd448de7e2aaa3e923674e2e554c --- /dev/null +++ b/mosesdecoder/jam-files/engine/pathsys.c @@ -0,0 +1,285 @@ +/* + * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* This file is ALSO: + * Copyright 2001-2004 David Abrahams. + * Copyright 2005 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) + */ + +/* + * pathsys.c - platform independent path manipulation support + * + * External routines: + * path_build() - build a filename given dir/base/suffix/member + * path_parent() - make a PATHNAME point to its parent dir + * path_parse() - split a file name into dir/base/suffix/member + * path_tmpdir() - returns the system dependent temporary folder path + * path_tmpfile() - returns a new temporary path + * path_tmpnam() - returns a new temporary name + * + * File_parse() and path_build() just manipulate a string and a structure; + * they do not make system calls. + */ + +#include "jam.h" +#include "pathsys.h" + +#include "filesys.h" + +#include +#include + + +/* Internal OS specific implementation details - have names ending with an + * underscore and are expected to be implemented in an OS specific pathXXX.c + * module. + */ +unsigned long path_get_process_id_( void ); +void path_get_temp_path_( string * buffer ); + + +/* + * path_parse() - split a file name into dir/base/suffix/member + */ + +void path_parse( char const * file, PATHNAME * f ) +{ + char const * p; + char const * q; + char const * end; + + memset( (char *)f, 0, sizeof( *f ) ); + + /* Look for ''. */ + + if ( ( file[ 0 ] == '<' ) && ( p = strchr( file, '>' ) ) ) + { + f->f_grist.ptr = file; + f->f_grist.len = p - file; + file = p + 1; + } + + /* Look for 'dir/'. */ + + p = strrchr( file, '/' ); + +#if PATH_DELIM == '\\' + /* On NT, look for dir\ as well */ + { + char * const p1 = strrchr( p ? p + 1 : file, '\\' ); + if ( p1 ) p = p1; + } +#endif + + if ( p ) + { + f->f_dir.ptr = file; + f->f_dir.len = p - file; + + /* Special case for / - dirname is /, not "" */ + if ( !f->f_dir.len ) + ++f->f_dir.len; + +#if PATH_DELIM == '\\' + /* Special case for D:/ - dirname is D:/, not "D:" */ + if ( f->f_dir.len == 2 && file[ 1 ] == ':' ) + ++f->f_dir.len; +#endif + + file = p + 1; + } + + end = file + strlen( file ); + + /* Look for '(member)'. */ + if ( ( p = strchr( file, '(' ) ) && ( end[ -1 ] == ')' ) ) + { + f->f_member.ptr = p + 1; + f->f_member.len = end - p - 2; + end = p; + } + + /* Look for '.suffix'. This would be memrchr(). */ + p = 0; + for ( q = file; ( q = (char *)memchr( q, '.', end - q ) ); ++q ) + p = q; + if ( p ) + { + f->f_suffix.ptr = p; + f->f_suffix.len = end - p; + end = p; + } + + /* Leaves base. */ + f->f_base.ptr = file; + f->f_base.len = end - file; +} + + +/* + * is_path_delim() - true iff c is a path delimiter + */ + +static int is_path_delim( char const c ) +{ + return c == PATH_DELIM +#if PATH_DELIM == '\\' + || c == '/' +#endif + ; +} + + +/* + * as_path_delim() - convert c to a path delimiter if it is not one already + */ + +static char as_path_delim( char const c ) +{ + return is_path_delim( c ) ? c : PATH_DELIM; +} + + +/* + * path_build() - build a filename given dir/base/suffix/member + * + * To avoid changing slash direction on NT when reconstituting paths, instead of + * unconditionally appending PATH_DELIM we check the past-the-end character of + * the previous path element. If it is a path delimiter, we append that, and + * only append PATH_DELIM as a last resort. This heuristic is based on the fact + * that PATHNAME objects are usually the result of calling path_parse, which + * leaves the original slashes in the past-the-end position. Correctness depends + * on the assumption that all strings are zero terminated, so a past-the-end + * character will always be available. + * + * As an attendant patch, we had to ensure that backslashes are used explicitly + * in 'timestamp.c'. + */ + +void path_build( PATHNAME * f, string * file ) +{ + file_build1( f, file ); + + /* Do not prepend root if it is '.' or the directory is rooted. */ + if ( f->f_root.len + && !( f->f_root.len == 1 && f->f_root.ptr[ 0 ] == '.' ) + && !( f->f_dir.len && f->f_dir.ptr[ 0 ] == '/' ) +#if PATH_DELIM == '\\' + && !( f->f_dir.len && f->f_dir.ptr[ 0 ] == '\\' ) + && !( f->f_dir.len && f->f_dir.ptr[ 1 ] == ':' ) +#endif + ) + { + string_append_range( file, f->f_root.ptr, f->f_root.ptr + f->f_root.len + ); + /* If 'root' already ends with a path delimeter, do not add another one. + */ + if ( !is_path_delim( f->f_root.ptr[ f->f_root.len - 1 ] ) ) + string_push_back( file, as_path_delim( f->f_root.ptr[ f->f_root.len + ] ) ); + } + + if ( f->f_dir.len ) + string_append_range( file, f->f_dir.ptr, f->f_dir.ptr + f->f_dir.len ); + + /* Put path separator between dir and file. */ + /* Special case for root dir: do not add another path separator. */ + if ( f->f_dir.len && ( f->f_base.len || f->f_suffix.len ) +#if PATH_DELIM == '\\' + && !( f->f_dir.len == 3 && f->f_dir.ptr[ 1 ] == ':' ) +#endif + && !( f->f_dir.len == 1 && is_path_delim( f->f_dir.ptr[ 0 ] ) ) ) + string_push_back( file, as_path_delim( f->f_dir.ptr[ f->f_dir.len ] ) ); + + if ( f->f_base.len ) + string_append_range( file, f->f_base.ptr, f->f_base.ptr + f->f_base.len + ); + + if ( f->f_suffix.len ) + string_append_range( file, f->f_suffix.ptr, f->f_suffix.ptr + + f->f_suffix.len ); + + if ( f->f_member.len ) + { + string_push_back( file, '(' ); + string_append_range( file, f->f_member.ptr, f->f_member.ptr + + f->f_member.len ); + string_push_back( file, ')' ); + } +} + + +/* + * path_parent() - make a PATHNAME point to its parent dir + */ + +void path_parent( PATHNAME * f ) +{ + f->f_base.ptr = f->f_suffix.ptr = f->f_member.ptr = ""; + f->f_base.len = f->f_suffix.len = f->f_member.len = 0; +} + + +/* + * path_tmpdir() - returns the system dependent temporary folder path + * + * Returned value is stored inside a static buffer and should not be modified. + * Returned value does *not* include a trailing path separator. + */ + +string const * path_tmpdir() +{ + static string buffer[ 1 ]; + static int have_result; + if ( !have_result ) + { + string_new( buffer ); + path_get_temp_path_( buffer ); + have_result = 1; + } + return buffer; +} + + +/* + * path_tmpnam() - returns a new temporary name + */ + +OBJECT * path_tmpnam( void ) +{ + char name_buffer[ 64 ]; + unsigned long const pid = path_get_process_id_(); + static unsigned long t; + if ( !t ) t = time( 0 ) & 0xffff; + t += 1; + sprintf( name_buffer, "jam%lx%lx.000", pid, t ); + return object_new( name_buffer ); +} + + +/* + * path_tmpfile() - returns a new temporary path + */ + +OBJECT * path_tmpfile( void ) +{ + OBJECT * result; + OBJECT * tmpnam; + + string file_path[ 1 ]; + string_copy( file_path, path_tmpdir()->value ); + string_push_back( file_path, PATH_DELIM ); + tmpnam = path_tmpnam(); + string_append( file_path, object_str( tmpnam ) ); + object_free( tmpnam ); + result = object_new( file_path->value ); + string_free( file_path ); + + return result; +} diff --git a/mosesdecoder/jam-files/engine/scan.c b/mosesdecoder/jam-files/engine/scan.c new file mode 100644 index 0000000000000000000000000000000000000000..d92fdca1459c3c409110871bb36f3f2e82a40129 --- /dev/null +++ b/mosesdecoder/jam-files/engine/scan.c @@ -0,0 +1,404 @@ +/* + * Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* + * scan.c - the jam yacc scanner + * + */ + +#include "jam.h" +#include "scan.h" + +#include "constants.h" +#include "jambase.h" +#include "jamgram.h" + + +struct keyword +{ + char * word; + int type; +} keywords[] = +{ +#include "jamgramtab.h" + { 0, 0 } +}; + +typedef struct include include; +struct include +{ + include * next; /* next serial include file */ + char * string; /* pointer into current line */ + char * * strings; /* for yyfparse() -- text to parse */ + FILE * file; /* for yyfparse() -- file being read */ + OBJECT * fname; /* for yyfparse() -- file name */ + int line; /* line counter for error messages */ + char buf[ 512 ]; /* for yyfparse() -- line buffer */ +}; + +static include * incp = 0; /* current file; head of chain */ + +static int scanmode = SCAN_NORMAL; +static int anyerrors = 0; + + +static char * symdump( YYSTYPE * ); + +#define BIGGEST_TOKEN 10240 /* no single token can be larger */ + + +/* + * Set parser mode: normal, string, or keyword. + */ + +void yymode( int n ) +{ + scanmode = n; +} + + +void yyerror( char const * s ) +{ + /* We use yylval instead of incp to access the error location information as + * the incp pointer will already be reset to 0 in case the error occurred at + * EOF. + * + * The two may differ only if ran into an unexpected EOF or we get an error + * while reading a lexical token spanning multiple lines, e.g. a multi-line + * string literal or action body, in which case yylval location information + * will hold the information about where the token started while incp will + * hold the information about where reading it broke. + */ + printf( "%s:%d: %s at %s\n", object_str( yylval.file ), yylval.line, s, + symdump( &yylval ) ); + ++anyerrors; +} + + +int yyanyerrors() +{ + return anyerrors != 0; +} + + +void yyfparse( OBJECT * s ) +{ + include * i = (include *)BJAM_MALLOC( sizeof( *i ) ); + + /* Push this onto the incp chain. */ + i->string = ""; + i->strings = 0; + i->file = 0; + i->fname = object_copy( s ); + i->line = 0; + i->next = incp; + incp = i; + + /* If the filename is "+", it means use the internal jambase. */ + if ( !strcmp( object_str( s ), "+" ) ) + i->strings = jambase; +} + + +/* + * yyline() - read new line and return first character. + * + * Fabricates a continuous stream of characters across include files, returning + * EOF at the bitter end. + */ + +int yyline() +{ + include * const i = incp; + + if ( !incp ) + return EOF; + + /* Once we start reading from the input stream, we reset the include + * insertion point so that the next include file becomes the head of the + * list. + */ + + /* If there is more data in this line, return it. */ + if ( *i->string ) + return *i->string++; + + /* If we are reading from an internal string list, go to the next string. */ + if ( i->strings ) + { + if ( *i->strings ) + { + ++i->line; + i->string = *(i->strings++); + return *i->string++; + } + } + else + { + /* If necessary, open the file. */ + if ( !i->file ) + { + FILE * f = stdin; + if ( strcmp( object_str( i->fname ), "-" ) && !( f = fopen( object_str( i->fname ), "r" ) ) ) + perror( object_str( i->fname ) ); + i->file = f; + } + + /* If there is another line in this file, start it. */ + if ( i->file && fgets( i->buf, sizeof( i->buf ), i->file ) ) + { + ++i->line; + i->string = i->buf; + return *i->string++; + } + } + + /* This include is done. Free it up and return EOF so yyparse() returns to + * parse_file(). + */ + + incp = i->next; + + /* Close file, free name. */ + if ( i->file && ( i->file != stdin ) ) + fclose( i->file ); + object_free( i->fname ); + BJAM_FREE( (char *)i ); + + return EOF; +} + + +/* + * yylex() - set yylval to current token; return its type. + * + * Macros to move things along: + * + * yychar() - return and advance character; invalid after EOF. + * yyprev() - back up one character; invalid before yychar(). + * + * yychar() returns a continuous stream of characters, until it hits the EOF of + * the current include file. + */ + +#define yychar() ( *incp->string ? *incp->string++ : yyline() ) +#define yyprev() ( incp->string-- ) + +int yylex() +{ + int c; + char buf[ BIGGEST_TOKEN ]; + char * b = buf; + + if ( !incp ) + goto eof; + + /* Get first character (whitespace or of token). */ + c = yychar(); + + if ( scanmode == SCAN_STRING ) + { + /* If scanning for a string (action's {}'s), look for the closing brace. + * We handle matching braces, if they match. + */ + + int nest = 1; + + while ( ( c != EOF ) && ( b < buf + sizeof( buf ) ) ) + { + if ( c == '{' ) + ++nest; + + if ( ( c == '}' ) && !--nest ) + break; + + *b++ = c; + + c = yychar(); + + /* Turn trailing "\r\n" sequences into plain "\n" for Cygwin. */ + if ( ( c == '\n' ) && ( b[ -1 ] == '\r' ) ) + --b; + } + + /* We ate the ending brace -- regurgitate it. */ + if ( c != EOF ) + yyprev(); + + /* Check for obvious errors. */ + if ( b == buf + sizeof( buf ) ) + { + yyerror( "action block too big" ); + goto eof; + } + + if ( nest ) + { + yyerror( "unmatched {} in action block" ); + goto eof; + } + + *b = 0; + yylval.type = STRING; + yylval.string = object_new( buf ); + yylval.file = incp->fname; + yylval.line = incp->line; + } + else + { + char * b = buf; + struct keyword * k; + int inquote = 0; + int notkeyword; + + /* Eat white space. */ + for ( ; ; ) + { + /* Skip past white space. */ + while ( ( c != EOF ) && isspace( c ) ) + c = yychar(); + + /* Not a comment? */ + if ( c != '#' ) + break; + + /* Swallow up comment line. */ + while ( ( ( c = yychar() ) != EOF ) && ( c != '\n' ) ) ; + } + + /* c now points to the first character of a token. */ + if ( c == EOF ) + goto eof; + + yylval.file = incp->fname; + yylval.line = incp->line; + + /* While scanning the word, disqualify it for (expensive) keyword lookup + * when we can: $anything, "anything", \anything + */ + notkeyword = c == '$'; + + /* Look for white space to delimit word. "'s get stripped but preserve + * white space. \ protects next character. + */ + while + ( + ( c != EOF ) && + ( b < buf + sizeof( buf ) ) && + ( inquote || !isspace( c ) ) + ) + { + if ( c == '"' ) + { + /* begin or end " */ + inquote = !inquote; + notkeyword = 1; + } + else if ( c != '\\' ) + { + /* normal char */ + *b++ = c; + } + else if ( ( c = yychar() ) != EOF ) + { + /* \c */ + if (c == 'n') + c = '\n'; + else if (c == 'r') + c = '\r'; + else if (c == 't') + c = '\t'; + *b++ = c; + notkeyword = 1; + } + else + { + /* \EOF */ + break; + } + + c = yychar(); + } + + /* Check obvious errors. */ + if ( b == buf + sizeof( buf ) ) + { + yyerror( "string too big" ); + goto eof; + } + + if ( inquote ) + { + yyerror( "unmatched \" in string" ); + goto eof; + } + + /* We looked ahead a character - back up. */ + if ( c != EOF ) + yyprev(); + + /* Scan token table. Do not scan if it is obviously not a keyword or if + * it is an alphabetic when were looking for punctuation. + */ + + *b = 0; + yylval.type = ARG; + + if ( !notkeyword && !( isalpha( *buf ) && ( scanmode == SCAN_PUNCT ) ) ) + for ( k = keywords; k->word; ++k ) + if ( ( *buf == *k->word ) && !strcmp( k->word, buf ) ) + { + yylval.type = k->type; + yylval.keyword = k->word; /* used by symdump */ + break; + } + + if ( yylval.type == ARG ) + yylval.string = object_new( buf ); + } + + if ( DEBUG_SCAN ) + printf( "scan %s\n", symdump( &yylval ) ); + + return yylval.type; + +eof: + /* We do not reset yylval.file & yylval.line here so unexpected EOF error + * messages would include correct error location information. + */ + yylval.type = EOF; + return yylval.type; +} + + +static char * symdump( YYSTYPE * s ) +{ + static char buf[ BIGGEST_TOKEN + 20 ]; + switch ( s->type ) + { + case EOF : sprintf( buf, "EOF" ); break; + case 0 : sprintf( buf, "unknown symbol %s", object_str( s->string ) ); break; + case ARG : sprintf( buf, "argument %s" , object_str( s->string ) ); break; + case STRING: sprintf( buf, "string \"%s\"" , object_str( s->string ) ); break; + default : sprintf( buf, "keyword %s" , s->keyword ); break; + } + return buf; +} + + +/* + * Get information about the current file and line, for those epsilon + * transitions that produce a parse. + */ + +void yyinput_last_read_token( OBJECT * * name, int * line ) +{ + /* TODO: Consider whether and when we might want to report where the last + * read token ended, e.g. EOF errors inside string literals. + */ + *name = yylval.file; + *line = yylval.line; +} diff --git a/mosesdecoder/jam-files/engine/scan.h b/mosesdecoder/jam-files/engine/scan.h new file mode 100644 index 0000000000000000000000000000000000000000..745477fc1a717394b8a17ce3caa100fff0951c43 --- /dev/null +++ b/mosesdecoder/jam-files/engine/scan.h @@ -0,0 +1,61 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* + * scan.h - the jam yacc scanner + * + * External functions: + * yyerror( char *s ) - print a parsing error message. + * yyfparse( char *s ) - scan include file s. + * yylex() - parse the next token, returning its type. + * yymode() - adjust lexicon of scanner. + * yyparse() - declaration for yacc parser. + * yyanyerrors() - indicate if any parsing errors occured. + * + * The yymode() function is for the parser to adjust the lexicon of the scanner. + * Aside from normal keyword scanning, there is a mode to handle action strings + * (look only for the closing }) and a mode to ignore most keywords when looking + * for a punctuation keyword. This allows non-punctuation keywords to be used in + * lists without quoting. + */ + +#include "lists.h" +#include "object.h" +#include "parse.h" + + +/* + * YYSTYPE - value of a lexical token + */ + +#define YYSTYPE YYSYMBOL + +typedef struct _YYSTYPE +{ + int type; + OBJECT * string; + PARSE * parse; + LIST * list; + int number; + OBJECT * file; + int line; + char const * keyword; +} YYSTYPE; + +extern YYSTYPE yylval; + +void yymode( int n ); +void yyerror( char const * s ); +int yyanyerrors(); +void yyfparse( OBJECT * s ); +int yyline(); +int yylex(); +int yyparse(); +void yyinput_last_read_token( OBJECT * * name, int * line ); + +#define SCAN_NORMAL 0 /* normal parsing */ +#define SCAN_STRING 1 /* look only for matching } */ +#define SCAN_PUNCT 2 /* only punctuation keywords */ diff --git a/mosesdecoder/jam-files/engine/search.h b/mosesdecoder/jam-files/engine/search.h new file mode 100644 index 0000000000000000000000000000000000000000..7e74f7972859538116f28f20bd16aea3a34522ea --- /dev/null +++ b/mosesdecoder/jam-files/engine/search.h @@ -0,0 +1,22 @@ +/* + * Copyright 1993, 1995 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* + * search.h - find a target along $(SEARCH) or $(LOCATE) + */ + +#ifndef SEARCH_SW20111118_H +#define SEARCH_SW20111118_H + +#include "object.h" +#include "timestamp.h" + +void set_explicit_binding( OBJECT * target, OBJECT * locate ); +OBJECT * search( OBJECT * target, timestamp * const time, + OBJECT * * another_target, int const file ); +void search_done( void ); + +#endif diff --git a/mosesdecoder/jam-files/engine/subst.c b/mosesdecoder/jam-files/engine/subst.c new file mode 100644 index 0000000000000000000000000000000000000000..a5fcee08cb9bd960e0d8e63c4602ac942def41bd --- /dev/null +++ b/mosesdecoder/jam-files/engine/subst.c @@ -0,0 +1,116 @@ +#include "jam.h" +#include "subst.h" + +#include "builtins.h" +#include "frames.h" +#include "hash.h" +#include "lists.h" + +#include + + +typedef struct regex_entry +{ + OBJECT * pattern; + regexp * regex; +} regex_entry; + +static struct hash * regex_hash; + + +regexp * regex_compile( OBJECT * pattern ) +{ + int found; + regex_entry * e ; + + if ( !regex_hash ) + regex_hash = hashinit( sizeof( regex_entry ), "regex" ); + + e = (regex_entry *)hash_insert( regex_hash, pattern, &found ); + if ( !found ) + { + e->pattern = object_copy( pattern ); + e->regex = regcomp( (char *)pattern ); + } + + return e->regex; +} + + +LIST * builtin_subst( FRAME * frame, int flags ) +{ + LIST * result = L0; + LIST * const arg1 = lol_get( frame->args, 0 ); + LISTITER iter = list_begin( arg1 ); + LISTITER const end = list_end( arg1 ); + + if ( iter != end && list_next( iter ) != end && list_next( list_next( iter ) + ) != end ) + { + char const * const source = object_str( list_item( iter ) ); + OBJECT * const pattern = list_item( list_next( iter ) ); + regexp * const repat = regex_compile( pattern ); + + if ( regexec( repat, (char *)source) ) + { + LISTITER subst = list_next( iter ); + + while ( ( subst = list_next( subst ) ) != end ) + { +#define BUFLEN 4096 + char buf[ BUFLEN + 1 ]; + char const * in = object_str( list_item( subst ) ); + char * out = buf; + + for ( ; *in && out < buf + BUFLEN; ++in ) + { + if ( *in == '\\' || *in == '$' ) + { + ++in; + if ( *in == 0 ) + break; + if ( *in >= '0' && *in <= '9' ) + { + unsigned int const n = *in - '0'; + size_t const srclen = repat->endp[ n ] - + repat->startp[ n ]; + size_t const remaining = buf + BUFLEN - out; + size_t const len = srclen < remaining + ? srclen + : remaining; + memcpy( out, repat->startp[ n ], len ); + out += len; + continue; + } + /* fall through and copy the next character */ + } + *out++ = *in; + } + *out = 0; + + result = list_push_back( result, object_new( buf ) ); +#undef BUFLEN + } + } + } + + return result; +} + + +static void free_regex( void * xregex, void * data ) +{ + regex_entry * const regex = (regex_entry *)xregex; + object_free( regex->pattern ); + BJAM_FREE( regex->regex ); +} + + +void regex_done() +{ + if ( regex_hash ) + { + hashenumerate( regex_hash, free_regex, (void *)0 ); + hashdone( regex_hash ); + } +} diff --git a/mosesdecoder/jam-files/engine/variable.h b/mosesdecoder/jam-files/engine/variable.h new file mode 100644 index 0000000000000000000000000000000000000000..ddb452bc1e99dbac4e4145dff9c3c54b19df5dce --- /dev/null +++ b/mosesdecoder/jam-files/engine/variable.h @@ -0,0 +1,34 @@ +/* + * Copyright 1993, 2000 Christopher Seiwald. + * + * This file is part of Jam - see jam.c for Copyright information. + */ + +/* + * variable.h - handle jam multi-element variables + */ + +#ifndef VARIABLE_SW20111119_H +#define VARIABLE_SW20111119_H + +#include "lists.h" +#include "object.h" + + +struct module_t; + +void var_defines( struct module_t *, char * const * e, int preprocess ); +LIST * var_get( struct module_t *, OBJECT * symbol ); +void var_set( struct module_t *, OBJECT * symbol, LIST * value, int flag ); +LIST * var_swap( struct module_t *, OBJECT * symbol, LIST * value ); +void var_done( struct module_t * ); + +/* + * Defines for var_set(). + */ + +#define VAR_SET 0 /* override previous value */ +#define VAR_APPEND 1 /* append to previous value */ +#define VAR_DEFAULT 2 /* set only if no previous value */ + +#endif diff --git a/mosesdecoder/search/context.hh b/mosesdecoder/search/context.hh new file mode 100644 index 0000000000000000000000000000000000000000..08f21bbf0f8da01ff6db895fe24123ef065cbd6c --- /dev/null +++ b/mosesdecoder/search/context.hh @@ -0,0 +1,49 @@ +#ifndef SEARCH_CONTEXT__ +#define SEARCH_CONTEXT__ + +#include "search/config.hh" +#include "search/vertex.hh" + +#include + +namespace search { + +class ContextBase { + public: + explicit ContextBase(const Config &config) : config_(config) {} + + VertexNode *NewVertexNode() { + VertexNode *ret = vertex_node_pool_.construct(); + assert(ret); + return ret; + } + + void DeleteVertexNode(VertexNode *node) { + vertex_node_pool_.destroy(node); + } + + unsigned int PopLimit() const { return config_.PopLimit(); } + + Score LMWeight() const { return config_.LMWeight(); } + + const Config &GetConfig() const { return config_; } + + private: + boost::object_pool vertex_node_pool_; + + Config config_; +}; + +template class Context : public ContextBase { + public: + Context(const Config &config, const Model &model) : ContextBase(config), model_(model) {} + + const Model &LanguageModel() const { return model_; } + + private: + const Model &model_; +}; + +} // namespace search + +#endif // SEARCH_CONTEXT__ diff --git a/mosesdecoder/search/edge.hh b/mosesdecoder/search/edge.hh new file mode 100644 index 0000000000000000000000000000000000000000..cee96b474e955ac06730f96df39b5430d9b2b982 --- /dev/null +++ b/mosesdecoder/search/edge.hh @@ -0,0 +1,54 @@ +#ifndef SEARCH_EDGE__ +#define SEARCH_EDGE__ + +#include "lm/state.hh" +#include "search/header.hh" +#include "search/types.hh" +#include "search/vertex.hh" +#include "util/pool.hh" + +#include + +#include + +namespace search { + +// Copyable, but the copy will be shallow. +class PartialEdge : public Header { + public: + // Allow default construction for STL. + PartialEdge() {} + + PartialEdge(util::Pool &pool, Arity arity) + : Header(pool.Allocate(Size(arity, arity + 1)), arity) {} + + PartialEdge(util::Pool &pool, Arity arity, Arity chart_states) + : Header(pool.Allocate(Size(arity, chart_states)), arity) {} + + // Non-terminals + const PartialVertex *NT() const { + return reinterpret_cast(After()); + } + PartialVertex *NT() { + return reinterpret_cast(After()); + } + + const lm::ngram::ChartState &CompletedState() const { + return *Between(); + } + const lm::ngram::ChartState *Between() const { + return reinterpret_cast(After() + GetArity() * sizeof(PartialVertex)); + } + lm::ngram::ChartState *Between() { + return reinterpret_cast(After() + GetArity() * sizeof(PartialVertex)); + } + + private: + static std::size_t Size(Arity arity, Arity chart_states) { + return kHeaderSize + arity * sizeof(PartialVertex) + chart_states * sizeof(lm::ngram::ChartState); + } +}; + + +} // namespace search +#endif // SEARCH_EDGE__ diff --git a/mosesdecoder/search/nbest.cc b/mosesdecoder/search/nbest.cc new file mode 100644 index 0000000000000000000000000000000000000000..7cf84dbb415fd7b079767f42be4552774cc3f7be --- /dev/null +++ b/mosesdecoder/search/nbest.cc @@ -0,0 +1,106 @@ +#include "search/nbest.hh" + +#include "util/pool.hh" +#include "moses/Util.h" + +#include +#include +#include +#include +#include + +namespace search { + +NBestList::NBestList(std::vector &partials, util::Pool &entry_pool, std::size_t keep) { + assert(!partials.empty()); + std::vector::iterator end; + if (partials.size() > keep) { + end = partials.begin() + keep; + NTH_ELEMENT4(partials.begin(), end, partials.end(), std::greater()); + } else { + end = partials.end(); + } + for (std::vector::const_iterator i(partials.begin()); i != end; ++i) { + queue_.push(QueueEntry(entry_pool.Allocate(QueueEntry::Size(i->GetArity())), *i)); + } +} + +Score NBestList::TopAfterConstructor() const { + assert(revealed_.empty()); + return queue_.top().GetScore(); +} + +const std::vector &NBestList::Extract(util::Pool &pool, std::size_t n) { + while (revealed_.size() < n && !queue_.empty()) { + MoveTop(pool); + } + return revealed_; +} + +Score NBestList::Visit(util::Pool &pool, std::size_t index) { + if (index + 1 < revealed_.size()) + return revealed_[index + 1].GetScore() - revealed_[index].GetScore(); + if (queue_.empty()) + return -INFINITY; + if (index + 1 == revealed_.size()) + return queue_.top().GetScore() - revealed_[index].GetScore(); + assert(index == revealed_.size()); + + MoveTop(pool); + + if (queue_.empty()) return -INFINITY; + return queue_.top().GetScore() - revealed_[index].GetScore(); +} + +Applied NBestList::Get(util::Pool &pool, std::size_t index) { + assert(index <= revealed_.size()); + if (index == revealed_.size()) MoveTop(pool); + return revealed_[index]; +} + +void NBestList::MoveTop(util::Pool &pool) { + assert(!queue_.empty()); + QueueEntry entry(queue_.top()); + queue_.pop(); + RevealedRef *const children_begin = entry.Children(); + RevealedRef *const children_end = children_begin + entry.GetArity(); + Score basis = entry.GetScore(); + for (RevealedRef *child = children_begin; child != children_end; ++child) { + Score change = child->in_->Visit(pool, child->index_); + if (change != -INFINITY) { + assert(change < 0.001); + QueueEntry new_entry(pool.Allocate(QueueEntry::Size(entry.GetArity())), basis + change, entry.GetArity(), entry.GetNote(), entry.GetRange()); + std::copy(children_begin, child, new_entry.Children()); + RevealedRef *update = new_entry.Children() + (child - children_begin); + update->in_ = child->in_; + update->index_ = child->index_ + 1; + std::copy(child + 1, children_end, update + 1); + queue_.push(new_entry); + } + // Gesmundo, A. and Henderson, J. Faster Cube Pruning, IWSLT 2010. + if (child->index_) break; + } + + // Convert QueueEntry to Applied. This leaves some unused memory. + void *overwrite = entry.Children(); + for (unsigned int i = 0; i < entry.GetArity(); ++i) { + RevealedRef from(*(static_cast(overwrite) + i)); + *(static_cast(overwrite) + i) = from.in_->Get(pool, from.index_); + } + revealed_.push_back(Applied(entry.Base())); +} + +NBestComplete NBest::Complete(std::vector &partials) { + assert(!partials.empty()); + NBestList *list = list_pool_.construct(partials, entry_pool_, config_.keep); + return NBestComplete( + list, + partials.front().CompletedState(), // All partials have the same state + list->TopAfterConstructor()); +} + +const std::vector &NBest::Extract(History history) { + return static_cast(history)->Extract(entry_pool_, config_.size); +} + +} // namespace search diff --git a/mosesdecoder/search/rule.hh b/mosesdecoder/search/rule.hh new file mode 100644 index 0000000000000000000000000000000000000000..dc45f6634c2e847a5d557bd9431a85bceccad5eb --- /dev/null +++ b/mosesdecoder/search/rule.hh @@ -0,0 +1,25 @@ +#ifndef SEARCH_RULE__ +#define SEARCH_RULE__ + +#include "lm/left.hh" +#include "lm/word_index.hh" +#include "search/types.hh" + +#include + +namespace search { + +const lm::WordIndex kNonTerminal = lm::kMaxWordIndex; + +struct ScoreRuleRet { + Score prob; + unsigned int oov; +}; + +// Pass and normally. +// Indicate non-terminals with kNonTerminal. +template ScoreRuleRet ScoreRule(const Model &model, const std::vector &words, lm::ngram::ChartState *state_out); + +} // namespace search + +#endif // SEARCH_RULE__ diff --git a/mosesdecoder/search/types.hh b/mosesdecoder/search/types.hh new file mode 100644 index 0000000000000000000000000000000000000000..e1239dfd079991da3902e2f4597124f15829aa3f --- /dev/null +++ b/mosesdecoder/search/types.hh @@ -0,0 +1,31 @@ +#ifndef SEARCH_TYPES__ +#define SEARCH_TYPES__ + +#include + +namespace lm { namespace ngram { struct ChartState; } } + +namespace search { + +typedef float Score; + +typedef uint32_t Arity; + +union Note { + const void *vp; +}; + +typedef void *History; + +struct NBestComplete { + NBestComplete(History in_history, const lm::ngram::ChartState &in_state, Score in_score) + : history(in_history), state(&in_state), score(in_score) {} + + History history; + const lm::ngram::ChartState *state; + Score score; +}; + +} // namespace search + +#endif // SEARCH_TYPES__ diff --git a/mosesdecoder/search/vertex.hh b/mosesdecoder/search/vertex.hh new file mode 100644 index 0000000000000000000000000000000000000000..e04325dc32ec184ff80bc1dd03b243dac171855d --- /dev/null +++ b/mosesdecoder/search/vertex.hh @@ -0,0 +1,196 @@ +#ifndef SEARCH_VERTEX__ +#define SEARCH_VERTEX__ + +#include "lm/left.hh" +#include "search/types.hh" + +#include + +#include +#include +#include +#include + +namespace search { + +class ContextBase; + +struct HypoState { + History history; + lm::ngram::ChartState state; + Score score; +}; + +class VertexNode { + public: + VertexNode() {} + + void InitRoot() { hypos_.clear(); } + + /* The steps of building a VertexNode: + * 1. Default construct. + * 2. AppendHypothesis at least once, possibly multiple times. + * 3. FinishAppending with the number of words on left and right guaranteed + * to be common. + * 4. If !Complete(), call BuildExtend to construct the extensions + */ + // Must default construct, call AppendHypothesis 1 or more times then do FinishedAppending. + void AppendHypothesis(const NBestComplete &best) { + assert(hypos_.empty() || !(hypos_.front().state == *best.state)); + HypoState hypo; + hypo.history = best.history; + hypo.state = *best.state; + hypo.score = best.score; + hypos_.push_back(hypo); + } + void AppendHypothesis(const HypoState &hypo) { + hypos_.push_back(hypo); + } + + // Sort hypotheses for the root. + void FinishRoot(); + + void FinishedAppending(const unsigned char common_left, const unsigned char common_right); + + void BuildExtend(); + + // Should only happen to a root node when the entire vertex is empty. + bool Empty() const { + return hypos_.empty() && extend_.empty(); + } + + bool Complete() const { + // HACK: prevent root from being complete. TODO: allow root to be complete. + return hypos_.size() == 1 && extend_.empty(); + } + + const lm::ngram::ChartState &State() const { return state_; } + bool RightFull() const { return right_full_; } + + // Priority relative to other non-terminals. 0 is highest. + unsigned char Niceness() const { return niceness_; } + + Score Bound() const { + return bound_; + } + + // Will be invalid unless this is a leaf. + const History End() const { + assert(hypos_.size() == 1); + return hypos_.front().history; + } + + VertexNode &operator[](size_t index) { + assert(!extend_.empty()); + return extend_[index]; + } + + size_t Size() const { + return extend_.size(); + } + + private: + // Hypotheses to be split. + std::vector hypos_; + + std::vector extend_; + + lm::ngram::ChartState state_; + bool right_full_; + + unsigned char niceness_; + + unsigned char policy_; + + Score bound_; +}; + +class PartialVertex { + public: + PartialVertex() {} + + explicit PartialVertex(VertexNode &back) : back_(&back), index_(0) {} + + bool Empty() const { return back_->Empty(); } + + bool Complete() const { return back_->Complete(); } + + const lm::ngram::ChartState &State() const { return back_->State(); } + bool RightFull() const { return back_->RightFull(); } + + Score Bound() const { return index_ ? (*back_)[index_].Bound() : back_->Bound(); } + + unsigned char Niceness() const { return back_->Niceness(); } + + // Split into continuation and alternative, rendering this the continuation. + bool Split(PartialVertex &alternative) { + assert(!Complete()); + back_->BuildExtend(); + bool ret; + if (index_ + 1 < back_->Size()) { + alternative.index_ = index_ + 1; + alternative.back_ = back_; + ret = true; + } else { + ret = false; + } + back_ = &((*back_)[index_]); + index_ = 0; + return ret; + } + + const History End() const { + return back_->End(); + } + + private: + VertexNode *back_; + unsigned int index_; +}; + +template class VertexGenerator; + +class Vertex { + public: + Vertex() {} + + //PartialVertex RootFirst() const { return PartialVertex(right_); } + PartialVertex RootAlternate() { return PartialVertex(root_); } + //PartialVertex RootLast() const { return PartialVertex(left_); } + + bool Empty() const { + return root_.Empty(); + } + + Score Bound() const { + return root_.Bound(); + } + + const History BestChild() { + // left_ and right_ are not set at the root. + PartialVertex top(RootAlternate()); + if (top.Empty()) { + return History(); + } else { + PartialVertex continuation; + while (!top.Complete()) { + top.Split(continuation); + } + return top.End(); + } + } + + private: + template friend class VertexGenerator; + template friend class RootVertexGenerator; + VertexNode root_; + + // These will not be set for the root vertex. + // Branches only on left state. + //VertexNode left_; + // Branches only on right state. + //VertexNode right_; +}; + +} // namespace search +#endif // SEARCH_VERTEX__ diff --git a/mosesdecoder/search/vertex_generator.hh b/mosesdecoder/search/vertex_generator.hh new file mode 100644 index 0000000000000000000000000000000000000000..6013cdb7d2eb788f390856d177b4ac5e1799fe37 --- /dev/null +++ b/mosesdecoder/search/vertex_generator.hh @@ -0,0 +1,75 @@ +#ifndef SEARCH_VERTEX_GENERATOR__ +#define SEARCH_VERTEX_GENERATOR__ + +#include "search/edge.hh" +#include "search/types.hh" +#include "search/vertex.hh" + +namespace lm { +namespace ngram { +struct ChartState; +} // namespace ngram +} // namespace lm + +namespace search { + +class ContextBase; + +// Output makes the single-best or n-best list. +template class VertexGenerator { + public: + VertexGenerator(ContextBase &context, Vertex &gen, Output &nbest) : context_(context), gen_(gen), nbest_(nbest) {} + + void NewHypothesis(PartialEdge partial) { + nbest_.Add(existing_[hash_value(partial.CompletedState())], partial); + } + + void FinishedSearch() { + gen_.root_.InitRoot(); + for (typename Existing::iterator i(existing_.begin()); i != existing_.end(); ++i) { + gen_.root_.AppendHypothesis(nbest_.Complete(i->second)); + } + existing_.clear(); + gen_.root_.FinishRoot(); + } + + Vertex &Generating() { return gen_; } + + private: + ContextBase &context_; + + Vertex &gen_; + + typedef boost::unordered_map Existing; + Existing existing_; + + Output &nbest_; +}; + +// Special case for root vertex: everything should come together into the root +// node. In theory, this should happen naturally due to state collapsing with +// and . If that's the case, VertexGenerator is fine, though it will +// make one connection. +template class RootVertexGenerator { + public: + RootVertexGenerator(Vertex &gen, Output &out) : gen_(gen), out_(out) {} + + void NewHypothesis(PartialEdge partial) { + out_.Add(combine_, partial); + } + + void FinishedSearch() { + gen_.root_.InitRoot(); + gen_.root_.AppendHypothesis(out_.Complete(combine_)); + gen_.root_.FinishRoot(); + } + + private: + Vertex &gen_; + + typename Output::Combine combine_; + Output &out_; +}; + +} // namespace search +#endif // SEARCH_VERTEX_GENERATOR__