Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmoses/.cdtbuild102
-rwxr-xr-xmoses/.cdtproject15
-rwxr-xr-xmoses/.project19
-rwxr-xr-xmoses/.settings/org.eclipse.cdt.managedbuilder.core.prefs19
-rw-r--r--moses/Makefile.am5
-rw-r--r--moses/aclocal.m41044
-rw-r--r--moses/config.h.in55
-rw-r--r--moses/configure.in78
-rwxr-xr-xmoses/depcomp441
-rwxr-xr-xmoses/install-sh276
-rw-r--r--moses/ltmain.sh6343
-rwxr-xr-xmoses/missing336
-rwxr-xr-xmoses/mkinstalldirs111
-rwxr-xr-xmoses/moses.sln52
-rwxr-xr-xmoses/moses.vcproj597
-rwxr-xr-xmoses/src/Arc.cpp57
-rwxr-xr-xmoses/src/Arc.h55
-rwxr-xr-xmoses/src/Factor.cpp40
-rwxr-xr-xmoses/src/Factor.h102
-rwxr-xr-xmoses/src/FactorCollection.cpp119
-rwxr-xr-xmoses/src/FactorCollection.h50
-rwxr-xr-xmoses/src/FactorTypeSet.cpp34
-rwxr-xr-xmoses/src/FactorTypeSet.h99
-rw-r--r--moses/src/FutureScore.h56
-rwxr-xr-xmoses/src/GenerationDictionary.cpp125
-rwxr-xr-xmoses/src/GenerationDictionary.h84
-rwxr-xr-xmoses/src/Hypothesis.cpp445
-rwxr-xr-xmoses/src/Hypothesis.h181
-rwxr-xr-xmoses/src/HypothesisCollection.cpp219
-rwxr-xr-xmoses/src/HypothesisCollection.h112
-rwxr-xr-xmoses/src/HypothesisCollectionIntermediate.cpp58
-rwxr-xr-xmoses/src/HypothesisCollectionIntermediate.h59
-rw-r--r--moses/src/InputFileStream.cpp22
-rw-r--r--moses/src/InputFileStream.h56
-rwxr-xr-xmoses/src/InputOutput.h43
-rwxr-xr-xmoses/src/LanguageModel.cpp351
-rwxr-xr-xmoses/src/LanguageModel.h139
-rwxr-xr-xmoses/src/LatticeEdge.cpp76
-rwxr-xr-xmoses/src/LatticeEdge.h133
-rwxr-xr-xmoses/src/LatticePath.cpp198
-rwxr-xr-xmoses/src/LatticePath.h124
-rwxr-xr-xmoses/src/LatticePathCollection.h56
-rwxr-xr-xmoses/src/LatticePathList.h43
-rw-r--r--moses/src/Makefile.am10
-rw-r--r--moses/src/Makefile.in473
-rwxr-xr-xmoses/src/Manager.cpp607
-rwxr-xr-xmoses/src/Manager.h79
-rwxr-xr-xmoses/src/NGramCollection.cpp54
-rwxr-xr-xmoses/src/NGramCollection.h46
-rwxr-xr-xmoses/src/NGramNode.h80
-rwxr-xr-xmoses/src/Object.h48
-rwxr-xr-xmoses/src/Parameter.cpp242
-rwxr-xr-xmoses/src/Parameter.h55
-rwxr-xr-xmoses/src/Phrase.cpp282
-rwxr-xr-xmoses/src/Phrase.h109
-rwxr-xr-xmoses/src/PhraseDictionary.cpp230
-rwxr-xr-xmoses/src/PhraseDictionary.h89
-rwxr-xr-xmoses/src/PossibleTranslation.cpp101
-rwxr-xr-xmoses/src/PossibleTranslation.h108
-rwxr-xr-xmoses/src/PossibleTranslationCollection.h44
-rw-r--r--moses/src/ScoreColl.h53
-rwxr-xr-xmoses/src/Sentence.cpp20
-rwxr-xr-xmoses/src/Sentence.h53
-rwxr-xr-xmoses/src/StaticData.cpp357
-rwxr-xr-xmoses/src/StaticData.h172
-rw-r--r--moses/src/TargetPhrase.cpp62
-rw-r--r--moses/src/TargetPhrase.h60
-rw-r--r--moses/src/Timer.h128
-rw-r--r--moses/src/TransScoreComponent.h88
-rw-r--r--moses/src/TransScoreComponentCollection.h64
-rwxr-xr-xmoses/src/TypeDef.h135
-rw-r--r--moses/src/UserMessage.cpp59
-rw-r--r--moses/src/UserMessage.h43
-rw-r--r--moses/src/Util.cpp93
-rw-r--r--moses/src/Util.h190
-rwxr-xr-xmoses/src/WeightOptimization.cpp75
-rwxr-xr-xmoses/src/WeightOptimization.h44
-rwxr-xr-xmoses/src/Word.cpp124
-rwxr-xr-xmoses/src/Word.h89
-rwxr-xr-xmoses/src/WordsBitmap.cpp22
-rwxr-xr-xmoses/src/WordsBitmap.h173
-rwxr-xr-xmoses/src/WordsRange.h56
-rw-r--r--moses/src/md5.cpp259
-rw-r--r--moses/src/md5.h26
-rw-r--r--moses/templates/cpp0
-rw-r--r--moses/templates/h0
86 files changed, 17731 insertions, 0 deletions
diff --git a/moses/.cdtbuild b/moses/.cdtbuild
new file mode 100755
index 000000000..451641d87
--- /dev/null
+++ b/moses/.cdtbuild
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?fileVersion 3.0.0?>
+
+<ManagedProjectBuildInfo>
+<project id="moses.cdt.managedbuild.target.gnu.lib.1654550987" name="Static Library (Gnu)" projectType="cdt.managedbuild.target.gnu.lib">
+<configuration artifactExtension="a" artifactName="moses" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.lib.debug.2082569407" name="Debug" parent="cdt.managedbuild.config.gnu.lib.debug">
+<toolChain id="cdt.managedbuild.toolchain.gnu.lib.debug.2031285777" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.lib.debug">
+<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.debug.1319234555" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.debug"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.1022475428" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug">
+<option id="gnu.cpp.compiler.option.preprocessor.def.2071633498" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="LM_SRI"/>
+<listOptionValue builtIn="false" value="TRACE_ENABLE"/>
+</option>
+<option id="gnu.cpp.compiler.option.include.paths.560695438" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${ProjDirPath}/../boost/include/boost-1_33_1"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/misc/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/dstruct/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/include"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/lm/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../mysql/include"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../mysqlpp/lib"/>
+</option>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.archiver.lib.debug.187676627" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.debug"/>
+<tool id="cdt.managedbuild.tool.gnu.assembler.lib.debug.1660142337" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.debug"/>
+<macros/>
+</toolChain>
+</configuration>
+<configuration artifactExtension="a" artifactName="moses" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.lib.release.875756117" name="Release" parent="cdt.managedbuild.config.gnu.lib.release">
+<toolChain id="cdt.managedbuild.toolchain.gnu.lib.release.1956672127" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.lib.release">
+<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.release.1930771681" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.release"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.703142952" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release">
+<option id="gnu.cpp.compiler.option.include.paths.28728819" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${ProjDirPath}/../boost/include/boost-1_33_1"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/misc/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/dstruct/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/include"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/lm/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../mysql/include"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../mysqlpp/lib"/>
+</option>
+<option id="gnu.cpp.compiler.option.preprocessor.def.444585015" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="LM_SRI"/>
+<listOptionValue builtIn="false" value="TRACE_ENABLE"/>
+</option>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.archiver.lib.release.1731276863" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.release"/>
+<tool id="cdt.managedbuild.tool.gnu.assembler.lib.release.693340097" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.release"/>
+<macros/>
+</toolChain>
+</configuration>
+<configuration artifactExtension="a" artifactName="moses" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.lib.debug.837708408" name="DebugNBest" parent="cdt.managedbuild.config.gnu.lib.debug">
+<toolChain id="cdt.managedbuild.toolchain.gnu.lib.debug.1361461230" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.lib.debug">
+<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.debug.489823169" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.debug"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug.57605597" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.debug">
+<option id="gnu.cpp.compiler.option.preprocessor.def.547610699" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="LM_SRI"/>
+<listOptionValue builtIn="false" value="TRACE_ENABLE"/>
+<listOptionValue builtIn="false" value="N_BEST"/>
+</option>
+<option id="gnu.cpp.compiler.option.include.paths.2084651176" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${ProjDirPath}/../boost/include/boost-1_33_1"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/misc/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/dstruct/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/include"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/lm/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../mysql/include"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../mysqlpp/lib"/>
+</option>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.archiver.lib.debug.1451721331" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.debug"/>
+<tool id="cdt.managedbuild.tool.gnu.assembler.lib.debug.1914532442" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.debug"/>
+<macros/>
+</toolChain>
+</configuration>
+<configuration artifactExtension="a" artifactName="moses" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.lib.release.1054653020" name="ReleaseNBest" parent="cdt.managedbuild.config.gnu.lib.release">
+<toolChain id="cdt.managedbuild.toolchain.gnu.lib.release.1271789636" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.lib.release">
+<tool id="cdt.managedbuild.tool.gnu.c.compiler.lib.release.1895488585" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.lib.release"/>
+<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release.322987396" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.lib.release">
+<option id="gnu.cpp.compiler.option.include.paths.1663320352" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
+<listOptionValue builtIn="false" value="${ProjDirPath}/../boost/include/boost-1_33_1"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/misc/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/dstruct/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/include"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../srilm/lm/src"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../mysql/include"/>
+<listOptionValue builtIn="false" value="${ProjDirPath}/../mysqlpp/lib"/>
+</option>
+<option id="gnu.cpp.compiler.option.preprocessor.def.1390867069" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
+<listOptionValue builtIn="false" value="LM_SRI"/>
+<listOptionValue builtIn="false" value="TRACE_ENABLE"/>
+<listOptionValue builtIn="false" value="N_BEST"/>
+</option>
+</tool>
+<tool id="cdt.managedbuild.tool.gnu.archiver.lib.release.22025776" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.lib.release"/>
+<tool id="cdt.managedbuild.tool.gnu.assembler.lib.release.676430715" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.lib.release"/>
+<macros/>
+</toolChain>
+</configuration>
+<macros/>
+</project>
+</ManagedProjectBuildInfo>
diff --git a/moses/.cdtproject b/moses/.cdtproject
new file mode 100755
index 000000000..41c23c46b
--- /dev/null
+++ b/moses/.cdtproject
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse-cdt version="2.0"?>
+
+<cdtproject id="org.eclipse.cdt.managedbuilder.core.managedMake">
+<extension id="org.eclipse.cdt.managedbuilder.core.ManagedBuildManager" point="org.eclipse.cdt.core.ScannerInfoProvider"/>
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>
+<data>
+<item id="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
+</item>
+</data>
+</cdtproject>
diff --git a/moses/.project b/moses/.project
new file mode 100755
index 000000000..bad551be6
--- /dev/null
+++ b/moses/.project
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>moses</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
+ </natures>
+</projectDescription>
diff --git a/moses/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/moses/.settings/org.eclipse.cdt.managedbuilder.core.prefs
new file mode 100755
index 000000000..7eb2ca3bc
--- /dev/null
+++ b/moses/.settings/org.eclipse.cdt.managedbuilder.core.prefs
@@ -0,0 +1,19 @@
+#Sat Jun 24 11:17:00 BST 2006
+eclipse.preferences.version=1
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.182985892=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.debug.454331295=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.1765997310=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.exe.release.659132175=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.2082569407=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.debug.837708408=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.release.1054653020=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.lib.release.875756117=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.182985892=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.debug.454331295=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.1765997310=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.exe.release.659132175=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n
+environment/project=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.lib.debug.2082569407=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.lib.debug.837708408=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.lib.release.1054653020=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
+environment/project/cdt.managedbuild.config.gnu.lib.release.875756117=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n
diff --git a/moses/Makefile.am b/moses/Makefile.am
new file mode 100644
index 000000000..fb57945f5
--- /dev/null
+++ b/moses/Makefile.am
@@ -0,0 +1,5 @@
+# not a GNU package. You can remove this line, if
+# have all needed files, that a GNU package needs
+#AUTOMAKE_OPTIONS = foreign 1.4
+SUBDIRS = src
+
diff --git a/moses/aclocal.m4 b/moses/aclocal.m4
new file mode 100644
index 000000000..ef60f9840
--- /dev/null
+++ b/moses/aclocal.m4
@@ -0,0 +1,1044 @@
+# generated automatically by aclocal 1.9.2 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+# Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+# -*- Autoconf -*-
+# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# Generated from amversion.in; do not edit by hand.
+
+# 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION so it can be traced.
+# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+ [AM_AUTOMAKE_VERSION([1.9.2])])
+
+# AM_AUX_DIR_EXPAND
+
+# Copyright (C) 2001, 2003 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory. The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run. This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+# fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+# fails if $ac_aux_dir is absolute,
+# fails when called from a subdirectory in a VPATH build with
+# a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir. In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
+# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+# MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH. The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 6
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
+ [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])
+AC_SUBST([$1_FALSE])
+if $2; then
+ $1_TRUE=
+ $1_FALSE='#'
+else
+ $1_TRUE='#'
+ $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+ AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# serial 7 -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+# 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery. Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
+ [$1], CXX, [depcc="$CXX" am_compiler_list=],
+ [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+ [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
+ [depcc="$$1" am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+ [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named `D' -- because `-MD' means `put the output
+ # in D'.
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_$1_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+ fi
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+ # Solaris 8's {/usr,}/bin/sh.
+ touch sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ case $depmode in
+ nosideeffect)
+ # after this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ none) break ;;
+ esac
+ # We check with `-c' and `-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle `-M -o', and we need to detect this.
+ if depmode=$depmode \
+ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_$1_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[ --disable-dependency-tracking speeds up one-time build
+ --enable-dependency-tracking do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])
+])
+
+# Generate code to set up dependency tracking. -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+# 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+#serial 2
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[for mf in $CONFIG_FILES; do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named `Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # So let's grep whole file.
+ if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
+ dirpart=`AS_DIRNAME("$mf")`
+ else
+ continue
+ fi
+ # Extract the definition of DEPDIR, am__include, and am__quote
+ # from the Makefile without running `make'.
+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ am__include=`sed -n 's/^am__include = //p' < "$mf"`
+ test -z "am__include" && continue
+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+ # When using ansi2knr, U may be empty or an underscore; expand it
+ U=`sed -n 's/^U = //p' < "$mf"`
+ # Find all dependency output files, they are included files with
+ # $(DEPDIR) in their names. We invoke sed twice because it is the
+ # simplest approach to changing $(DEPDIR) to its actual value in the
+ # expansion.
+ for file in `sed -n "
+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`AS_DIRNAME(["$file"])`
+ AS_MKDIR_P([$dirpart/$fdir])
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
+ done
+done
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled. FIXME. This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+ [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 7
+
+# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
+# Do all the work for Automake. -*- Autoconf -*-
+
+# This macro actually does too much some checks are only needed if
+# your package does certain things. But this isn't really a big deal.
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+# 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 11
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out. PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition. After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.58])dnl
+dnl Autoconf wants to disallow AM_ names. We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+# test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" &&
+ test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AM_PROG_INSTALL_SH
+AM_PROG_INSTALL_STRIP
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+ [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+ [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+ [_AM_DEPENDENCIES(CC)],
+ [define([AC_PROG_CC],
+ defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [_AM_DEPENDENCIES(CXX)],
+ [define([AC_PROG_CXX],
+ defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+])
+])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated. The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $1 | $1:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+
+# Copyright (C) 2001, 2003 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+install_sh=${install_sh-"$am_aux_dir/install-sh"}
+AC_SUBST(install_sh)])
+
+# -*- Autoconf -*-
+# Copyright (C) 2003 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot. For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes. -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo done
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# We grep out `Entering directory' and `Leaving directory'
+# messages which can occur if `w' ends up in MAKEFLAGS.
+# In particular we don't look at `^make:' because GNU make might
+# be invoked under some other name (usually "gmake"), in which
+# case it prints its new name instead of `make'.
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
+ am__include=include
+ am__quote=
+ _am_result=GNU
+fi
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+ echo '.include "confinc"' > confmf
+ if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
+ am__include=.include
+ am__quote="\""
+ _am_result=BSD
+ fi
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# -*- Autoconf -*-
+
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+ am_missing_run="$MISSING --run "
+else
+ am_missing_run=
+ AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
+
+# Copyright (C) 2003, 2004 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
+# created by `make install' are always world readable, even if the
+# installer happens to have an overly restrictive umask (e.g. 077).
+# This was a mistake. There are at least two reasons why we must not
+# use `-m 0755':
+# - it causes special bits like SGID to be ignored,
+# - it may be too restrictive (some setups expect 775 directories).
+#
+# Do not use -m 0755 and let people choose whatever they expect by
+# setting umask.
+#
+# We cannot accept any implementation of `mkdir' that recognizes `-p'.
+# Some implementations (such as Solaris 8's) are not thread-safe: if a
+# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
+# concurrently, both version can detect that a/ is missing, but only
+# one can create it and the other will error out. Consequently we
+# restrict ourselves to GNU make (using the --version option ensures
+# this.)
+AC_DEFUN([AM_PROG_MKDIR_P],
+[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+ # We used to keeping the `.' as first argument, in order to
+ # allow $(mkdir_p) to be used without argument. As in
+ # $(mkdir_p) $(somedir)
+ # where $(somedir) is conditionally defined. However this is wrong
+ # for two reasons:
+ # 1. if the package is installed by a user who cannot write `.'
+ # make install will fail,
+ # 2. the above comment should most certainly read
+ # $(mkdir_p) $(DESTDIR)$(somedir)
+ # so it does not work when $(somedir) is undefined and
+ # $(DESTDIR) is not.
+ # To support the latter case, we have to write
+ # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
+ # so the `.' trick is pointless.
+ mkdir_p='mkdir -p --'
+else
+ # On NextStep and OpenStep, the `mkdir' command does not
+ # recognize any option. It will interpret all options as
+ # directories to create, and then abort because `.' already
+ # exists.
+ for d in ./-p ./--version;
+ do
+ test -d $d && rmdir $d
+ done
+ # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
+ if test -f "$ac_aux_dir/mkinstalldirs"; then
+ mkdir_p='$(mkinstalldirs)'
+ else
+ mkdir_p='$(install_sh) -d'
+ fi
+fi
+AC_SUBST([mkdir_p])])
+
+# Helper functions for option handling. -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 2
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME. Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 3
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+ if test "$[*]" = "X"; then
+ # -L didn't work.
+ set X `ls -t $srcdir/configure conftest.file`
+ fi
+ rm -f conftest.file
+ if test "$[*]" != "X $srcdir/configure conftest.file" \
+ && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+alias in your environment])
+ fi
+
+ test "$[2]" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# AM_PROG_INSTALL_STRIP
+
+# Copyright (C) 2001, 2003 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries. This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'. However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+ AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Check how to create a tarball. -*- Autoconf -*-
+
+# Copyright (C) 2004 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+# tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+# $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+ [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+ [m4_case([$1], [ustar],, [pax],,
+ [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+ case $_am_tool in
+ gnutar)
+ for _am_tar in tar gnutar gtar;
+ do
+ AM_RUN_LOG([$_am_tar --version]) && break
+ done
+ am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+ am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+ am__untar="$_am_tar -xf -"
+ ;;
+ plaintar)
+ # Must skip GNU tar: if it does not support --format= it doesn't create
+ # ustar tarball either.
+ (tar --version) >/dev/null 2>&1 && continue
+ am__tar='tar chf - "$$tardir"'
+ am__tar_='tar chf - "$tardir"'
+ am__untar='tar xf -'
+ ;;
+ pax)
+ am__tar='pax -L -x $1 -w "$$tardir"'
+ am__tar_='pax -L -x $1 -w "$tardir"'
+ am__untar='pax -r'
+ ;;
+ cpio)
+ am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+ am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+ am__untar='cpio -i -H $1 -d'
+ ;;
+ none)
+ am__tar=false
+ am__tar_=false
+ am__untar=false
+ ;;
+ esac
+
+ # If the value was cached, stop now. We just wanted to have am__tar
+ # and am__untar set.
+ test -n "${am_cv_prog_tar_$1}" && break
+
+ # tar/untar a dummy directory, and stop if the command works
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ echo GrepMe > conftest.dir/file
+ AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+ rm -rf conftest.dir
+ if test -s conftest.tar; then
+ AM_RUN_LOG([$am__untar <conftest.tar])
+ grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+ fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
diff --git a/moses/config.h.in b/moses/config.h.in
new file mode 100644
index 000000000..90ee0d001
--- /dev/null
+++ b/moses/config.h.in
@@ -0,0 +1,55 @@
+/* config.h.in. Generated from configure.in by autoheader. */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* flag for SRILM */
+#undef HAVE_SRILM
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Version number of package */
+#undef VERSION
diff --git a/moses/configure.in b/moses/configure.in
new file mode 100644
index 000000000..e96d6849d
--- /dev/null
+++ b/moses/configure.in
@@ -0,0 +1,78 @@
+AC_INIT(src)
+
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(moses, 0.1)
+
+AC_PROG_CXX
+AC_LANG_CPLUSPLUS
+AC_PROG_RANLIB
+#AM_PROG_LIBTOOL
+
+AC_ARG_WITH(srilm,
+ [AC_HELP_STRING([--with-srilm=PATH], [(optional) path to SRI's LM toolkit])],
+ [with_srilm=$withval],
+ [with_srilm=no]
+ )
+
+AC_ARG_WITH(boost,
+ [AC_HELP_STRING([--with-srilm=PATH], [path to BOOST libraries])],
+ [with_boost=$withval],
+ [with_boost=no]
+ )
+
+AC_ARG_ENABLE(mysql, AC_HELP_STRING([--enable-mysql], [(optional) build in MySQL support])],
+ [mysql_flag=yes], [mysql_flag=no])
+if test "x$with_boost" != 'xno'
+then
+ CPPFLAGS="$CPPFLAGS -I${with_boost}"
+fi
+
+AC_CHECK_HEADER([boost/algorithm/string.hpp], [], [AC_MSG_ERROR([Cannot find boost. Use --with-boost=PATH])])
+AC_CHECK_HEADER([boost/iostreams/filtering_stream.hpp], [], [AC_MSG_ERROR([Cannot find boost. Use --with-boost=PATH])])
+
+if test "$mysql_flag" = 'yes'
+then
+ AC_MYSQLCLIENT(,,
+ [AC_ERROR([Could not locate mysql client libraries. Try --with-mysql-prefix/-include/-lib])])
+ LDFLAGS="$LDFLAGS $MYSQLCLIENT_LDFLAGS"
+ CPPFLAGS="$CPPFLAGS $MYSQLCLIENT_CPPFLAGS"
+ LIBS="$LIBS $MYSQLCLIENT_LIBS"
+
+ MYSQLPP_DEVEL
+ LIBS="$LIBS -lmysqlpp"
+
+ AM_CONDITIONAL([BUILD_MYSQL_SUPPORT], true)
+else
+ AM_CONDITIONAL([BUILD_MYSQL_SUPPORT], false)
+fi
+
+if test "x$with_srilm" != 'xno'
+then
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS -I${with_srilm}/include"
+
+ AC_CHECK_HEADER(Ngram.h,
+ [AC_DEFINE([HAVE_SRILM], [], [flag for SRILM])],
+ [AC_MSG_ERROR([Cannot find SRILM!])])
+
+ LIB_SRILM="-loolm -ldstruct -lmisc"
+ # ROOT/lib/i686-m64/liboolm.a
+ # ROOT/lib/i686-m64/libdstruct.a
+ # ROOT/lib/i686-m64/libmisc.a
+ MY_ARCH=`${with_srilm}/sbin/machine-type`
+ LDFLAGS="$LDFLAGS -L${with_srilm}/lib/${MY_ARCH}"
+ LIBS="$LIBS $LIB_SRILM"
+ FMTLIBS="$FMTLIBS liboolm.a libdstruct.a libmisc.a"
+ AM_CONDITIONAL([SRI_LM], true)
+ AM_CONDITIONAL([INTERNAL_LM], false)
+else
+ echo "Using internal language model (use --with-srilm to change)!"
+ AM_CONDITIONAL([SRI_LM], false)
+ AM_CONDITIONAL([INTERNAL_LM], true)
+fi
+
+LIBS="$LIBS -lboost_iostreams -lboost_filesystem -lboost_thread"
+FMT_LIBS="$FMT_LIBS libboost_iostreams.a libboost_filesystem.a libboost_thread.a"
+
+
+AC_OUTPUT(Makefile src/Makefile)
diff --git a/moses/depcomp b/moses/depcomp
new file mode 100755
index 000000000..4c20c6c94
--- /dev/null
+++ b/moses/depcomp
@@ -0,0 +1,441 @@
+#! /bin/sh
+
+# depcomp - compile a program generating dependencies as side-effects
+# Copyright 1999, 2000 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+ echo "depcomp: Variables source, object and depmode must be set" 1>&2
+ exit 1
+fi
+# `libtool' can also be set to `yes' or `no'.
+
+depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags. We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write. Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+ # HP compiler uses -M and no extra arg.
+ gccflag=-M
+ depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+ # This is just like dashmstdout with a different argument.
+ dashmflag=-xM
+ depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want. Yay! Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff. Hmm.
+ "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ mv "$tmpdepfile" "$depfile"
+ ;;
+
+gcc)
+## There are various ways to get dependency output from gcc. Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+## up in a subdir. Having to rename by hand is ugly.
+## (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+## -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+## than renaming).
+ if test -z "$gccflag"; then
+ gccflag=-MD,
+ fi
+ "$@" -Wp,"$gccflag$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+ sed -e 's/^[^:]*: / /' \
+ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header). We avoid this by adding
+## dummy dependencies for each header file. Too bad gcc doesn't do
+## this for us directly.
+ tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'. On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+sgi)
+ if test "$libtool" = yes; then
+ "$@" "-Wp,-MDupdate,$tmpdepfile"
+ else
+ "$@" -MDupdate "$tmpdepfile"
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+
+ if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
+ echo "$object : \\" > "$depfile"
+
+ # Clip off the initial element (the dependent). Don't try to be
+ # clever and replace this with sed code, as IRIX sed won't handle
+ # lines with more than a fixed number of characters (4096 in
+ # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
+ # the IRIX cc adds comments like `#:fec' to the end of the
+ # dependency line.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+ tr '
+' ' ' >> $depfile
+ echo >> $depfile
+
+ # The second pass generates a dummy entry for each header file.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+ >> $depfile
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+aix)
+ # The C for AIX Compiler uses -M and outputs the dependencies
+ # in a .u file. This file always lives in the current directory.
+ # Also, the AIX compiler puts `$object:' at the start of each line;
+ # $object doesn't have directory information.
+ stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'`
+ tmpdepfile="$stripped.u"
+ outname="$stripped.o"
+ if test "$libtool" = yes; then
+ "$@" -Wc,-M
+ else
+ "$@" -M
+ fi
+
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+
+ if test -f "$tmpdepfile"; then
+ # Each line is of the form `foo.o: dependent.h'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
+ sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+icc)
+ # Must come before tru64.
+
+ # Intel's C compiler understands `-MD -MF file'. However
+ # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # will fill foo.d with something like
+ # foo.o: sub/foo.c
+ # foo.o: sub/foo.h
+ # which is wrong. We want:
+ # sub/foo.o: sub/foo.c
+ # sub/foo.o: sub/foo.h
+ # sub/foo.c:
+ # sub/foo.h:
+
+ "$@" -MD -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each line is of the form `foo.o: dependent.h'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed -e "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+ sed -e "s,^[^:]*: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+tru64)
+ # The Tru64 AIX compiler uses -MD to generate dependencies as a side
+ # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+ # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+ # dependencies in `foo.d' instead, so we check for that too.
+ # Subdirectories are respected.
+
+ tmpdepfile1="$object.d"
+ tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'`
+ if test "$libtool" = yes; then
+ "$@" -Wc,-MD
+ else
+ "$@" -MD
+ fi
+
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2"
+ exit $stat
+ fi
+
+ if test -f "$tmpdepfile1"; then
+ tmpdepfile="$tmpdepfile1"
+ else
+ tmpdepfile="$tmpdepfile2"
+ fi
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a space and a tab in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+#nosideeffect)
+ # This comment above is used by automake to tell side-effect
+ # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the proprocessed file to stdout, regardless of -o,
+ # because we must use -o when running libtool.
+ test -z "$dashmflag" && dashmflag=-M
+ ( IFS=" "
+ case " $* " in
+ *" --mode=compile "*) # this is libtool, let us make it quiet
+ for arg
+ do # cycle over the arguments
+ case "$arg" in
+ "--mode=compile")
+ # insert --quiet before "--mode=compile"
+ set fnord "$@" --quiet
+ shift # fnord
+ ;;
+ esac
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # "$arg"
+ done
+ ;;
+ esac
+ "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
+ ) &
+ proc=$!
+ "$@"
+ stat=$?
+ wait "$proc"
+ if test "$stat" != 0; then exit $stat; fi
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+dashXmstdout)
+ # This case only exists to satisfy depend.m4. It is never actually
+ # run, as this mode is specially recognized in the preamble.
+ exit 1
+ ;;
+
+makedepend)
+ # X makedepend
+ (
+ shift
+ cleared=no
+ for arg in "$@"; do
+ case $cleared in no)
+ set ""; shift
+ cleared=yes
+ esac
+ case "$arg" in
+ -D*|-I*)
+ set fnord "$@" "$arg"; shift;;
+ -*)
+ ;;
+ *)
+ set fnord "$@" "$arg"; shift;;
+ esac
+ done
+ obj_suffix="`echo $object | sed 's/^.*\././'`"
+ touch "$tmpdepfile"
+ ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@"
+ ) &
+ proc=$!
+ "$@"
+ stat=$?
+ wait "$proc"
+ if test "$stat" != 0; then exit $stat; fi
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ tail +3 "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile" "$tmpdepfile".bak
+ ;;
+
+cpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the proprocessed file to stdout, regardless of -o,
+ # because we must use -o when running libtool.
+ ( IFS=" "
+ case " $* " in
+ *" --mode=compile "*)
+ for arg
+ do # cycle over the arguments
+ case $arg in
+ "--mode=compile")
+ # insert --quiet before "--mode=compile"
+ set fnord "$@" --quiet
+ shift # fnord
+ ;;
+ esac
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # "$arg"
+ done
+ ;;
+ esac
+ "$@" -E |
+ sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+ sed '$ s: \\$::' > "$tmpdepfile"
+ ) &
+ proc=$!
+ "$@"
+ stat=$?
+ wait "$proc"
+ if test "$stat" != 0; then exit $stat; fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ cat < "$tmpdepfile" >> "$depfile"
+ sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+msvisualcpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the proprocessed file to stdout, regardless of -o,
+ # because we must use -o when running libtool.
+ ( IFS=" "
+ case " $* " in
+ *" --mode=compile "*)
+ for arg
+ do # cycle over the arguments
+ case $arg in
+ "--mode=compile")
+ # insert --quiet before "--mode=compile"
+ set fnord "$@" --quiet
+ shift # fnord
+ ;;
+ esac
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # "$arg"
+ done
+ ;;
+ esac
+ "$@" -E |
+ sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+ ) &
+ proc=$!
+ "$@"
+ stat=$?
+ wait "$proc"
+ if test "$stat" != 0; then exit $stat; fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
+ echo " " >> "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+none)
+ exec "$@"
+ ;;
+
+*)
+ echo "Unknown depmode $depmode" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/moses/install-sh b/moses/install-sh
new file mode 100755
index 000000000..36f96f3e0
--- /dev/null
+++ b/moses/install-sh
@@ -0,0 +1,276 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch. It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd=$cpprog
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd=$stripprog
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "$0: no input file specified" >&2
+ exit 1
+else
+ :
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d "$dst" ]; then
+ instcmd=:
+ chmodcmd=""
+ else
+ instcmd=$mkdirprog
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f "$src" ] || [ -d "$src" ]
+ then
+ :
+ else
+ echo "$0: $src does not exist" >&2
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "$0: no destination specified" >&2
+ exit 1
+ else
+ :
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d "$dst" ]
+ then
+ dst=$dst/`basename "$src"`
+ else
+ :
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+ '
+IFS="${IFS-$defaultIFS}"
+
+oIFS=$IFS
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS=$oIFS
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp=$pathcomp$1
+ shift
+
+ if [ ! -d "$pathcomp" ] ;
+ then
+ $mkdirprog "$pathcomp"
+ else
+ :
+ fi
+
+ pathcomp=$pathcomp/
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd "$dst" &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename "$dst"`
+ else
+ dstfile=`basename "$dst" $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename "$dst"`
+ else
+ :
+ fi
+
+# Make a couple of temp file names in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+ rmtmp=$dstdir/#rm.$$#
+
+# Trap to clean up temp files at exit.
+
+ trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
+ trap '(exit $?); exit' 1 2 13 15
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd "$src" "$dsttmp" &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
+
+# Now remove or move aside any old file at destination location. We try this
+# two ways since rm can't unlink itself on some systems and the destination
+# file might be busy for other reasons. In this case, the final cleanup
+# might fail but the new file should still install successfully.
+
+{
+ if [ -f "$dstdir/$dstfile" ]
+ then
+ $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
+ $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
+ {
+ echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+ (exit 1); exit
+ }
+ else
+ :
+ fi
+} &&
+
+# Now rename the file to the real destination.
+
+ $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+
+fi &&
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+
+{
+ (exit 0); exit
+}
diff --git a/moses/ltmain.sh b/moses/ltmain.sh
new file mode 100644
index 000000000..b36e997fe
--- /dev/null
+++ b/moses/ltmain.sh
@@ -0,0 +1,6343 @@
+# ltmain.sh - Provide generalized library-building support services.
+# NOTE: Changing this file will not affect anything until you rerun configure.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003
+# Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# 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 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Check that we have a working $echo.
+if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X$1" = X--fallback-echo; then
+ # Avoid inline document here, it may be left over
+ :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+ # Yippee, $echo works!
+ :
+else
+ # Restart under the correct shell, and then maybe $echo will work.
+ exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<EOF
+$*
+EOF
+ exit 0
+fi
+
+# The name of this program.
+progname=`$echo "$0" | ${SED} 's%^.*/%%'`
+modename="$progname"
+
+# Constants.
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=1.5a
+TIMESTAMP=" (1.1240 2003/06/26 06:55:19)"
+
+default_mode=
+help="Try \`$progname --help' for more information."
+magic="%%%MAGIC variable%%%"
+mkdir="mkdir"
+mv="mv -f"
+rm="rm -f"
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+# test EBCDIC or ASCII
+case `echo A|tr A '\301'` in
+ A) # EBCDIC based system
+ SP2NL="tr '\100' '\n'"
+ NL2SP="tr '\r\n' '\100\100'"
+ ;;
+ *) # Assume ASCII based system
+ SP2NL="tr '\040' '\012'"
+ NL2SP="tr '\015\012' '\040\040'"
+ ;;
+esac
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+# We save the old values to restore during execute mode.
+if test "${LC_ALL+set}" = set; then
+ save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
+fi
+if test "${LANG+set}" = set; then
+ save_LANG="$LANG"; LANG=C; export LANG
+fi
+
+# Make sure IFS has a sensible default
+: ${IFS=" "}
+
+if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+ $echo "$modename: not configured to build any kind of library" 1>&2
+ $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
+ exit 1
+fi
+
+# Global variables.
+mode=$default_mode
+nonopt=
+prev=
+prevopt=
+run=
+show="$echo"
+show_help=
+execute_dlfiles=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+
+#####################################
+# Shell function definitions:
+# This seems to be the best place for them
+
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+win32_libid () {
+ win32_libid_type="unknown"
+ win32_fileres=`file -L $1 2>/dev/null`
+ case $win32_fileres in
+ *ar\ archive\ import\ library*) # definitely import
+ win32_libid_type="x86 archive import"
+ ;;
+ *ar\ archive*) # could be an import, or static
+ if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
+ grep -E 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+ win32_nmres=`eval $NM -f posix -A $1 | \
+ sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
+ if test "X$win32_nmres" = "Ximport" ; then
+ win32_libid_type="x86 archive import"
+ else
+ win32_libid_type="x86 archive static"
+ fi
+ fi
+ ;;
+ *DLL*)
+ win32_libid_type="x86 DLL"
+ ;;
+ *executable*) # but shell scripts are "executable" too...
+ case $win32_fileres in
+ *MS\ Windows\ PE\ Intel*)
+ win32_libid_type="x86 DLL"
+ ;;
+ esac
+ ;;
+ esac
+ $echo $win32_libid_type
+}
+
+# End of Shell function definitions
+#####################################
+
+# Parse our command line options once, thoroughly.
+while test "$#" -gt 0
+do
+ arg="$1"
+ shift
+
+ case $arg in
+ -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case $prev in
+ execute_dlfiles)
+ execute_dlfiles="$execute_dlfiles $arg"
+ ;;
+ tag)
+ tagname="$arg"
+
+ # Check whether tagname contains only valid characters
+ case $tagname in
+ *[!-_A-Za-z0-9,/]*)
+ $echo "$progname: invalid tag name: $tagname" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case $tagname in
+ CC)
+ # Don't test for the "default" C tag, as we know, it's there, but
+ # not specially marked.
+ ;;
+ *)
+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then
+ taglist="$taglist $tagname"
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $0`"
+ else
+ $echo "$progname: ignoring unknown tag $tagname" 1>&2
+ fi
+ ;;
+ esac
+ ;;
+ *)
+ eval "$prev=\$arg"
+ ;;
+ esac
+
+ prev=
+ prevopt=
+ continue
+ fi
+
+ # Have we seen a non-optional argument yet?
+ case $arg in
+ --help)
+ show_help=yes
+ ;;
+
+ --version)
+ $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
+ $echo
+ $echo "Copyright (C) 2003 Free Software Foundation, Inc."
+ $echo "This is free software; see the source for copying conditions. There is NO"
+ $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+ exit 0
+ ;;
+
+ --config)
+ ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
+ # Now print the configurations for the tags.
+ for tagname in $taglist; do
+ ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$0"
+ done
+ exit 0
+ ;;
+
+ --debug)
+ $echo "$progname: enabling shell trace mode"
+ set -x
+ ;;
+
+ --dry-run | -n)
+ run=:
+ ;;
+
+ --features)
+ $echo "host: $host"
+ if test "$build_libtool_libs" = yes; then
+ $echo "enable shared libraries"
+ else
+ $echo "disable shared libraries"
+ fi
+ if test "$build_old_libs" = yes; then
+ $echo "enable static libraries"
+ else
+ $echo "disable static libraries"
+ fi
+ exit 0
+ ;;
+
+ --finish) mode="finish" ;;
+
+ --mode) prevopt="--mode" prev=mode ;;
+ --mode=*) mode="$optarg" ;;
+
+ --preserve-dup-deps) duplicate_deps="yes" ;;
+
+ --quiet | --silent)
+ show=:
+ ;;
+
+ --tag) prevopt="--tag" prev=tag ;;
+ --tag=*)
+ set tag "$optarg" ${1+"$@"}
+ shift
+ prev=tag
+ ;;
+
+ -dlopen)
+ prevopt="-dlopen"
+ prev=execute_dlfiles
+ ;;
+
+ -*)
+ $echo "$modename: unrecognized option \`$arg'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+
+ *)
+ nonopt="$arg"
+ break
+ ;;
+ esac
+done
+
+if test -n "$prevopt"; then
+ $echo "$modename: option \`$prevopt' requires an argument" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+fi
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end. This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+if test -z "$show_help"; then
+
+ # Infer the operation mode.
+ if test -z "$mode"; then
+ $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
+ $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
+ case $nonopt in
+ *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
+ mode=link
+ for arg
+ do
+ case $arg in
+ -c)
+ mode=compile
+ break
+ ;;
+ esac
+ done
+ ;;
+ *db | *dbx | *strace | *truss)
+ mode=execute
+ ;;
+ *install*|cp|mv)
+ mode=install
+ ;;
+ *rm)
+ mode=uninstall
+ ;;
+ *)
+ # If we have no mode, but dlfiles were specified, then do execute mode.
+ test -n "$execute_dlfiles" && mode=execute
+
+ # Just use the default operation mode.
+ if test -z "$mode"; then
+ if test -n "$nonopt"; then
+ $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
+ else
+ $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
+ fi
+ fi
+ ;;
+ esac
+ fi
+
+ # Only execute mode is allowed to have -dlopen flags.
+ if test -n "$execute_dlfiles" && test "$mode" != execute; then
+ $echo "$modename: unrecognized option \`-dlopen'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Change the help message to a mode-specific one.
+ generic_help="$help"
+ help="Try \`$modename --help --mode=$mode' for more information."
+
+ # These modes are in order of execution frequency so that they run quickly.
+ case $mode in
+ # libtool compile mode
+ compile)
+ modename="$modename: compile"
+ # Get the compilation command and the source file.
+ base_compile=
+ srcfile="$nonopt" # always keep a non-empty value in "srcfile"
+ suppress_output=
+ arg_mode=normal
+ libobj=
+
+ for arg
+ do
+ case "$arg_mode" in
+ arg )
+ # do not "continue". Instead, add this to base_compile
+ lastarg="$arg"
+ arg_mode=normal
+ ;;
+
+ target )
+ libobj="$arg"
+ arg_mode=normal
+ continue
+ ;;
+
+ normal )
+ # Accept any command-line options.
+ case $arg in
+ -o)
+ if test -n "$libobj" ; then
+ $echo "$modename: you cannot specify \`-o' more than once" 1>&2
+ exit 1
+ fi
+ arg_mode=target
+ continue
+ ;;
+
+ -static)
+ build_old_libs=yes
+ continue
+ ;;
+
+ -prefer-pic)
+ pic_mode=yes
+ continue
+ ;;
+
+ -prefer-non-pic)
+ pic_mode=no
+ continue
+ ;;
+
+ -Xcompiler)
+ arg_mode=arg # the next one goes into the "base_compile" arg list
+ continue # The current "srcfile" will either be retained or
+ ;; # replaced later. I would guess that would be a bug.
+
+ -Wc,*)
+ args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
+ lastarg=
+ save_ifs="$IFS"; IFS=','
+ for arg in $args; do
+ IFS="$save_ifs"
+
+ # Double-quote args containing other shell metacharacters.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ arg="\"$arg\""
+ ;;
+ esac
+ lastarg="$lastarg $arg"
+ done
+ IFS="$save_ifs"
+ lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
+
+ # Add the arguments to base_compile.
+ base_compile="$base_compile $lastarg"
+ continue
+ ;;
+
+ * )
+ # Accept the current argument as the source file.
+ # The previous "srcfile" becomes the current argument.
+ #
+ lastarg="$srcfile"
+ srcfile="$arg"
+ ;;
+ esac # case $arg
+ ;;
+ esac # case $arg_mode
+
+ # Aesthetically quote the previous argument.
+ lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
+
+ case $lastarg in
+ # Double-quote args containing other shell metacharacters.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ lastarg="\"$lastarg\""
+ ;;
+ esac
+
+ base_compile="$base_compile $lastarg"
+ done # for arg
+
+ case $arg_mode in
+ arg)
+ $echo "$modename: you must specify an argument for -Xcompile"
+ exit 1
+ ;;
+ target)
+ $echo "$modename: you must specify a target with \`-o'" 1>&2
+ exit 1
+ ;;
+ *)
+ # Get the name of the library object.
+ [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
+ ;;
+ esac
+
+ # Recognize several different file suffixes.
+ # If the user specifies -o file.o, it is replaced with file.lo
+ xform='[cCFSifmso]'
+ case $libobj in
+ *.ada) xform=ada ;;
+ *.adb) xform=adb ;;
+ *.ads) xform=ads ;;
+ *.asm) xform=asm ;;
+ *.c++) xform=c++ ;;
+ *.cc) xform=cc ;;
+ *.ii) xform=ii ;;
+ *.class) xform=class ;;
+ *.cpp) xform=cpp ;;
+ *.cxx) xform=cxx ;;
+ *.f90) xform=f90 ;;
+ *.for) xform=for ;;
+ *.java) xform=java ;;
+ esac
+
+ libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
+
+ case $libobj in
+ *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
+ *)
+ $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
+ exit 1
+ ;;
+ esac
+
+ # Infer tagged configuration to use if any are available and
+ # if one wasn't chosen via the "--tag" command line option.
+ # Only attempt this if the compiler in the base compile
+ # command doesn't match the default compiler.
+ if test -n "$available_tags" && test -z "$tagname"; then
+ case $base_compile in
+ # Blanks in the command may have been stripped by the calling shell,
+ # but not from the CC environment variable when configure was run.
+ " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "*) ;;
+ # Blanks at the start of $base_compile will cause this to fail
+ # if we don't check for them as well.
+ *)
+ for z in $available_tags; do
+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
+ case "$base_compile " in
+ "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*)
+ # The compiler in the base compile command matches
+ # the one in the tagged configuration.
+ # Assume this is the tagged configuration we want.
+ tagname=$z
+ break
+ ;;
+ esac
+ fi
+ done
+ # If $tagname still isn't set, then no tagged configuration
+ # was found and let the user know that the "--tag" command
+ # line option must be used.
+ if test -z "$tagname"; then
+ $echo "$modename: unable to infer tagged configuration"
+ $echo "$modename: specify a tag with \`--tag'" 1>&2
+ exit 1
+# else
+# $echo "$modename: using $tagname tagged configuration"
+ fi
+ ;;
+ esac
+ fi
+
+ objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+ xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$obj"; then
+ xdir=
+ else
+ xdir=$xdir/
+ fi
+ lobj=${xdir}$objdir/$objname
+
+ if test -z "$base_compile"; then
+ $echo "$modename: you must specify a compilation command" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Delete any leftover library objects.
+ if test "$build_old_libs" = yes; then
+ removelist="$obj $lobj $libobj ${libobj}T"
+ else
+ removelist="$lobj $libobj ${libobj}T"
+ fi
+
+ $run $rm $removelist
+ trap "$run $rm $removelist; exit 1" 1 2 15
+
+ # On Cygwin there's no "real" PIC flag so we must build both object types
+ case $host_os in
+ cygwin* | mingw* | pw32* | os2*)
+ pic_mode=default
+ ;;
+ esac
+ if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+ # non-PIC code in shared libraries is not supported
+ pic_mode=default
+ fi
+
+ # Calculate the filename of the output object if compiler does
+ # not support -o with -c
+ if test "$compiler_c_o" = no; then
+ output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+ lockfile="$output_obj.lock"
+ removelist="$removelist $output_obj $lockfile"
+ trap "$run $rm $removelist; exit 1" 1 2 15
+ else
+ output_obj=
+ need_locks=no
+ lockfile=
+ fi
+
+ # Lock this critical section if it is needed
+ # We use this script file to make the link, it avoids creating a new file
+ if test "$need_locks" = yes; then
+ until $run ln "$0" "$lockfile" 2>/dev/null; do
+ $show "Waiting for $lockfile to be removed"
+ sleep 2
+ done
+ elif test "$need_locks" = warn; then
+ if test -f "$lockfile"; then
+ $echo "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $run $rm $removelist
+ exit 1
+ fi
+ $echo $srcfile > "$lockfile"
+ fi
+
+ if test -n "$fix_srcfile_path"; then
+ eval srcfile=\"$fix_srcfile_path\"
+ fi
+
+ $run $rm "$libobj" "${libobj}T"
+
+ # Create a libtool object file (analogous to a ".la" file),
+ # but don't create it if we're doing a dry run.
+ test -z "$run" && cat > ${libobj}T <<EOF
+# $libobj - a libtool object file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+EOF
+
+ # Only build a PIC object if we are building libtool libraries.
+ if test "$build_libtool_libs" = yes; then
+ # Without this assignment, base_compile gets emptied.
+ fbsd_hideous_sh_bug=$base_compile
+
+ if test "$pic_mode" != no; then
+ command="$base_compile $srcfile $pic_flag"
+ else
+ # Don't build PIC code
+ command="$base_compile $srcfile"
+ fi
+
+ if test ! -d "${xdir}$objdir"; then
+ $show "$mkdir ${xdir}$objdir"
+ $run $mkdir ${xdir}$objdir
+ status=$?
+ if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
+ exit $status
+ fi
+ fi
+
+ if test -z "$output_obj"; then
+ # Place PIC objects in $objdir
+ command="$command -o $lobj"
+ fi
+
+ $run $rm "$lobj" "$output_obj"
+
+ $show "$command"
+ if $run eval "$command"; then :
+ else
+ test -n "$output_obj" && $run $rm $removelist
+ exit 1
+ fi
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $run $rm $removelist
+ exit 1
+ fi
+
+ # Just move the object if needed, then go on to compile the next one
+ if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+ $show "$mv $output_obj $lobj"
+ if $run $mv $output_obj $lobj; then :
+ else
+ error=$?
+ $run $rm $removelist
+ exit $error
+ fi
+ fi
+
+ # Append the name of the PIC object to the libtool object file.
+ test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object='$objdir/$objname'
+
+EOF
+
+ # Allow error messages only from the first compilation.
+ suppress_output=' >/dev/null 2>&1'
+ else
+ # No PIC object so indicate it doesn't exist in the libtool
+ # object file.
+ test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object=none
+
+EOF
+ fi
+
+ # Only build a position-dependent object if we build old libraries.
+ if test "$build_old_libs" = yes; then
+ if test "$pic_mode" != yes; then
+ # Don't build PIC code
+ command="$base_compile $srcfile"
+ else
+ command="$base_compile $srcfile $pic_flag"
+ fi
+ if test "$compiler_c_o" = yes; then
+ command="$command -o $obj"
+ fi
+
+ # Suppress compiler output if we already did a PIC compilation.
+ command="$command$suppress_output"
+ $run $rm "$obj" "$output_obj"
+ $show "$command"
+ if $run eval "$command"; then :
+ else
+ $run $rm $removelist
+ exit 1
+ fi
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $run $rm $removelist
+ exit 1
+ fi
+
+ # Just move the object if needed
+ if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+ $show "$mv $output_obj $obj"
+ if $run $mv $output_obj $obj; then :
+ else
+ error=$?
+ $run $rm $removelist
+ exit $error
+ fi
+ fi
+
+ # Append the name of the non-PIC object the libtool object file.
+ # Only append if the libtool object file exists.
+ test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object='$objname'
+
+EOF
+ else
+ # Append the name of the non-PIC object the libtool object file.
+ # Only append if the libtool object file exists.
+ test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object=none
+
+EOF
+ fi
+
+ $run $mv "${libobj}T" "${libobj}"
+
+ # Unlock the critical section if it was locked
+ if test "$need_locks" != no; then
+ $run $rm "$lockfile"
+ fi
+
+ exit 0
+ ;;
+
+ # libtool link mode
+ link | relink)
+ modename="$modename: link"
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ # It is impossible to link a dll without this setting, and
+ # we shouldn't force the makefile maintainer to figure out
+ # which system we are compiling for in order to pass an extra
+ # flag for every libtool invocation.
+ # allow_undefined=no
+
+ # FIXME: Unfortunately, there are problems with the above when trying
+ # to make a dll which has undefined symbols, in which case not
+ # even a static library is built. For now, we need to specify
+ # -no-undefined on the libtool link line when we can be certain
+ # that all symbols are satisfied, otherwise we get a static library.
+ allow_undefined=yes
+ ;;
+ *)
+ allow_undefined=yes
+ ;;
+ esac
+ libtool_args="$nonopt"
+ base_compile="$nonopt"
+ compile_command="$nonopt"
+ finalize_command="$nonopt"
+
+ compile_rpath=
+ finalize_rpath=
+ compile_shlibpath=
+ finalize_shlibpath=
+ convenience=
+ old_convenience=
+ deplibs=
+ old_deplibs=
+ add_flags=
+ compiler_flags=
+ linker_flags=
+ dllsearchpath=
+ lib_search_path=`pwd`
+ inst_prefix_dir=
+
+ avoid_version=no
+ dlfiles=
+ dlprefiles=
+ dlself=no
+ export_dynamic=no
+ export_symbols=
+ export_symbols_regex=
+ generated=
+ libobjs=
+ ltlibs=
+ module=no
+ no_install=no
+ objs=
+ non_pic_objects=
+ prefer_static_libs=no
+ preload=no
+ prev=
+ prevarg=
+ release=
+ rpath=
+ xrpath=
+ perm_rpath=
+ temp_rpath=
+ thread_safe=no
+ vinfo=
+ vinfo_number=no
+
+ # We need to know -static, to get the right output filenames.
+ for arg
+ do
+ case $arg in
+ -all-static | -static)
+ if test "X$arg" = "X-all-static"; then
+ if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+ $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
+ fi
+ if test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ else
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ fi
+ build_libtool_libs=no
+ build_old_libs=yes
+ prefer_static_libs=yes
+ break
+ ;;
+ esac
+ done
+
+ # See if our shared archives depend on static archives.
+ test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+ # Go through the arguments, transforming them on the way.
+ while test "$#" -gt 0; do
+ arg="$1"
+ base_compile="$base_compile $arg"
+ shift
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
+ ;;
+ *) qarg=$arg ;;
+ esac
+ libtool_args="$libtool_args $qarg"
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case $prev in
+ output)
+ compile_command="$compile_command @OUTPUT@"
+ finalize_command="$finalize_command @OUTPUT@"
+ ;;
+ esac
+
+ case $prev in
+ dlfiles|dlprefiles)
+ if test "$preload" = no; then
+ # Add the symbol object into the linking commands.
+ compile_command="$compile_command @SYMFILE@"
+ finalize_command="$finalize_command @SYMFILE@"
+ preload=yes
+ fi
+ case $arg in
+ *.la | *.lo) ;; # We handle these cases below.
+ force)
+ if test "$dlself" = no; then
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ self)
+ if test "$prev" = dlprefiles; then
+ dlself=yes
+ elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+ dlself=yes
+ else
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ *)
+ if test "$prev" = dlfiles; then
+ dlfiles="$dlfiles $arg"
+ else
+ dlprefiles="$dlprefiles $arg"
+ fi
+ prev=
+ continue
+ ;;
+ esac
+ ;;
+ expsyms)
+ export_symbols="$arg"
+ if test ! -f "$arg"; then
+ $echo "$modename: symbol file \`$arg' does not exist"
+ exit 1
+ fi
+ prev=
+ continue
+ ;;
+ expsyms_regex)
+ export_symbols_regex="$arg"
+ prev=
+ continue
+ ;;
+ inst_prefix)
+ inst_prefix_dir="$arg"
+ prev=
+ continue
+ ;;
+ release)
+ release="-$arg"
+ prev=
+ continue
+ ;;
+ objectlist)
+ if test -f "$arg"; then
+ save_arg=$arg
+ moreargs=
+ for fil in `cat $save_arg`
+ do
+# moreargs="$moreargs $fil"
+ arg=$fil
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ # If there is no directory component, then add one.
+ case $arg in
+ */* | *\\*) . $arg ;;
+ *) . ./$arg ;;
+ esac
+
+ if test -z "$pic_object" || \
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none && \
+ test "$non_pic_object" = none; then
+ $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+ exit 1
+ fi
+
+ # Extract subdirectory from the argument.
+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$arg"; then
+ xdir=
+ else
+ xdir="$xdir/"
+ fi
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ dlfiles="$dlfiles $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ dlprefiles="$dlprefiles $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ libobjs="$libobjs $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ non_pic_objects="$non_pic_objects $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if test -z "$run"; then
+ $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+ exit 1
+ else
+ # Dry-run case.
+
+ # Extract subdirectory from the argument.
+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$arg"; then
+ xdir=
+ else
+ xdir="$xdir/"
+ fi
+
+ pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+ non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+ libobjs="$libobjs $pic_object"
+ non_pic_objects="$non_pic_objects $non_pic_object"
+ fi
+ fi
+ done
+ else
+ $echo "$modename: link input file \`$save_arg' does not exist"
+ exit 1
+ fi
+ arg=$save_arg
+ prev=
+ continue
+ ;;
+ rpath | xrpath)
+ # We need an absolute path.
+ case $arg in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ $echo "$modename: only absolute run-paths are allowed" 1>&2
+ exit 1
+ ;;
+ esac
+ if test "$prev" = rpath; then
+ case "$rpath " in
+ *" $arg "*) ;;
+ *) rpath="$rpath $arg" ;;
+ esac
+ else
+ case "$xrpath " in
+ *" $arg "*) ;;
+ *) xrpath="$xrpath $arg" ;;
+ esac
+ fi
+ prev=
+ continue
+ ;;
+ xcompiler)
+ compiler_flags="$compiler_flags $qarg"
+ prev=
+ compile_command="$compile_command $qarg"
+ finalize_command="$finalize_command $qarg"
+ continue
+ ;;
+ xlinker)
+ linker_flags="$linker_flags $qarg"
+ compiler_flags="$compiler_flags $wl$qarg"
+ prev=
+ compile_command="$compile_command $wl$qarg"
+ finalize_command="$finalize_command $wl$qarg"
+ continue
+ ;;
+ xcclinker)
+ linker_flags="$linker_flags $qarg"
+ compiler_flags="$compiler_flags $qarg"
+ prev=
+ compile_command="$compile_command $qarg"
+ finalize_command="$finalize_command $qarg"
+ continue
+ ;;
+ *)
+ eval "$prev=\"\$arg\""
+ prev=
+ continue
+ ;;
+ esac
+ fi # test -n "$prev"
+
+ prevarg="$arg"
+
+ case $arg in
+ -all-static)
+ if test -n "$link_static_flag"; then
+ compile_command="$compile_command $link_static_flag"
+ finalize_command="$finalize_command $link_static_flag"
+ fi
+ continue
+ ;;
+
+ -allow-undefined)
+ # FIXME: remove this flag sometime in the future.
+ $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
+ continue
+ ;;
+
+ -avoid-version)
+ avoid_version=yes
+ continue
+ ;;
+
+ -dlopen)
+ prev=dlfiles
+ continue
+ ;;
+
+ -dlpreopen)
+ prev=dlprefiles
+ continue
+ ;;
+
+ -export-dynamic)
+ export_dynamic=yes
+ continue
+ ;;
+
+ -export-symbols | -export-symbols-regex)
+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+ $echo "$modename: more than one -exported-symbols argument is not allowed"
+ exit 1
+ fi
+ if test "X$arg" = "X-export-symbols"; then
+ prev=expsyms
+ else
+ prev=expsyms_regex
+ fi
+ continue
+ ;;
+
+ -inst-prefix-dir)
+ prev=inst_prefix
+ continue
+ ;;
+
+ # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+ # so, if we see these flags be careful not to treat them like -L
+ -L[A-Z][A-Z]*:*)
+ case $with_gcc/$host in
+ no/*-*-irix* | /*-*-irix*)
+ compile_command="$compile_command $arg"
+ finalize_command="$finalize_command $arg"
+ ;;
+ esac
+ continue
+ ;;
+
+ -L*)
+ dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ if test -z "$absdir"; then
+ $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
+ exit 1
+ fi
+ dir="$absdir"
+ ;;
+ esac
+ case "$deplibs " in
+ *" -L$dir "*) ;;
+ *)
+ deplibs="$deplibs -L$dir"
+ lib_search_path="$lib_search_path $dir"
+ ;;
+ esac
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ case :$dllsearchpath: in
+ *":$dir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$dir";;
+ esac
+ ;;
+ esac
+ continue
+ ;;
+
+ -l*)
+ if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+ case $host in
+ *-*-cygwin* | *-*-pw32* | *-*-beos*)
+ # These systems don't actually have a C or math library (as such)
+ continue
+ ;;
+ *-*-freebsd*-gnu*)
+ # prevent being parsed by the freebsd regexp below
+ ;;
+ *-*-mingw* | *-*-os2*)
+ # These systems don't actually have a C library (as such)
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-openbsd* | *-*-freebsd*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C and math libraries are in the System framework
+ deplibs="$deplibs -framework System"
+ continue
+ esac
+ elif test "X$arg" = "X-lc_r"; then
+ case $host in
+ *-*-freebsd*-gnu*)
+ # prevent being parsed by the freebsd regexp below
+ ;;
+ *-*-openbsd*)
+ # Do not include libc_r directly, use -pthread flag.
+ continue
+ ;;
+ esac
+ fi
+ deplibs="$deplibs $arg"
+ continue
+ ;;
+
+ -module)
+ module=yes
+ continue
+ ;;
+
+ # gcc -m* arguments should be passed to the linker via $compiler_flags
+ # in order to pass architecture information to the linker
+ # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
+ # but this is not reliable with gcc because gcc may use -mfoo to
+ # select a different linker, different libraries, etc, while
+ # -Wl,-mfoo simply passes -mfoo to the linker.
+ -m*)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ arg="\"$arg\""
+ ;;
+ esac
+ compile_command="$compile_command $arg"
+ finalize_command="$finalize_command $arg"
+ if test "$with_gcc" = "yes" ; then
+ compiler_flags="$compiler_flags $arg"
+ fi
+ continue
+ ;;
+
+ -shrext)
+ prev=shrext
+ continue
+ ;;
+
+ -no-fast-install)
+ fast_install=no
+ continue
+ ;;
+
+ -no-install)
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ # The PATH hackery in wrapper scripts is required on Windows
+ # in order for the loader to find any dlls it needs.
+ $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
+ $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
+ fast_install=no
+ ;;
+ *) no_install=yes ;;
+ esac
+ continue
+ ;;
+
+ -no-undefined)
+ allow_undefined=no
+ continue
+ ;;
+
+ -objectlist)
+ prev=objectlist
+ continue
+ ;;
+
+ -o) prev=output ;;
+
+ -release)
+ prev=release
+ continue
+ ;;
+
+ -rpath)
+ prev=rpath
+ continue
+ ;;
+
+ -R)
+ prev=xrpath
+ continue
+ ;;
+
+ -R*)
+ dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ $echo "$modename: only absolute run-paths are allowed" 1>&2
+ exit 1
+ ;;
+ esac
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) xrpath="$xrpath $dir" ;;
+ esac
+ continue
+ ;;
+
+ -static)
+ # The effects of -static are defined in a previous loop.
+ # We used to do the same as -all-static on platforms that
+ # didn't have a PIC flag, but the assumption that the effects
+ # would be equivalent was wrong. It would break on at least
+ # Digital Unix and AIX.
+ continue
+ ;;
+
+ -thread-safe)
+ thread_safe=yes
+ continue
+ ;;
+
+ -version-info)
+ prev=vinfo
+ continue
+ ;;
+ -version-number)
+ prev=vinfo
+ vinfo_number=yes
+ continue
+ ;;
+
+ -Wc,*)
+ args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ case $flag in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ flag="\"$flag\""
+ ;;
+ esac
+ arg="$arg $wl$flag"
+ compiler_flags="$compiler_flags $flag"
+ done
+ IFS="$save_ifs"
+ arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+ ;;
+
+ -Wl,*)
+ args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ case $flag in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ flag="\"$flag\""
+ ;;
+ esac
+ arg="$arg $wl$flag"
+ compiler_flags="$compiler_flags $wl$flag"
+ linker_flags="$linker_flags $flag"
+ done
+ IFS="$save_ifs"
+ arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+ ;;
+
+ -Xcompiler)
+ prev=xcompiler
+ continue
+ ;;
+
+ -Xlinker)
+ prev=xlinker
+ continue
+ ;;
+
+ -XCClinker)
+ prev=xcclinker
+ continue
+ ;;
+
+ # Some other compiler flag.
+ -* | +*)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ arg="\"$arg\""
+ ;;
+ esac
+ add_flags="$add_flags $arg"
+ ;;
+
+ *.$objext)
+ # A standard object.
+ objs="$objs $arg"
+ ;;
+
+ *.lo)
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ # If there is no directory component, then add one.
+ case $arg in
+ */* | *\\*) . $arg ;;
+ *) . ./$arg ;;
+ esac
+
+ if test -z "$pic_object" || \
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none && \
+ test "$non_pic_object" = none; then
+ $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+ exit 1
+ fi
+
+ # Extract subdirectory from the argument.
+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$arg"; then
+ xdir=
+ else
+ xdir="$xdir/"
+ fi
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ dlfiles="$dlfiles $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ dlprefiles="$dlprefiles $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ libobjs="$libobjs $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ non_pic_objects="$non_pic_objects $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if test -z "$run"; then
+ $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+ exit 1
+ else
+ # Dry-run case.
+
+ # Extract subdirectory from the argument.
+ xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$xdir" = "X$arg"; then
+ xdir=
+ else
+ xdir="$xdir/"
+ fi
+
+ pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+ non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+ libobjs="$libobjs $pic_object"
+ non_pic_objects="$non_pic_objects $non_pic_object"
+ fi
+ fi
+ ;;
+
+ *.$libext)
+ # An archive.
+ deplibs="$deplibs $arg"
+ old_deplibs="$old_deplibs $arg"
+ continue
+ ;;
+
+ *.la)
+ # A libtool-controlled library.
+
+ if test "$prev" = dlfiles; then
+ # This library was specified with -dlopen.
+ dlfiles="$dlfiles $arg"
+ prev=
+ elif test "$prev" = dlprefiles; then
+ # The library was specified with -dlpreopen.
+ dlprefiles="$dlprefiles $arg"
+ prev=
+ else
+ deplibs="$deplibs $arg"
+ fi
+ continue
+ ;;
+
+ # Some other compiler argument.
+ *)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ arg="\"$arg\""
+ ;;
+ esac
+ add_flags="$add_flags $arg"
+ ;;
+ esac # arg
+
+ # Now actually substitute the argument into the commands.
+ if test -n "$arg"; then
+ compile_command="$compile_command $arg"
+ finalize_command="$finalize_command $arg"
+ fi
+ done # argument parsing loop
+
+ if test -n "$prev"; then
+ $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Infer tagged configuration to use if any are available and
+ # if one wasn't chosen via the "--tag" command line option.
+ # Only attempt this if the compiler in the base link
+ # command doesn't match the default compiler.
+ if test -n "$available_tags" && test -z "$tagname"; then
+ case $base_compile in
+ # Blanks in the command may have been stripped by the calling shell,
+ # but not from the CC environment variable when configure was run.
+ "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) ;;
+ # Blanks at the start of $base_compile will cause this to fail
+ # if we don't check for them as well.
+ *)
+ for z in $available_tags; do
+ if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
+ case $base_compile in
+ "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*)
+ # The compiler in $compile_command matches
+ # the one in the tagged configuration.
+ # Assume this is the tagged configuration we want.
+ tagname=$z
+ break
+ ;;
+ esac
+ fi
+ done
+ # If $tagname still isn't set, then no tagged configuration
+ # was found and let the user know that the "--tag" command
+ # line option must be used.
+ if test -z "$tagname"; then
+ $echo "$modename: unable to infer tagged configuration"
+ $echo "$modename: specify a tag with \`--tag'" 1>&2
+ exit 1
+# else
+# $echo "$modename: using $tagname tagged configuration"
+ fi
+ ;;
+ esac
+ fi
+
+ if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+ eval arg=\"$export_dynamic_flag_spec\"
+ compile_command="$compile_command $arg"
+ finalize_command="$finalize_command $arg"
+ fi
+
+ oldlibs=
+ # calculate the name of the file, without its directory
+ outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
+ libobjs_save="$libobjs"
+
+ if test -n "$shlibpath_var"; then
+ # get the directories listed in $shlibpath_var
+ eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+ else
+ shlib_search_path=
+ fi
+ eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+ eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+ output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$output_objdir" = "X$output"; then
+ output_objdir="$objdir"
+ else
+ output_objdir="$output_objdir/$objdir"
+ fi
+ # Create the object directory.
+ if test ! -d "$output_objdir"; then
+ $show "$mkdir $output_objdir"
+ $run $mkdir $output_objdir
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$output_objdir"; then
+ exit $status
+ fi
+ fi
+
+ # Determine the type of output
+ case $output in
+ "")
+ $echo "$modename: you must specify an output file" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+ *.$libext) linkmode=oldlib ;;
+ *.lo | *.$objext) linkmode=obj ;;
+ *.la) linkmode=lib ;;
+ *) linkmode=prog ;; # Anything else should be a program.
+ esac
+
+ case $host in
+ *cygwin* | *mingw* | *pw32*)
+ # don't eliminate duplcations in $postdeps and $predeps
+ duplicate_compiler_generated_deps=yes
+ ;;
+ *)
+ duplicate_compiler_generated_deps=$duplicate_deps
+ ;;
+ esac
+ specialdeplibs=
+
+ libs=
+ # Find all interdependent deplibs by searching for libraries
+ # that are linked more than once (e.g. -la -lb -la)
+ for deplib in $deplibs; do
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ libs="$libs $deplib"
+ done
+
+ if test "$linkmode" = lib; then
+ libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+ # Compute libraries that are listed more than once in $predeps
+ # $postdeps and mark them as special (i.e., whose duplicates are
+ # not to be eliminated).
+ pre_post_deps=
+ if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
+ for pre_post_dep in $predeps $postdeps; do
+ case "$pre_post_deps " in
+ *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+ esac
+ pre_post_deps="$pre_post_deps $pre_post_dep"
+ done
+ fi
+ pre_post_deps=
+ fi
+
+ deplibs=
+ newdependency_libs=
+ newlib_search_path=
+ need_relink=no # whether we're linking any uninstalled libtool libraries
+ notinst_deplibs= # not-installed libtool libraries
+ notinst_path= # paths that contain not-installed libtool libraries
+ case $linkmode in
+ lib)
+ passes="conv link"
+ for file in $dlfiles $dlprefiles; do
+ case $file in
+ *.la) ;;
+ *)
+ $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+ ;;
+ prog)
+ compile_deplibs=
+ finalize_deplibs=
+ alldeplibs=no
+ newdlfiles=
+ newdlprefiles=
+ passes="conv scan dlopen dlpreopen link"
+ ;;
+ *) passes="conv"
+ ;;
+ esac
+ for pass in $passes; do
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan"; then
+ libs="$deplibs"
+ deplibs=
+ fi
+ if test "$linkmode" = prog; then
+ case $pass in
+ dlopen) libs="$dlfiles" ;;
+ dlpreopen) libs="$dlprefiles" ;;
+ link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+ esac
+ fi
+ if test "$pass" = dlopen; then
+ # Collect dlpreopened libraries
+ save_deplibs="$deplibs"
+ deplibs=
+ fi
+ for deplib in $libs; do
+ lib=
+ found=no
+ case $deplib in
+ -l*)
+ if test "$linkmode" != lib && test "$linkmode" != prog; then
+ $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
+ continue
+ fi
+ if test "$pass" = conv && test "$allow_undefined" = yes; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
+ for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ for search_ext in .la $shrext .so .a; do
+ # Search the libtool library
+ lib="$searchdir/lib${name}${search_ext}"
+ if test -f "$lib"; then
+ if test "$search_ext" = ".la"; then
+ found=yes
+ else
+ found=no
+ fi
+ break 2
+ fi
+ done
+ done
+ if test "$found" != yes; then
+ # deplib doesn't seem to be a libtool library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ else # deplib is a libtool library
+ # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+ # We need to do some special things here, and not later.
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $deplib "*)
+ if (${SED} -e '2q' $lib |
+ grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ library_names=
+ old_library=
+ case $lib in
+ */* | *\\*) . $lib ;;
+ *) . ./$lib ;;
+ esac
+ for l in $old_library $library_names; do
+ ll="$l"
+ done
+ if test "X$ll" = "X$old_library" ; then # only static version available
+ found=no
+ ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$ladir" = "X$lib" && ladir="."
+ lib=$ladir/$old_library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ fi
+ fi
+ ;;
+ *) ;;
+ esac
+ fi
+ fi
+ ;; # -l
+ -L*)
+ case $linkmode in
+ lib)
+ deplibs="$deplib $deplibs"
+ test "$pass" = conv && continue
+ newdependency_libs="$deplib $newdependency_libs"
+ newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+ ;;
+ prog)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ if test "$pass" = scan; then
+ deplibs="$deplib $deplibs"
+ newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ ;;
+ *)
+ $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
+ ;;
+ esac # linkmode
+ continue
+ ;; # -L
+ -R*)
+ if test "$pass" = link; then
+ dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
+ # Make sure the xrpath contains only unique directories.
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) xrpath="$xrpath $dir" ;;
+ esac
+ fi
+ deplibs="$deplib $deplibs"
+ continue
+ ;;
+ *.la) lib="$deplib" ;;
+ *.$libext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ case $linkmode in
+ lib)
+ if test "$deplibs_check_method" != pass_all; then
+ $echo
+ $echo "*** Warning: Trying to link with static lib archive $deplib."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have"
+ $echo "*** because the file extensions .$libext of this argument makes me believe"
+ $echo "*** that it is just a static archive that I should not used here."
+ else
+ $echo
+ $echo "*** Warning: Linking the shared library $output against the"
+ $echo "*** static library $deplib is not portable!"
+ deplibs="$deplib $deplibs"
+ fi
+ continue
+ ;;
+ prog)
+ if test "$pass" != link; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ continue
+ ;;
+ esac # linkmode
+ ;; # *.$libext
+ *.lo | *.$objext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ elif test "$linkmode" = prog; then
+ if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+ # If there is no dlopen support or we're linking statically,
+ # we need to preload.
+ newdlprefiles="$newdlprefiles $deplib"
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ newdlfiles="$newdlfiles $deplib"
+ fi
+ fi
+ continue
+ ;;
+ %DEPLIBS%)
+ alldeplibs=yes
+ continue
+ ;;
+ esac # case $deplib
+ if test "$found" = yes || test -f "$lib"; then :
+ else
+ $echo "$modename: cannot find the library \`$lib'" 1>&2
+ exit 1
+ fi
+
+ # Check to see that this really is a libtool archive.
+ if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ else
+ $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+
+ ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$ladir" = "X$lib" && ladir="."
+
+ dlname=
+ dlopen=
+ dlpreopen=
+ libdir=
+ library_names=
+ old_library=
+ # If the library was installed with an old release of libtool,
+ # it will not redefine variables installed, or shouldnotlink
+ installed=yes
+ shouldnotlink=no
+
+ # Read the .la file
+ case $lib in
+ */* | *\\*) . $lib ;;
+ *) . ./$lib ;;
+ esac
+
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan" ||
+ { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+ test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+ test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+ fi
+
+ if test "$pass" = conv; then
+ # Only check for convenience libraries
+ deplibs="$lib $deplibs"
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ #echo "Adding $deplib to \$deplibs"
+ deplibs="$deplib $deplibs"
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done
+ if test -z "$libdir"; then
+ if test -z "$old_library"; then
+ $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+ exit 1
+ fi
+ # It is a libtool convenience library, so add in its objects.
+ convenience="$convenience $ladir/$objdir/$old_library"
+ old_convenience="$old_convenience $ladir/$objdir/$old_library"
+ elif test "$linkmode" != prog && test "$linkmode" != lib; then
+ $echo "$modename: \`$lib' is not a convenience library" 1>&2
+ exit 1
+ fi
+ continue
+ fi # $pass = conv
+
+
+ # Get the name of the library we link against.
+ linklib=
+ for l in $old_library $library_names; do
+ linklib="$l"
+ done
+ if test -z "$linklib"; then
+ $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+ exit 1
+ fi
+
+ # This library was specified with -dlopen.
+ if test "$pass" = dlopen; then
+ if test -z "$libdir"; then
+ $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
+ exit 1
+ fi
+ if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+ # If there is no dlname, no dlopen support or we're linking
+ # statically, we need to preload. We also need to preload any
+ # dependent libraries so libltdl's deplib preloader doesn't
+ # bomb out in the load deplibs phase.
+ dlprefiles="$dlprefiles $lib $dependency_libs"
+ else
+ newdlfiles="$newdlfiles $lib"
+ fi
+ continue
+ fi # $pass = dlopen
+
+ # We need an absolute path.
+ case $ladir in
+ [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+ *)
+ abs_ladir=`cd "$ladir" && pwd`
+ if test -z "$abs_ladir"; then
+ $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
+ $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
+ abs_ladir="$ladir"
+ fi
+ ;;
+ esac
+ laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+
+ # Find the relevant object directory and library name.
+ if test "X$installed" = Xyes; then
+ if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ $echo "$modename: warning: library \`$lib' was moved." 1>&2
+ dir="$ladir"
+ absdir="$abs_ladir"
+ libdir="$abs_ladir"
+ else
+ dir="$libdir"
+ absdir="$libdir"
+ fi
+ else
+ dir="$ladir/$objdir"
+ absdir="$abs_ladir/$objdir"
+ # Remove this search path later
+ notinst_path="$notinst_path $abs_ladir"
+ fi # $installed = yes
+ name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+
+ # This library was specified with -dlpreopen.
+ if test "$pass" = dlpreopen; then
+ if test -z "$libdir"; then
+ $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
+ exit 1
+ fi
+ # Prefer using a static library (so that no silly _DYNAMIC symbols
+ # are required to link).
+ if test -n "$old_library"; then
+ newdlprefiles="$newdlprefiles $dir/$old_library"
+ # Otherwise, use the dlname, so that lt_dlopen finds it.
+ elif test -n "$dlname"; then
+ newdlprefiles="$newdlprefiles $dir/$dlname"
+ else
+ newdlprefiles="$newdlprefiles $dir/$linklib"
+ fi
+ fi # $pass = dlpreopen
+
+ if test -z "$libdir"; then
+ # Link the convenience library
+ if test "$linkmode" = lib; then
+ deplibs="$dir/$old_library $deplibs"
+ elif test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$dir/$old_library $compile_deplibs"
+ finalize_deplibs="$dir/$old_library $finalize_deplibs"
+ else
+ deplibs="$lib $deplibs" # used for prog,scan pass
+ fi
+ continue
+ fi
+
+
+ if test "$linkmode" = prog && test "$pass" != link; then
+ newlib_search_path="$newlib_search_path $ladir"
+ deplibs="$lib $deplibs"
+
+ linkalldeplibs=no
+ if test "$link_all_deplibs" != no || test -z "$library_names" ||
+ test "$build_libtool_libs" = no; then
+ linkalldeplibs=yes
+ fi
+
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
+ esac
+ # Need to link against all dependency_libs?
+ if test "$linkalldeplibs" = yes; then
+ deplibs="$deplib $deplibs"
+ else
+ # Need to hardcode shared library paths
+ # or/and link against static libraries
+ newdependency_libs="$deplib $newdependency_libs"
+ fi
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done # for deplib
+ continue
+ fi # $linkmode = prog...
+
+ if test "$linkmode,$pass" = "prog,link"; then
+ if test -n "$library_names" &&
+ { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+ # We need to hardcode the library path
+ if test -n "$shlibpath_var"; then
+ # Make sure the rpath contains only unique directories.
+ case "$temp_rpath " in
+ *" $dir "*) ;;
+ *" $absdir "*) ;;
+ *) temp_rpath="$temp_rpath $dir" ;;
+ esac
+ fi
+
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) compile_rpath="$compile_rpath $absdir"
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir"
+ esac
+ ;;
+ esac
+ fi # $linkmode,$pass = prog,link...
+
+ if test "$alldeplibs" = yes &&
+ { test "$deplibs_check_method" = pass_all ||
+ { test "$build_libtool_libs" = yes &&
+ test -n "$library_names"; }; }; then
+ # We only need to search for static libraries
+ continue
+ fi
+ fi
+
+ link_static=no # Whether the deplib will be linked statically
+ if test -n "$library_names" &&
+ { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+ if test "$installed" = no; then
+ notinst_deplibs="$notinst_deplibs $lib"
+ need_relink=yes
+ fi
+ # This is a shared library
+
+ # Warn about portability, can't link against -module's on some systems (darwin)
+ if test "$shouldnotlink" = yes && test "$pass" = link ; then
+ $echo
+ if test "$linkmode" = prog; then
+ $echo "*** Warning: Linking the executable $output against the loadable module"
+ else
+ $echo "*** Warning: Linking the shared library $output against the loadable module"
+ fi
+ $echo "*** $linklib is not portable!"
+ fi
+ if test "$linkmode" = lib &&
+ test "$hardcode_into_libs" = yes; then
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) compile_rpath="$compile_rpath $absdir"
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir"
+ esac
+ ;;
+ esac
+ fi
+
+ if test -n "$old_archive_from_expsyms_cmds"; then
+ # figure out the soname
+ set dummy $library_names
+ realname="$2"
+ shift; shift
+ libname=`eval \\$echo \"$libname_spec\"`
+ # use dlname if we got it. it's perfectly good, no?
+ if test -n "$dlname"; then
+ soname="$dlname"
+ elif test -n "$soname_spec"; then
+ # bleh windows
+ case $host in
+ *cygwin* | mingw*)
+ major=`expr $current - $age`
+ versuffix="-$major"
+ ;;
+ esac
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+
+ # Make a new name for the extract_expsyms_cmds to use
+ soroot="$soname"
+ soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
+ newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
+
+ # If the library has no export list, then create one now
+ if test -f "$output_objdir/$soname-def"; then :
+ else
+ $show "extracting exported symbol list from \`$soname'"
+ save_ifs="$IFS"; IFS='~'
+ eval cmds=\"$extract_expsyms_cmds\"
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ fi
+
+ # Create $newlib
+ if test -f "$output_objdir/$newlib"; then :; else
+ $show "generating import library for \`$soname'"
+ save_ifs="$IFS"; IFS='~'
+ eval cmds=\"$old_archive_from_expsyms_cmds\"
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ fi
+ # make sure the library variables are pointing to the new library
+ dir=$output_objdir
+ linklib=$newlib
+ fi # test -n "$old_archive_from_expsyms_cmds"
+
+ if test "$linkmode" = prog || test "$mode" != relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ lib_linked=yes
+ case $hardcode_action in
+ immediate | unsupported)
+ if test "$hardcode_direct" = no; then
+ add="$dir/$linklib"
+ case $host in
+ *-*-sco3.2v5* ) add_dir="-L$dir" ;;
+ *-*-darwin* )
+ # if the lib is a module then we can not link against it, someone
+ # is ignoring the new warnings I added
+ if /usr/bin/file -L $add 2> /dev/null | grep "bundle" >/dev/null ; then
+ $echo "** Warning, lib $linklib is a module, not a shared library"
+ if test -z "$old_library" ; then
+ $echo
+ $echo "** And there doesn't seem to be a static archive available"
+ $echo "** The link will probably fail, sorry"
+ else
+ add="$dir/$old_library"
+ fi
+ fi
+ esac
+ elif test "$hardcode_minus_L" = no; then
+ case $host in
+ *-*-sunos*) add_shlibpath="$dir" ;;
+ esac
+ add_dir="-L$dir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = no; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ relink)
+ if test "$hardcode_direct" = yes; then
+ add="$dir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$dir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case "$libdir" in
+ [\\/]*)
+ add_dir="-L$inst_prefix_dir$libdir $add_dir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ *) lib_linked=no ;;
+ esac
+
+ if test "$lib_linked" != yes; then
+ $echo "$modename: configuration error: unsupported hardcode properties"
+ exit 1
+ fi
+
+ if test -n "$add_shlibpath"; then
+ case :$compile_shlibpath: in
+ *":$add_shlibpath:"*) ;;
+ *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+ esac
+ fi
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+ test -n "$add" && compile_deplibs="$add $compile_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ if test "$hardcode_direct" != yes && \
+ test "$hardcode_minus_L" != yes && \
+ test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+ esac
+ fi
+ fi
+ fi
+
+ if test "$linkmode" = prog || test "$mode" = relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ # Finalize command for both is simple: just hardcode it.
+ if test "$hardcode_direct" = yes; then
+ add="$libdir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$libdir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+ esac
+ add="-l$name"
+ elif test "$hardcode_automatic" = yes; then
+ if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then
+ add="$inst_prefix_dir$libdir/$linklib"
+ else
+ add="$libdir/$linklib"
+ fi
+ else
+ # We cannot seem to hardcode it, guess we'll fake it.
+ add_dir="-L$libdir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case "$libdir" in
+ [\\/]*)
+ add_dir="-L$inst_prefix_dir$libdir $add_dir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ fi
+
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+ test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ fi
+ fi
+ elif test "$linkmode" = prog; then
+ # Here we assume that one of hardcode_direct or hardcode_minus_L
+ # is not unsupported. This is valid on all known static and
+ # shared platforms.
+ if test "$hardcode_direct" != unsupported; then
+ test -n "$old_library" && linklib="$old_library"
+ compile_deplibs="$dir/$linklib $compile_deplibs"
+ finalize_deplibs="$dir/$linklib $finalize_deplibs"
+ else
+ compile_deplibs="-l$name -L$dir $compile_deplibs"
+ finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+ fi
+ elif test "$build_libtool_libs" = yes; then
+ # Not a shared library
+ if test "$deplibs_check_method" != pass_all; then
+ # We're trying link a shared library against a static one
+ # but the system doesn't support it.
+
+ # Just print a warning and add the library to dependency_libs so
+ # that the program can be linked against the static library.
+ $echo
+ $echo "*** Warning: This system can not link to static lib archive $lib."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have."
+ if test "$module" = yes; then
+ $echo "*** But as you try to build a module library, libtool will still create "
+ $echo "*** a static module, that should work as long as the dlopening application"
+ $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
+ if test -z "$global_symbol_pipe"; then
+ $echo
+ $echo "*** However, this would only work if libtool was able to extract symbol"
+ $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ $echo "*** not find such a program. So, this module is probably useless."
+ $echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ else
+ convenience="$convenience $dir/$old_library"
+ old_convenience="$old_convenience $dir/$old_library"
+ deplibs="$dir/$old_library $deplibs"
+ link_static=yes
+ fi
+ fi # link shared/static library?
+
+ if test "$linkmode" = lib; then
+ #if test -n "$dependency_libs" &&
+ # { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes ||
+ # test "$link_static" = yes; }; then
+ # Extract -R from dependency_libs
+ temp_deplibs=
+ for libdir in $dependency_libs; do
+ case $libdir in
+ -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
+ case " $xrpath " in
+ *" $temp_xrpath "*) ;;
+ *) xrpath="$xrpath $temp_xrpath";;
+ esac;;
+ *) temp_deplibs="$temp_deplibs $libdir";;
+ esac
+ done
+ dependency_libs="$temp_deplibs"
+ #fi
+
+ newlib_search_path="$newlib_search_path $absdir"
+ # Link against this library
+ test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+ # ... and its dependency_libs
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ newdependency_libs="$deplib $newdependency_libs"
+ if test "X$duplicate_deps" = "Xyes" ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done
+
+ if test "$link_all_deplibs" != no; then
+ # Add the search paths of all dependency libraries
+ for deplib in $dependency_libs; do
+ case $deplib in
+ -L*) path="$deplib" ;;
+ *.la)
+ dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$dir" = "X$deplib" && dir="."
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ if test -z "$absdir"; then
+ $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+ absdir="$dir"
+ fi
+ ;;
+ esac
+ if grep "^installed=no" $deplib > /dev/null; then
+ path="$absdir/$objdir"
+ else
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ if test -z "$libdir"; then
+ $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+ if test "$absdir" != "$libdir"; then
+ # Sure, some shells/systems don't implement the -ef.
+ # Those will have to live with the warning.
+ test "$absdir" -ef "$libdir" > /dev/null 2>&1 ||
+ $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
+ fi
+ path="$absdir"
+ fi
+ depdepl=
+ case $host in
+ *-*-darwin*)
+ # we do not want to link against static libs, but need to link against shared
+ eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+ if test -n "$deplibrary_names" ; then
+ for tmp in $deplibrary_names ; do
+ depdepl=$tmp
+ done
+ if test -f "$path/$depdepl" ; then
+ depdepl="$path/$depdepl"
+ fi
+ # do not add paths which are already there
+ case " $newlib_search_path " in
+ *" $path "*) ;;
+ *) newlib_search_path="$newlib_search_path $path";;
+ esac
+ path=""
+ fi
+ ;;
+ *)
+ path="-L$path"
+ ;;
+ esac
+
+ ;;
+ -l*)
+ case $host in
+ *-*-darwin*)
+ # Again, we only want to link against shared libraries
+ eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
+ for tmp in $newlib_search_path ; do
+ if test -f "$tmp/lib$tmp_libs.dylib" ; then
+ eval depdepl="$tmp/lib$tmp_libs.dylib"
+ break
+ fi
+ done
+ path=""
+ ;;
+ *) continue ;;
+ esac
+ ;;
+ *) continue ;;
+ esac
+ case " $deplibs " in
+ *" $depdepl "*) ;;
+ *) deplibs="$deplibs $depdepl" ;;
+ esac
+ case " $deplibs " in
+ *" $path "*) ;;
+ *) deplibs="$deplibs $path" ;;
+ esac
+ done
+ fi # link_all_deplibs != no
+ fi # linkmode = lib
+ done # for deplib in $libs
+ dependency_libs="$newdependency_libs"
+ if test "$pass" = dlpreopen; then
+ # Link the dlpreopened libraries before other libraries
+ for deplib in $save_deplibs; do
+ deplibs="$deplib $deplibs"
+ done
+ fi
+ if test "$pass" != dlopen; then
+ if test "$pass" != conv; then
+ # Make sure lib_search_path contains only unique directories.
+ lib_search_path=
+ for dir in $newlib_search_path; do
+ case "$lib_search_path " in
+ *" $dir "*) ;;
+ *) lib_search_path="$lib_search_path $dir" ;;
+ esac
+ done
+ newlib_search_path=
+ fi
+
+ if test "$linkmode,$pass" != "prog,link"; then
+ vars="deplibs"
+ else
+ vars="compile_deplibs finalize_deplibs"
+ fi
+ for var in $vars dependency_libs; do
+ # Add libraries to $var in reverse order
+ eval tmp_libs=\"\$$var\"
+ new_libs=
+ for deplib in $tmp_libs; do
+ # FIXME: Pedantically, this is the right thing to do, so
+ # that some nasty dependency loop isn't accidentally
+ # broken:
+ #new_libs="$deplib $new_libs"
+ # Pragmatically, this seems to cause very few problems in
+ # practice:
+ case $deplib in
+ -L*) new_libs="$deplib $new_libs" ;;
+ -R*) ;;
+ *)
+ # And here is the reason: when a library appears more
+ # than once as an explicit dependence of a library, or
+ # is implicitly linked in more than once by the
+ # compiler, it is considered special, and multiple
+ # occurrences thereof are not removed. Compare this
+ # with having the same library being listed as a
+ # dependency of multiple other libraries: in this case,
+ # we know (pedantically, we assume) the library does not
+ # need to be listed more than once, so we keep only the
+ # last copy. This is not always right, but it is rare
+ # enough that we require users that really mean to play
+ # such unportable linking tricks to link the library
+ # using -Wl,-lname, so that libtool does not consider it
+ # for duplicate removal.
+ case " $specialdeplibs " in
+ *" $deplib "*) new_libs="$deplib $new_libs" ;;
+ *)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$deplib $new_libs" ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ done
+ tmp_libs=
+ for deplib in $new_libs; do
+ case $deplib in
+ -L*)
+ case " $tmp_libs " in
+ *" $deplib "*) ;;
+ *) tmp_libs="$tmp_libs $deplib" ;;
+ esac
+ ;;
+ *) tmp_libs="$tmp_libs $deplib" ;;
+ esac
+ done
+ eval $var=\"$tmp_libs\"
+ done # for var
+ fi
+ # Last step: remove runtime libs from dependency_libs (they stay in deplibs)
+ tmp_libs=
+ for i in $dependency_libs ; do
+ case " $predeps $postdeps $compiler_lib_search_path " in
+ *" $i "*)
+ i=""
+ ;;
+ esac
+ if test -n "$i" ; then
+ tmp_libs="$tmp_libs $i"
+ fi
+ done
+ dependency_libs=$tmp_libs
+ done # for pass
+ if test "$linkmode" = prog; then
+ dlfiles="$newdlfiles"
+ dlprefiles="$newdlprefiles"
+ fi
+
+ case $linkmode in
+ oldlib)
+ if test -n "$deplibs"; then
+ $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
+ fi
+
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$rpath"; then
+ $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$xrpath"; then
+ $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
+ fi
+
+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+ $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
+ fi
+
+ # Now set the variables for building old libraries.
+ build_libtool_libs=no
+ oldlibs="$output"
+ objs="$objs$old_deplibs"
+ ;;
+
+ lib)
+ # Make sure we only generate libraries of the form `libNAME.la'.
+ case $outputname in
+ lib*)
+ name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+ eval shared_ext=\"$shrext\"
+ eval libname=\"$libname_spec\"
+ ;;
+ *)
+ if test "$module" = no; then
+ $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+ if test "$need_lib_prefix" != no; then
+ # Add the "lib" prefix for modules if required
+ name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+ eval shared_ext=\"$shrext\"
+ eval libname=\"$libname_spec\"
+ else
+ libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+ fi
+ ;;
+ esac
+
+ if test -n "$objs"; then
+ if test "$deplibs_check_method" != pass_all; then
+ $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
+ exit 1
+ else
+ $echo
+ $echo "*** Warning: Linking the shared library $output against the non-libtool"
+ $echo "*** objects $objs is not portable!"
+ libobjs="$libobjs $objs"
+ fi
+ fi
+
+ if test "$dlself" != no; then
+ $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
+ fi
+
+ set dummy $rpath
+ if test "$#" -gt 2; then
+ $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
+ fi
+ install_libdir="$2"
+
+ oldlibs=
+ if test -z "$rpath"; then
+ if test "$build_libtool_libs" = yes; then
+ # Building a libtool convenience library.
+ # Some compilers have problems with a `.al' extension so
+ # convenience libraries should have the same extension an
+ # archive normally would.
+ oldlibs="$output_objdir/$libname.$libext $oldlibs"
+ build_libtool_libs=convenience
+ build_old_libs=yes
+ fi
+
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
+ fi
+ else
+
+ # Parse the version information argument.
+ save_ifs="$IFS"; IFS=':'
+ set dummy $vinfo 0 0 0
+ IFS="$save_ifs"
+
+ if test -n "$8"; then
+ $echo "$modename: too many parameters to \`-version-info'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # convert absolute version numbers to libtool ages
+ # this retains compatibility with .la files and attempts
+ # to make the code below a bit more comprehensible
+
+ case $vinfo_number in
+ yes)
+ number_major="$2"
+ number_minor="$3"
+ number_revision="$4"
+ #
+ # There are really only two kinds -- those that
+ # use the current revision as the major version
+ # and those that subtract age and use age as
+ # a minor version. But, then there is irix
+ # which has an extra 1 added just for fun
+ #
+ case $version_type in
+ darwin|linux|osf|windows)
+ current=`expr $number_major + $number_minor`
+ age="$number_minor"
+ revision="$number_revision"
+ ;;
+ freebsd-aout|freebsd-elf|sunos)
+ current="$number_major"
+ revision="$number_minor"
+ age="0"
+ ;;
+ irix|nonstopux)
+ current=`expr $number_major + $number_minor - 1`
+ age="$number_minor"
+ revision="$number_minor"
+ ;;
+ esac
+ ;;
+ no)
+ current="$2"
+ revision="$3"
+ age="$4"
+ ;;
+ esac
+
+ # Check that each of the things are valid numbers.
+ case $current in
+ 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+ *)
+ $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case $revision in
+ 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+ *)
+ $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ ;;
+ esac
+
+ case $age in
+ 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
+ *)
+ $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ ;;
+ esac
+
+ if test "$age" -gt "$current"; then
+ $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
+ $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+ exit 1
+ fi
+
+ # Calculate the version variables.
+ major=
+ versuffix=
+ verstring=
+ case $version_type in
+ none) ;;
+
+ darwin)
+ # Like Linux, but with the current version available in
+ # verstring for coding it into the library header
+ major=.`expr $current - $age`
+ versuffix="$major.$age.$revision"
+ # Darwin ld doesn't like 0 for these options...
+ minor_current=`expr $current + 1`
+ verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+ ;;
+
+ freebsd-aout)
+ major=".$current"
+ versuffix=".$current.$revision";
+ ;;
+
+ freebsd-elf)
+ major=".$current"
+ versuffix=".$current";
+ ;;
+
+ irix | nonstopux)
+ major=`expr $current - $age + 1`
+
+ case $version_type in
+ nonstopux) verstring_prefix=nonstopux ;;
+ *) verstring_prefix=sgi ;;
+ esac
+ verstring="$verstring_prefix$major.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$revision
+ while test "$loop" -ne 0; do
+ iface=`expr $revision - $loop`
+ loop=`expr $loop - 1`
+ verstring="$verstring_prefix$major.$iface:$verstring"
+ done
+
+ # Before this point, $major must not contain `.'.
+ major=.$major
+ versuffix="$major.$revision"
+ ;;
+
+ linux)
+ major=.`expr $current - $age`
+ versuffix="$major.$age.$revision"
+ ;;
+
+ osf)
+ major=.`expr $current - $age`
+ versuffix=".$current.$age.$revision"
+ verstring="$current.$age.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$age
+ while test "$loop" -ne 0; do
+ iface=`expr $current - $loop`
+ loop=`expr $loop - 1`
+ verstring="$verstring:${iface}.0"
+ done
+
+ # Make executables depend on our current version.
+ verstring="$verstring:${current}.0"
+ ;;
+
+ sunos)
+ major=".$current"
+ versuffix=".$current.$revision"
+ ;;
+
+ windows)
+ # Use '-' rather than '.', since we only want one
+ # extension on DOS 8.3 filesystems.
+ major=`expr $current - $age`
+ versuffix="-$major"
+ ;;
+
+ *)
+ $echo "$modename: unknown library version type \`$version_type'" 1>&2
+ $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
+ exit 1
+ ;;
+ esac
+
+ # Clear the version info if we defaulted, and they specified a release.
+ if test -z "$vinfo" && test -n "$release"; then
+ major=
+ case $version_type in
+ darwin)
+ # we can't check for "0.0" in archive_cmds due to quoting
+ # problems, so we reset it completely
+ verstring=
+ ;;
+ *)
+ verstring="0.0"
+ ;;
+ esac
+ if test "$need_version" = no; then
+ versuffix=
+ else
+ versuffix=".0.0"
+ fi
+ fi
+
+ # Remove version info from name if versioning should be avoided
+ if test "$avoid_version" = yes && test "$need_version" = no; then
+ major=
+ versuffix=
+ verstring=""
+ fi
+
+ # Check to see if the archive will have undefined symbols.
+ if test "$allow_undefined" = yes; then
+ if test "$allow_undefined_flag" = unsupported; then
+ $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
+ build_libtool_libs=no
+ build_old_libs=yes
+ fi
+ else
+ # Don't allow undefined symbols.
+ allow_undefined_flag="$no_undefined_flag"
+ fi
+ fi
+
+ if test "$mode" != relink; then
+ # Remove our outputs, but don't remove object files since they
+ # may have been created when compiling PIC objects.
+ removelist=
+ tempremovelist=`$echo "$output_objdir/*"`
+ for p in $tempremovelist; do
+ case $p in
+ *.$objext)
+ ;;
+ $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+ removelist="$removelist $p"
+ ;;
+ *) ;;
+ esac
+ done
+ if test -n "$removelist"; then
+ $show "${rm}r $removelist"
+ $run ${rm}r $removelist
+ fi
+ fi
+
+ # Now set the variables for building old libraries.
+ if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+ oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+ # Transform .lo files to .o files.
+ oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+ fi
+
+ # Eliminate all temporary directories.
+ for path in $notinst_path; do
+ lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
+ deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
+ dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
+ done
+
+ if test -n "$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ temp_xrpath=
+ for libdir in $xrpath; do
+ temp_xrpath="$temp_xrpath -R$libdir"
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir" ;;
+ esac
+ done
+ if true || test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+ dependency_libs="$temp_xrpath $dependency_libs"
+ fi
+ fi
+
+ # Make sure dlfiles contains only unique files that won't be dlpreopened
+ old_dlfiles="$dlfiles"
+ dlfiles=
+ for lib in $old_dlfiles; do
+ case " $dlprefiles $dlfiles " in
+ *" $lib "*) ;;
+ *) dlfiles="$dlfiles $lib" ;;
+ esac
+ done
+
+ # Make sure dlprefiles contains only unique files
+ old_dlprefiles="$dlprefiles"
+ dlprefiles=
+ for lib in $old_dlprefiles; do
+ case "$dlprefiles " in
+ *" $lib "*) ;;
+ *) dlprefiles="$dlprefiles $lib" ;;
+ esac
+ done
+
+ if test "$build_libtool_libs" = yes; then
+ if test -n "$rpath"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
+ # these systems don't actually have a c library (as such)!
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C library is in the System framework
+ deplibs="$deplibs -framework System"
+ ;;
+ *-*-netbsd*)
+ # Don't link with libc until the a.out ld.so is fixed.
+ ;;
+ *-*-freebsd*-gnu*)
+ # Prevent $arg from being parsed by the freebsd regexp below.
+ if test "$build_libtool_need_lc" = "yes"; then
+ deplibs="$deplibs -lc"
+ fi
+ ;;
+ *-*-openbsd* | *-*-freebsd*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *)
+ # Add libc to deplibs on all other systems if necessary.
+ if test "$build_libtool_need_lc" = "yes"; then
+ deplibs="$deplibs -lc"
+ fi
+ ;;
+ esac
+ fi
+
+ # Transform deplibs into only deplibs that can be linked in shared.
+ name_save=$name
+ libname_save=$libname
+ release_save=$release
+ versuffix_save=$versuffix
+ major_save=$major
+ # I'm not sure if I'm treating the release correctly. I think
+ # release should show up in the -l (ie -lgmp5) so we don't want to
+ # add it in twice. Is that correct?
+ release=""
+ versuffix=""
+ major=""
+ newdeplibs=
+ droppeddeps=no
+ case $deplibs_check_method in
+ pass_all)
+ # Don't check for shared/static. Everything works.
+ # This might be a little naive. We might want to check
+ # whether the library exists or not. But this is on
+ # osf3 & osf4 and I'm not really sure... Just
+ # implementing what was already the behavior.
+ newdeplibs=$deplibs
+ ;;
+ test_compile)
+ # This code stresses the "libraries are programs" paradigm to its
+ # limits. Maybe even breaks it. We compile a program, linking it
+ # against the deplibs as a proxy for the library. Then we can check
+ # whether they linked in statically or dynamically with ldd.
+ $rm conftest.c
+ cat > conftest.c <<EOF
+ int main() { return 0; }
+EOF
+ $rm conftest
+ $LTCC -o conftest conftest.c $deplibs
+ if test "$?" -eq 0 ; then
+ ldd_output=`ldd conftest`
+ for i in $deplibs; do
+ name="`expr $i : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test "$name" != "" && test "$name" -ne "0"; then
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ newdeplibs="$newdeplibs $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ deplib_matches=`eval \\$echo \"$library_names_spec\"`
+ set dummy $deplib_matches
+ deplib_match=$2
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning: dynamic linker does not accept needed library $i."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which I believe you do not have"
+ $echo "*** because a test_compile did reveal that the linker did not use it for"
+ $echo "*** its dynamic dependency list that programs get resolved with at runtime."
+ fi
+ fi
+ else
+ newdeplibs="$newdeplibs $i"
+ fi
+ done
+ else
+ # Error occurred in the first compile. Let's try to salvage
+ # the situation: Compile a separate program for each library.
+ for i in $deplibs; do
+ name="`expr $i : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test "$name" != "" && test "$name" != "0"; then
+ $rm conftest
+ $LTCC -o conftest conftest.c $i
+ # Did it work?
+ if test "$?" -eq 0 ; then
+ ldd_output=`ldd conftest`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ newdeplibs="$newdeplibs $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ deplib_matches=`eval \\$echo \"$library_names_spec\"`
+ set dummy $deplib_matches
+ deplib_match=$2
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning: dynamic linker does not accept needed library $i."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have"
+ $echo "*** because a test_compile did reveal that the linker did not use this one"
+ $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
+ fi
+ fi
+ else
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning! Library $i is needed by this library but I was not able to"
+ $echo "*** make it link in! You will probably need to install it or some"
+ $echo "*** library that it depends on before this library will be fully"
+ $echo "*** functional. Installing it before continuing would be even better."
+ fi
+ else
+ newdeplibs="$newdeplibs $i"
+ fi
+ done
+ fi
+ ;;
+ file_magic*)
+ set dummy $deplibs_check_method
+ file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+ for a_deplib in $deplibs; do
+ name="`expr $a_deplib : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test "$name" != "" && test "$name" != "0"; then
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ # Follow soft links.
+ if ls -lLd "$potent_lib" 2>/dev/null \
+ | grep " -> " >/dev/null; then
+ continue
+ fi
+ # The statement above tries to avoid entering an
+ # endless loop below, in case of cyclic links.
+ # We might still enter an endless loop, since a link
+ # loop can be closed while we follow links,
+ # but so what?
+ potlib="$potent_lib"
+ while test -h "$potlib" 2>/dev/null; do
+ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+ case $potliblink in
+ [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+ *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+ esac
+ done
+ if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
+ | ${SED} 10q \
+ | $EGREP "$file_magic_regex" > /dev/null; then
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning: linker path does not have real file for library $a_deplib."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have"
+ $echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $echo "*** with $libname but no candidates were found. (...for file magic test)"
+ else
+ $echo "*** with $libname and none of the candidates passed a file format test"
+ $echo "*** using a file magic. Last file checked: $potlib"
+ fi
+ fi
+ else
+ # Add a -L argument.
+ newdeplibs="$newdeplibs $a_deplib"
+ fi
+ done # Gone through all deplibs.
+ ;;
+ match_pattern*)
+ set dummy $deplibs_check_method
+ match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+ for a_deplib in $deplibs; do
+ name="`expr $a_deplib : '-l\(.*\)'`"
+ # If $name is empty we are operating on a -L argument.
+ if test -n "$name" && test "$name" != "0"; then
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval \\$echo \"$libname_spec\"`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ potlib="$potent_lib" # see symlink-check above in file_magic test
+ if eval $echo \"$potent_lib\" 2>/dev/null \
+ | ${SED} 10q \
+ | $EGREP "$match_pattern_regex" > /dev/null; then
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ $echo
+ $echo "*** Warning: linker path does not have real file for library $a_deplib."
+ $echo "*** I have the capability to make that library automatically link in when"
+ $echo "*** you link to this library. But I can only do this if you have a"
+ $echo "*** shared version of the library, which you do not appear to have"
+ $echo "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
+ else
+ $echo "*** with $libname and none of the candidates passed a file format test"
+ $echo "*** using a regex pattern. Last file checked: $potlib"
+ fi
+ fi
+ else
+ # Add a -L argument.
+ newdeplibs="$newdeplibs $a_deplib"
+ fi
+ done # Gone through all deplibs.
+ ;;
+ none | unknown | *)
+ newdeplibs=""
+ tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+ -e 's/ -[LR][^ ]*//g'`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ for i in $predeps $postdeps ; do
+ # can't use Xsed below, because $i might contain '/'
+ tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
+ done
+ fi
+ if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \
+ | grep . >/dev/null; then
+ $echo
+ if test "X$deplibs_check_method" = "Xnone"; then
+ $echo "*** Warning: inter-library dependencies are not supported in this platform."
+ else
+ $echo "*** Warning: inter-library dependencies are not known to be supported."
+ fi
+ $echo "*** All declared inter-library dependencies are being dropped."
+ droppeddeps=yes
+ fi
+ ;;
+ esac
+ versuffix=$versuffix_save
+ major=$major_save
+ release=$release_save
+ libname=$libname_save
+ name=$name_save
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library is the System framework
+ newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
+ ;;
+ esac
+
+ if test "$droppeddeps" = yes; then
+ if test "$module" = yes; then
+ $echo
+ $echo "*** Warning: libtool could not satisfy all declared inter-library"
+ $echo "*** dependencies of module $libname. Therefore, libtool will create"
+ $echo "*** a static module, that should work as long as the dlopening"
+ $echo "*** application is linked with the -dlopen flag."
+ if test -z "$global_symbol_pipe"; then
+ $echo
+ $echo "*** However, this would only work if libtool was able to extract symbol"
+ $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ $echo "*** not find such a program. So, this module is probably useless."
+ $echo "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ else
+ $echo "*** The inter-library dependencies that have been dropped here will be"
+ $echo "*** automatically added whenever a program is linked with this library"
+ $echo "*** or is declared to -dlopen it."
+
+ if test "$allow_undefined" = no; then
+ $echo
+ $echo "*** Since this library must not contain undefined symbols,"
+ $echo "*** because either the platform does not support them or"
+ $echo "*** it was explicitly requested with -no-undefined,"
+ $echo "*** libtool will only create a static version of it."
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ fi
+ fi
+ # Done checking deplibs!
+ deplibs=$newdeplibs
+ fi
+
+ # All the library-specific variables (install_libdir is set above).
+ library_names=
+ old_library=
+ dlname=
+
+ # Test again, we may have decided not to build it any more
+ if test "$build_libtool_libs" = yes; then
+ if test "$hardcode_into_libs" = yes; then
+ # Hardcode the library paths
+ hardcode_libdirs=
+ dep_rpath=
+ rpath="$finalize_rpath"
+ test "$mode" != relink && test "$fast_install" = no && rpath="$compile_rpath$rpath"
+ for libdir in $rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ dep_rpath="$dep_rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) perm_rpath="$perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ if test -n "$hardcode_libdir_flag_spec_ld"; then
+ eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+ else
+ eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+ fi
+ fi
+ if test -n "$runpath_var" && test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+ fi
+ test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+ fi
+
+ shlibpath="$finalize_shlibpath"
+ test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+ if test -n "$shlibpath"; then
+ eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+ fi
+
+ # Get the real and link names of the library.
+ eval shared_ext=\"$shrext\"
+ eval library_names=\"$library_names_spec\"
+ set dummy $library_names
+ realname="$2"
+ shift; shift
+
+ if test -n "$soname_spec"; then
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+ if test -z "$dlname"; then
+ dlname=$soname
+ fi
+
+ lib="$output_objdir/$realname"
+ for link
+ do
+ linknames="$linknames $link"
+ done
+
+ # Use standard objects if they are pic
+ test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+ $show "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $run $rm $export_symbols
+ eval cmds=\"$export_symbols_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ if len=`expr "X$cmd" : ".*"` &&
+ test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ skipped_export=false
+ else
+ # The command line is too long to execute in one step.
+ $show "using reloadable object file for export list..."
+ skipped_export=:
+ fi
+ done
+ IFS="$save_ifs"
+ if test -n "$export_symbols_regex"; then
+ $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
+ $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ $show "$mv \"${export_symbols}T\" \"$export_symbols\""
+ $run eval '$mv "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+ fi
+
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
+ fi
+
+ tmp_deplibs=
+ for test_deplib in $deplibs; do
+ case " $convenience " in
+ *" $test_deplib "*) ;;
+ *)
+ tmp_deplibs="$tmp_deplibs $test_deplib"
+ ;;
+ esac
+ done
+ deplibs="$tmp_deplibs"
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ else
+ gentop="$output_objdir/${outputname}x"
+ $show "${rm}r $gentop"
+ $run ${rm}r "$gentop"
+ $show "$mkdir $gentop"
+ $run $mkdir "$gentop"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$gentop"; then
+ exit $status
+ fi
+ generated="$generated $gentop"
+
+ for xlib in $convenience; do
+ # Extract the objects.
+ case $xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+ *) xabs=`pwd`"/$xlib" ;;
+ esac
+ xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+ xdir="$gentop/$xlib"
+
+ $show "${rm}r $xdir"
+ $run ${rm}r "$xdir"
+ $show "$mkdir $xdir"
+ $run $mkdir "$xdir"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$xdir"; then
+ exit $status
+ fi
+ # We will extract separately just the conflicting names and we will no
+ # longer touch any unique names. It is faster to leave these extract
+ # automatically by $AR in one run.
+ $show "(cd $xdir && $AR x $xabs)"
+ $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+ if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+ $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+ $AR t "$xabs" | sort | uniq -cd | while read -r count name
+ do
+ i=1
+ while test "$i" -le "$count"
+ do
+ # Put our $i before any first dot (extension)
+ # Never overwrite any file
+ name_to="$name"
+ while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
+ do
+ name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+ done
+ $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
+ $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
+ i=`expr $i + 1`
+ done
+ done
+ fi
+
+ libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+ done
+ fi
+ fi
+
+ if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+ eval flag=\"$thread_safe_flag_spec\"
+ linker_flags="$linker_flags $flag"
+ fi
+
+ # Make a backup of the uninstalled library when relinking
+ if test "$mode" = relink; then
+ $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
+ fi
+
+ # Add all flags from the command line. We here create a library,
+ # but those flags were only added to compile_command and
+ # finalize_command, which are only used when creating executables.
+ # So do it by hand here.
+ compiler_flags="$compiler_flags $add_flags"
+ # Only add it to commands which use CC, instead of LD, i.e.
+ # only to $compiler_flags
+ #linker_flags="$linker_flags $add_flags"
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ eval cmds=\"$module_expsym_cmds\"
+ else
+ eval cmds=\"$module_cmds\"
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval cmds=\"$archive_expsym_cmds\"
+ else
+ eval cmds=\"$archive_cmds\"
+ fi
+ fi
+
+ if test "X$skipped_export" != "X:" && len=`expr "X$cmds" : ".*"` &&
+ test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ :
+ else
+ # The command line is too long to link in one step, link piecewise.
+ $echo "creating reloadable object files..."
+
+ # Save the value of $output and $libobjs because we want to
+ # use them later. If we have whole_archive_flag_spec, we
+ # want to use save_libobjs as it was before
+ # whole_archive_flag_spec was expanded, because we can't
+ # assume the linker understands whole_archive_flag_spec.
+ # This may have to be revisited, in case too many
+ # convenience libraries get linked in and end up exceeding
+ # the spec.
+ if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ fi
+ save_output=$output
+
+ # Clear the reloadable object creation command queue and
+ # initialize k to one.
+ test_cmds=
+ concat_cmds=
+ objlist=
+ delfiles=
+ last_robj=
+ k=1
+ output=$output_objdir/$save_output-${k}.$objext
+ # Loop over the list of objects to be linked.
+ for obj in $save_libobjs
+ do
+ eval test_cmds=\"$reload_cmds $objlist $last_robj\"
+ if test "X$objlist" = X ||
+ { len=`expr "X$test_cmds" : ".*"` &&
+ test "$len" -le "$max_cmd_len"; }; then
+ objlist="$objlist $obj"
+ else
+ # The command $test_cmds is almost too long, add a
+ # command to the queue.
+ if test "$k" -eq 1 ; then
+ # The first file doesn't have a previous command to add.
+ eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+ else
+ # All subsequent reloadable object files will link in
+ # the last one created.
+ eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
+ fi
+ last_robj=$output_objdir/$save_output-${k}.$objext
+ k=`expr $k + 1`
+ output=$output_objdir/$save_output-${k}.$objext
+ objlist=$obj
+ len=1
+ fi
+ done
+ # Handle the remaining objects by creating one last
+ # reloadable object file. All subsequent reloadable object
+ # files will link in the last one created.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+
+ if ${skipped_export-false}; then
+ $show "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $run $rm $export_symbols
+ libobjs=$output
+ # Append the command to create the export file.
+ eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
+ fi
+
+ # Set up a command to remove the reloadale object files
+ # after they are used.
+ i=0
+ while test "$i" -lt "$k"
+ do
+ i=`expr $i + 1`
+ delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
+ done
+
+ $echo "creating a temporary reloadable object file: $output"
+
+ # Loop through the commands generated above and execute them.
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $concat_cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+
+ libobjs=$output
+ # Restore the value of output.
+ output=$save_output
+
+ if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ fi
+ # Expand the library linking commands again to reset the
+ # value of $libobjs for piecewise linking.
+
+ # Do each of the archive commands.
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval cmds=\"$archive_expsym_cmds\"
+ else
+ eval cmds=\"$archive_cmds\"
+ fi
+
+ # Append the command to remove the reloadable object files
+ # to the just-reset $cmds.
+ eval cmds=\"\$cmds~$rm $delfiles\"
+ fi
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+
+ # Restore the uninstalled library and exit
+ if test "$mode" = relink; then
+ $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
+ exit 0
+ fi
+
+ # Create links to the real library.
+ for linkname in $linknames; do
+ if test "$realname" != "$linkname"; then
+ $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
+ $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
+ fi
+ done
+
+ # If -module or -export-dynamic was specified, set the dlname.
+ if test "$module" = yes || test "$export_dynamic" = yes; then
+ # On all known operating systems, these are identical.
+ dlname="$soname"
+ fi
+ fi
+ ;;
+
+ obj)
+ if test -n "$deplibs"; then
+ $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
+ fi
+
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$rpath"; then
+ $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$xrpath"; then
+ $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
+ fi
+
+ case $output in
+ *.lo)
+ if test -n "$objs$old_deplibs"; then
+ $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
+ exit 1
+ fi
+ libobj="$output"
+ obj=`$echo "X$output" | $Xsed -e "$lo2o"`
+ ;;
+ *)
+ libobj=
+ obj="$output"
+ ;;
+ esac
+
+ # Delete the old objects.
+ $run $rm $obj $libobj
+
+ # Objects from convenience libraries. This assumes
+ # single-version convenience libraries. Whenever we create
+ # different ones for PIC/non-PIC, this we'll have to duplicate
+ # the extraction.
+ reload_conv_objs=
+ gentop=
+ # reload_cmds runs $LD directly, so let us get rid of
+ # -Wl from whole_archive_flag_spec
+ wl=
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec"; then
+ eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
+ else
+ gentop="$output_objdir/${obj}x"
+ $show "${rm}r $gentop"
+ $run ${rm}r "$gentop"
+ $show "$mkdir $gentop"
+ $run $mkdir "$gentop"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$gentop"; then
+ exit $status
+ fi
+ generated="$generated $gentop"
+
+ for xlib in $convenience; do
+ # Extract the objects.
+ case $xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+ *) xabs=`pwd`"/$xlib" ;;
+ esac
+ xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+ xdir="$gentop/$xlib"
+
+ $show "${rm}r $xdir"
+ $run ${rm}r "$xdir"
+ $show "$mkdir $xdir"
+ $run $mkdir "$xdir"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$xdir"; then
+ exit $status
+ fi
+ # We will extract separately just the conflicting names and we will no
+ # longer touch any unique names. It is faster to leave these extract
+ # automatically by $AR in one run.
+ $show "(cd $xdir && $AR x $xabs)"
+ $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+ if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+ $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+ $AR t "$xabs" | sort | uniq -cd | while read -r count name
+ do
+ i=1
+ while test "$i" -le "$count"
+ do
+ # Put our $i before any first dot (extension)
+ # Never overwrite any file
+ name_to="$name"
+ while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
+ do
+ name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+ done
+ $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
+ $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
+ i=`expr $i + 1`
+ done
+ done
+ fi
+
+ reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+ done
+ fi
+ fi
+
+ # Create the old-style object.
+ reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+ output="$obj"
+ eval cmds=\"$reload_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+
+ # Exit if we aren't doing a library object file.
+ if test -z "$libobj"; then
+ if test -n "$gentop"; then
+ $show "${rm}r $gentop"
+ $run ${rm}r $gentop
+ fi
+
+ exit 0
+ fi
+
+ if test "$build_libtool_libs" != yes; then
+ if test -n "$gentop"; then
+ $show "${rm}r $gentop"
+ $run ${rm}r $gentop
+ fi
+
+ # Create an invalid libtool object if no PIC, so that we don't
+ # accidentally link it into a program.
+ # $show "echo timestamp > $libobj"
+ # $run eval "echo timestamp > $libobj" || exit $?
+ exit 0
+ fi
+
+ if test -n "$pic_flag" || test "$pic_mode" != default; then
+ # Only do commands if we really have different PIC objects.
+ reload_objs="$libobjs $reload_conv_objs"
+ output="$libobj"
+ eval cmds=\"$reload_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ fi
+
+ if test -n "$gentop"; then
+ $show "${rm}r $gentop"
+ $run ${rm}r $gentop
+ fi
+
+ exit 0
+ ;;
+
+ prog)
+ case $host in
+ *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
+ esac
+ if test -n "$vinfo"; then
+ $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
+ fi
+
+ if test -n "$release"; then
+ $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
+ fi
+
+ if test "$preload" = yes; then
+ if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
+ test "$dlopen_self_static" = unknown; then
+ $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
+ fi
+ fi
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library is the System framework
+ compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+ finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+ ;;
+ esac
+
+ case $host in
+ *darwin*)
+ # Don't allow lazy linking, it breaks C++ global constructors
+ if test "$tagname" = CXX ; then
+ compile_command="$compile_command ${wl}-bind_at_load"
+ finalize_command="$finalize_command ${wl}-bind_at_load"
+ fi
+ ;;
+ esac
+
+ compile_command="$compile_command $compile_deplibs"
+ finalize_command="$finalize_command $finalize_deplibs"
+
+ if test -n "$rpath$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ for libdir in $rpath $xrpath; do
+ # This is the magic to use -rpath.
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir" ;;
+ esac
+ done
+ fi
+
+ # Now hardcode the library paths
+ rpath=
+ hardcode_libdirs=
+ for libdir in $compile_rpath $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) perm_rpath="$perm_rpath $libdir" ;;
+ esac
+ fi
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+ case :$dllsearchpath: in
+ *":$libdir:"*) ;;
+ *) dllsearchpath="$dllsearchpath:$libdir";;
+ esac
+ ;;
+ esac
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ compile_rpath="$rpath"
+
+ rpath=
+ hardcode_libdirs=
+ for libdir in $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$finalize_perm_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ finalize_rpath="$rpath"
+
+ if test -n "$libobjs" && test "$build_old_libs" = yes; then
+ # Transform all the library objects into standard objects.
+ compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ fi
+
+ dlsyms=
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ if test -n "$NM" && test -n "$global_symbol_pipe"; then
+ dlsyms="${outputname}S.c"
+ else
+ $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
+ fi
+ fi
+
+ if test -n "$dlsyms"; then
+ case $dlsyms in
+ "") ;;
+ *.c)
+ # Discover the nlist of each of the dlfiles.
+ nlist="$output_objdir/${outputname}.nm"
+
+ $show "$rm $nlist ${nlist}S ${nlist}T"
+ $run $rm "$nlist" "${nlist}S" "${nlist}T"
+
+ # Parse the name list into a source file.
+ $show "creating $output_objdir/$dlsyms"
+
+ test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
+/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
+/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* Prevent the only kind of declaration conflicts we can make. */
+#define lt_preloaded_symbols some_other_symbol
+
+/* External symbol declarations for the compiler. */\
+"
+
+ if test "$dlself" = yes; then
+ $show "generating symbol list for \`$output'"
+
+ test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
+
+ # Add our own program objects to the symbol list.
+ progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ for arg in $progfiles; do
+ $show "extracting global C symbols from \`$arg'"
+ $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -n "$exclude_expsyms"; then
+ $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+ $run eval '$mv "$nlist"T "$nlist"'
+ fi
+
+ if test -n "$export_symbols_regex"; then
+ $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+ $run eval '$mv "$nlist"T "$nlist"'
+ fi
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ export_symbols="$output_objdir/$output.exp"
+ $run $rm $export_symbols
+ $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ else
+ $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
+ $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
+ $run eval 'mv "$nlist"T "$nlist"'
+ fi
+ fi
+
+ for arg in $dlprefiles; do
+ $show "extracting global C symbols from \`$arg'"
+ name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
+ $run eval '$echo ": $name " >> "$nlist"'
+ $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -z "$run"; then
+ # Make sure we have at least an empty file.
+ test -f "$nlist" || : > "$nlist"
+
+ if test -n "$exclude_expsyms"; then
+ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+ $mv "$nlist"T "$nlist"
+ fi
+
+ # Try sorting and uniquifying the output.
+ if grep -v "^: " < "$nlist" |
+ if sort -k 3 </dev/null >/dev/null 2>&1; then
+ sort -k 3
+ else
+ sort +2
+ fi |
+ uniq > "$nlist"S; then
+ :
+ else
+ grep -v "^: " < "$nlist" > "$nlist"S
+ fi
+
+ if test -f "$nlist"S; then
+ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
+ else
+ $echo '/* NONE */' >> "$output_objdir/$dlsyms"
+ fi
+
+ $echo >> "$output_objdir/$dlsyms" "\
+
+#undef lt_preloaded_symbols
+
+#if defined (__STDC__) && __STDC__
+# define lt_ptr void *
+#else
+# define lt_ptr char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ lt_ptr address;
+}
+lt_preloaded_symbols[] =
+{\
+"
+
+ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
+
+ $echo >> "$output_objdir/$dlsyms" "\
+ {0, (lt_ptr) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+ fi
+
+ pic_flag_for_symtable=
+ case $host in
+ # compiling the symbol table file with pic_flag works around
+ # a FreeBSD bug that causes programs to crash when -lm is
+ # linked before any other PIC object. But we must not use
+ # pic_flag when linking with -static. The problem exists in
+ # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+ *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+ case "$compile_command " in
+ *" -static "*) ;;
+ *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
+ esac;;
+ *-*-hpux*)
+ case "$compile_command " in
+ *" -static "*) ;;
+ *) pic_flag_for_symtable=" $pic_flag";;
+ esac
+ esac
+
+ # Now compile the dynamic symbol file.
+ $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+ $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+
+ # Clean up the generated files.
+ $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
+ $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
+
+ # Transform the symbol file into the correct name.
+ compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+ finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+ ;;
+ *)
+ $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
+ exit 1
+ ;;
+ esac
+ else
+ # We keep going just in case the user didn't refer to
+ # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
+ # really was required.
+
+ # Nullify the symbol file.
+ compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+ finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+ fi
+
+ # AIX runtime linking requires linking programs with -Wl,-brtl and libs with -Wl,-G
+ # Also add -bnolibpath to the beginning of the link line, to clear the hardcoded runpath.
+ # Otherwise, things like the -L path to libgcc.a are accidentally hardcoded by ld.
+ # This does not apply on AIX for ia64, which uses a SysV linker.
+ case "$host" in
+ ia64-*-aix5*) ;;
+ *-*-aix4* | *-*-aix5*)
+ compile_command=`$echo "X$compile_command $wl-brtl" | $Xsed -e "s/\$CC/\$CC $wl-bnolibpath/1"`
+ finalize_command=`$echo "X$finalize_command $wl-brtl" | $Xsed -e "s/\$CC/\$CC $wl-bnolibpath/1"` ;;
+ esac
+
+ if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+ # Replace the output file specification.
+ compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+ link_command="$compile_command$compile_rpath"
+
+ # We have no uninstalled library dependencies, so finalize right now.
+ $show "$link_command"
+ $run eval "$link_command"
+ status=$?
+
+ # Delete the generated files.
+ if test -n "$dlsyms"; then
+ $show "$rm $output_objdir/${outputname}S.${objext}"
+ $run $rm "$output_objdir/${outputname}S.${objext}"
+ fi
+
+ exit $status
+ fi
+
+ if test -n "$shlibpath_var"; then
+ # We should set the shlibpath_var
+ rpath=
+ for dir in $temp_rpath; do
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*)
+ # Absolute path.
+ rpath="$rpath$dir:"
+ ;;
+ *)
+ # Relative path: add a thisdir entry.
+ rpath="$rpath\$thisdir/$dir:"
+ ;;
+ esac
+ done
+ temp_rpath="$rpath"
+ fi
+
+ if test -n "$compile_shlibpath$finalize_shlibpath"; then
+ compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+ fi
+ if test -n "$finalize_shlibpath"; then
+ finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+ fi
+
+ compile_var=
+ finalize_var=
+ if test -n "$runpath_var"; then
+ if test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ if test -n "$finalize_perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $finalize_perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ fi
+
+ if test "$no_install" = yes; then
+ # We don't need to create a wrapper script.
+ link_command="$compile_var$compile_command$compile_rpath"
+ # Replace the output file specification.
+ link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+ # Delete the old output file.
+ $run $rm $output
+ # Link the executable and exit
+ $show "$link_command"
+ $run eval "$link_command" || exit $?
+ exit 0
+ fi
+
+ if test "$hardcode_action" = relink; then
+ # Fast installation is not supported
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+ $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
+ $echo "$modename: \`$output' will be relinked during installation" 1>&2
+ else
+ if test "$fast_install" != no; then
+ link_command="$finalize_var$compile_command$finalize_rpath"
+ if test "$fast_install" = yes; then
+ relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+ else
+ # fast_install is set to needless
+ relink_command=
+ fi
+ else
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+ fi
+ fi
+
+ # Replace the output file specification.
+ link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+ # Delete the old output files.
+ $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+ $show "$link_command"
+ $run eval "$link_command" || exit $?
+
+ # Now create the wrapper script.
+ $show "creating $output"
+
+ # Quote the relink command for shipping.
+ if test -n "$relink_command"; then
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+ relink_command="$var=\"$var_value\"; export $var; $relink_command"
+ fi
+ done
+ relink_command="(cd `pwd`; $relink_command)"
+ relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Quote $echo for shipping.
+ if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
+ case $0 in
+ [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";;
+ *) qecho="$SHELL `pwd`/$0 --fallback-echo";;
+ esac
+ qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
+ else
+ qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Only actually do things if our run command is non-null.
+ if test -z "$run"; then
+ # win32 will think the script is a binary if it has
+ # a .exe suffix, so we strip it off here.
+ case $output in
+ *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
+ esac
+ # test for cygwin because mv fails w/o .exe extensions
+ case $host in
+ *cygwin*)
+ exeext=.exe
+ outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
+ *) exeext= ;;
+ esac
+ case $host in
+ *cygwin* | *mingw* )
+ cwrappersource=`$echo ${objdir}/lt-${output}.c`
+ cwrapper=`$echo ${output}.exe`
+ $rm $cwrappersource $cwrapper
+ trap "$rm $cwrappersource $cwrapper; exit 1" 1 2 15
+
+ cat > $cwrappersource <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+ Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+
+ The $output program cannot be directly executed until all the libtool
+ libraries that it depends on are installed.
+
+ This wrapper executable should never be moved out of the build directory.
+ If it is, it will not operate correctly.
+
+ Currently, it simply execs the wrapper *script* "/bin/sh $output",
+ but could eventually absorb all of the scripts functionality and
+ exec $objdir/$outputname directly.
+*/
+EOF
+ cat >> $cwrappersource<<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef DIR_SEPARATOR
+#define DIR_SEPARATOR '/'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+ defined (__OS2__)
+#define HAVE_DOS_BASED_FILE_SYSTEM
+#ifndef DIR_SEPARATOR_2
+#define DIR_SEPARATOR_2 '\\'
+#endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+ if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+const char *program_name = NULL;
+
+void * xmalloc (size_t num);
+char * xstrdup (const char *string);
+char * basename (const char *name);
+char * fnqualify(const char *path);
+char * strendzap(char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+
+int
+main (int argc, char *argv[])
+{
+ char **newargz;
+ int i;
+
+ program_name = (char *) xstrdup ((char *) basename (argv[0]));
+ newargz = XMALLOC(char *, argc+2);
+EOF
+
+ cat >> $cwrappersource <<EOF
+ newargz[0] = "$SHELL";
+EOF
+
+ cat >> $cwrappersource <<"EOF"
+ newargz[1] = fnqualify(argv[0]);
+ /* we know the script has the same name, without the .exe */
+ /* so make sure newargz[1] doesn't end in .exe */
+ strendzap(newargz[1],".exe");
+ for (i = 1; i < argc; i++)
+ newargz[i+1] = xstrdup(argv[i]);
+ newargz[argc+1] = NULL;
+EOF
+
+ cat >> $cwrappersource <<EOF
+ execv("$SHELL",newargz);
+EOF
+
+ cat >> $cwrappersource <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+ void * p = (void *) malloc (num);
+ if (!p)
+ lt_fatal ("Memory exhausted");
+
+ return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+ return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
+;
+}
+
+char *
+basename (const char *name)
+{
+ const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ /* Skip over the disk name in MSDOS pathnames. */
+ if (isalpha (name[0]) && name[1] == ':')
+ name += 2;
+#endif
+
+ for (base = name; *name; name++)
+ if (IS_DIR_SEPARATOR (*name))
+ base = name + 1;
+ return (char *) base;
+}
+
+char *
+fnqualify(const char *path)
+{
+ size_t size;
+ char *p;
+ char tmp[LT_PATHMAX + 1];
+
+ assert(path != NULL);
+
+ /* Is it qualified already? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ if (isalpha (path[0]) && path[1] == ':')
+ return xstrdup (path);
+#endif
+ if (IS_DIR_SEPARATOR (path[0]))
+ return xstrdup (path);
+
+ /* prepend the current directory */
+ /* doesn't handle '~' */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal ("getcwd failed");
+ size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
+ p = XMALLOC(char, size);
+ sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
+ return p;
+}
+
+char *
+strendzap(char *str, const char *pat)
+{
+ size_t len, patlen;
+
+ assert(str != NULL);
+ assert(pat != NULL);
+
+ len = strlen(str);
+ patlen = strlen(pat);
+
+ if (patlen <= len)
+ {
+ str += len - patlen;
+ if (strcmp(str, pat) == 0)
+ *str = '\0';
+ }
+ return str;
+}
+
+static void
+lt_error_core (int exit_status, const char * mode,
+ const char * message, va_list ap)
+{
+ fprintf (stderr, "%s: %s: ", program_name, mode);
+ vfprintf (stderr, message, ap);
+ fprintf (stderr, ".\n");
+
+ if (exit_status >= 0)
+ exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+ va_list ap;
+ va_start (ap, message);
+ lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+ va_end (ap);
+}
+EOF
+ # we should really use a build-platform specific compiler
+ # here, but OTOH, the wrappers (shell script and this C one)
+ # are only useful if you want to execute the "real" binary.
+ # Since the "real" binary is built for $host, then this
+ # wrapper might as well be built for $host, too.
+ $run $LTCC -s -o $cwrapper $cwrappersource
+ ;;
+ esac
+ $rm $output
+ trap "$rm $output; exit 1" 1 2 15
+
+ $echo > $output "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+ # install mode needs the following variable:
+ notinst_deplibs='$notinst_deplibs'
+else
+ # When we are sourced in execute mode, \$file and \$echo are already set.
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ echo=\"$qecho\"
+ file=\"\$0\"
+ # Make sure echo works.
+ if test \"X\$1\" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+ elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
+ # Yippee, \$echo works!
+ :
+ else
+ # Restart under the correct shell, and then maybe \$echo will work.
+ exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+ fi
+ fi\
+"
+ $echo >> $output "\
+
+ # Find the directory that this script lives in.
+ thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+ test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+ while test -n \"\$file\"; do
+ destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+ # If there was a directory component, then change thisdir.
+ if test \"x\$destdir\" != \"x\$file\"; then
+ case \"\$destdir\" in
+ [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+ *) thisdir=\"\$thisdir/\$destdir\" ;;
+ esac
+ fi
+
+ file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+ file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+ done
+
+ # Try to get the absolute directory name.
+ absdir=\`cd \"\$thisdir\" && pwd\`
+ test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+ if test "$fast_install" = yes; then
+ $echo >> $output "\
+ program=lt-'$outputname'$exeext
+ progdir=\"\$thisdir/$objdir\"
+
+ if test ! -f \"\$progdir/\$program\" || \\
+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+ test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+ file=\"\$\$-\$program\"
+
+ if test ! -d \"\$progdir\"; then
+ $mkdir \"\$progdir\"
+ else
+ $rm \"\$progdir/\$file\"
+ fi"
+
+ $echo >> $output "\
+
+ # relink executable if necessary
+ if test -n \"\$relink_command\"; then
+ if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+ else
+ $echo \"\$relink_command_output\" >&2
+ $rm \"\$progdir/\$file\"
+ exit 1
+ fi
+ fi
+
+ $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+ { $rm \"\$progdir/\$program\";
+ $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+ $rm \"\$progdir/\$file\"
+ fi"
+ else
+ $echo >> $output "\
+ program='$outputname'
+ progdir=\"\$thisdir/$objdir\"
+"
+ fi
+
+ $echo >> $output "\
+
+ if test -f \"\$progdir/\$program\"; then"
+
+ # Export our shlibpath_var if we have one.
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ $echo >> $output "\
+ # Add our own library path to $shlibpath_var
+ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+ # Some systems cannot cope with colon-terminated $shlibpath_var
+ # The second colon is a workaround for a bug in BeOS R4 sed
+ $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+ export $shlibpath_var
+"
+ fi
+
+ # fixup the dll searchpath if we need to.
+ if test -n "$dllsearchpath"; then
+ $echo >> $output "\
+ # Add the dll search path components to the executable PATH
+ PATH=$dllsearchpath:\$PATH
+"
+ fi
+
+ $echo >> $output "\
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ # Run the actual program with our arguments.
+"
+ case $host in
+ # Backslashes separate directories on plain windows
+ *-*-mingw | *-*-os2*)
+ $echo >> $output "\
+ exec \$progdir\\\\\$program \${1+\"\$@\"}
+"
+ ;;
+
+ *)
+ $echo >> $output "\
+ exec \$progdir/\$program \${1+\"\$@\"}
+"
+ ;;
+ esac
+ $echo >> $output "\
+ \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+ exit 1
+ fi
+ else
+ # The program doesn't exist.
+ \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
+ \$echo \"This script is just a wrapper for \$program.\" 1>&2
+ $echo \"See the $PACKAGE documentation for more information.\" 1>&2
+ exit 1
+ fi
+fi\
+"
+ chmod +x $output
+ fi
+ exit 0
+ ;;
+ esac
+
+ # See if we need to build an old-fashioned archive.
+ for oldlib in $oldlibs; do
+
+ if test "$build_libtool_libs" = convenience; then
+ oldobjs="$libobjs_save"
+ addlibs="$convenience"
+ build_libtool_libs=no
+ else
+ if test "$build_libtool_libs" = module; then
+ oldobjs="$libobjs_save"
+ build_libtool_libs=no
+ else
+ oldobjs="$old_deplibs $non_pic_objects"
+ fi
+ addlibs="$old_convenience"
+ fi
+
+ if test -n "$addlibs"; then
+ gentop="$output_objdir/${outputname}x"
+ $show "${rm}r $gentop"
+ $run ${rm}r "$gentop"
+ $show "$mkdir $gentop"
+ $run $mkdir "$gentop"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$gentop"; then
+ exit $status
+ fi
+ generated="$generated $gentop"
+
+ # Add in members from convenience archives.
+ for xlib in $addlibs; do
+ # Extract the objects.
+ case $xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+ *) xabs=`pwd`"/$xlib" ;;
+ esac
+ xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+ xdir="$gentop/$xlib"
+
+ $show "${rm}r $xdir"
+ $run ${rm}r "$xdir"
+ $show "$mkdir $xdir"
+ $run $mkdir "$xdir"
+ status=$?
+ if test "$status" -ne 0 && test ! -d "$xdir"; then
+ exit $status
+ fi
+ # We will extract separately just the conflicting names and we will no
+ # longer touch any unique names. It is faster to leave these extract
+ # automatically by $AR in one run.
+ $show "(cd $xdir && $AR x $xabs)"
+ $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+ if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
+ $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
+ $AR t "$xabs" | sort | uniq -cd | while read -r count name
+ do
+ i=1
+ while test "$i" -le "$count"
+ do
+ # Put our $i before any first dot (extension)
+ # Never overwrite any file
+ name_to="$name"
+ while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
+ do
+ name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
+ done
+ $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
+ $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
+ i=`expr $i + 1`
+ done
+ done
+ fi
+
+ oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
+ done
+ fi
+
+ compiler_flags="$compiler_flags $add_flags"
+
+ # Do each command in the archive commands.
+ if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+ eval cmds=\"$old_archive_from_new_cmds\"
+ else
+ eval cmds=\"$old_archive_cmds\"
+
+ if len=`expr "X$cmds" : ".*"` &&
+ test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ :
+ else
+ # the command line is too long to link in one step, link in parts
+ $echo "using piecewise archive linking..."
+ save_RANLIB=$RANLIB
+ RANLIB=:
+ objlist=
+ concat_cmds=
+ save_oldobjs=$oldobjs
+ # GNU ar 2.10+ was changed to match POSIX; thus no paths are
+ # encoded into archives. This makes 'ar r' malfunction in
+ # this piecewise linking case whenever conflicting object
+ # names appear in distinct ar calls; check, warn and compensate.
+ if (for obj in $save_oldobjs
+ do
+ $echo "X$obj" | $Xsed -e 's%^.*/%%'
+ done | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
+ $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
+ AR_FLAGS=cq
+ fi
+ # Is there a better way of finding the last object in the list?
+ for obj in $save_oldobjs
+ do
+ last_oldobj=$obj
+ done
+ for obj in $save_oldobjs
+ do
+ oldobjs="$objlist $obj"
+ objlist="$objlist $obj"
+ eval test_cmds=\"$old_archive_cmds\"
+ if len=`expr "X$test_cmds" : ".*"` &&
+ test "$len" -le "$max_cmd_len"; then
+ :
+ else
+ # the above command should be used before it gets too long
+ oldobjs=$objlist
+ if test "$obj" = "$last_oldobj" ; then
+ RANLIB=$save_RANLIB
+ fi
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+ objlist=
+ fi
+ done
+ RANLIB=$save_RANLIB
+ oldobjs=$objlist
+ if test "X$oldobjs" = "X" ; then
+ eval cmds=\"\$concat_cmds\"
+ else
+ eval cmds=\"\$concat_cmds~$old_archive_cmds\"
+ fi
+ fi
+ fi
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ done
+
+ if test -n "$generated"; then
+ $show "${rm}r$generated"
+ $run ${rm}r$generated
+ fi
+
+ # Now create the libtool archive.
+ case $output in
+ *.la)
+ old_library=
+ test "$build_old_libs" = yes && old_library="$libname.$libext"
+ $show "creating $output"
+
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+ relink_command="$var=\"$var_value\"; export $var; $relink_command"
+ fi
+ done
+ # Quote the link command for shipping.
+ relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@)"
+ relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+ if test "$hardcode_automatic" = yes ; then
+ relink_command=
+ fi
+ # Only create the output if not a dry run.
+ if test -z "$run"; then
+ for installed in no yes; do
+ if test "$installed" = yes; then
+ if test -z "$install_libdir"; then
+ break
+ fi
+ output="$output_objdir/$outputname"i
+ # Replace all uninstalled libtool libraries with the installed ones
+ newdependency_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ *.la)
+ name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ if test -z "$libdir"; then
+ $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+ newdependency_libs="$newdependency_libs $libdir/$name"
+ ;;
+ *) newdependency_libs="$newdependency_libs $deplib" ;;
+ esac
+ done
+ dependency_libs="$newdependency_libs"
+ newdlfiles=
+ for lib in $dlfiles; do
+ name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ if test -z "$libdir"; then
+ $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+ newdlfiles="$newdlfiles $libdir/$name"
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ if test -z "$libdir"; then
+ $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+ exit 1
+ fi
+ newdlprefiles="$newdlprefiles $libdir/$name"
+ done
+ dlprefiles="$newdlprefiles"
+ fi
+ $rm $output
+ # place dlname in correct position for cygwin
+ tdlname=$dlname
+ case $host,$output,$installed,$module,$dlname in
+ *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+ esac
+ $echo > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+ if test "$installed" = no && test "$need_relink" = yes && test "$fast_install" = no; then
+ $echo >> $output "\
+relink_command=\"$relink_command\""
+ fi
+ done
+ fi
+
+ # Do a symbolic link so that the libtool archive can be found in
+ # LD_LIBRARY_PATH before the program is installed.
+ $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
+ $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
+ ;;
+ esac
+ exit 0
+ ;;
+
+ # libtool install mode
+ install)
+ modename="$modename: install"
+
+ # There may be an optional sh(1) argument at the beginning of
+ # install_prog (especially on Windows NT).
+ if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+ # Allow the use of GNU shtool's install command.
+ $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then
+ # Aesthetically quote it.
+ arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ install_prog="$arg "
+ arg="$1"
+ shift
+ else
+ install_prog=
+ arg="$nonopt"
+ fi
+
+ # The real first argument should be the name of the installation program.
+ # Aesthetically quote it.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ install_prog="$install_prog$arg"
+
+ # We need to accept at least all the BSD install flags.
+ dest=
+ files=
+ opts=
+ prev=
+ install_type=
+ isdir=no
+ stripme=
+ for arg
+ do
+ if test -n "$dest"; then
+ files="$files $dest"
+ dest="$arg"
+ continue
+ fi
+
+ case $arg in
+ -d) isdir=yes ;;
+ -f) prev="-f" ;;
+ -g) prev="-g" ;;
+ -m) prev="-m" ;;
+ -o) prev="-o" ;;
+ -s)
+ stripme=" -s"
+ continue
+ ;;
+ -*) ;;
+
+ *)
+ # If the previous option needed an argument, then skip it.
+ if test -n "$prev"; then
+ prev=
+ else
+ dest="$arg"
+ continue
+ fi
+ ;;
+ esac
+
+ # Aesthetically quote the argument.
+ arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+ case $arg in
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
+ arg="\"$arg\""
+ ;;
+ esac
+ install_prog="$install_prog $arg"
+ done
+
+ if test -z "$install_prog"; then
+ $echo "$modename: you must specify an install program" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ if test -n "$prev"; then
+ $echo "$modename: the \`$prev' option requires an argument" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ if test -z "$files"; then
+ if test -z "$dest"; then
+ $echo "$modename: no file or destination specified" 1>&2
+ else
+ $echo "$modename: you must specify a destination" 1>&2
+ fi
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Strip any trailing slash from the destination.
+ dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
+
+ # Check to see that the destination is a directory.
+ test -d "$dest" && isdir=yes
+ if test "$isdir" = yes; then
+ destdir="$dest"
+ destname=
+ else
+ destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$destdir" = "X$dest" && destdir=.
+ destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
+
+ # Not a directory, so check to see that there is only one file specified.
+ set dummy $files
+ if test "$#" -gt 2; then
+ $echo "$modename: \`$dest' is not a directory" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+ fi
+ case $destdir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ for file in $files; do
+ case $file in
+ *.lo) ;;
+ *)
+ $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ staticlibs=
+ future_libdirs=
+ current_libdirs=
+ for file in $files; do
+
+ # Do each installation.
+ case $file in
+ *.$libext)
+ # Do the static libraries later.
+ staticlibs="$staticlibs $file"
+ ;;
+
+ *.la)
+ # Check to see that this really is a libtool archive.
+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ else
+ $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ library_names=
+ old_library=
+ relink_command=
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Add the libdir to current_libdirs if it is the destination.
+ if test "X$destdir" = "X$libdir"; then
+ case "$current_libdirs " in
+ *" $libdir "*) ;;
+ *) current_libdirs="$current_libdirs $libdir" ;;
+ esac
+ else
+ # Note the libdir as a future libdir.
+ case "$future_libdirs " in
+ *" $libdir "*) ;;
+ *) future_libdirs="$future_libdirs $libdir" ;;
+ esac
+ fi
+
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
+ test "X$dir" = "X$file/" && dir=
+ dir="$dir$objdir"
+
+ if test -n "$relink_command"; then
+ # Determine the prefix the user has applied to our future dir.
+ inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
+
+ # Don't allow the user to place us outside of our expected
+ # location b/c this prevents finding dependent libraries that
+ # are installed to the same prefix.
+ # At present, this check doesn't affect windows .dll's that
+ # are installed into $libdir/../bin (currently, that works fine)
+ # but it's something to keep an eye on.
+ if test "$inst_prefix_dir" = "$destdir"; then
+ $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+ exit 1
+ fi
+
+ if test -n "$inst_prefix_dir"; then
+ # Stick the inst_prefix_dir data into the link command.
+ relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+ else
+ relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+ fi
+
+ $echo "$modename: warning: relinking \`$file'" 1>&2
+ $show "$relink_command"
+ if $run eval "$relink_command"; then :
+ else
+ $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+ exit 1
+ fi
+ fi
+
+ # See the names of the shared library.
+ set dummy $library_names
+ if test -n "$2"; then
+ realname="$2"
+ shift
+ shift
+
+ srcname="$realname"
+ test -n "$relink_command" && srcname="$realname"T
+
+ # Install the shared library and build the symlinks.
+ $show "$install_prog $dir/$srcname $destdir/$realname"
+ $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
+ if test -n "$stripme" && test -n "$striplib"; then
+ $show "$striplib $destdir/$realname"
+ $run eval "$striplib $destdir/$realname" || exit $?
+ fi
+
+ if test "$#" -gt 0; then
+ # Delete the old symlinks, and create new ones.
+ for linkname
+ do
+ if test "$linkname" != "$realname"; then
+ $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+ $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+ fi
+ done
+ fi
+
+ # Do each command in the postinstall commands.
+ lib="$destdir/$realname"
+ eval cmds=\"$postinstall_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ fi
+
+ # Install the pseudo-library for information purposes.
+ name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ instname="$dir/$name"i
+ $show "$install_prog $instname $destdir/$name"
+ $run eval "$install_prog $instname $destdir/$name" || exit $?
+
+ # Maybe install the static library, too.
+ test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+ ;;
+
+ *.lo)
+ # Install (i.e. copy) a libtool object.
+
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ destfile="$destdir/$destfile"
+ fi
+
+ # Deduce the name of the destination old-style object file.
+ case $destfile in
+ *.lo)
+ staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
+ ;;
+ *.$objext)
+ staticdest="$destfile"
+ destfile=
+ ;;
+ *)
+ $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+ esac
+
+ # Install the libtool object if requested.
+ if test -n "$destfile"; then
+ $show "$install_prog $file $destfile"
+ $run eval "$install_prog $file $destfile" || exit $?
+ fi
+
+ # Install the old object if enabled.
+ if test "$build_old_libs" = yes; then
+ # Deduce the name of the old-style object file.
+ staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
+
+ $show "$install_prog $staticobj $staticdest"
+ $run eval "$install_prog \$staticobj \$staticdest" || exit $?
+ fi
+ exit 0
+ ;;
+
+ *)
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ destfile="$destdir/$destfile"
+ fi
+
+ # If the file is missing, and there is a .exe on the end, strip it
+ # because it is most likely a libtool script we actually want to
+ # install
+ stripped_ext=""
+ case $file in
+ *.exe)
+ if test ! -f "$file"; then
+ file=`$echo $file|${SED} 's,.exe$,,'`
+ stripped_ext=".exe"
+ fi
+ ;;
+ esac
+
+ # Do a test to see if this is really a libtool program.
+ case $host in
+ *cygwin*|*mingw*)
+ wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
+ ;;
+ *)
+ wrapper=$file
+ ;;
+ esac
+ if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
+ notinst_deplibs=
+ relink_command=
+
+ # To insure that "foo" is sourced, and not "foo.exe",
+ # finese the cygwin/MSYS system by explicitly sourcing "foo."
+ # which disallows the automatic-append-.exe behavior.
+ case $build in
+ *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
+ *) wrapperdot=${wrapper} ;;
+ esac
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . ${wrapperdot} ;;
+ *) . ./${wrapperdot} ;;
+ esac
+
+ # Check the variables that should have been set.
+ if test -z "$notinst_deplibs"; then
+ $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
+ exit 1
+ fi
+
+ finalize=yes
+ for lib in $notinst_deplibs; do
+ # Check to see that each library is installed.
+ libdir=
+ if test -f "$lib"; then
+ # If there is no directory component, then add one.
+ case $lib in
+ */* | *\\*) . $lib ;;
+ *) . ./$lib ;;
+ esac
+ fi
+ libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+ if test -n "$libdir" && test ! -f "$libfile"; then
+ $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
+ finalize=no
+ fi
+ done
+
+ relink_command=
+ # To insure that "foo" is sourced, and not "foo.exe",
+ # finese the cygwin/MSYS system by explicitly sourcing "foo."
+ # which disallows the automatic-append-.exe behavior.
+ case $build in
+ *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
+ *) wrapperdot=${wrapper} ;;
+ esac
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . ${wrapperdot} ;;
+ *) . ./${wrapperdot} ;;
+ esac
+
+ outputname=
+ if test "$fast_install" = no && test -n "$relink_command"; then
+ if test "$finalize" = yes && test -z "$run"; then
+ tmpdir="/tmp"
+ test -n "$TMPDIR" && tmpdir="$TMPDIR"
+ tmpdir="$tmpdir/libtool-$$"
+ if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
+ else
+ $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
+ continue
+ fi
+ file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
+ outputname="$tmpdir/$file"
+ # Replace the output file specification.
+ relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+ $show "$relink_command"
+ if $run eval "$relink_command"; then :
+ else
+ $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+ ${rm}r "$tmpdir"
+ continue
+ fi
+ file="$outputname"
+ else
+ $echo "$modename: warning: cannot relink \`$file'" 1>&2
+ fi
+ else
+ # Install the binary that we compiled earlier.
+ file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+ fi
+ fi
+
+ # remove .exe since cygwin /usr/bin/install will append another
+ # one anyways
+ case $install_prog,$host in
+ */usr/bin/install*,*cygwin*)
+ case $file:$destfile in
+ *.exe:*.exe)
+ # this is ok
+ ;;
+ *.exe:*)
+ destfile=$destfile.exe
+ ;;
+ *:*.exe)
+ destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
+ ;;
+ esac
+ ;;
+ esac
+ $show "$install_prog$stripme $file $destfile"
+ $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
+ test -n "$outputname" && ${rm}r "$tmpdir"
+ ;;
+ esac
+ done
+
+ for file in $staticlibs; do
+ name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+ # Set up the ranlib parameters.
+ oldlib="$destdir/$name"
+
+ $show "$install_prog $file $oldlib"
+ $run eval "$install_prog \$file \$oldlib" || exit $?
+
+ if test -n "$stripme" && test -n "$striplib"; then
+ $show "$old_striplib $oldlib"
+ $run eval "$old_striplib $oldlib" || exit $?
+ fi
+
+ # Do each command in the postinstall commands.
+ eval cmds=\"$old_postinstall_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || exit $?
+ done
+ IFS="$save_ifs"
+ done
+
+ if test -n "$future_libdirs"; then
+ $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
+ fi
+
+ if test -n "$current_libdirs"; then
+ # Maybe just do a dry run.
+ test -n "$run" && current_libdirs=" -n$current_libdirs"
+ exec_cmd='$SHELL $0 --finish$current_libdirs'
+ else
+ exit 0
+ fi
+ ;;
+
+ # libtool finish mode
+ finish)
+ modename="$modename: finish"
+ libdirs="$nonopt"
+ admincmds=
+
+ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+ for dir
+ do
+ libdirs="$libdirs $dir"
+ done
+
+ for libdir in $libdirs; do
+ if test -n "$finish_cmds"; then
+ # Do each command in the finish commands.
+ eval cmds=\"$finish_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd" || admincmds="$admincmds
+ $cmd"
+ done
+ IFS="$save_ifs"
+ fi
+ if test -n "$finish_eval"; then
+ # Do the single finish_eval.
+ eval cmds=\"$finish_eval\"
+ $run eval "$cmds" || admincmds="$admincmds
+ $cmds"
+ fi
+ done
+ fi
+
+ # Exit here if they wanted silent mode.
+ exit 0
+
+ $echo "----------------------------------------------------------------------"
+ $echo "Libraries have been installed in:"
+ for libdir in $libdirs; do
+ $echo " $libdir"
+ done
+ $echo
+ $echo "If you ever happen to want to link against installed libraries"
+ $echo "in a given directory, LIBDIR, you must either use libtool, and"
+ $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+ $echo "flag during linking and do at least one of the following:"
+ if test -n "$shlibpath_var"; then
+ $echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
+ $echo " during execution"
+ fi
+ if test -n "$runpath_var"; then
+ $echo " - add LIBDIR to the \`$runpath_var' environment variable"
+ $echo " during linking"
+ fi
+ if test -n "$hardcode_libdir_flag_spec"; then
+ libdir=LIBDIR
+ eval flag=\"$hardcode_libdir_flag_spec\"
+
+ $echo " - use the \`$flag' linker flag"
+ fi
+ if test -n "$admincmds"; then
+ $echo " - have your system administrator run these commands:$admincmds"
+ fi
+ if test -f /etc/ld.so.conf; then
+ $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+ fi
+ $echo
+ $echo "See any operating system documentation about shared libraries for"
+ $echo "more information, such as the ld(1) and ld.so(8) manual pages."
+ $echo "----------------------------------------------------------------------"
+ exit 0
+ ;;
+
+ # libtool execute mode
+ execute)
+ modename="$modename: execute"
+
+ # The first argument is the command name.
+ cmd="$nonopt"
+ if test -z "$cmd"; then
+ $echo "$modename: you must specify a COMMAND" 1>&2
+ $echo "$help"
+ exit 1
+ fi
+
+ # Handle -dlopen flags immediately.
+ for file in $execute_dlfiles; do
+ if test ! -f "$file"; then
+ $echo "$modename: \`$file' is not a file" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ dir=
+ case $file in
+ *.la)
+ # Check to see that this really is a libtool archive.
+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+ else
+ $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ # Read the libtool library.
+ dlname=
+ library_names=
+
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Skip this library if it cannot be dlopened.
+ if test -z "$dlname"; then
+ # Warn if it was a shared library.
+ test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
+ continue
+ fi
+
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$dir" = "X$file" && dir=.
+
+ if test -f "$dir/$objdir/$dlname"; then
+ dir="$dir/$objdir"
+ else
+ $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+ exit 1
+ fi
+ ;;
+
+ *.lo)
+ # Just add the directory containing the .lo file.
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ test "X$dir" = "X$file" && dir=.
+ ;;
+
+ *)
+ $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
+ continue
+ ;;
+ esac
+
+ # Get the absolute pathname.
+ absdir=`cd "$dir" && pwd`
+ test -n "$absdir" && dir="$absdir"
+
+ # Now add the directory to shlibpath_var.
+ if eval "test -z \"\$$shlibpath_var\""; then
+ eval "$shlibpath_var=\"\$dir\""
+ else
+ eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+ fi
+ done
+
+ # This variable tells wrapper scripts just to set shlibpath_var
+ # rather than running their programs.
+ libtool_execute_magic="$magic"
+
+ # Check if any of the arguments is a wrapper script.
+ args=
+ for file
+ do
+ case $file in
+ -*) ;;
+ *)
+ # Do a test to see if this is really a libtool program.
+ if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ # If there is no directory component, then add one.
+ case $file in
+ */* | *\\*) . $file ;;
+ *) . ./$file ;;
+ esac
+
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ fi
+ ;;
+ esac
+ # Quote arguments (to preserve shell metacharacters).
+ file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
+ args="$args \"$file\""
+ done
+
+ if test -z "$run"; then
+ if test -n "$shlibpath_var"; then
+ # Export the shlibpath_var.
+ eval "export $shlibpath_var"
+ fi
+
+ # Restore saved environment variables
+ if test "${save_LC_ALL+set}" = set; then
+ LC_ALL="$save_LC_ALL"; export LC_ALL
+ fi
+ if test "${save_LANG+set}" = set; then
+ LANG="$save_LANG"; export LANG
+ fi
+
+ # Now prepare to actually exec the command.
+ exec_cmd="\$cmd$args"
+ else
+ # Display what would be done.
+ if test -n "$shlibpath_var"; then
+ eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
+ $echo "export $shlibpath_var"
+ fi
+ $echo "$cmd$args"
+ exit 0
+ fi
+ ;;
+
+ # libtool clean and uninstall mode
+ clean | uninstall)
+ modename="$modename: $mode"
+ rm="$nonopt"
+ files=
+ rmforce=
+ exit_status=0
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ for arg
+ do
+ case $arg in
+ -f) rm="$rm $arg"; rmforce=yes ;;
+ -*) rm="$rm $arg" ;;
+ *) files="$files $arg" ;;
+ esac
+ done
+
+ if test -z "$rm"; then
+ $echo "$modename: you must specify an RM program" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+
+ rmdirs=
+
+ origobjdir="$objdir"
+ for file in $files; do
+ dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+ if test "X$dir" = "X$file"; then
+ dir=.
+ objdir="$origobjdir"
+ else
+ objdir="$dir/$origobjdir"
+ fi
+ name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+ test "$mode" = uninstall && objdir="$dir"
+
+ # Remember objdir for removal later, being careful to avoid duplicates
+ if test "$mode" = clean; then
+ case " $rmdirs " in
+ *" $objdir "*) ;;
+ *) rmdirs="$rmdirs $objdir" ;;
+ esac
+ fi
+
+ # Don't error if the file doesn't exist and rm -f was used.
+ if (test -L "$file") >/dev/null 2>&1 \
+ || (test -h "$file") >/dev/null 2>&1 \
+ || test -f "$file"; then
+ :
+ elif test -d "$file"; then
+ exit_status=1
+ continue
+ elif test "$rmforce" = yes; then
+ continue
+ fi
+
+ rmfiles="$file"
+
+ case $name in
+ *.la)
+ # Possibly a libtool archive, so verify it.
+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ . $dir/$name
+
+ # Delete the libtool libraries and symlinks.
+ for n in $library_names; do
+ rmfiles="$rmfiles $objdir/$n"
+ done
+ test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+ test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+
+ if test "$mode" = uninstall; then
+ if test -n "$library_names"; then
+ # Do each command in the postuninstall commands.
+ eval cmds=\"$postuninstall_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd"
+ if test "$?" -ne 0 && test "$rmforce" != yes; then
+ exit_status=1
+ fi
+ done
+ IFS="$save_ifs"
+ fi
+
+ if test -n "$old_library"; then
+ # Do each command in the old_postuninstall commands.
+ eval cmds=\"$old_postuninstall_cmds\"
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ $show "$cmd"
+ $run eval "$cmd"
+ if test "$?" -ne 0 && test "$rmforce" != yes; then
+ exit_status=1
+ fi
+ done
+ IFS="$save_ifs"
+ fi
+ # FIXME: should reinstall the best remaining shared library.
+ fi
+ fi
+ ;;
+
+ *.lo)
+ # Possibly a libtool object, so verify it.
+ if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+
+ # Read the .lo file
+ . $dir/$name
+
+ # Add PIC object to the list of files to remove.
+ if test -n "$pic_object" \
+ && test "$pic_object" != none; then
+ rmfiles="$rmfiles $dir/$pic_object"
+ fi
+
+ # Add non-PIC object to the list of files to remove.
+ if test -n "$non_pic_object" \
+ && test "$non_pic_object" != none; then
+ rmfiles="$rmfiles $dir/$non_pic_object"
+ fi
+ fi
+ ;;
+
+ *)
+ if test "$mode" = clean ; then
+ noexename=$name
+ case $file in
+ *.exe)
+ file=`$echo $file|${SED} 's,.exe$,,'`
+ noexename=`$echo $name|${SED} 's,.exe$,,'`
+ # $file with .exe has already been added to rmfiles,
+ # add $file without .exe
+ rmfiles="$rmfiles $file"
+ ;;
+ esac
+ # Do a test to see if this is a libtool program.
+ if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+ relink_command=
+ . $dir/$noexename
+
+ # note $name still contains .exe if it was in $file originally
+ # as does the version of $file that was added into $rmfiles
+ rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+ if test "$fast_install" = yes && test -n "$relink_command"; then
+ rmfiles="$rmfiles $objdir/lt-$name"
+ fi
+ if test "X$noexename" != "X$name" ; then
+ rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+ fi
+ fi
+ fi
+ ;;
+ esac
+ $show "$rm $rmfiles"
+ $run $rm $rmfiles || exit_status=1
+ done
+ objdir="$origobjdir"
+
+ # Try to remove the ${objdir}s in the directories where we deleted files
+ for dir in $rmdirs; do
+ if test -d "$dir"; then
+ $show "rmdir $dir"
+ $run rmdir $dir >/dev/null 2>&1
+ fi
+ done
+
+ exit $exit_status
+ ;;
+
+ "")
+ $echo "$modename: you must specify a MODE" 1>&2
+ $echo "$generic_help" 1>&2
+ exit 1
+ ;;
+ esac
+
+ if test -z "$exec_cmd"; then
+ $echo "$modename: invalid operation mode \`$mode'" 1>&2
+ $echo "$generic_help" 1>&2
+ exit 1
+ fi
+fi # test -z "$show_help"
+
+if test -n "$exec_cmd"; then
+ eval exec $exec_cmd
+ exit 1
+fi
+
+# We need to display help for each of the modes.
+case $mode in
+"") $echo \
+"Usage: $modename [OPTION]... [MODE-ARG]...
+
+Provide generalized library-building support services.
+
+ --config show all configuration variables
+ --debug enable verbose shell tracing
+-n, --dry-run display commands without modifying any files
+ --features display basic configuration information and exit
+ --finish same as \`--mode=finish'
+ --help display this help message and exit
+ --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS]
+ --quiet same as \`--silent'
+ --silent don't print informational messages
+ --tag=TAG use configuration variables from tag TAG
+ --version print version information
+
+MODE must be one of the following:
+
+ clean remove files from the build directory
+ compile compile a source file into a libtool object
+ execute automatically set library path, then run a program
+ finish complete the installation of libtool libraries
+ install install libraries or executables
+ link create a library or an executable
+ uninstall remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for
+a more detailed description of MODE.
+
+Report bugs to <bug-libtool@gnu.org>."
+ exit 0
+ ;;
+
+clean)
+ $echo \
+"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+compile)
+ $echo \
+"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+ -o OUTPUT-FILE set the output file name to OUTPUT-FILE
+ -prefer-pic try to building PIC objects only
+ -prefer-non-pic try to building non-PIC objects only
+ -static always build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+ ;;
+
+execute)
+ $echo \
+"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+ -dlopen FILE add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+ ;;
+
+finish)
+ $echo \
+"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges. Use
+the \`--dry-run' option if you just want to see what would be executed."
+ ;;
+
+install)
+ $echo \
+"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command. The first component should be
+either the \`install' or \`cp' program.
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+ ;;
+
+link)
+ $echo \
+"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+ -all-static do not do any dynamic linking at all
+ -avoid-version do not add a version suffix if possible
+ -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
+ -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
+ -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+ -export-symbols SYMFILE
+ try to export only the symbols listed in SYMFILE
+ -export-symbols-regex REGEX
+ try to export only the symbols matching REGEX
+ -LLIBDIR search LIBDIR for required installed libraries
+ -lNAME OUTPUT-FILE requires the installed library libNAME
+ -module build a library that can dlopened
+ -no-fast-install disable the fast-install mode
+ -no-install link a not-installable executable
+ -no-undefined declare that a library does not refer to external symbols
+ -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
+ -objectlist FILE Use a list of object files found in FILE to specify objects
+ -release RELEASE specify package release information
+ -rpath LIBDIR the created library will eventually be installed in LIBDIR
+ -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
+ -static do not do any dynamic linking of libtool libraries
+ -version-info CURRENT[:REVISION[:AGE]]
+ specify library version info [each variable defaults to 0]
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename. Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+ ;;
+
+uninstall)
+ $echo \
+"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+*)
+ $echo "$modename: invalid operation mode \`$mode'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ ;;
+esac
+
+$echo
+$echo "Try \`$modename --help' for more information about other modes."
+
+exit 0
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries. Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them. This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration. But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
diff --git a/moses/missing b/moses/missing
new file mode 100755
index 000000000..6a37006e8
--- /dev/null
+++ b/moses/missing
@@ -0,0 +1,336 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# 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 2, 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+ configure_ac=configure.ac
+else
+ configure_ac=configure.in
+fi
+
+case "$1" in
+--run)
+ # Try to run requested program, and just exit if it succeeds.
+ run=
+ shift
+ "$@" && exit 0
+ ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+ --run try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ help2man touch the output file
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ tar try tar, gnutar, gtar, then tar without non-portable flags
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing 0.4 - GNU automake"
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+ aclocal*)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acinclude.m4' or \`${configure_ac}'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`${configure_ac}'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`acconfig.h' or \`${configure_ac}'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case "$f" in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake*)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ autom4te)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them.
+ You can get \`$1Help2man' as part of \`Autoconf' from any GNU
+ archive site."
+
+ file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+ test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo "#! /bin/sh"
+ echo "# Created by GNU Automake missing as a replacement of"
+ echo "# $ $@"
+ echo "exit 0"
+ chmod +x $file
+ exit 1
+ fi
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f y.tab.h ]; then
+ echo >y.tab.h
+ fi
+ if [ ! -f y.tab.c ]; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex|flex)
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if [ $# -ne 1 ]; then
+ eval LASTARG="\${$#}"
+ case "$LASTARG" in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if [ -f "$SRCFILE" ]; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if [ ! -f lex.yy.c ]; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ help2man)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a dependency of a manual page. You may need the
+ \`Help2man' package in order for those modifications to take
+ effect. You can get \`Help2man' from any GNU archive site."
+
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+ fi
+ if [ -f "$file" ]; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo ".ab help2man is required to generate this page"
+ exit 1
+ fi
+ ;;
+
+ makeinfo)
+ if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then
+ # We have makeinfo, but it failed.
+ exit 1
+ fi
+
+ echo 1>&2 "\
+WARNING: \`$1' is missing on your system. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+ if test -z "$file"; then
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+ fi
+ touch $file
+ ;;
+
+ tar)
+ shift
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ fi
+
+ # We have already tried tar in the generic part.
+ # Look for gnutar/gtar before invocation to avoid ugly error
+ # messages.
+ if (gnutar --version > /dev/null 2>&1); then
+ gnutar "$@" && exit 0
+ fi
+ if (gtar --version > /dev/null 2>&1); then
+ gtar "$@" && exit 0
+ fi
+ firstarg="$1"
+ if shift; then
+ case "$firstarg" in
+ *o*)
+ firstarg=`echo "$firstarg" | sed s/o//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ case "$firstarg" in
+ *h*)
+ firstarg=`echo "$firstarg" | sed s/h//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ fi
+
+ echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+ You may want to install GNU tar or Free paxutils, or check the
+ command line arguments."
+ exit 1
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+ system. You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequirements for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/moses/mkinstalldirs b/moses/mkinstalldirs
new file mode 100755
index 000000000..d2d5f21b6
--- /dev/null
+++ b/moses/mkinstalldirs
@@ -0,0 +1,111 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+errstatus=0
+dirmode=""
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage" 1>&2
+ exit 0
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
+
+for file
+do
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+case $dirmode in
+ '')
+ if mkdir -p -- . 2>/dev/null; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ fi
+ ;;
+esac
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=""
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# End:
+# mkinstalldirs ends here
diff --git a/moses/moses.sln b/moses/moses.sln
new file mode 100755
index 000000000..48a5af6e5
--- /dev/null
+++ b/moses/moses.sln
@@ -0,0 +1,52 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "moses", "moses.vcproj", "{8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}"
+ ProjectSection(ProjectDependencies) = postProject
+ {B4E902E1-D423-4BD5-A603-314D06483F46} = {B4E902E1-D423-4BD5-A603-314D06483F46}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mysqlpp", "..\mysqlpp\mysqlpp.vcproj", "{B4E902E1-D423-4BD5-A603-314D06483F46}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "moses-cmd", "..\moses-cmd\moses-cmd.vcproj", "{5BBAC701-84F5-438E-8F54-B3391F451F2A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF} = {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ DebugNBest|Win32 = DebugNBest|Win32
+ Release|Win32 = Release|Win32
+ ReleaseNBest|Win32 = ReleaseNBest|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}.Debug|Win32.Build.0 = Debug|Win32
+ {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}.DebugNBest|Win32.ActiveCfg = DebugNBest|Win32
+ {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}.DebugNBest|Win32.Build.0 = DebugNBest|Win32
+ {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}.Release|Win32.ActiveCfg = Release|Win32
+ {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}.Release|Win32.Build.0 = Release|Win32
+ {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}.ReleaseNBest|Win32.ActiveCfg = ReleaseNBest|Win32
+ {8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}.ReleaseNBest|Win32.Build.0 = ReleaseNBest|Win32
+ {B4E902E1-D423-4BD5-A603-314D06483F46}.Debug|Win32.ActiveCfg = Release|Win32
+ {B4E902E1-D423-4BD5-A603-314D06483F46}.Debug|Win32.Build.0 = Release|Win32
+ {B4E902E1-D423-4BD5-A603-314D06483F46}.DebugNBest|Win32.ActiveCfg = Release|Win32
+ {B4E902E1-D423-4BD5-A603-314D06483F46}.DebugNBest|Win32.Build.0 = Release|Win32
+ {B4E902E1-D423-4BD5-A603-314D06483F46}.Release|Win32.ActiveCfg = Release|Win32
+ {B4E902E1-D423-4BD5-A603-314D06483F46}.Release|Win32.Build.0 = Release|Win32
+ {B4E902E1-D423-4BD5-A603-314D06483F46}.ReleaseNBest|Win32.ActiveCfg = Release|Win32
+ {B4E902E1-D423-4BD5-A603-314D06483F46}.ReleaseNBest|Win32.Build.0 = Release|Win32
+ {5BBAC701-84F5-438E-8F54-B3391F451F2A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5BBAC701-84F5-438E-8F54-B3391F451F2A}.Debug|Win32.Build.0 = Debug|Win32
+ {5BBAC701-84F5-438E-8F54-B3391F451F2A}.DebugNBest|Win32.ActiveCfg = DebugNBest|Win32
+ {5BBAC701-84F5-438E-8F54-B3391F451F2A}.DebugNBest|Win32.Build.0 = DebugNBest|Win32
+ {5BBAC701-84F5-438E-8F54-B3391F451F2A}.Release|Win32.ActiveCfg = Release|Win32
+ {5BBAC701-84F5-438E-8F54-B3391F451F2A}.Release|Win32.Build.0 = Release|Win32
+ {5BBAC701-84F5-438E-8F54-B3391F451F2A}.ReleaseNBest|Win32.ActiveCfg = ReleaseNBest|Win32
+ {5BBAC701-84F5-438E-8F54-B3391F451F2A}.ReleaseNBest|Win32.Build.0 = ReleaseNBest|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/moses/moses.vcproj b/moses/moses.vcproj
new file mode 100755
index 000000000..ebc9aa055
--- /dev/null
+++ b/moses/moses.vcproj
@@ -0,0 +1,597 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="moses"
+ ProjectGUID="{8122157A-0DE5-44FF-8E5B-024ED6ACE7AF}"
+ RootNamespace="moses"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(SolutionDir)..\mysqlpp\lib&quot;"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;LM_INTERNAL;TRACE_ENABLE;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="&quot;$(SolutionDir)..\mysqlpp\lib&quot;"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;LM_INTERNAL;TRACE_ENABLE;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="DebugNBest|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(SolutionDir)..\mysqlpp\lib&quot;"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;LM_INTERNAL;TRACE_ENABLE;N_BEST;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="ReleaseNBest|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="&quot;$(SolutionDir)..\mysqlpp\lib&quot;"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;LM_INTERNAL;N_BEST;TRACE_ENABLE;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\src\Arc.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Factor.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\FactorCollection.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\FactorTypeSet.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\GenerationDictionary.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Hypothesis.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\HypothesisCollection.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\HypothesisCollectionIntermediate.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\InputFileStream.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\LanguageModel.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\LatticeEdge.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\LatticePath.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Manager.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\md5.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ ObjectFile="$(IntDir)\$(InputName)1.obj"
+ XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ ObjectFile="$(IntDir)\$(InputName)1.obj"
+ XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="DebugNBest|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ ObjectFile="$(IntDir)\$(InputName)1.obj"
+ XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="ReleaseNBest|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ ObjectFile="$(IntDir)\$(InputName)1.obj"
+ XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\src\NGramCollection.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Parameter.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Phrase.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\PhraseDictionary.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\PossibleTranslation.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Sentence.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\StaticData.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\TargetPhrase.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\UserMessage.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Util.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\WeightOptimization.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Word.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\WordsBitmap.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\src\Arc.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Factor.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\FactorCollection.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\FactorTypeSet.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\GenerationDictionary.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Hypothesis.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\HypothesisCollection.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\HypothesisCollectionIntermediate.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\InputFileStream.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\InputOutput.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\LanguageModel.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\LatticeEdge.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\LatticePath.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\LatticePathCollection.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\LatticePathList.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Manager.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\md5.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\NGramCollection.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\NGramNode.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Object.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Parameter.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Phrase.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\PhraseDictionary.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\PossibleTranslation.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\PossibleTranslationCollection.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\ScoreColl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Sentence.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\StaticData.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\TargetPhrase.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Timer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\TransScoreComponent.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\TransScoreComponentCollection.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\TypeDef.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\UserMessage.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Util.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\WeightOptimization.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Word.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\WordsBitmap.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\WordsRange.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/moses/src/Arc.cpp b/moses/src/Arc.cpp
new file mode 100755
index 000000000..5f4b5b612
--- /dev/null
+++ b/moses/src/Arc.cpp
@@ -0,0 +1,57 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "Arc.h"
+#include "Hypothesis.h"
+
+#ifdef N_BEST
+
+const std::list<Arc*> &Arc::GetArcList() const
+{
+ return m_mainHypo->GetArcList();
+}
+
+#endif
+
+Arc::~Arc()
+{
+}
+
+std::ostream& operator<<(std::ostream& out, const Arc& arc)
+{
+ const Hypothesis *prevHypo = arc.GetPrevHypo();
+ if (prevHypo != NULL)
+ {
+ out << *prevHypo;
+ }
+ out << arc.GetPhrase();
+
+ // score
+ out << " [" << arc.GetScore( static_cast<ScoreType>(0));
+ for (size_t i = 1 ; i < NUM_SCORES ; i++)
+ {
+ out << "," << arc.GetScore( static_cast<ScoreType>(i));
+ }
+ out << "]";
+
+ return out;
+}
+
diff --git a/moses/src/Arc.h b/moses/src/Arc.h
new file mode 100755
index 000000000..f9ae34f26
--- /dev/null
+++ b/moses/src/Arc.h
@@ -0,0 +1,55 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <vector>
+#include "Phrase.h"
+#include "LatticeEdge.h"
+#include "TransScoreComponent.h"
+
+class Arc : public LatticeEdge
+{
+public:
+ const Hypothesis *m_mainHypo;
+
+ Arc(const Arc &arc); // not implemented
+
+ Arc( const float score[NUM_SCORES]
+ , const TransScoreComponentCollection &transScoreComponent
+ , const ScoreColl &lmScoreComponent
+ , const ScoreColl &generationScoreColl
+ , const Phrase &phrase
+ , const Hypothesis *prevHypo)
+ :LatticeEdge(score, transScoreComponent, lmScoreComponent, generationScoreColl, phrase, prevHypo)
+ {
+ }
+
+ inline void SetMainHypo(const Hypothesis &hypo)
+ {
+ m_mainHypo = &hypo;
+ }
+ ~Arc();
+
+ const std::list<Arc*> &GetArcList() const;
+};
+
+std::ostream& operator<<(std::ostream& out, const Arc& arc);
diff --git a/moses/src/Factor.cpp b/moses/src/Factor.cpp
new file mode 100755
index 000000000..de4a18256
--- /dev/null
+++ b/moses/src/Factor.cpp
@@ -0,0 +1,40 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "Factor.h"
+
+using namespace std;
+
+Factor::Factor(Language language, FactorType factorType, const std::string *factorString, LmId lmId)
+:m_language(language)
+,m_factorType(factorType)
+,m_ptrString(factorString)
+,m_lmId(lmId)
+{
+}
+
+// friend
+ostream& operator<<(ostream& out, const Factor& factor)
+{
+ out << factor.GetString();
+ return out;
+}
+
diff --git a/moses/src/Factor.h b/moses/src/Factor.h
new file mode 100755
index 000000000..7affed80f
--- /dev/null
+++ b/moses/src/Factor.h
@@ -0,0 +1,102 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <sstream>
+#include <iostream>
+#include <list>
+#include <vector>
+#include <map>
+#include <string>
+#include "TypeDef.h"
+#include "Util.h"
+
+class FactorCollection;
+
+class Factor
+{
+ friend std::ostream& operator<<(std::ostream&, const Factor&);
+
+ // only these classes are allowed to instantiate this class
+ friend class FactorCollection;
+
+protected:
+ Language m_language;
+ FactorType m_factorType;
+ const std::string *m_ptrString;
+ LmId m_lmId;
+
+ Factor(Language language, FactorType factorType, const std::string *factorString, LmId lmId);
+
+ inline void SetLmId(LmId lmId)
+ {
+ m_lmId = lmId;
+ }
+
+public:
+ inline Language GetLanguage() const
+ {
+ return m_language;
+ }
+ inline FactorType GetFactorType() const
+ {
+ return m_factorType;
+ }
+ inline const std::string &GetString() const
+ {
+ return *m_ptrString;
+ }
+ inline LmId GetLmId() const
+ {
+ return m_lmId;
+ }
+
+ // do it properly. needed for insert & finding of words in dictionary
+ inline int Compare(const Factor &compare) const
+ {
+ if (m_ptrString < compare.m_ptrString)
+ return -1;
+ if (m_ptrString > compare.m_ptrString)
+ return 1;
+
+ if (m_language < compare.m_language)
+ return -1;
+ if (m_language > compare.m_language)
+ return 1;
+
+ if (m_factorType < compare.m_factorType)
+ return -1;
+ if (m_factorType > compare.m_factorType)
+ return 1;
+
+ return 0;
+ }
+
+ inline bool operator<(const Factor &compare) const
+ {
+ return Compare(compare) < 0;
+ }
+
+ TO_STRING
+
+};
+
diff --git a/moses/src/FactorCollection.cpp b/moses/src/FactorCollection.cpp
new file mode 100755
index 000000000..6f019e329
--- /dev/null
+++ b/moses/src/FactorCollection.cpp
@@ -0,0 +1,119 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <vector>
+#include "FactorCollection.h"
+#include "LanguageModel.h"
+#include "Util.h"
+
+using namespace std;
+
+void FactorCollection::LoadVocab(Language language, FactorType factorType, const string &fileName)
+{
+ ifstream inFile(fileName.c_str());
+
+ string line;
+
+ while( !getline(inFile, line, '\n').eof())
+ {
+ vector<string> token = Tokenize( line );
+ if (token.size() < 2)
+ {
+ continue;
+ }
+ // looks like good line
+ AddFactor(language, factorType, token[1]);
+ }
+}
+
+const Factor *FactorCollection::AddFactor(Language language
+ , FactorType factorType
+ , const string &factorString
+ , LmId lmId)
+{
+ // find string id
+ const string *ptr;
+ StringSet::const_iterator iterString = m_factorStringCollection.find(factorString);
+ if (iterString == m_factorStringCollection.end())
+ {
+ const pair< StringSet::iterator, bool > &pairRet = m_factorStringCollection.insert(factorString);
+ const string &str = *pairRet.first;
+ ptr = &str;
+ }
+ else
+ {
+ const string &str = *iterString;
+ ptr = &str;
+ }
+
+ Factor findFactor(language, factorType, ptr, lmId);
+ FactorSet::const_iterator iter = m_collection.find(findFactor);
+
+ if (iter == m_collection.end())
+ { // new factor
+ pair< FactorSet::iterator, bool > pairRet = m_collection.insert(findFactor);
+ return &(*pairRet.first);
+ }
+ else
+ {
+ return &(*iter);
+ }
+}
+
+const Factor *FactorCollection::AddFactor(Language language
+ , FactorType factorType
+ , const string &factorString)
+{
+ return AddFactor(language, factorType, factorString, LanguageModel::UNKNOWN_LM_ID);
+}
+
+void FactorCollection::SetFactorLmId(const Factor *factor, LmId lmId)
+{ // only used by non-srilm code
+ Factor *changeFactor = const_cast<Factor *>(factor);
+ changeFactor->SetLmId(lmId);
+}
+
+FactorCollection::~FactorCollection()
+{
+ //FactorSet::iterator iter;
+ //for (iter = m_collection.begin() ; iter != m_collection.end() ; iter++)
+ //{
+ // delete (*iter);
+ //}
+}
+
+// friend
+ostream& operator<<(ostream& out, const FactorCollection& factorCollection)
+{
+ FactorSet::const_iterator iterFactor;
+
+ for (iterFactor = factorCollection.m_collection.begin() ; iterFactor != factorCollection.m_collection.end() ; ++iterFactor)
+ {
+ const Factor &factor = *iterFactor;
+ out << factor;
+ }
+
+ return out;
+}
+
diff --git a/moses/src/FactorCollection.h b/moses/src/FactorCollection.h
new file mode 100755
index 000000000..20092fc10
--- /dev/null
+++ b/moses/src/FactorCollection.h
@@ -0,0 +1,50 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <set>
+#include <string>
+#include "Factor.h"
+
+class LanguageModel;
+
+typedef std::set<Factor> FactorSet;
+typedef std::set<std::string> StringSet;
+
+class FactorCollection
+{
+ friend std::ostream& operator<<(std::ostream&, const FactorCollection&);
+
+protected:
+
+ FactorSet m_collection;
+ StringSet m_factorStringCollection;
+public:
+ ~FactorCollection();
+
+ const Factor *AddFactor(Language language, FactorType factorType, const std::string &factorString);
+ const Factor *AddFactor(Language language, FactorType factorType, const std::string &factorString, LmId lmId);
+ void SetFactorLmId(const Factor *factor, LmId lmId);
+
+ void LoadVocab(Language language, FactorType factorType, const std::string &fileName);
+};
+
diff --git a/moses/src/FactorTypeSet.cpp b/moses/src/FactorTypeSet.cpp
new file mode 100755
index 000000000..37bf2e29d
--- /dev/null
+++ b/moses/src/FactorTypeSet.cpp
@@ -0,0 +1,34 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "FactorTypeSet.h"
+
+using namespace std;
+
+FactorTypeSet::FactorTypeSet(const vector<FactorType> &factors)
+{
+ m_bit = 0;
+ vector<FactorType>::const_iterator iter;
+ for (iter = factors.begin() ; iter != factors.end() ; ++iter)
+ {
+ Add(*iter);
+ }
+}
diff --git a/moses/src/FactorTypeSet.h b/moses/src/FactorTypeSet.h
new file mode 100755
index 000000000..54678f113
--- /dev/null
+++ b/moses/src/FactorTypeSet.h
@@ -0,0 +1,99 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+#include <set>
+#include <vector>
+#include <algorithm>
+#include <iterator>
+#include "TypeDef.h"
+#include "Util.h"
+
+class FactorTypeSet
+{
+ friend std::ostream& operator<<(std::ostream&, const FactorTypeSet&);
+
+protected:
+ unsigned int m_bit;
+
+ inline FactorTypeSet(unsigned int bit)
+ {
+ m_bit = bit;
+ }
+public:
+ inline FactorTypeSet()
+ :m_bit(0)
+ {
+ }
+ FactorTypeSet (const std::vector<FactorType> &factors);
+
+ inline void Add(const FactorType &factorType)
+ {
+ unsigned int value = static_cast<unsigned int>(factorType);
+ m_bit |= (1 << value);
+ }
+
+ inline FactorTypeSet Intersect(const FactorTypeSet &other) const
+ {
+ unsigned int bit = m_bit & other.m_bit;
+ return FactorTypeSet(bit);;
+ }
+
+ inline void Merge(const FactorTypeSet &other)
+ {
+ m_bit |= other.m_bit;
+ }
+ void Set(const FactorTypeSet &other)
+ {
+ m_bit = 0;
+ Merge(other);
+ }
+ inline bool Contains(FactorType factorType) const
+ {
+ unsigned int value = static_cast<unsigned int>(factorType);
+ return Contains(value);
+ }
+ inline bool Contains(size_t factorType) const
+ {
+ unsigned int value = static_cast<unsigned int>(factorType);
+ return (m_bit & (1 << value)) > 0;
+ }
+};
+
+// friend
+inline
+std::ostream& operator<<(std::ostream& out, const FactorTypeSet& factorTypeSet)
+{
+ out << "(";
+
+ for (size_t currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+ {
+ if (factorTypeSet.Contains(currFactor))
+ {
+ out << "," << currFactor;
+ }
+ }
+ out << ") ";
+
+ return out;
+}
diff --git a/moses/src/FutureScore.h b/moses/src/FutureScore.h
new file mode 100644
index 000000000..202ea7e46
--- /dev/null
+++ b/moses/src/FutureScore.h
@@ -0,0 +1,56 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include "TypeDef.h"
+#include "Util.h"
+
+class FutureScore
+{
+protected:
+ const size_t m_size;
+ float *m_futureScore;
+
+ FutureScore(); // not implemented
+ FutureScore(const FutureScore &copy); // not implemented
+
+public:
+ FutureScore(size_t size)
+ :m_size(size)
+ {
+ m_futureScore = (float*) malloc(sizeof(float) * size * size);
+ }
+ ~FutureScore()
+ {
+ free(m_futureScore);
+ }
+ inline float GetScore(size_t row, size_t col) const
+ {
+ return m_futureScore[row * m_size + col];
+ }
+ inline void SetScore(size_t row, size_t col, float value)
+ {
+ m_futureScore[row * m_size + col] = value;
+ }
+
+};
+
diff --git a/moses/src/GenerationDictionary.cpp b/moses/src/GenerationDictionary.cpp
new file mode 100755
index 000000000..b26875a85
--- /dev/null
+++ b/moses/src/GenerationDictionary.cpp
@@ -0,0 +1,125 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <fstream>
+#include <string>
+#include "GenerationDictionary.h"
+#include "FactorCollection.h"
+#include "Word.h"
+#include "Util.h"
+#include "InputFileStream.h"
+
+using namespace std;
+
+void GenerationDictionary::Load(const std::vector<FactorType> &input
+ , const std::vector<FactorType> &output
+ , FactorCollection &factorCollection
+ , const std::string &filePath
+ , float weight
+ , Language language
+ , size_t id)
+{
+ m_id = id;
+ m_weight = weight;
+
+ //factors
+ m_factorsUsed[Input] = new FactorTypeSet(input);
+ m_factorsUsed[Output] = new FactorTypeSet(output);
+
+ // data from file
+ InputFileStream inFile(filePath);
+
+ string line;
+ while(getline(inFile, line))
+ {
+ vector<string> token = Tokenize( line );
+
+ // add each line in generation file into class
+ Word inputWord, outputWord;
+
+ // create word with certain factors filled out
+
+ // inputs
+ vector<string> factorString = Tokenize( token[0], "|" );
+ for (size_t i = 0 ; i < input.size() ; i++)
+ {
+ FactorType factorType = input[i];
+ const Factor *factor = factorCollection.AddFactor( language, factorType, factorString[i]);
+ inputWord.SetFactor(factorType, factor);
+ }
+
+ factorString = Tokenize( token[1], "|" );
+ for (size_t i = 0 ; i < output.size() ; i++)
+ {
+ FactorType factorType = output[i];
+
+ const Factor *factor = factorCollection.AddFactor( language, factorType, factorString[i]);
+ outputWord.SetFactor(factorType, factor);
+ }
+
+ float score = TransformScore(Scan<float>(token[2]));
+
+ m_collection[inputWord][outputWord] = score;
+ }
+ inFile.Close();
+
+ // ??? temporary solution for unknown words
+ // always assume it POS tags
+ Word outputWord, word2, word3;
+ const Factor *factor = factorCollection.AddFactor( Target, POS, "NNP");
+ outputWord.SetFactor(POS, factor);
+ m_unknownWord[outputWord] = 0.25f;
+
+ factor = factorCollection.AddFactor( Target, POS, "NN");
+ word2.SetFactor(POS, factor);
+ m_unknownWord[word2] = 0.25f;
+
+ factor = factorCollection.AddFactor( Target, POS, UNKNOWN_FACTOR);
+ word3.SetFactor(POS, factor);
+ m_unknownWord[word3] = 0.5f;
+}
+
+GenerationDictionary::~GenerationDictionary()
+{
+ for (size_t i = 0 ; i < m_factorsUsed.size() ; i++)
+ {
+ delete m_factorsUsed[i];
+ }
+}
+
+const OutputWordCollection *GenerationDictionary::FindWord(const FactorArray &factorArray) const
+{
+ const OutputWordCollection *ret;
+ Word word;
+ Word::Copy(word.GetFactorArray(), factorArray);
+
+ std::map<Word , OutputWordCollection>::const_iterator iter = m_collection.find(word);
+ if (iter == m_collection.end())
+ { // can't find source phrase
+ ret = &m_unknownWord;
+ }
+ else
+ {
+ ret = &(*iter).second;
+ }
+ return ret;
+}
+
diff --git a/moses/src/GenerationDictionary.h b/moses/src/GenerationDictionary.h
new file mode 100755
index 000000000..d8b79e1c6
--- /dev/null
+++ b/moses/src/GenerationDictionary.h
@@ -0,0 +1,84 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <list>
+#include <map>
+#include <vector>
+#include "Phrase.h"
+#include "TypeDef.h"
+
+class FactorCollection;
+
+typedef std::map < Word , float > OutputWordCollection;
+ // 1st = output phrase
+ // 2nd = log probability (score)
+
+class GenerationDictionary
+{
+protected:
+ std::map<Word , OutputWordCollection> m_collection;
+ // 1st = source
+ // 2nd = target
+ OutputWordCollection m_unknownWord;
+ float m_weight;
+ size_t m_id;
+
+ std::vector< FactorTypeSet* > m_factorsUsed;
+public:
+ GenerationDictionary()
+ :m_factorsUsed(2)
+ {
+ }
+ ~GenerationDictionary();
+
+ void Load(const std::vector<FactorType> &input
+ , const std::vector<FactorType> &output
+ , FactorCollection &factorCollection
+ , const std::string &filePath
+ , float weight
+ , Language language
+ , size_t id);
+
+ float GetWeight() const
+ {
+ return m_weight;
+ }
+ const FactorTypeSet &GetFactorsUsed(FactorDirection direction) const
+ {
+ return *m_factorsUsed[direction];
+ }
+ size_t GetSize() const
+ {
+ return m_collection.size();
+ }
+ size_t GetId() const
+ {
+ return m_id;
+ }
+ void SetWeight(float weight)
+ {
+ m_weight = weight;
+ }
+ const OutputWordCollection *FindWord(const FactorArray &factorArray) const;
+};
+
diff --git a/moses/src/Hypothesis.cpp b/moses/src/Hypothesis.cpp
new file mode 100755
index 000000000..4e3c81788
--- /dev/null
+++ b/moses/src/Hypothesis.cpp
@@ -0,0 +1,445 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <iostream>
+#include <limits>
+#include <assert.h>
+#include "PossibleTranslation.h"
+#include "PossibleTranslationCollection.h"
+#include "Hypothesis.h"
+#include "Util.h"
+#include "Arc.h"
+#include "FutureScore.h"
+
+using namespace std;
+
+Hypothesis::Hypothesis(const Phrase &phrase)
+ : LatticeEdge(Target, NULL)
+ , m_sourceCompleted(phrase.GetSize())
+ , m_currSourceWordsRange(NOT_FOUND, NOT_FOUND)
+ , m_currTargetWordsRange(NOT_FOUND, NOT_FOUND)
+{ // used for initial seeding of trans process
+ // initialize scores
+ ResetScore();
+}
+
+Hypothesis::Hypothesis(const Hypothesis &copy)
+ : LatticeEdge (Target, copy.m_prevHypo)
+ , m_sourceCompleted (copy.m_sourceCompleted )
+ , m_currSourceWordsRange (copy.m_currSourceWordsRange)
+ , m_currTargetWordsRange (copy.m_currTargetWordsRange)
+{
+ m_phrase.AddWords( copy.m_phrase );
+
+ // initialize scores
+ SetScore(copy.GetScore());
+#ifdef N_BEST
+ m_lmScoreComponent = copy.GetLMScoreComponent();
+ m_transScoreComponent = copy.GetTransScoreComponent();
+ m_generationScoreComponent = copy.GetGenerationScoreComponent();
+
+#endif
+}
+
+Hypothesis::Hypothesis(const Hypothesis &prevHypo, const PossibleTranslation &possTrans)
+ : LatticeEdge (Target, &prevHypo)
+ , m_sourceCompleted (prevHypo.m_sourceCompleted )
+ , m_currSourceWordsRange (prevHypo.m_currSourceWordsRange)
+ , m_currTargetWordsRange ( prevHypo.m_currTargetWordsRange.GetEndPos() + 1
+ ,prevHypo.m_currTargetWordsRange.GetEndPos() + possTrans.GetPhrase().GetSize())
+{
+ const Phrase &possPhrase = possTrans.GetPhrase();
+ const WordsRange &wordsRange = possTrans.GetWordsRange();
+ m_currSourceWordsRange = wordsRange;
+ m_sourceCompleted.SetValue(wordsRange.GetStartPos(), wordsRange.GetEndPos(), true);
+ // add new words from poss trans
+ //m_phrase.AddWords(prev.m_phrase);
+ m_phrase.AddWords(possPhrase);
+
+ // scores
+ SetScore(prevHypo.GetScore());
+ m_score[PhraseTrans] += possTrans.GetTranslationScore();
+ m_score[FutureScoreEnum] += possTrans.GetFutureScore();
+ m_score[LanguageModelScore] += possTrans.GetNgramScore();
+
+#ifdef N_BEST
+ // language model score (ngram)
+ m_lmScoreComponent = prevHypo.GetLMScoreComponent();
+ const list< pair<size_t, float> > &nGramComponent = possTrans.GetTrigramComponent();
+
+ list< pair<size_t, float> >::const_iterator iter;
+ for (iter = nGramComponent.begin() ; iter != nGramComponent.end() ; ++iter)
+ {
+ size_t lmId = (*iter).first;
+ float score = (*iter).second;
+ m_lmScoreComponent[lmId] += score;
+ }
+
+ // translation score
+ const TransScoreComponentCollection &prevComponent= prevHypo.GetTransScoreComponent();
+ m_transScoreComponent = prevComponent;
+
+ // add components specific to poss trans
+ const TransScoreComponent &possComponent = possTrans.GetScoreComponents();
+ TransScoreComponent &transComponent = m_transScoreComponent.GetTransScoreComponent(possComponent.GetPhraseDictionaryId());
+ for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
+ {
+ transComponent[i] += possComponent[i];
+ }
+
+ // generation score
+ m_generationScoreComponent = prevHypo.GetGenerationScoreComponent();
+
+#endif
+}
+
+Hypothesis::~Hypothesis()
+{
+#ifdef N_BEST
+
+ RemoveAllInColl< list<Arc*>::iterator >(m_arcList);
+#endif
+}
+
+Hypothesis *Hypothesis::CreateNext(const PossibleTranslation &possTrans) const
+{
+ Hypothesis *clone = new Hypothesis(*this, possTrans);
+ return clone;
+}
+
+Hypothesis *Hypothesis::MergeNext(const PossibleTranslation &possTrans) const
+{
+ // check each word is compatible and merge 1-by-1
+ const Phrase &possPhrase = possTrans.GetPhrase();
+ if (! IsCompatible(possPhrase))
+ {
+ return NULL;
+ }
+
+ // ok, merge
+ Hypothesis *clone = new Hypothesis(*this);
+
+ int currWord = 0;
+ size_t len = GetSize();
+ for (size_t currPos = len - m_currTargetWordsRange.GetWordsCount() ; currPos < len ; currPos++)
+ {
+ const FactorArray &sourceWord = possPhrase.GetFactorArray(currWord);
+ FactorArray &targetWord = clone->GetCurrFactorArray(currPos - m_currTargetWordsRange.GetStartPos());
+ Word::Merge(targetWord, sourceWord);
+
+ currWord++;
+ }
+
+#ifdef N_BEST
+ const TransScoreComponent &possTransComponent = possTrans.GetScoreComponents();
+ clone->m_transScoreComponent.Add(possTransComponent);
+#endif
+
+ return clone;
+
+}
+
+void Hypothesis::MergeFactors(vector< const Word* > mergeWords, size_t idDict, float generationScore, float weight)
+{
+ assert (mergeWords.size() == m_currTargetWordsRange.GetWordsCount());
+
+ const size_t startPos = GetSize() - m_currTargetWordsRange.GetWordsCount();
+
+ int mergeWordPos = 0;
+ for (size_t currPos = startPos ; currPos < startPos + mergeWords.size() ; currPos++)
+ {
+ const Word &mergeWord = *mergeWords[mergeWordPos];
+ FactorArray &origWord = GetCurrFactorArray(currPos - m_currTargetWordsRange.GetStartPos());
+
+ for (unsigned int currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+ {
+ FactorType factorType = static_cast<FactorType>(currFactor);
+ const Factor *factor = mergeWord.GetFactor(factorType);
+ if (factor != NULL)
+ {
+ origWord[factorType] = factor;
+ }
+ }
+
+ mergeWordPos++;
+ }
+
+ // score
+ m_score[Generation] += generationScore * weight;
+#ifdef N_BEST
+ m_generationScoreComponent[idDict] += generationScore;
+#endif
+}
+
+bool Hypothesis::IsCompatible(const Phrase &phrase) const
+{
+ // make sure factors don't contradict each other
+ // similar to phrase comparison
+
+ if (m_currTargetWordsRange.GetWordsCount() != phrase.GetSize())
+ {
+ return false;
+ }
+ size_t hypoSize = GetSize();
+
+ size_t possTransPos = 0;
+ for (size_t hypoPos = hypoSize - m_currTargetWordsRange.GetWordsCount() ; hypoPos < hypoSize ; hypoPos++)
+ {
+ for (unsigned int currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+ {
+ FactorType factorType = static_cast<FactorType>(currFactor);
+ const Factor *thisFactor = GetFactor(hypoPos, factorType)
+ ,*compareFactor = phrase.GetFactor(possTransPos, factorType);
+ if (thisFactor != NULL && compareFactor != NULL && thisFactor != compareFactor)
+ return false;
+ }
+ possTransPos++;
+ }
+ return true;
+}
+
+int Hypothesis::NGramCompare(const Hypothesis &compare, size_t nGramSize) const
+{ // -1 = this < compare
+ // +1 = this > compare
+ // 0 = this ==compare
+
+ size_t thisSize = GetSize();
+ size_t compareSize = compare.GetSize();
+ size_t minSize = std::min(nGramSize, thisSize)
+ , minCompareSize= std::min(nGramSize, compareSize);
+
+ if ( minSize != minCompareSize )
+ { // quick decision
+ return (minSize < minCompareSize) ? -1 : 1;
+ }
+
+ for (size_t currNGram = 1 ; currNGram <= minSize ; currNGram++)
+ {
+ for (unsigned int currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+ {
+ FactorType factorType = static_cast<FactorType>(currFactor);
+ const Factor *thisFactor = GetFactor(thisSize - currNGram, factorType)
+ ,*compareFactor = compare.GetFactor(compareSize - currNGram, factorType);
+ // just use address of factor
+ if (thisFactor < compareFactor)
+ return -1;
+ if (thisFactor > compareFactor)
+ return 1;
+ }
+ }
+ // identical
+ return 0;
+}
+
+void Hypothesis::CalcLMScore(const LMList &lmListInitial, const LMList &lmListEnd)
+{
+ const size_t startPos = m_currTargetWordsRange.GetStartPos();
+ LMList::const_iterator iterLM;
+
+ // for LM which are not in PossTran
+ // must go through each trigram in current phrase
+ for (iterLM = lmListEnd.begin() ; iterLM != lmListEnd.end() ; ++iterLM)
+ {
+ const LanguageModel &languageModel = **iterLM;
+ FactorType factorType = languageModel.GetFactorType();
+ size_t nGramOrder = languageModel.GetNGramOrder();
+ float lmScore;
+
+ // 1st n-gram
+ vector<const Factor*> contextFactor(nGramOrder);
+ size_t index = 0;
+ for (int currPos = (int) startPos - (int) nGramOrder + 1 ; currPos <= (int) startPos ; currPos++)
+ {
+ if (currPos >= 0)
+ contextFactor[index++] = GetFactor(currPos, factorType);
+ else
+ contextFactor[index++] = languageModel.GetSentenceStart();
+ }
+ lmScore = languageModel.GetValue(contextFactor);
+
+ // main loop
+ for (size_t currPos = startPos + 1 ; currPos <= m_currTargetWordsRange.GetEndPos() ; currPos++)
+ {
+ // shift all args down 1 place
+ for (size_t i = 0 ; i < nGramOrder - 1 ; i++)
+ contextFactor[i] = contextFactor[i + 1];
+
+ // add last factor
+ contextFactor.back() = GetFactor(currPos, factorType);
+
+ lmScore += languageModel.GetValue(contextFactor);
+ }
+
+ // end of sentence
+ if (m_sourceCompleted.IsComplete())
+ {
+ // shift all args down 1 place
+ for (size_t i = 0 ; i < nGramOrder - 1 ; i++)
+ contextFactor[i] = contextFactor[i + 1];
+
+ contextFactor.back() = languageModel.GetSentenceEnd();
+ lmScore += languageModel.GetValue(contextFactor);
+ }
+ m_score[LanguageModelScore] += lmScore * languageModel.GetWeight();
+#ifdef N_BEST
+ size_t lmId = languageModel.GetId();
+ m_lmScoreComponent[lmId] += lmScore;
+#endif
+ }
+
+ // for LM which are in possTran
+ // already have LM scores from previous and trigram score of poss trans.
+ // just need trigram score of the words of the start of current phrase
+ for (iterLM = lmListInitial.begin() ; iterLM != lmListInitial.end() ; ++iterLM)
+ {
+ const LanguageModel &languageModel = **iterLM;
+ FactorType factorType = languageModel.GetFactorType();
+ size_t nGramOrder = languageModel.GetNGramOrder();
+ float lmScore;
+
+ // 1st n-gram
+ vector<const Factor*> contextFactor(nGramOrder);
+ size_t index = 0;
+ for (int currPos = (int) startPos - (int) nGramOrder + 1 ; currPos <= (int) startPos ; currPos++)
+ {
+ if (currPos >= 0)
+ contextFactor[index++] = GetFactor(currPos, factorType);
+ else
+ contextFactor[index++] = languageModel.GetSentenceStart();
+ }
+ lmScore = languageModel.GetValue(contextFactor);
+
+ // main loop
+ size_t endPos = std::min(startPos + nGramOrder - 2
+ , m_currTargetWordsRange.GetEndPos());
+ for (size_t currPos = startPos + 1 ; currPos <= endPos ; currPos++)
+ {
+ // shift all args down 1 place
+ for (size_t i = 0 ; i < nGramOrder - 1 ; i++)
+ contextFactor[i] = contextFactor[i + 1];
+
+ // add last factor
+ contextFactor.back() = GetFactor(currPos, factorType);
+
+ lmScore += languageModel.GetValue(contextFactor);
+ }
+
+ // end of sentence
+ if (m_sourceCompleted.IsComplete())
+ {
+ // shift all args down 1 place
+ for (size_t i = 0 ; i < nGramOrder - 1 ; i++)
+ contextFactor[i] = contextFactor[i + 1];
+
+ contextFactor.back() = languageModel.GetSentenceEnd();
+ lmScore += languageModel.GetValue(contextFactor);
+ }
+ m_score[LanguageModelScore] += lmScore * languageModel.GetWeight();
+#ifdef N_BEST
+ size_t lmId = languageModel.GetId();
+ m_lmScoreComponent[lmId] += lmScore;
+#endif
+ }
+
+}
+
+void Hypothesis::CalcScore(const LMList &lmListInitial
+ , const LMList &lmListEnd
+ , float weightDistortion
+ , float weightWordPenalty
+ , const FutureScore &futureScore)
+{
+ // DISTORTION COST
+ const WordsRange &prevRange = m_prevHypo->GetCurrSourceWordsRange()
+ , &currRange = GetCurrSourceWordsRange();
+
+ if (prevRange.GetWordsCount() == 0)
+ { // 1st hypothesis with translated phrase. NOT the seed hypo.
+ m_score[Distortion] = - (float) currRange.GetStartPos();
+ }
+ else
+ { // add distortion score of current translated phrase to
+ // distortions scores of all previous partial translations
+ m_score[Distortion] -= (float) currRange.CalcDistortion(prevRange) ;
+ }
+
+ // LANGUAGE MODEL COST
+ CalcLMScore(lmListInitial, lmListEnd);
+
+ // WORD PENALTY
+ m_score[WordPenalty] = - (float) GetSize();
+
+ // FUTURE COST
+ CalcFutureScore(futureScore);
+
+ // TOTAL COST
+ m_score[Total] = m_score[PhraseTrans]
+ + m_score[Generation]
+ + m_score[LanguageModelScore]
+ + m_score[Distortion] * weightDistortion
+ + m_score[WordPenalty] * weightWordPenalty
+ + m_score[FutureScoreEnum];
+}
+
+void Hypothesis::CalcFutureScore(const FutureScore &futureScore)
+{
+ const size_t maxSize= numeric_limits<size_t>::max();
+ size_t start = maxSize;
+ m_score[FutureScoreEnum] = 0;
+ for(size_t currPos = 0 ; currPos < m_sourceCompleted.GetSize() ; currPos++)
+ {
+ if(m_sourceCompleted.GetValue(currPos) == 0 && start == maxSize)
+ {
+ start = currPos;
+ }
+ if(m_sourceCompleted.GetValue(currPos) == 1 && start != maxSize)
+ {
+ m_score[FutureScoreEnum] += futureScore.GetScore(start, currPos - 1);
+ start = maxSize;
+ }
+ }
+ if (start != maxSize)
+ {
+ m_score[FutureScoreEnum] += futureScore.GetScore(start, m_sourceCompleted.GetSize() - 1);
+ }
+}
+
+// friend
+ostream& operator<<(ostream& out, const Hypothesis& hypothesis)
+{
+ hypothesis.ToStream(out);
+ // words bitmap
+ out << "[" << hypothesis.m_sourceCompleted << "] ";
+
+ // scores
+ out << " [" << hypothesis.GetScore( static_cast<ScoreType>(0));
+ for (size_t i = 1 ; i < NUM_SCORES ; i++)
+ {
+ out << "," << hypothesis.GetScore( static_cast<ScoreType>(i));
+ }
+ out << "]";
+#ifdef N_BEST
+ out << " " << hypothesis.GetTransScoreComponent();
+ out << " " << hypothesis.GetGenerationScoreComponent();
+#endif
+ return out;
+}
+
diff --git a/moses/src/Hypothesis.h b/moses/src/Hypothesis.h
new file mode 100755
index 000000000..6a9beb6f5
--- /dev/null
+++ b/moses/src/Hypothesis.h
@@ -0,0 +1,181 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+#include <list>
+#include "Phrase.h"
+#include "TypeDef.h"
+#include "WordsBitmap.h"
+#include "Sentence.h"
+#include "Phrase.h"
+#include "PhraseDictionary.h"
+#include "LanguageModel.h"
+#include "Arc.h"
+#include "LatticeEdge.h"
+#include "TransScoreComponentCollection.h"
+
+class FutureScore;
+class PossibleTranslation;
+
+class Hypothesis : public LatticeEdge
+{
+ friend std::ostream& operator<<(std::ostream&, const Hypothesis&);
+
+protected:
+ // phrase in target language. factors completed will be superset
+ // as that in dictionary
+ WordsBitmap m_sourceCompleted;
+ WordsRange m_currSourceWordsRange, m_currTargetWordsRange;
+#ifdef N_BEST
+ std::list<Arc*> m_arcList;
+#endif
+
+ bool IsCompatible(const Phrase &phrase) const;
+ // none of the factors clash
+ void CalcFutureScore(const FutureScore &futureScore);
+ void CalcLMScore(const LMList &lmListInitial, const LMList &lmListEnd);
+
+public:
+ Hypothesis(const Hypothesis &copy);
+ // used to create clone
+ Hypothesis(const Phrase &phrase);
+ // used for initial seeding of trans process
+ Hypothesis(const Hypothesis &prevHypo, const PossibleTranslation &possTrans);
+ // create next
+ ~Hypothesis();
+ inline Hypothesis *Clone() const
+ {
+ return new Hypothesis(*this);
+ }
+
+ Hypothesis *CreateNext(const PossibleTranslation &possTrans) const;
+ Hypothesis *MergeNext(const PossibleTranslation &possTrans) const;
+
+ inline const WordsRange &GetCurrSourceWordsRange() const
+ {
+ return m_currSourceWordsRange;
+ }
+ inline size_t GetCurrTargetLength() const
+ {
+ return m_currTargetWordsRange.GetWordsCount();
+ }
+ // subsequent translation should only translate this sub-phrase
+
+ void CalcScore(const LMList &lmListInitial
+ , const LMList &lmListEnd
+ , float weightDistortion
+ , float weightWordPenalty
+ , const FutureScore &futureScore);
+
+ // same as for phrase
+ inline size_t GetSize() const
+ {
+ return m_currTargetWordsRange.GetEndPos() + 1;
+ }
+ inline const Phrase &GetPhrase() const
+ {
+ return m_phrase;
+ }
+
+ // curr
+ inline FactorArray &GetCurrFactorArray(size_t pos)
+ {
+ return m_phrase.GetFactorArray(pos);
+ }
+ inline const FactorArray &GetCurrFactorArray(size_t pos) const
+ {
+ return m_phrase.GetFactorArray(pos);
+ }
+ inline const Factor *GetCurrFactor(size_t pos, FactorType factorType) const
+ {
+ return m_phrase.GetFactor(pos, factorType);
+ }
+ // recursive
+ inline const FactorArray &GetFactorArray(size_t pos) const
+ {
+ if (pos < m_currTargetWordsRange.GetStartPos())
+ return m_prevHypo->GetFactorArray(pos);
+ return m_phrase.GetFactorArray(pos - m_currTargetWordsRange.GetStartPos());
+ }
+ inline const Factor *GetFactor(size_t pos, FactorType factorType) const
+ {
+ if (pos < m_currTargetWordsRange.GetStartPos())
+ return m_prevHypo->GetFactor(pos, factorType);
+ return m_phrase.GetFactor(pos - m_currTargetWordsRange.GetStartPos(), factorType);
+ }
+
+ inline const WordsBitmap &GetWordsBitmap() const
+ {
+ return m_sourceCompleted;
+ }
+
+ void MergeFactors(std::vector< const Word* > mergeWord, size_t idDict, float generationScore, float weight);
+ // used in generation processing
+ // startPos is usually the start of the last phrase
+
+ int NGramCompare(const Hypothesis &compare, size_t nGramSize) const;
+
+ void ToStream(std::ostream& out) const
+ {
+ if (m_prevHypo != NULL)
+ {
+ m_prevHypo->ToStream(out);
+ }
+ out << GetPhrase();
+ }
+
+ TO_STRING;
+
+#ifdef N_BEST
+ inline void AddArc(Hypothesis &loserHypo)
+ {
+ Arc *arc = new Arc(loserHypo.m_score
+ , loserHypo.GetTransScoreComponent()
+ , loserHypo.GetLMScoreComponent()
+ , loserHypo.GetGenerationScoreComponent()
+ , loserHypo.GetPhrase()
+ , loserHypo.GetPrevHypo());
+ m_arcList.push_back(arc);
+
+ // add loser's arcs too
+ std::copy(loserHypo.m_arcList.begin(), loserHypo.m_arcList.end()
+ , std::inserter(m_arcList, m_arcList.end()));
+ loserHypo.m_arcList.clear();
+ }
+ inline void InitializeArcs()
+ {
+ std::list<Arc*>::iterator iter;
+ for (iter = m_arcList.begin() ; iter != m_arcList.end() ; ++iter)
+ {
+ Arc *arc = *iter;
+ arc->SetMainHypo(*this);
+ }
+ }
+ inline const std::list<Arc*> &GetArcList() const
+ {
+ return m_arcList;
+ }
+#endif
+};
+
+std::ostream& operator<<(std::ostream& out, const Hypothesis& hypothesis);
diff --git a/moses/src/HypothesisCollection.cpp b/moses/src/HypothesisCollection.cpp
new file mode 100755
index 000000000..d5da536d5
--- /dev/null
+++ b/moses/src/HypothesisCollection.cpp
@@ -0,0 +1,219 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <algorithm>
+#include <set>
+#include "HypothesisCollection.h"
+#include "TypeDef.h"
+#include "Util.h"
+
+using namespace std;
+
+size_t CompareHypothesisCollection::m_NGramMaxOrder;
+
+void HypothesisCollection::RemoveAll()
+{
+ while (begin() != end())
+ {
+ Remove(begin());
+ }
+}
+
+void HypothesisCollection::Add(Hypothesis *hypo)
+{
+ AddNoPrune(hypo);
+
+ if (hypo->GetScore(Total) > m_bestScore)
+ {
+ m_bestScore = hypo->GetScore(Total);
+ }
+
+ if (size() > MAXIMUM_HYPO_COLL_SIZE)
+ {
+ PruneToSize(MAXIMUM_HYPO_COLL_SIZE/2);
+ }
+}
+
+bool HypothesisCollection::Add(Hypothesis *hypo, float beamThreshold)
+{
+ if (hypo->GetScore(Total) < m_bestScore + beamThreshold)
+ return false;
+
+ // over threshold
+ // recombine if ngram-equivalent to another hypo
+ iterator iter = find(hypo);
+ if (iter == end())
+ { // nothing found. add to collection
+ Add(hypo);
+ return true;
+ }
+
+ // found existing hypo with same target ending.
+ // keep the best 1
+ Hypothesis *hypoExisting = *iter;
+ if (hypo->GetScore(Total) > hypoExisting->GetScore(Total))
+ {
+#ifdef N_BEST
+ hypo->AddArc(**iter);
+#endif
+ Remove(iter);
+ Add(hypo);
+ return true;
+ }
+ else
+ { // already storing the best hypo. discard current hypo
+#ifdef N_BEST
+ (*iter)->AddArc(*hypo);
+#endif
+ return false;
+ }
+}
+
+//
+//void HypothesisCollection::Prune()
+//{
+// if (size() > MAXIMUM_HYPO_COLL_SIZE / 2)
+// {
+// float minScore = m_bestScore + m_beamThreshold;
+// HypothesisCollection::iterator iter = begin();
+// while (iter != end())
+// {
+// Hypothesis *hypo = *iter;
+// if (hypo->GetScore(Total) < minScore)
+// {
+// HypothesisCollection::iterator iterRemove = iter++;
+// Remove(iterRemove);
+// }
+// else
+// {
+// iter++;
+// }
+// }
+// }
+//}
+
+void HypothesisCollection::PruneToSize(size_t newSize)
+{
+ if (size() > newSize)
+ {
+ multiset<float> bestScores;
+
+ iterator iter = begin();
+ // fill up set to newSize
+ for (size_t i = 0 ; i < newSize ; i++)
+ {
+ Hypothesis *hypo = *iter;
+ bestScores.insert(hypo->GetScore(Total));
+ ++iter;
+ }
+ // only add score if better than score threshold
+ float scoreThreshold = *bestScores.begin();
+ while (iter != end())
+ {
+ Hypothesis *hypo = *iter;
+ float score = hypo->GetScore(Total);
+ if (score > scoreThreshold)
+ {
+ bestScores.insert(score);
+ bestScores.erase(bestScores.begin());
+ scoreThreshold = *bestScores.begin();
+ }
+ ++iter;
+ }
+ // delete hypo under score threshold
+ iter = begin();
+ while (iter != end())
+ {
+ Hypothesis *hypo = *iter;
+ float score = hypo->GetScore(Total);
+ if (score < scoreThreshold)
+ {
+ iterator iterRemove = iter++;
+ Remove(iterRemove);
+ }
+ else
+ {
+ ++iter;
+ }
+ }
+ }
+}
+
+const Hypothesis *HypothesisCollection::GetBestHypothesis() const
+{
+ if (!empty())
+ {
+ const_iterator iter = begin();
+ Hypothesis *bestHypo = *iter;
+ while (++iter != end())
+ {
+ Hypothesis *hypo = *iter;
+ if (hypo->GetScore(Total) > bestHypo->GetScore(Total))
+ bestHypo = hypo;
+ }
+ return bestHypo;
+ }
+ return NULL;
+}
+
+// sorting helper
+struct HypothesisSortDescending
+{
+ bool operator()(const Hypothesis*& hypo1, const Hypothesis*& hypo2)
+ {
+ return hypo1->GetScore(Total) > hypo2->GetScore(Total);
+ }
+};
+
+list<const Hypothesis*> HypothesisCollection::GetSortedList() const
+{
+ list<const Hypothesis*> ret;
+ std::copy(begin(), end(), std::inserter(ret, ret.end()));
+ ret.sort(HypothesisSortDescending());
+
+ return ret;
+}
+
+void HypothesisCollection::InitializeArcs()
+{
+#ifdef N_BEST
+ iterator iter;
+ for (iter = begin() ; iter != end() ; ++iter)
+ {
+ Hypothesis *mainHypo = *iter;
+ mainHypo->InitializeArcs();
+ }
+#endif
+}
+
+// friend
+std::ostream& operator<<(std::ostream& out, const HypothesisCollection& hypoColl)
+{
+ HypothesisCollection::const_iterator iter;
+
+ for (iter = hypoColl.begin() ; iter != hypoColl.end() ; ++iter)
+ {
+ const Hypothesis &hypo = **iter;
+ out << hypo << endl;
+ }
+ return out;
+}
+
diff --git a/moses/src/HypothesisCollection.h b/moses/src/HypothesisCollection.h
new file mode 100755
index 000000000..793d73c4b
--- /dev/null
+++ b/moses/src/HypothesisCollection.h
@@ -0,0 +1,112 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <limits>
+#include <set>
+#include "Hypothesis.h"
+
+class CompareHypothesisCollection
+{
+protected:
+ // static
+ static size_t m_NGramMaxOrder;
+
+public:
+ bool operator()(const Hypothesis* hypoA, const Hypothesis* hypoB) const
+ {
+ int ret = hypoA->NGramCompare(*hypoB, m_NGramMaxOrder - 1);
+ if (ret != 0)
+ {
+ return (ret < 0);
+ }
+
+ // same last n-grams. compare source words translated
+ const WordsBitmap &bitmapA = hypoA->GetWordsBitmap()
+ , &bitmapB = hypoB->GetWordsBitmap();
+ ret = bitmapA.Compare(bitmapB);
+
+ return (ret < 0);
+ }
+
+ // static
+ static inline void SetMaxNGramOrder(size_t nGramMaxOrder)
+ {
+ m_NGramMaxOrder = nGramMaxOrder;
+ }
+ static inline size_t GetMaxNGramOrder()
+ {
+ return m_NGramMaxOrder;
+ }
+
+};
+
+class HypothesisCollection : public std::set< Hypothesis*, CompareHypothesisCollection >
+{
+ friend std::ostream& operator<<(std::ostream&, const HypothesisCollection&);
+
+protected:
+ float m_bestScore, m_beamThreshold;
+
+// std::list<Arc> m_arc;
+ void Add(Hypothesis *hypothesis);
+ // used by Add(Hypothesis *hypothesis, float beamThreshold);
+ void RemoveAll();
+
+public:
+ inline HypothesisCollection()
+ {
+ m_bestScore = -std::numeric_limits<float>::infinity();
+ }
+
+ inline void AddNoPrune(Hypothesis *hypothesis)
+ {
+ //push_back(hypothesis);
+ insert(hypothesis);
+ }
+ bool Add(Hypothesis *hypothesis, float beamThreshold);
+ inline void Detach(const HypothesisCollection::iterator &iter)
+ {
+ erase(iter);
+ }
+ inline void Remove(const HypothesisCollection::iterator &iter)
+ {
+ delete *iter;
+ Detach(iter);
+ }
+
+ inline ~HypothesisCollection()
+ {
+ RemoveAll();
+ }
+ inline void SetBeamThreshold(float beamThreshold)
+ {
+ m_beamThreshold = beamThreshold;
+ }
+
+ //void Prune();
+ void PruneToSize(size_t newSize);
+
+ const Hypothesis *GetBestHypothesis() const;
+ std::list<const Hypothesis*> GetSortedList() const;
+ void InitializeArcs();
+};
diff --git a/moses/src/HypothesisCollectionIntermediate.cpp b/moses/src/HypothesisCollectionIntermediate.cpp
new file mode 100755
index 000000000..76d89de54
--- /dev/null
+++ b/moses/src/HypothesisCollectionIntermediate.cpp
@@ -0,0 +1,58 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <algorithm>
+#include "HypothesisCollectionIntermediate.h"
+#include "TypeDef.h"
+#include "Util.h"
+
+using namespace std;
+
+void HypothesisCollectionIntermediate::RemoveAll()
+{
+ while (begin() != end())
+ {
+ Remove(begin());
+ }
+}
+
+// sorting helper
+struct HypothesisSort
+{
+ bool operator()(Hypothesis*& hypo1, Hypothesis*& hypo2)
+ {
+ return hypo1->GetScore(Total) < hypo2->GetScore(Total);
+ }
+};
+
+// friend
+std::ostream& operator<<(std::ostream& out, const HypothesisCollectionIntermediate& hypoColl)
+{
+ HypothesisCollectionIntermediate::const_iterator iter;
+
+ for (iter = hypoColl.begin() ; iter != hypoColl.end() ; ++iter)
+ {
+ const Hypothesis &hypo = **iter;
+ out << hypo << endl;
+ }
+ return out;
+}
+
diff --git a/moses/src/HypothesisCollectionIntermediate.h b/moses/src/HypothesisCollectionIntermediate.h
new file mode 100755
index 000000000..83acfd193
--- /dev/null
+++ b/moses/src/HypothesisCollectionIntermediate.h
@@ -0,0 +1,59 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <limits>
+#include <list>
+#include "Hypothesis.h"
+
+class HypothesisCollectionIntermediate : public std::list< Hypothesis* >
+{
+ friend std::ostream& operator<<(std::ostream&, const HypothesisCollectionIntermediate&);
+
+protected:
+ void RemoveAll();
+
+public:
+ inline HypothesisCollectionIntermediate()
+ {
+ }
+
+ inline void AddNoPrune(Hypothesis *hypothesis)
+ {
+ push_front(hypothesis);
+ }
+ inline void Detach(const HypothesisCollectionIntermediate::iterator &iter)
+ {
+ erase(iter);
+ }
+ inline void Remove(const HypothesisCollectionIntermediate::iterator &iter)
+ {
+ delete *iter;
+ Detach(iter);
+ }
+
+ inline ~HypothesisCollectionIntermediate()
+ {
+ RemoveAll();
+ }
+};
+
diff --git a/moses/src/InputFileStream.cpp b/moses/src/InputFileStream.cpp
new file mode 100644
index 000000000..e6f02698b
--- /dev/null
+++ b/moses/src/InputFileStream.cpp
@@ -0,0 +1,22 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "InputFileStream.h"
diff --git a/moses/src/InputFileStream.h b/moses/src/InputFileStream.h
new file mode 100644
index 000000000..90fc9a465
--- /dev/null
+++ b/moses/src/InputFileStream.h
@@ -0,0 +1,56 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <fstream>
+#include <string>
+#include <boost/iostreams/filtering_stream.hpp>
+#include <boost/iostreams/filter/gzip.hpp>
+
+class InputFileStream : public boost::iostreams::filtering_stream<boost::iostreams::input>
+{
+protected:
+ std::ifstream m_file;
+public:
+
+ InputFileStream(const std::string &filePath)
+ {
+ using namespace boost::iostreams;
+
+ if (filePath.substr(filePath.size() - 3, 3) == ".gz")
+ {
+ m_file.open(filePath.c_str(), ios_base::in | ios_base::binary);
+ push(gzip_decompressor());
+ }
+ else
+ {
+ m_file.open(filePath.c_str());
+ }
+ push(m_file);
+ }
+
+ void Close()
+ {
+ pop();
+ }
+};
+
diff --git a/moses/src/InputOutput.h b/moses/src/InputOutput.h
new file mode 100755
index 000000000..6daf5a05b
--- /dev/null
+++ b/moses/src/InputOutput.h
@@ -0,0 +1,43 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <string>
+#include "Sentence.h"
+
+class Hypothesis;
+class LatticePathList;
+class FactorCollection;
+
+class InputOutput
+{
+public:
+ virtual Sentence *GetInput() = 0;
+ virtual void SetOutput(const Hypothesis *hypo, long translationId) = 0;
+ virtual void SetNBest(const LatticePathList &nBestList, long translationId) = 0;
+ virtual ~InputOutput()
+ {}
+ virtual void Release(Sentence *sentence)
+ {
+ delete sentence;
+ }
+};
diff --git a/moses/src/LanguageModel.cpp b/moses/src/LanguageModel.cpp
new file mode 100755
index 000000000..5575050f5
--- /dev/null
+++ b/moses/src/LanguageModel.cpp
@@ -0,0 +1,351 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <assert.h>
+#include <limits>
+#include <iostream>
+#include <fstream>
+
+#include "NGramNode.h"
+
+#include "LanguageModel.h"
+#include "TypeDef.h"
+#include "Util.h"
+#include "FactorCollection.h"
+#include "Phrase.h"
+
+using namespace std;
+
+void LanguageModel::CalcScore(const Phrase &phrase
+ , float &fullScore
+ , float &ngramScore
+ , list< std::pair<size_t, float> > &ngramComponent) const
+{
+ fullScore = 0;
+ ngramScore = 0;
+ FactorType factorType = GetFactorType();
+
+ size_t phraseSize = phrase.GetSize();
+ vector<const Factor*> contextFactor;
+ contextFactor.reserve(m_nGramOrder);
+
+ // start of sentence
+ for (size_t currPos = 0 ; currPos < m_nGramOrder && currPos < phraseSize ; currPos++)
+ {
+ contextFactor.push_back(phrase.GetFactor(currPos, factorType));
+ fullScore = GetValue(contextFactor);
+ }
+
+ // main loop
+ for (size_t currPos = m_nGramOrder ; currPos < phraseSize ; currPos++)
+ { // used by hypo to speed up lm score calc
+ contextFactor[0] = phrase.GetFactor(currPos-2, factorType);
+ contextFactor[1] = phrase.GetFactor(currPos-1, factorType);
+ contextFactor[2] = phrase.GetFactor(currPos, factorType);
+ ngramScore += GetValue(contextFactor);
+ }
+ fullScore += ngramScore;
+#ifdef N_BEST
+ size_t lmId = GetId();
+ pair<size_t, float> store(lmId, ngramScore);
+ ngramComponent.push_back(store);
+#endif
+}
+
+#ifdef LM_SRI
+
+LanguageModel::LanguageModel()
+:m_srilmVocab()
+,m_srilmModel(m_srilmVocab, 3)
+{
+ m_srilmModel.skipOOVs() = false;
+}
+
+void LanguageModel::Load(size_t id
+ , const std::string &fileName
+ , FactorCollection &factorCollection
+ , FactorType factorType
+ , float weight
+ , size_t nGramOrder)
+{
+ m_id = id;
+ m_factorType = factorType;
+ m_weight = weight;
+ m_nGramOrder = nGramOrder;
+
+ File file( fileName.c_str(), "r" );
+ if (m_srilmModel.read(file))
+ {
+ }
+ else
+ {
+ TRACE_ERR("warning/failed loading language model" << endl);
+ }
+ // LM can be ok, just outputs warnings
+ CreateFactors(factorCollection);
+
+}
+
+void LanguageModel::CreateFactors(FactorCollection &factorCollection)
+{ // add factors which have srilm id
+
+ VocabString str;
+ LmId lmId;
+ VocabIter iter(m_srilmVocab);
+ while ( (str = iter.next()) != NULL)
+ {
+ LmId lmId = GetLmID(str);
+ factorCollection.AddFactor(Target, m_factorType, str, lmId);
+ }
+
+ lmId = GetLmID(SENTENCE_START);
+ m_sentenceStart = factorCollection.AddFactor(Target, m_factorType, SENTENCE_START, lmId);
+ lmId = GetLmID(SENTENCE_END);
+ m_sentenceEnd = factorCollection.AddFactor(Target, m_factorType, SENTENCE_END, lmId);
+
+}
+
+float LanguageModel::GetValue(const vector<const Factor*> &contextFactor) const
+{
+ // set up context
+ size_t count = contextFactor.size();
+ LmId *context = (LmId*) malloc(count * sizeof(LmId));
+ for (size_t i = 0 ; i < count - 1 ; i++)
+ {
+ context[i] = GetLmID(contextFactor[count-2-i]);
+ }
+ context[count-1] = Vocab_None;
+
+ // call sri lm fn
+ float ret = GetValue(GetLmID(contextFactor[count-1]), context);
+ free(context);
+ return ret;
+}
+
+#endif
+#ifdef LM_INTERNAL
+
+#include "InputFileStream.h"
+
+// static variable init
+const LmId LanguageModel::UNKNOWN_LM_ID = NULL;
+
+// class methods
+LanguageModel::LanguageModel()
+{
+}
+
+void LanguageModel::Load(size_t id
+ , const std::string &fileName
+ , FactorCollection &factorCollection
+ , FactorType factorType
+ , float weight
+ , size_t nGramOrder)
+{
+ m_id = id;
+ m_factorType = factorType;
+ m_weight = weight;
+ m_nGramOrder = nGramOrder;
+ // make sure start & end tags in factor collection
+ m_sentenceStart = factorCollection.AddFactor(Target, m_factorType, SENTENCE_START);
+ m_sentenceEnd = factorCollection.AddFactor(Target, m_factorType, SENTENCE_END);
+
+ // read in file
+ TRACE_ERR(fileName << endl);
+
+ InputFileStream inFile(fileName);
+
+ string line;
+
+ int lineNo = 0;
+ while( !getline(inFile, line, '\n').eof())
+ {
+ lineNo++;
+ if (line.size() != 0 && line.substr(0,1) != "\\")
+ {
+ vector<string> tokens = Tokenize(line, "\t");
+ if (tokens.size() >= 2)
+ {
+ // split unigram/bigram trigrams
+ vector<string> factorStr = Tokenize(tokens[1], " ");
+
+ // create / traverse down tree
+ NGramCollection *ngramColl = &m_map;
+ NGramNode *nGram;
+ const Factor *factor;
+ for (int currFactor = (int) factorStr.size() - 1 ; currFactor >= 0 ; currFactor--)
+ {
+ factor = factorCollection.AddFactor(Target, m_factorType, factorStr[currFactor]);
+ nGram = ngramColl->GetOrCreateNGram(factor);
+
+ ngramColl = nGram->GetNGramColl();
+ }
+
+ NGramNode *rootNGram = m_map.GetNGram(factor);
+ nGram->SetRootNGram(rootNGram);
+ factorCollection.SetFactorLmId(factor, rootNGram);
+
+ float score = TransformSRIScore(Scan<float>(tokens[0]));
+ nGram->SetScore( score );
+ if (tokens.size() == 3)
+ {
+ float logBackOff = TransformSRIScore(Scan<float>(tokens[2]));
+ nGram->SetLogBackOff( logBackOff );
+ }
+ else
+ {
+ nGram->SetLogBackOff( 0 );
+ }
+ }
+ }
+ }
+}
+
+float LanguageModel::GetValue(const std::vector<const Factor*> &contextFactor) const
+{
+ float score;
+ size_t nGramOrder = contextFactor.size();
+ assert(nGramOrder <= 3);
+
+ if (nGramOrder == 1)
+ score = GetValue(contextFactor[0]);
+ else if (nGramOrder == 2)
+ score = GetValue(contextFactor[0], contextFactor[1]);
+ else if (nGramOrder == 3)
+ score = GetValue(contextFactor[0], contextFactor[1], contextFactor[2]);
+
+ return FloorSRIScore(score);
+}
+
+float LanguageModel::GetValue(const Factor *factor0) const
+{
+ float prob;
+ const NGramNode *nGram = factor0->GetLmId();
+ if (nGram == NULL)
+ {
+ prob = -numeric_limits<float>::infinity();
+ }
+ else
+ {
+ prob = nGram->GetScore();
+ }
+ return FloorSRIScore(prob);
+}
+float LanguageModel::GetValue(const Factor *factor0, const Factor *factor1) const
+{
+ float score;
+ const NGramNode *nGram[2];
+
+ nGram[1] = factor1->GetLmId();
+ if (nGram[1] == NULL)
+ {
+ score = -numeric_limits<float>::infinity();
+ }
+ else
+ {
+ nGram[0] = nGram[1]->GetNGram(factor0);
+ if (nGram[0] == NULL)
+ { // something unigram
+ nGram[0] = factor0->GetLmId();
+ if (nGram[0] == NULL)
+ { // stops at unigram
+ score = nGram[1]->GetScore();
+ }
+ else
+ { // unigram unigram
+ score = nGram[1]->GetScore() + nGram[0]->GetLogBackOff();
+ }
+ }
+ else
+ { // bigram
+ score = nGram[0]->GetScore();
+ }
+ }
+
+ return FloorSRIScore(score);
+
+}
+
+float LanguageModel::GetValue(const Factor *factor0, const Factor *factor1, const Factor *factor2) const
+{
+ float score;
+ const NGramNode *nGram[3];
+
+ nGram[2] = factor2->GetLmId();
+ if (nGram[2] == NULL)
+ {
+ score = -numeric_limits<float>::infinity();
+ }
+ else
+ {
+ nGram[1] = nGram[2]->GetNGram(factor1);
+ if (nGram[1] == NULL)
+ { // something unigram
+ nGram[1] = factor1->GetLmId();
+ if (nGram[1] == NULL)
+ { // stops at unigram
+ score = nGram[2]->GetScore();
+ }
+ else
+ {
+ nGram[0] = nGram[1]->GetNGram(factor0);
+ if (nGram[0] == NULL)
+ { // unigram unigram
+ score = nGram[2]->GetScore() + nGram[1]->GetLogBackOff();
+ }
+ else
+ { // unigram bigram
+ score = nGram[2]->GetScore() + nGram[1]->GetLogBackOff() + nGram[0]->GetLogBackOff();
+ }
+ }
+ }
+ else
+ { // trigram, or something bigram
+ nGram[0] = nGram[1]->GetNGram(factor0);
+ if (nGram[0] != NULL)
+ { // trigram
+ score = nGram[0]->GetScore();
+ }
+ else
+ {
+ score = nGram[1]->GetScore();
+ nGram[1] = nGram[1]->GetRootNGram();
+ nGram[0] = nGram[1]->GetNGram(factor0);
+ if (nGram[0] == NULL)
+ { // just bigram
+ // do nothing
+ }
+ else
+ {
+ score += nGram[0]->GetLogBackOff();
+ }
+
+ }
+ // else do nothing. just use 1st bigram
+ }
+ }
+
+ return FloorSRIScore(score);
+
+}
+
+#endif
+
diff --git a/moses/src/LanguageModel.h b/moses/src/LanguageModel.h
new file mode 100755
index 000000000..a3d74755a
--- /dev/null
+++ b/moses/src/LanguageModel.h
@@ -0,0 +1,139 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <string>
+#include <vector>
+#include "NGramNode.h"
+#include "Factor.h"
+#include "TypeDef.h"
+#include "Util.h"
+
+#ifdef LM_SRI
+#include "Ngram.h"
+#include "Vocab.h"
+#endif
+
+class FactorCollection;
+class Factor;
+class Phrase;
+
+class LanguageModel
+{
+protected:
+ const Factor *m_sentenceStart, *m_sentenceEnd;
+ FactorType m_factorType;
+ float m_weight;
+ size_t m_id, m_nGramOrder;
+public:
+
+ LanguageModel();
+ void Load(size_t id
+ , const std::string &fileName
+ , FactorCollection &factorCollection
+ , FactorType factorType
+ , float weight
+ , size_t nGramOrder);
+
+ size_t GetNGramOrder() const
+ {
+ return m_nGramOrder;
+ }
+ const Factor *GetSentenceStart() const
+ {
+ return m_sentenceStart;
+ }
+ const Factor *GetSentenceEnd() const
+ {
+ return m_sentenceEnd;
+ }
+ void CalcScore(const Phrase &phrase
+ , float &fullScore
+ , float &ngramScore
+ , std::list< std::pair<size_t, float> > &ngramComponent) const;
+ FactorType GetFactorType() const
+ {
+ return m_factorType;
+ }
+ float GetWeight() const
+ {
+ return m_weight;
+ }
+ void SetWeight(float weight)
+ {
+ m_weight = weight;
+ }
+ size_t GetId() const
+ {
+ return m_id;
+ }
+ float GetValue(const std::vector<const Factor*> &contextFactor) const;
+
+#ifdef LM_SRI
+protected:
+ Ngram m_srilmModel;
+ Vocab m_srilmVocab;
+
+ float GetValue(LmId wordId, LmId *context) const
+ {
+ LanguageModel *lm = const_cast<LanguageModel*>(this); // hack. not sure if supposed to cast this
+ float p = lm->m_srilmModel.wordProb( wordId, context );
+ return FloorSRIScore(TransformSRIScore(p)); // log10->log
+ }
+
+ LmId GetLmID( const Factor *factor ) const
+ {
+ return GetLmID(factor->GetString());
+ }
+ void CreateFactors(FactorCollection &factorCollection);
+public:
+ static const LmId UNKNOWN_LM_ID = 0;
+
+ LmId GetLmID( const std::string &str ) const
+ {
+ LanguageModel *lm = const_cast<LanguageModel*>(this); // hack. not sure if supposed to cast this
+ return lm->m_srilmVocab.getIndex( str.c_str(), lm->m_srilmVocab.unkIndex() );
+ }
+
+#endif
+#ifdef LM_INTERNAL
+
+#define Vocab_None NULL;
+
+protected:
+ NGramCollection m_map;
+
+ float GetValue(const Factor *factor0) const;
+ float GetValue(const Factor *factor0, const Factor *factor1) const;
+ float GetValue(const Factor *factor0, const Factor *factor1, const Factor *factor2) const;
+
+public:
+ static const LmId UNKNOWN_LM_ID;
+
+ LmId GetLmID( const Factor *factor ) const
+ {
+ return factor->GetLmId();
+ }
+#endif
+
+};
+
diff --git a/moses/src/LatticeEdge.cpp b/moses/src/LatticeEdge.cpp
new file mode 100755
index 000000000..2b3250875
--- /dev/null
+++ b/moses/src/LatticeEdge.cpp
@@ -0,0 +1,76 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "LatticeEdge.h"
+#include "LanguageModel.h"
+
+using namespace std;
+
+void LatticeEdge::ResetScore()
+{
+ for (size_t i = 0 ; i < NUM_SCORES ; i++)
+ {
+ m_score[i] = 0;
+ }
+}
+
+#ifdef N_BEST
+
+void LatticeEdge::ResizeComponentScore(const LMList &allLM, const list < DecodeStep > &decodeStepList)
+{
+ // LM
+ LMList::const_iterator iter;
+ for (iter = allLM.begin() ; iter != allLM.end() ; ++iter)
+ {
+ LanguageModel *lm = *iter;
+ m_lmScoreComponent[lm->GetId()] = 0.0f;
+ }
+
+ // trans & gen
+ list < DecodeStep >::const_iterator iterDecodeStep;
+ for (iterDecodeStep = decodeStepList.begin() ; iterDecodeStep != decodeStepList.end() ; ++iterDecodeStep)
+ {
+ const DecodeStep &step = *iterDecodeStep;
+ switch (step.first)
+ {
+ case Translate:
+ {
+ TransScoreComponent &transScoreComponent = m_transScoreComponent.Add(step.second);
+ transScoreComponent.Reset();
+ break;
+ }
+ case Generate:
+ {
+ m_generationScoreComponent[step.second] = 0.0f;
+ break;
+ }
+ }
+ }
+
+ // reset score
+ for (size_t i = 0 ; i < m_lmScoreComponent.size() ; i++)
+ {
+ m_lmScoreComponent[i] = 0;
+ }
+}
+
+#endif
+
diff --git a/moses/src/LatticeEdge.h b/moses/src/LatticeEdge.h
new file mode 100755
index 000000000..2d3020fa4
--- /dev/null
+++ b/moses/src/LatticeEdge.h
@@ -0,0 +1,133 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+#include <list>
+#include "TypeDef.h"
+#include "Phrase.h"
+#include "TransScoreComponent.h"
+#include "TransScoreComponentCollection.h"
+#include "ScoreColl.h"
+
+class Hypothesis;
+class Arc;
+class GenerationDictionary;
+
+class LatticeEdge
+{
+protected:
+ // scores
+ float m_score[NUM_SCORES];
+
+ const Hypothesis *m_prevHypo;
+ Phrase m_phrase;
+
+#ifdef N_BEST
+ TransScoreComponentCollection m_transScoreComponent;
+ ScoreColl m_generationScoreComponent
+ ,m_lmScoreComponent;
+#endif
+
+public:
+ LatticeEdge(const LatticeEdge &edge); // not implemented
+ LatticeEdge(const float score[NUM_SCORES]
+ , const TransScoreComponentCollection &transScoreComponent
+ , const ScoreColl &lmScoreComponent
+ , const ScoreColl &generationScoreComponent
+ , const Phrase &phrase
+ , const Hypothesis *prevHypo)
+ :m_prevHypo(prevHypo)
+ ,m_phrase(phrase)
+ {
+ SetScore(score);
+#ifdef N_BEST
+ m_transScoreComponent = transScoreComponent;
+ m_lmScoreComponent = lmScoreComponent;
+ m_generationScoreComponent = generationScoreComponent;
+#endif
+ }
+ LatticeEdge(Language language, const Hypothesis *prevHypo)
+ :m_prevHypo(prevHypo)
+ ,m_phrase(language)
+ {}
+ virtual ~LatticeEdge()
+ {
+ }
+
+ inline const Phrase &GetPhrase() const
+ {
+ return m_phrase;
+ }
+ inline void SetFactor(size_t pos, FactorType factorType, const Factor *factor)
+ { // pos starts from current phrase, not from beginning of 1st phrase
+ m_phrase.SetFactor(pos, factorType, factor);
+ }
+ inline void SetScore(const float score[NUM_SCORES])
+ {
+ for (size_t currScore = 0 ; currScore < NUM_SCORES ; currScore++)
+ {
+ m_score[currScore] = score[currScore];
+ }
+ }
+ void ResetScore();
+
+ inline const float *GetScore() const
+ {
+ return m_score;
+ }
+ inline float GetScore(ScoreType scoreType) const
+ {
+ return m_score[scoreType];
+ }
+
+ inline const Hypothesis *GetPrevHypo() const
+ {
+ return m_prevHypo;
+ }
+
+#ifdef N_BEST
+ virtual const std::list<Arc*> &GetArcList() const = 0;
+
+ inline const TransScoreComponentCollection &GetTransScoreComponent() const
+ {
+ return m_transScoreComponent;
+ }
+ inline const ScoreColl &GetLMScoreComponent() const
+ {
+ return m_lmScoreComponent;
+ }
+ inline const ScoreColl &GetGenerationScoreComponent() const
+ {
+ return m_generationScoreComponent;
+ }
+
+ void ResizeComponentScore(const LMList &allLM, const std::list < DecodeStep > &decodeStepList);
+#endif
+};
+
+inline std::ostream& operator<<(std::ostream& out, const LatticeEdge& edge)
+{
+ out << edge.GetPhrase();
+ return out;
+}
+
diff --git a/moses/src/LatticePath.cpp b/moses/src/LatticePath.cpp
new file mode 100755
index 000000000..0ea50c503
--- /dev/null
+++ b/moses/src/LatticePath.cpp
@@ -0,0 +1,198 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "LatticePath.h"
+#include "LatticePathCollection.h"
+
+using namespace std;
+
+LatticePath::LatticePath(const Hypothesis *hypo)
+: m_prevEdgeChanged(NOT_FOUND)
+{ // create path OF pure hypo
+
+ // initial scores
+ for (size_t i = 0 ; i < NUM_SCORES ; i++)
+ {
+ m_score[i] = hypo->GetScore(static_cast<ScoreType>(i));
+ }
+#ifdef N_BEST
+ m_lmScoreComponent = hypo->GetLMScoreComponent();
+ m_transScoreComponent = hypo->GetTransScoreComponent();
+ m_generationScoreComponent = hypo->GetGenerationScoreComponent();
+#endif
+
+ // enumerate path using prevHypo
+ while (hypo != NULL)
+ {
+ m_path.push_back(hypo);
+ hypo = hypo->GetPrevHypo();
+ }
+}
+
+LatticePath::LatticePath(const LatticePath &copy, size_t edgeIndex, const Arc *arc)
+:m_prevEdgeChanged(edgeIndex)
+{
+ for (size_t currEdge = 0 ; currEdge < edgeIndex ; currEdge++)
+ { // copy path from parent
+ m_path.push_back(copy.m_path[currEdge]);
+ }
+
+ // 1 deviation
+ m_path.push_back(arc);
+
+ // rest of path comes from the deviation
+ const Hypothesis *prevHypo = arc->GetPrevHypo();
+ while (prevHypo != NULL)
+ {
+ m_path.push_back(prevHypo);
+ prevHypo = prevHypo->GetPrevHypo();
+ }
+
+ CalcScore(copy, edgeIndex, arc);
+}
+
+LatticePath::LatticePath(const LatticePath &copy, size_t edgeIndex, const Arc *arc, bool reserve)
+:m_prevEdgeChanged(edgeIndex)
+,m_path(copy.m_path)
+{
+ // 1 deviation
+ m_path[edgeIndex] = arc;
+
+ CalcScore(copy, edgeIndex, arc);
+}
+
+void LatticePath::CalcScore(const LatticePath &copy, size_t edgeIndex, const Arc *arc)
+{
+#ifdef N_BEST
+// calc score
+ for (size_t i = 0 ; i < NUM_SCORES ; i++)
+ {
+ ScoreType scoreType = static_cast<ScoreType>(i);
+ float adj = (arc->GetScore(scoreType) - copy.m_path[edgeIndex]->GetScore(scoreType));
+ m_score[i] = copy.GetScore(scoreType) + adj;
+
+ }
+ // lm
+ m_lmScoreComponent = copy.GetLMScoreComponent();
+
+ const ScoreColl &lmArcComponent = arc->GetLMScoreComponent()
+ ,&lmCopyComponent = copy.m_path[edgeIndex]->GetLMScoreComponent();
+ ScoreColl::const_iterator iterLM;
+ for (iterLM = lmArcComponent.begin() ; iterLM != lmArcComponent.end() ; ++iterLM)
+ {
+ size_t idLM = iterLM->first;
+ float adj = iterLM->second - lmCopyComponent.GetValue(idLM);
+ m_lmScoreComponent[idLM] = copy.GetLMScoreComponent(idLM) + adj;
+ }
+
+ // phrase trans
+ m_transScoreComponent = copy.GetTransScoreComponent();
+
+ const TransScoreComponentCollection
+ &arcComponent = arc->GetTransScoreComponent()
+ ,&copyComponent = copy.m_path[edgeIndex]->GetTransScoreComponent()
+ ,&totalComponent= copy.GetTransScoreComponent();
+
+ TransScoreComponentCollection::iterator iterTrans;
+ for (iterTrans = m_transScoreComponent.begin() ; iterTrans != m_transScoreComponent.end() ; ++iterTrans)
+ {
+ size_t idPhraseDict = iterTrans->first;
+ TransScoreComponent &transScore = iterTrans->second;
+ const TransScoreComponent &arcScore = arcComponent.GetTransScoreComponent(idPhraseDict)
+ ,&copyScore = copyComponent.GetTransScoreComponent(idPhraseDict)
+ ,&totalScore = totalComponent.GetTransScoreComponent(idPhraseDict);
+ for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
+ {
+ float adj = arcScore[i] - copyScore[i];
+ transScore[i] = totalScore[i] + adj;
+ }
+ }
+
+ // generation
+ m_generationScoreComponent = copy.GetGenerationScoreComponent();
+
+ const ScoreColl &arcGenComponent = arc->GetGenerationScoreComponent()
+ ,&copyGenComponent = copy.m_path[edgeIndex]->GetGenerationScoreComponent();
+
+ ScoreColl::iterator iterGen;
+ for (iterGen = m_generationScoreComponent.begin() ; iterGen != m_generationScoreComponent.end() ; ++iterGen)
+ {
+ pair<const size_t , float> &scorePair = *iterGen;
+ size_t idGenDict = scorePair.first;
+ float score = scorePair.second;
+ float arcScore = arcGenComponent.GetValue(idGenDict);
+ float copyScore = copyGenComponent.GetValue(idGenDict);
+ float adj = arcScore - copyScore;
+ scorePair.second = score + adj;
+ }
+
+#endif
+}
+
+#ifdef N_BEST
+void LatticePath::CreateDeviantPaths(LatticePathCollection &pathColl) const
+{
+ const size_t sizePath = m_path.size();
+
+ if (m_prevEdgeChanged == NOT_FOUND)
+ { // initial enumration from a pure hypo
+ for (size_t currEdge = 0 ; currEdge < sizePath ; currEdge++)
+ {
+ const Hypothesis *hypo = static_cast<const Hypothesis*>(m_path[currEdge]);
+ const list<Arc*> &arcList = hypo->GetArcList();
+
+ // every possible Arc to replace this edge
+ list<Arc*>::const_iterator iterArc;
+ for (iterArc = arcList.begin() ; iterArc != arcList.end() ; ++iterArc)
+ {
+ const Arc *arc = *iterArc;
+ LatticePath *deviantPath = new LatticePath(*this, currEdge, arc);
+ pathColl.insert(deviantPath);
+ }
+ }
+ }
+ else
+ { // wiggle 1 of the edges only
+ for (size_t currEdge = 0 ; currEdge < sizePath ; currEdge++)
+ {
+ if (currEdge != m_prevEdgeChanged)
+ {
+ const LatticeEdge *edgeOrig = m_path[currEdge];
+
+ const list<Arc*> &arcList = m_path[currEdge]->GetArcList();
+ list<Arc*>::const_iterator iterArc;
+
+ for (iterArc = arcList.begin() ; iterArc != arcList.end() ; ++iterArc)
+ { // copy this Path & change 1 edge
+ const Arc *arcReplace = *iterArc;
+
+ if (arcReplace != edgeOrig && arcReplace->GetPrevHypo() == edgeOrig->GetPrevHypo())
+ {
+ LatticePath *deviantPath = new LatticePath(*this, currEdge, arcReplace, true);
+ pathColl.insert(deviantPath);
+ }
+ }
+ }
+ }
+ }
+}
+#endif
+
diff --git a/moses/src/LatticePath.h b/moses/src/LatticePath.h
new file mode 100755
index 000000000..e09931fe3
--- /dev/null
+++ b/moses/src/LatticePath.h
@@ -0,0 +1,124 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+#include <vector>
+#include <limits>
+#include "LatticeEdge.h"
+#include "Hypothesis.h"
+#include "TypeDef.h"
+#include "TransScoreComponent.h"
+#include "ScoreColl.h"
+
+class Arc;
+class LatticePathCollection;
+
+class LatticePath
+{
+ friend std::ostream& operator<<(std::ostream&, const LatticePath&);
+
+protected:
+ std::vector<const LatticeEdge*> m_path;
+ size_t m_prevEdgeChanged;
+ float m_score[NUM_SCORES];
+
+ TransScoreComponentCollection m_transScoreComponent;
+ ScoreColl m_generationScoreComponent
+ , m_lmScoreComponent;
+
+ void CalcScore(const LatticePath &copy, size_t edgeIndex, const Arc *arc);
+
+public:
+ LatticePath(); // not implemented
+
+ LatticePath(const Hypothesis *hypo);
+ // create path OF pure hypo
+ LatticePath(const LatticePath &copy, size_t edgeIndex, const Arc *arc);
+ // create path FROM pure hypo
+ // deviate from edgeIndex backwards
+ LatticePath(const LatticePath &copy, size_t edgeIndex, const Arc *arc, bool reserve);
+ // create path from ANY hypo
+ // reserve arg not used. to differential from other constructor
+ // deviate from edgeIndex. however, all other edges the same
+
+ inline float GetScore(ScoreType scoreType) const
+ {
+ return m_score[scoreType];
+ }
+ inline const std::vector<const LatticeEdge*> &GetEdges() const
+ {
+ return m_path;
+ }
+
+ inline bool IsPurePath() const
+ {
+ return m_prevEdgeChanged == NOT_FOUND;
+ }
+
+#ifdef N_BEST
+ void CreateDeviantPaths(LatticePathCollection &pathColl) const;
+
+ inline const ScoreColl &GetLMScoreComponent() const
+ {
+ return m_lmScoreComponent;
+ }
+ inline float GetLMScoreComponent(size_t index) const
+ {
+ return m_lmScoreComponent.GetValue(index);
+ }
+ inline const TransScoreComponentCollection &GetTransScoreComponent() const
+ {
+ return m_transScoreComponent;
+ }
+ inline const ScoreColl &GetGenerationScoreComponent() const
+ {
+ return m_generationScoreComponent;
+ }
+
+#endif
+
+};
+
+// friend
+inline std::ostream& operator<<(std::ostream& out, const LatticePath& path)
+{
+ const size_t sizePath = path.m_path.size();
+ for (int pos = (int) sizePath - 1 ; pos >= 0 ; pos--)
+ {
+ const LatticeEdge *edge = path.m_path[pos];
+ out << *edge;
+ }
+ // scores
+ out << " [" << path.GetScore( static_cast<ScoreType>(0));
+ for (size_t i = 1 ; i < NUM_SCORES ; i++)
+ {
+ out << "," << path.GetScore( static_cast<ScoreType>(i));
+ }
+ out << "]";
+#ifdef N_BEST
+ out << " " << path.GetTransScoreComponent();
+ out << " " << path.GetGenerationScoreComponent();
+#endif
+
+ return out;
+}
diff --git a/moses/src/LatticePathCollection.h b/moses/src/LatticePathCollection.h
new file mode 100755
index 000000000..846afc9cc
--- /dev/null
+++ b/moses/src/LatticePathCollection.h
@@ -0,0 +1,56 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <set>
+#include <iostream>
+
+struct CompareLatticePathCollection
+{
+ bool operator()(const LatticePath* pathA, const LatticePath* pathB) const
+ {
+ return (pathA->GetScore(Total) > pathB->GetScore(Total));
+ }
+};
+
+class LatticePathCollection : public std::multiset<LatticePath*, CompareLatticePathCollection>
+{
+public:
+ ~LatticePathCollection()
+ {
+ // clean up
+ RemoveAllInColl<LatticePathCollection::iterator> (*this);
+ }
+};
+
+inline std::ostream& operator<<(std::ostream& out, const LatticePathCollection& pathColl)
+{
+ LatticePathCollection::const_iterator iter;
+
+ for (iter = pathColl.begin() ; iter != pathColl.end() ; ++iter)
+ {
+ const LatticePath &path = **iter;
+ out << path << std::endl;
+ }
+ return out;
+}
+
diff --git a/moses/src/LatticePathList.h b/moses/src/LatticePathList.h
new file mode 100755
index 000000000..0e9a6bc22
--- /dev/null
+++ b/moses/src/LatticePathList.h
@@ -0,0 +1,43 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <list>
+#include "LatticePath.h"
+
+
+class LatticePathList : public std::list<const LatticePath*>
+{
+
+public:
+ ~LatticePathList()
+ {
+ // clean up
+ LatticePathList::iterator iter;
+ for (iter = begin() ; iter != end() ; ++iter)
+ {
+ delete *iter;
+ }
+ clear();
+ }
+};
+
diff --git a/moses/src/Makefile.am b/moses/src/Makefile.am
new file mode 100644
index 000000000..ee29860de
--- /dev/null
+++ b/moses/src/Makefile.am
@@ -0,0 +1,10 @@
+lib_LIBRARIES = libmoses.a
+libmoses_a_SOURCES = Arc.cpp FactorCollection.cpp Factor.cpp FactorTypeSet.cpp GenerationDictionary.cpp HypothesisCollection.cpp HypothesisCollectionIntermediate.cpp Hypothesis.cpp InputFileStream.cpp LanguageModel.cpp LatticeEdge.cpp LatticePath.cpp Manager.cpp md5.cpp Parameter.cpp Phrase.cpp PhraseDictionary.cpp PossibleTranslation.cpp Sentence.cpp StaticData.cpp TargetPhrase.cpp Util.cpp WeightOptimization.cpp Word.cpp WordsBitmap.cpp
+
+if INTERNAL_LM
+libmoses_a_SOURCES += NGramCollection.cpp
+endif
+
+if SRI_LM
+endif
+
diff --git a/moses/src/Makefile.in b/moses/src/Makefile.in
new file mode 100644
index 000000000..daffdcbec
--- /dev/null
+++ b/moses/src/Makefile.in
@@ -0,0 +1,473 @@
+# Makefile.in generated by automake 1.9.2 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+SOURCES = $(libmoses_a_SOURCES)
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+@INTERNAL_LM_TRUE@am__append_1 = NGramCollection.cpp
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(libdir)"
+libLIBRARIES_INSTALL = $(INSTALL_DATA)
+LIBRARIES = $(lib_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+libmoses_a_AR = $(AR) $(ARFLAGS)
+libmoses_a_LIBADD =
+am__libmoses_a_SOURCES_DIST = Arc.cpp FactorCollection.cpp Factor.cpp \
+ FactorTypeSet.cpp GenerationDictionary.cpp \
+ HypothesisCollection.cpp HypothesisCollectionIntermediate.cpp \
+ Hypothesis.cpp InputFileStream.cpp LanguageModel.cpp \
+ LatticeEdge.cpp LatticePath.cpp Manager.cpp md5.cpp \
+ Parameter.cpp Phrase.cpp PhraseDictionary.cpp \
+ PossibleTranslation.cpp Sentence.cpp StaticData.cpp \
+ TargetPhrase.cpp Util.cpp WeightOptimization.cpp Word.cpp \
+ WordsBitmap.cpp NGramCollection.cpp
+@INTERNAL_LM_TRUE@am__objects_1 = NGramCollection.$(OBJEXT)
+am_libmoses_a_OBJECTS = Arc.$(OBJEXT) FactorCollection.$(OBJEXT) \
+ Factor.$(OBJEXT) FactorTypeSet.$(OBJEXT) \
+ GenerationDictionary.$(OBJEXT) HypothesisCollection.$(OBJEXT) \
+ HypothesisCollectionIntermediate.$(OBJEXT) \
+ Hypothesis.$(OBJEXT) InputFileStream.$(OBJEXT) \
+ LanguageModel.$(OBJEXT) LatticeEdge.$(OBJEXT) \
+ LatticePath.$(OBJEXT) Manager.$(OBJEXT) md5.$(OBJEXT) \
+ Parameter.$(OBJEXT) Phrase.$(OBJEXT) \
+ PhraseDictionary.$(OBJEXT) PossibleTranslation.$(OBJEXT) \
+ Sentence.$(OBJEXT) StaticData.$(OBJEXT) TargetPhrase.$(OBJEXT) \
+ Util.$(OBJEXT) WeightOptimization.$(OBJEXT) Word.$(OBJEXT) \
+ WordsBitmap.$(OBJEXT) $(am__objects_1)
+libmoses_a_OBJECTS = $(am_libmoses_a_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+ -o $@
+SOURCES = $(libmoses_a_SOURCES)
+DIST_SOURCES = $(am__libmoses_a_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BUILD_MYSQL_SUPPORT_FALSE = @BUILD_MYSQL_SUPPORT_FALSE@
+BUILD_MYSQL_SUPPORT_TRUE = @BUILD_MYSQL_SUPPORT_TRUE@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTERNAL_LM_FALSE = @INTERNAL_LM_FALSE@
+INTERNAL_LM_TRUE = @INTERNAL_LM_TRUE@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MYSQLCLIENT_CPPFLAGS = @MYSQLCLIENT_CPPFLAGS@
+MYSQLCLIENT_LDFLAGS = @MYSQLCLIENT_LDFLAGS@
+MYSQLCLIENT_LIBS = @MYSQLCLIENT_LIBS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SRI_LM_FALSE = @SRI_LM_FALSE@
+SRI_LM_TRUE = @SRI_LM_TRUE@
+STRIP = @STRIP@
+VERSION = @VERSION@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build_alias = @build_alias@
+datadir = @datadir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+lib_LIBRARIES = libmoses.a
+libmoses_a_SOURCES = Arc.cpp FactorCollection.cpp Factor.cpp \
+ FactorTypeSet.cpp GenerationDictionary.cpp \
+ HypothesisCollection.cpp HypothesisCollectionIntermediate.cpp \
+ Hypothesis.cpp InputFileStream.cpp LanguageModel.cpp \
+ LatticeEdge.cpp LatticePath.cpp Manager.cpp md5.cpp \
+ Parameter.cpp Phrase.cpp PhraseDictionary.cpp \
+ PossibleTranslation.cpp Sentence.cpp StaticData.cpp \
+ TargetPhrase.cpp Util.cpp WeightOptimization.cpp Word.cpp \
+ WordsBitmap.cpp $(am__append_1)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-libLIBRARIES: $(lib_LIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(libLIBRARIES_INSTALL) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
+ $(libLIBRARIES_INSTALL) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
+ else :; fi; \
+ done
+ @$(POST_INSTALL)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ p=$(am__strip_dir) \
+ echo " $(RANLIB) '$(DESTDIR)$(libdir)/$$p'"; \
+ $(RANLIB) "$(DESTDIR)$(libdir)/$$p"; \
+ else :; fi; \
+ done
+
+uninstall-libLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(libdir)/$$p'"; \
+ rm -f "$(DESTDIR)$(libdir)/$$p"; \
+ done
+
+clean-libLIBRARIES:
+ -test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
+libmoses.a: $(libmoses_a_OBJECTS) $(libmoses_a_DEPENDENCIES)
+ -rm -f libmoses.a
+ $(libmoses_a_AR) libmoses.a $(libmoses_a_OBJECTS) $(libmoses_a_LIBADD)
+ $(RANLIB) libmoses.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Arc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Factor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FactorCollection.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FactorTypeSet.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GenerationDictionary.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Hypothesis.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HypothesisCollection.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HypothesisCollectionIntermediate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InputFileStream.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LanguageModel.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LatticeEdge.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LatticePath.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Manager.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NGramCollection.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Parameter.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Phrase.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PhraseDictionary.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PossibleTranslation.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sentence.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StaticData.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TargetPhrase.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WeightOptimization.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Word.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WordsBitmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am: install-libLIBRARIES
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am uninstall-libLIBRARIES
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libLIBRARIES ctags distclean distclean-compile \
+ distclean-generic distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-exec install-exec-am install-info \
+ install-info-am install-libLIBRARIES install-man install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am uninstall-info-am uninstall-libLIBRARIES
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/moses/src/Manager.cpp b/moses/src/Manager.cpp
new file mode 100755
index 000000000..7d0c1855e
--- /dev/null
+++ b/moses/src/Manager.cpp
@@ -0,0 +1,607 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <limits>
+#include <math.h>
+#include "Manager.h"
+#include "TypeDef.h"
+#include "Util.h"
+#include "TargetPhrase.h"
+#include "HypothesisCollectionIntermediate.h"
+#include "LatticePath.h"
+#include "LatticePathCollection.h"
+
+using namespace std;
+
+Manager::Manager(const Sentence &sentence, StaticData &staticData)
+:m_source(sentence)
+,m_hypoStack(sentence.GetSize() + 1)
+,m_staticData(staticData)
+,m_futureScore(sentence.GetSize())
+{
+ std::vector < HypothesisCollection >::iterator iterStack;
+ for (iterStack = m_hypoStack.begin() ; iterStack != m_hypoStack.end() ; ++iterStack)
+ {
+ HypothesisCollection &sourceHypoColl = *iterStack;
+ sourceHypoColl.SetBeamThreshold(m_staticData.GetBeamThreshold());
+ }
+}
+
+Manager::~Manager()
+{
+}
+
+void Manager::ProcessSentence()
+{
+ list < DecodeStep > &decodeStepList = m_staticData.GetDecodeStepList();
+
+ const PhraseDictionary &phraseDictionary
+ = m_staticData.GetPhraseDictionary(decodeStepList.front());
+ const LMList &lmListInitial = m_staticData.GetLanguageModel(Initial);
+ // create list of all possible translations
+ // this is only valid if:
+ // 1. generation of source sentence is not done 1st
+ // 2. initial hypothesis factors are given in the sentence
+ CreatePossibleTranslations(m_source, phraseDictionary, lmListInitial);
+
+
+ // output
+ //TRACE_ERR (m_possibleTranslations << endl);
+
+
+ // seed hypothesis
+ {
+ Hypothesis *hypo = new Hypothesis(m_source);
+#ifdef N_BEST
+ LMList allLM = m_staticData.GetAllLM();
+ hypo->ResizeComponentScore(allLM, decodeStepList);
+#endif
+ m_hypoStack[0].Add(hypo, m_staticData.GetBeamThreshold());
+ }
+
+ // go thru each stack
+ std::vector < HypothesisCollection >::iterator iterStack;
+ for (iterStack = m_hypoStack.begin() ; iterStack != m_hypoStack.end() ; ++iterStack)
+ {
+ HypothesisCollection &sourceHypoColl = *iterStack;
+ sourceHypoColl.PruneToSize(MAXIMUM_HYPO_COLL_SIZE/2);
+ sourceHypoColl.InitializeArcs();
+ //sourceHypoColl.Prune();
+ ProcessOneStack(decodeStepList, sourceHypoColl);
+
+ //OutputHypoStack();
+ OutputHypoStackSize();
+ }
+
+ // output
+ //OutputHypoStack();
+ OutputHypoStackSize();
+}
+
+const Hypothesis *Manager::GetBestHypothesis() const
+{
+ // best
+ const HypothesisCollection &hypoColl = m_hypoStack.back();
+ return hypoColl.GetBestHypothesis();
+}
+
+void Manager::ProcessOneStack(const list < DecodeStep > &decodeStepList
+ ,HypothesisCollection &sourceHypoColl)
+{
+ // go thru each hypothesis in the stack
+ HypothesisCollection::iterator iterHypo;
+ for (iterHypo = sourceHypoColl.begin() ; iterHypo != sourceHypoColl.end() ; ++iterHypo)
+ {
+ Hypothesis &hypothesis = **iterHypo;
+ ProcessOneHypothesis(decodeStepList, hypothesis);
+ }
+}
+
+void Manager::ProcessOneHypothesis(const list < DecodeStep > &decodeStepList
+ , const Hypothesis &hypothesis)
+{
+ vector < HypothesisCollectionIntermediate > outputHypoCollVec( decodeStepList.size() );
+ HypothesisCollectionIntermediate::iterator iterHypo;
+
+ // initial translation step
+ list < DecodeStep >::const_iterator iterStep = decodeStepList.begin();
+ const DecodeStep &decodeStep = *iterStep;
+ ProcessInitialTranslation(hypothesis, decodeStep, outputHypoCollVec[0]);
+
+ // do rest of decode steps
+ int indexStep = 0;
+ for (++iterStep ; iterStep != decodeStepList.end() ; ++iterStep)
+ {
+ const DecodeStep &decodeStep = *iterStep;
+ HypothesisCollectionIntermediate
+ &inputHypoColl = outputHypoCollVec[indexStep]
+ ,&outputHypoColl = outputHypoCollVec[indexStep + 1];
+
+ // is it translation or generation
+ switch (decodeStep.first)
+ {
+ case Translate:
+ {
+ // go thru each hypothesis just created
+ for (iterHypo = inputHypoColl.begin() ; iterHypo != inputHypoColl.end() ; ++iterHypo)
+ {
+ Hypothesis &inputHypo = **iterHypo;
+ ProcessTranslation(inputHypo, decodeStep, outputHypoColl);
+ }
+ break;
+ }
+ case Generate:
+ {
+ // go thru each hypothesis just created
+ for (iterHypo = inputHypoColl.begin() ; iterHypo != inputHypoColl.end() ; ++iterHypo)
+ {
+ Hypothesis &inputHypo = **iterHypo;
+ ProcessGeneration(inputHypo, decodeStep, outputHypoColl);
+ }
+ break;
+ }
+ }
+
+ indexStep++;
+ } // for (++iterStep
+
+ // add to real hypothesis stack
+ HypothesisCollectionIntermediate &lastHypoColl = outputHypoCollVec[decodeStepList.size() - 1];
+ for (iterHypo = lastHypoColl.begin() ; iterHypo != lastHypoColl.end() ; )
+ {
+ Hypothesis *hypo = *iterHypo;
+
+ hypo->CalcScore(m_staticData.GetLanguageModel(Initial)
+ , m_staticData.GetLanguageModel(Other)
+ , m_staticData.GetWeightDistortion()
+ , m_staticData.GetWeightWordPenalty()
+ , m_futureScore);
+ size_t wordsTranslated = hypo->GetWordsBitmap().GetWordsCount();
+
+ if (m_hypoStack[wordsTranslated].Add(hypo, m_staticData.GetBeamThreshold()))
+ {
+ HypothesisCollectionIntermediate::iterator iterCurr = iterHypo++;
+ lastHypoColl.Detach(iterCurr);
+ }
+ else
+ {
+ ++iterHypo;
+ }
+ }
+}
+
+void Manager::ProcessInitialTranslation(const Hypothesis &hypothesis
+ , const DecodeStep &decodeStep
+ ,HypothesisCollectionIntermediate &outputHypoColl)
+{
+ int maxDistortion = m_staticData.GetMaxDistortion();
+ if (maxDistortion < 0)
+ { // no limit on distortion
+ PossibleTranslationCollection::const_iterator iterPossTrans;
+ for (iterPossTrans = m_possibleTranslations.begin(); iterPossTrans != m_possibleTranslations.end(); ++iterPossTrans)
+ {
+ const PossibleTranslation &possTrans = *iterPossTrans;
+
+ if ( !possTrans.Overlap(hypothesis))
+ {
+ Hypothesis *newHypo = hypothesis.CreateNext(possTrans);
+ outputHypoColl.AddNoPrune( newHypo );
+ }
+ }
+ }
+ else
+ {
+ const WordsBitmap hypoBitmap = hypothesis.GetWordsBitmap();
+ size_t hypoWordCount = hypoBitmap.GetWordsCount()
+ ,hypoFirstGapPos = hypoBitmap.GetFirstGapPos();
+
+ // MAIN LOOP. go through each possible hypo
+ PossibleTranslationCollection::const_iterator iterPossTrans;
+ for (iterPossTrans = m_possibleTranslations.begin(); iterPossTrans != m_possibleTranslations.end(); ++iterPossTrans)
+ {
+ const PossibleTranslation &possTrans = *iterPossTrans;
+ // calc distortion if using this poss trans
+
+ size_t possTransStartPos = possTrans.GetStartPos();
+
+ if (hypoFirstGapPos == hypoWordCount)
+ {
+ if (possTransStartPos == hypoWordCount
+ || (possTransStartPos > hypoWordCount
+ && possTrans.GetEndPos() <= hypoWordCount + m_staticData.GetMaxDistortion())
+ )
+ {
+ Hypothesis *newHypo = hypothesis.CreateNext(possTrans);
+ outputHypoColl.AddNoPrune( newHypo );
+ }
+ }
+ else
+ {
+ if (possTransStartPos < hypoWordCount)
+ {
+ if (possTransStartPos >= hypoFirstGapPos
+ && !possTrans.Overlap(hypothesis))
+ {
+ Hypothesis *newHypo = hypothesis.CreateNext(possTrans);
+ outputHypoColl.AddNoPrune( newHypo );
+ }
+ }
+ else
+ {
+ if (possTrans.GetEndPos() <= hypoFirstGapPos + m_staticData.GetMaxDistortion()
+ && !possTrans.Overlap(hypothesis))
+ {
+ Hypothesis *newHypo = hypothesis.CreateNext(possTrans);
+ outputHypoColl.AddNoPrune( newHypo );
+ }
+ }
+ }
+ }
+ }
+}
+
+void Manager::ProcessTranslation(const Hypothesis &hypothesis
+ , const DecodeStep &decodeStep
+ ,HypothesisCollectionIntermediate &outputHypoColl)
+{
+ const WordsRange &sourceWordsRange = hypothesis.GetCurrSourceWordsRange();
+ const Phrase sourcePhrase = m_source.GetSubString(sourceWordsRange);
+ const PhraseDictionary &phraseDictionary = m_staticData.GetPhraseDictionary(decodeStep);
+ const TargetPhraseCollection *phraseColl = phraseDictionary.FindEquivPhrase(sourcePhrase);
+ size_t currTargetLength = hypothesis.GetCurrTargetLength();
+
+ if (phraseColl != NULL)
+ {
+ TargetPhraseCollection::const_iterator iterTargetPhrase;
+
+ for (iterTargetPhrase = phraseColl->begin(); iterTargetPhrase != phraseColl->end(); ++iterTargetPhrase)
+ {
+ const TargetPhrase &targetPhrase = *iterTargetPhrase;
+
+ float transScore = targetPhrase.GetScore()
+ ,weightWP = m_staticData.GetWeightWordPenalty();
+ PossibleTranslation possTrans(sourceWordsRange
+ , targetPhrase
+ , transScore
+ , weightWP);
+
+ Hypothesis *newHypo = hypothesis.MergeNext(possTrans);
+ if (newHypo != NULL)
+ {
+ outputHypoColl.AddNoPrune( newHypo );
+ }
+ }
+ }
+ else if (sourceWordsRange.GetWordsCount() == 1 && currTargetLength == 1)
+ { // unknown handler here
+ const FactorTypeSet &targetFactors = phraseDictionary.GetFactorsUsed(Target);
+ Hypothesis *newHypo = new Hypothesis(hypothesis);
+
+ for (unsigned int currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+ {
+ if (targetFactors.Contains(currFactor))
+ {
+ FactorType factorType = static_cast<FactorType>(currFactor);
+ const Factor *targetFactor = newHypo->GetFactor(newHypo->GetSize() - 1, factorType);
+
+ if (targetFactor == NULL)
+ {
+ const Factor *sourceFactor = sourcePhrase.GetFactor(0, factorType)
+ ,*unkownfactor;
+ switch (factorType)
+ {
+ case POS:
+ unkownfactor = m_staticData.GetFactorCollection().AddFactor(Target, factorType, UNKNOWN_FACTOR);
+ newHypo->SetFactor(0, factorType, unkownfactor);
+ break;
+ default:
+ unkownfactor = m_staticData.GetFactorCollection().AddFactor(Target, factorType, sourceFactor->GetString());
+ newHypo->SetFactor(0, factorType, unkownfactor);
+ break;
+ }
+ }
+ }
+ }
+ outputHypoColl.AddNoPrune( newHypo );
+ }
+}
+
+void Manager::CreatePossibleTranslations(const Phrase &phrase
+ , const PhraseDictionary &phraseDictionary
+ , const LMList &lmListInitial)
+{
+ for (size_t startPos = 0 ; startPos < phrase.GetSize() ; startPos++)
+ {
+ // reuse phrase, add next word on
+ Phrase sourcePhrase( phrase.GetLanguage());
+
+ for (size_t endPos = startPos ; endPos < phrase.GetSize() ; endPos++)
+ {
+ const WordsRange wordsRange(startPos, endPos);
+
+ FactorArray &newWord = sourcePhrase.AddWord();
+ Word::Copy(newWord, phrase.GetFactorArray(endPos));
+
+ const TargetPhraseCollection *phraseColl = phraseDictionary.FindEquivPhrase(sourcePhrase);
+ if (phraseColl != NULL)
+ {
+ TargetPhraseCollection::const_iterator iterTargetPhrase;
+ for (iterTargetPhrase = phraseColl->begin() ; iterTargetPhrase != phraseColl->end() ; ++iterTargetPhrase)
+ {
+ const TargetPhrase &targetPhrase = *iterTargetPhrase;
+
+ float score = targetPhrase.GetScore()
+ ,weightWP = m_staticData.GetWeightWordPenalty();
+ const WordsRange wordsRange(startPos, endPos);
+ PossibleTranslation possTrans(wordsRange
+ , targetPhrase
+ , score
+ , lmListInitial
+ , weightWP);
+ m_possibleTranslations.push_back(possTrans);
+ }
+ }
+ else if (sourcePhrase.GetSize() == 1)
+ {
+ // unknown word, add to target, and add as poss trans
+ float weightWP = m_staticData.GetWeightWordPenalty();
+ const FactorTypeSet &targetFactors = phraseDictionary.GetFactorsUsed(Target);
+
+ // make sure new phrase isn't deallocated while we're using it
+ m_unknownPhrase.push_back(TargetPhrase(Target, phraseDictionary.GetId()));
+ TargetPhrase &targetPhrase = m_unknownPhrase.back();
+ FactorArray &targetWord = targetPhrase.AddWord();
+
+ const FactorArray &sourceWord = sourcePhrase.GetFactorArray(0);
+
+ for (unsigned int currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+ {
+ if (targetFactors.Contains(currFactor))
+ {
+ FactorType factorType = static_cast<FactorType>(currFactor);
+
+ const Factor *factor = sourceWord[factorType]
+ ,*unkownfactor;
+ switch (factorType)
+ {
+ case POS:
+ unkownfactor = m_staticData.GetFactorCollection().AddFactor(Target, factorType, UNKNOWN_FACTOR);
+ targetWord[factorType] = unkownfactor;
+ break;
+ default:
+ unkownfactor = m_staticData.GetFactorCollection().AddFactor(Target, factorType, factor->GetString());
+ targetWord[factorType] = unkownfactor;
+ break;
+ }
+ }
+ }
+
+ targetPhrase.ResetScore();
+
+ PossibleTranslation possTrans(wordsRange
+ , targetPhrase
+ , 0
+ , lmListInitial
+ , weightWP);
+ m_possibleTranslations.push_back(possTrans);
+ }
+ }
+ }
+
+ // create future score matrix
+ for(size_t start = 0; start < phrase.GetSize() ; start++)
+ {
+ for(size_t end = start; end < phrase.GetSize() ; end++)
+ {
+ size_t length = end - start + 1;
+ vector< float > score(length + 1);
+ score[0] = 0;
+ for(size_t currLength = 1 ; currLength <= length ; currLength++)
+ {
+ score[currLength] = - numeric_limits<float>::infinity();
+ }
+
+ for(size_t currLength = 0 ; currLength < length ; currLength++)
+ {
+ PossibleTranslationCollection::const_iterator iterPossTrans;
+ for(iterPossTrans = m_possibleTranslations.begin() ; iterPossTrans != m_possibleTranslations.end() ; ++iterPossTrans)
+ {
+ const PossibleTranslation &possTrans = *iterPossTrans;
+ size_t index = currLength + possTrans.GetSize();
+
+ if (possTrans.GetStartPos() == currLength + start
+ && possTrans.GetEndPos() <= end
+ && possTrans.GetFutureScore() + score[currLength] > score[index])
+ {
+ score[index] = possTrans.GetFutureScore() + score[currLength];
+ }
+ }
+ }
+ m_futureScore.SetScore(start, end, score[length]);
+ }
+ }
+}
+
+// helpers
+typedef pair<Word, float> WordPair;
+typedef list< WordPair > WordList;
+ // 1st = word
+ // 2nd = score
+typedef list< WordPair >::const_iterator WordListIterator;
+
+void IncrementIterators(vector< WordListIterator > &wordListIterVector
+ , const vector< WordList > &wordListVector)
+{
+ for (size_t currPos = 0 ; currPos < wordListVector.size() ; currPos++)
+ {
+ WordListIterator &iter = wordListIterVector[currPos];
+ iter++;
+ if (iter != wordListVector[currPos].end())
+ { // eg. 4 -> 5
+ return;
+ }
+ else
+ { // eg 9 -> 10
+ iter = wordListVector[currPos].begin();
+ }
+ }
+}
+
+void Manager::ProcessGeneration(const Hypothesis &hypothesis
+ , const DecodeStep &decodeStep
+ , HypothesisCollectionIntermediate &outputHypoColl)
+{
+ const GenerationDictionary &generationDictionary = m_staticData.GetGenerationDictionary(decodeStep);
+ size_t idDict = generationDictionary.GetId();
+ const float weight = generationDictionary.GetWeight();
+
+ size_t hypoSize = hypothesis.GetSize()
+ , targetLength = hypothesis.GetCurrTargetLength();
+
+ // generation list for each word in hypothesis
+ vector< WordList > wordListVector(targetLength);
+
+ // create generation list
+ int wordListVectorPos = 0;
+ for (size_t currPos = hypoSize - targetLength ; currPos < hypoSize ; currPos++)
+ {
+ WordList &wordList = wordListVector[wordListVectorPos];
+ const FactorArray &factorArray = hypothesis.GetFactorArray(currPos);
+
+ const OutputWordCollection *wordColl = generationDictionary.FindWord(factorArray);
+
+ if (wordColl == NULL)
+ { // word not found in generation dictionary
+ // go no further
+ return;
+ }
+
+ OutputWordCollection::const_iterator iterWordColl;
+ for (iterWordColl = wordColl->begin() ; iterWordColl != wordColl->end(); ++iterWordColl)
+ {
+ const Word &outputWord = (*iterWordColl).first;
+ float score = (*iterWordColl).second;
+ wordList.push_back(WordPair(outputWord, score));
+ }
+
+ wordListVectorPos++;
+ }
+
+ // use generation list (wordList)
+ // set up iterators
+ size_t numIteration = 1;
+ vector< WordListIterator > wordListIterVector(targetLength);
+ vector< const Word* > mergeWords(targetLength);
+ for (size_t currPos = 0 ; currPos < targetLength ; currPos++)
+ {
+ wordListIterVector[currPos] = wordListVector[currPos].begin();
+ numIteration *= wordListVector[currPos].size();
+ }
+
+ // go thru each possible factor for each word & create hypothesis
+ for (size_t currIter = 0 ; currIter < numIteration ; currIter++)
+ {
+ float generationScore = 0; // total score for this string of words
+
+ // create vector of words with new factors for last phrase
+ for (size_t currPos = 0 ; currPos < targetLength ; currPos++)
+ {
+ const WordPair &wordPair = *wordListIterVector[currPos];
+ mergeWords[currPos] = &(wordPair.first);
+ generationScore += wordPair.second;
+ }
+
+ // merge with existing hypothesis
+ Hypothesis *mergeHypo = hypothesis.Clone();
+ mergeHypo->MergeFactors(mergeWords, idDict, generationScore, weight);
+ outputHypoColl.AddNoPrune(mergeHypo);
+
+ // increment iterators
+ IncrementIterators(wordListIterVector, wordListVector);
+ }
+}
+
+void Manager::OutputHypoStackSize()
+{
+ std::vector < HypothesisCollection >::const_iterator iterStack;
+ for (iterStack = m_hypoStack.begin() ; iterStack != m_hypoStack.end() ; ++iterStack)
+ {
+ TRACE_ERR ( (int)(*iterStack).size() << ", ");
+ }
+ TRACE_ERR (endl);
+}
+
+void Manager::OutputHypoStack(int stack)
+{
+ if (stack >= 0)
+ {
+ TRACE_ERR ( "Stack " << stack << ": " << endl << m_hypoStack[stack] << endl);
+ }
+ else
+ { // all stacks
+ int i = 0;
+ vector < HypothesisCollection >::iterator iterStack;
+ for (iterStack = m_hypoStack.begin() ; iterStack != m_hypoStack.end() ; ++iterStack)
+ {
+ HypothesisCollection &hypoColl = *iterStack;
+ TRACE_ERR ( "Stack " << i++ << ": " << endl << hypoColl << endl);
+ }
+ }
+}
+
+void Manager::CalcNBest(size_t count, LatticePathList &ret) const
+{
+#ifdef N_BEST
+ if (count <= 0)
+ return;
+
+ list<const Hypothesis*> sortedPureHypo = m_hypoStack.back().GetSortedList();
+
+ if (sortedPureHypo.size() == 0)
+ return;
+
+ LatticePathCollection contenders;
+
+ // path of the best
+ contenders.insert(new LatticePath(*sortedPureHypo.begin()));
+
+ // used to add next pure hypo path
+ list<const Hypothesis*>::const_iterator iterBestHypo = ++sortedPureHypo.begin();
+
+ for (size_t currBest = 0 ; currBest <= count && contenders.size() > 0 ; currBest++)
+ {
+ // get next best from list of contenders
+ LatticePath *path = *contenders.begin();
+ ret.push_back(path);
+ contenders.erase(contenders.begin());
+
+ // create deviations from current best
+ path->CreateDeviantPaths(contenders);
+
+ // if necessary, add next pure path
+ if (path->IsPurePath() && iterBestHypo != sortedPureHypo.end())
+ {
+ contenders.insert(new LatticePath(*iterBestHypo));
+ ++iterBestHypo;
+ }
+ }
+#endif
+}
diff --git a/moses/src/Manager.h b/moses/src/Manager.h
new file mode 100755
index 000000000..ea4e71971
--- /dev/null
+++ b/moses/src/Manager.h
@@ -0,0 +1,79 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <vector>
+#include <list>
+#include "Sentence.h"
+#include "Hypothesis.h"
+#include "StaticData.h"
+#include "PossibleTranslation.h"
+#include "HypothesisCollection.h"
+#include "HypothesisCollectionIntermediate.h"
+#include "PossibleTranslationCollection.h"
+#include "LatticePathList.h"
+#include "FutureScore.h"
+
+class LatticePath;
+
+class Manager
+{
+protected:
+ // data
+ Sentence m_source;
+ std::vector < HypothesisCollection > m_hypoStack;
+ // no of elements = no of words in source + 1
+ StaticData &m_staticData;
+ PossibleTranslationCollection m_possibleTranslations;
+ FutureScore m_futureScore;
+ std::list<TargetPhrase> m_unknownPhrase;
+
+// PossibleTranslationCollection m_possibleTranslations;
+
+ // functions
+ void ProcessOneStack(const std::list < DecodeStep > &decodeStepList
+ , HypothesisCollection &sourceHypoColl);
+ void ProcessOneHypothesis(const std::list < DecodeStep > &decodeStepList
+ , const Hypothesis &hypothesis);
+ void ProcessInitialTranslation(const Hypothesis &hypothesis
+ , const DecodeStep &decodeStep
+ ,HypothesisCollectionIntermediate &outputHypoColl);
+ void ProcessTranslation(const Hypothesis &hypothesis
+ , const DecodeStep &decodeStep
+ , HypothesisCollectionIntermediate &outputHypoColl);
+ void ProcessGeneration(const Hypothesis &hypothesis
+ , const DecodeStep &decodeStep
+ , HypothesisCollectionIntermediate &outputHypoColl);
+ void CreatePossibleTranslations(const Phrase &phrase
+ , const PhraseDictionary &phraseDictionary
+ , const LMList &lmListInitial);
+ void OutputHypoStack(int stack = -1);
+ void OutputHypoStackSize();
+public:
+ Manager(const Sentence &sentence, StaticData &staticData);
+ ~Manager();
+
+ void ProcessSentence();
+ const Hypothesis *GetBestHypothesis() const;
+ void CalcNBest(size_t count, LatticePathList &ret) const;
+};
+
diff --git a/moses/src/NGramCollection.cpp b/moses/src/NGramCollection.cpp
new file mode 100755
index 000000000..1dec46677
--- /dev/null
+++ b/moses/src/NGramCollection.cpp
@@ -0,0 +1,54 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "NGramCollection.h"
+#include "NGramNode.h"
+
+NGramCollection::~NGramCollection()
+{
+ clear();
+}
+
+NGramNode *NGramCollection::GetOrCreateNGram(const Factor *factor)
+{
+ NGramCollection::iterator iter = this->find(factor);
+ if (iter == NGramCollection::end())
+ {
+ return &((*this)[factor] = NGramNode());
+ }
+ else
+ {
+ return &(iter->second);
+ }
+}
+
+NGramNode *NGramCollection::GetNGram(const Factor *factor)
+{
+ NGramCollection::iterator iter = this->find(factor);
+ return (iter == NGramCollection::end()) ? NULL : &(iter->second) ;
+}
+
+const NGramNode *NGramCollection::GetNGram(const Factor *factor) const
+{
+ NGramCollection::const_iterator iter = this->find(factor);
+ return (iter == NGramCollection::end()) ? NULL : &(iter->second) ;
+}
+
diff --git a/moses/src/NGramCollection.h b/moses/src/NGramCollection.h
new file mode 100755
index 000000000..6179c7e4f
--- /dev/null
+++ b/moses/src/NGramCollection.h
@@ -0,0 +1,46 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <map>
+#include <vector>
+
+class Factor;
+class NGramNode;
+
+typedef std::vector<const Factor*> FactorVector;
+
+class NGramCollection : public std::map<const Factor*, NGramNode>
+{
+
+public:
+ NGramCollection()
+ {
+ }
+ ~NGramCollection();
+
+ NGramNode *GetOrCreateNGram(const Factor *factor);
+ NGramNode *GetNGram(const Factor *factor);
+ const NGramNode *GetNGram(const Factor *factor) const;
+
+};
+
diff --git a/moses/src/NGramNode.h b/moses/src/NGramNode.h
new file mode 100755
index 000000000..c79d4d678
--- /dev/null
+++ b/moses/src/NGramNode.h
@@ -0,0 +1,80 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include "NGramCollection.h"
+
+class NGramNode
+{
+protected:
+ float m_score, m_logBackOff;
+ NGramCollection m_map;
+ NGramNode *m_rootNGram;
+public:
+ NGramNode()
+ {
+ }
+ NGramCollection *GetNGramColl()
+ {
+ return &m_map;
+ }
+ //const NGramCollection *GetNGramColl() const
+ //{
+ // return &m_map;
+ //}
+ const NGramNode *GetNGram(const Factor *factor) const
+ {
+ return m_map.GetNGram(factor);
+ }
+ NGramNode *GetNGram(const Factor *factor)
+ {
+ return m_map.GetNGram(factor);
+ }
+
+ const NGramNode *GetRootNGram() const
+ {
+ return m_rootNGram;
+ }
+ void SetRootNGram(NGramNode *rootNGram)
+ {
+ m_rootNGram = rootNGram;
+ }
+
+ float GetScore() const
+ {
+ return m_score;
+ }
+ float GetLogBackOff() const
+ {
+ return m_logBackOff;
+ }
+ void SetScore(float score)
+ {
+ m_score = score;
+ }
+ void SetLogBackOff(float logBackOff)
+ {
+ m_logBackOff = logBackOff;
+ }
+
+};
+
diff --git a/moses/src/Object.h b/moses/src/Object.h
new file mode 100755
index 000000000..f9dcb8e77
--- /dev/null
+++ b/moses/src/Object.h
@@ -0,0 +1,48 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <string>
+#include <iostream>
+
+class Object
+{
+ friend std::ostream& operator<<(std::ostream&, const Object&);
+
+public:
+ virtual void ToStream(std::ostream &out) const = 0
+
+ virtual std::string ToString() const
+ {
+ std::stringstream out;
+ out << *this;
+ return out.str();
+ }
+};
+
+
+inline std::ostream& operator<<(std::ostream& out, const Object& object)
+{
+ object.ToStream(out);
+ return out;
+}
+
diff --git a/moses/src/Parameter.cpp b/moses/src/Parameter.cpp
new file mode 100755
index 000000000..6d947d5db
--- /dev/null
+++ b/moses/src/Parameter.cpp
@@ -0,0 +1,242 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
+#include "boost/filesystem/fstream.hpp" // ditto
+#include <boost/algorithm/string.hpp>
+#include "Parameter.h"
+#include "Util.h"
+#include "InputFileStream.h"
+#include "UserMessage.h"
+
+using namespace std;
+
+PARAM_VEC &Parameter::AddParam(const string &paramName)
+{
+ return m_setting[paramName];
+}
+
+// default parameter values
+Parameter::Parameter()
+{
+ AddParam("ttable-file");
+ AddParam("dtable-file");
+ AddParam("lmodel-file");
+ AddParam("ttable-limit");
+ AddParam("weight-d");
+ AddParam("weight-l");
+ AddParam("weight-t");
+ AddParam("weight-w");
+ AddParam("weight-generation");
+ AddParam("mapping");
+ AddParam("n-best-list");
+ AddParam("beam-threshold");
+ AddParam("distortion-limit");
+ AddParam("input-factors");
+ AddParam("mysql");
+ AddParam("input-file");
+ AddParam("cache-path");
+ AddParam("input-file");
+}
+
+// check if parameter settings make sense
+bool Parameter::Validate()
+{
+ bool ret = true;
+
+ // required parameters
+ if (m_setting["ttable-file"].size() == 0)
+ {
+ UserMessage::Add("No phrase translation table (ttable-file)");
+ ret = false;
+ }
+
+ if (m_setting["lmodel-file"].size() == 0)
+ {
+ UserMessage::Add("No language model (lmodel-file)");
+ ret = false;
+ }
+
+ if (m_setting["lmodel-file"].size() != m_setting["weight-l"].size())
+ {
+ stringstream errorMsg("");
+ errorMsg << static_cast<int>(m_setting["lmodel-file"].size())
+ << " language model files given (lmodel-file), but "
+ << static_cast<int>(m_setting["weight-l"].size())
+ << " weights (weight-l)";
+ UserMessage::Add(errorMsg.str());
+ ret = false;
+ }
+
+ // do files exist?
+ // phrase tables
+ if (ret)
+ ret = FilesExist("ttable-file", 2);
+ // generation tables
+ if (ret)
+ ret = FilesExist("generation-file", 2);
+ // language model
+ if (ret)
+ ret = FilesExist("lmodel-file", 3);
+
+ return ret;
+}
+
+bool Parameter::FilesExist(const string &paramName, size_t tokenizeIndex)
+{
+ using namespace boost::filesystem;
+
+ typedef std::vector<std::string> StringVec;
+ StringVec::const_iterator iter;
+
+ PARAM_MAP::const_iterator iterParam = m_setting.find(paramName);
+ if (iterParam == m_setting.end())
+ { // no param. therefore nothing to check
+ return true;
+ }
+ const StringVec &pathVec = (*iterParam).second;
+ for (iter = pathVec.begin() ; iter != pathVec.end() ; ++iter)
+ {
+ StringVec vec = Tokenize(*iter);
+ if (tokenizeIndex > vec.size())
+ {
+ stringstream errorMsg("");
+ errorMsg << "Expected " << tokenizeIndex << " tokens per"
+ << " entry in '" << paramName << "', but only found "
+ << vec.size();
+ UserMessage::Add(errorMsg.str());
+ return false;
+ }
+ const string &pathStr = vec[tokenizeIndex];
+ path filePath(pathStr, native);
+ if (!exists(filePath))
+ {
+ stringstream errorMsg("");
+ errorMsg << "File " << pathStr << " does not exists";
+ UserMessage::Add(errorMsg.str());
+ return false;
+ }
+ }
+ return true;
+}
+
+string Parameter::FindParam(const string &paramSwitch, int argc, char* argv[])
+{
+ for (int i = 0 ; i < argc ; i++)
+ {
+ if (string(argv[i]) == paramSwitch)
+ {
+ return argv[i+1];
+ }
+ }
+ return "";
+}
+
+void Parameter::OverwriteParam(const string &paramSwitch, const string &paramName, int argc, char* argv[])
+{
+ int startPos = -1;
+ for (int i = 0 ; i < argc ; i++)
+ {
+ if (string(argv[i]) == paramSwitch)
+ {
+ startPos = i+1;
+ break;
+ }
+ }
+ if (startPos < 0)
+ return;
+
+ int index = 0;
+ while (startPos < argc && string(argv[startPos]).substr(0,1) != "-")
+ {
+ if (m_setting[paramName].size() > (size_t)index)
+ m_setting[paramName][index] = argv[startPos];
+ else
+ m_setting[paramName].push_back(argv[startPos]);
+ index++;
+ startPos++;
+ }
+}
+
+bool Parameter::LoadParam(int argc, char* argv[])
+{
+ // config file (-f) arg mandatory
+ string configPath;
+ if ( (configPath = FindParam("-f", argc, argv)) == ""
+ && (configPath = FindParam("-config", argc, argv)) == "")
+ {
+ UserMessage::Add("No configuration file was specified. Use -config or -f");
+ return false;
+ }
+ else
+ ReadConfigFile(configPath);
+
+ string inFile = FindParam("-i", argc, argv);
+ if (inFile != "")
+ m_setting["input-file"].push_back(inFile);
+
+ // overwrite weights
+ OverwriteParam("-dl", "distortion-limit", argc, argv);
+ OverwriteParam("-d", "weight-d", argc, argv);
+ OverwriteParam("-lm", "weight-l", argc, argv);
+ OverwriteParam("-tm", "weight-t", argc, argv);
+ OverwriteParam("-w", "weight-w", argc, argv);
+ OverwriteParam("-g", "weight-generation", argc, argv);
+ OverwriteParam("-n-best-list", "n-best-list", argc, argv);
+
+ // check if parameters make sense
+ return Validate();
+}
+
+// read parameters from a configuration file
+void Parameter::ReadConfigFile( string filePath )
+{
+ InputFileStream inFile(filePath);
+ string line, paramName;
+ while(getline(inFile, line))
+ {
+ // comments
+ size_t comPos = line.find_first_of("#");
+ if (comPos != string::npos)
+ line = line.substr(0, comPos);
+ // trim leading and trailing spaces/tabs
+ boost::trim(line);
+
+ if (line[0]=='[')
+ { // new parameter
+ for (size_t currPos = 0 ; currPos < line.size() ; currPos++)
+ {
+ if (line[currPos] == ']')
+ {
+ paramName = line.substr(1, currPos - 1);
+ break;
+ }
+ }
+ }
+ else if (line != "")
+ { // add value to parameter
+ m_setting[paramName].push_back(line);
+ }
+ }
+}
diff --git a/moses/src/Parameter.h b/moses/src/Parameter.h
new file mode 100755
index 000000000..2d144d4c3
--- /dev/null
+++ b/moses/src/Parameter.h
@@ -0,0 +1,55 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <string>
+#include <map>
+#include <vector>
+#include "TypeDef.h"
+
+typedef std::vector<std::string> PARAM_VEC;
+typedef std::map<std::string, PARAM_VEC > PARAM_MAP;
+
+class Parameter
+{
+protected:
+ PARAM_MAP m_setting;
+
+ std::string FindParam(const std::string &paramSwitch, int argc, char* argv[]);
+ void OverwriteParam(const std::string &paramSwitch, const std::string &paramName, int argc, char* argv[]);
+ void ReadConfigFile( std::string filePath );
+ bool FilesExist(const std::string &paramName, size_t tokenizeIndex);
+
+ bool Validate();
+
+ PARAM_VEC &AddParam(const std::string &paramName);
+
+public:
+ Parameter();
+ bool LoadParam(int argc, char* argv[]);
+
+ const PARAM_VEC &GetParam(const std::string &paramName)
+ {
+ return m_setting[paramName];
+ }
+};
+
diff --git a/moses/src/Phrase.cpp b/moses/src/Phrase.cpp
new file mode 100755
index 000000000..eb50f85bb
--- /dev/null
+++ b/moses/src/Phrase.cpp
@@ -0,0 +1,282 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <algorithm>
+#include <sstream>
+#include "memory.h"
+#include "FactorCollection.h"
+#include "Phrase.h"
+#include "Util.h"
+
+using namespace std;
+
+Phrase::Phrase(const Phrase &copy)
+:m_language(copy.m_language)
+,m_phraseSize(copy.m_phraseSize)
+,m_arraySize(copy.m_arraySize)
+{
+ if (m_phraseSize==0)
+ {
+ m_factorArray = NULL;
+ }
+ else
+ {
+ m_factorArray = (FactorArray*) malloc(m_arraySize * sizeof(FactorArray));
+ memcpy(m_factorArray, copy.m_factorArray, m_phraseSize * sizeof(FactorArray));
+ }
+}
+
+Phrase::~Phrase()
+{
+ free (m_factorArray);
+}
+
+void Phrase::AddWords(const Phrase &copy)
+{
+ for (size_t pos = 0 ; pos < copy.GetSize() ; pos++)
+ {
+ FactorArray &newWord = AddWord();
+ Word::Copy(newWord, copy.GetFactorArray(pos));
+ }
+}
+
+Phrase Phrase::GetSubString(const WordsRange &wordsRange)
+{
+ Phrase retPhrase(m_language);
+
+ for (size_t currPos = wordsRange.GetStartPos() ; currPos <= wordsRange.GetEndPos() ; currPos++)
+ {
+ FactorArray &newWord = retPhrase.AddWord();
+ Word::Copy(newWord, GetFactorArray(currPos));
+ }
+
+ return retPhrase;
+}
+
+FactorArray &Phrase::AddWord()
+{
+ if (m_phraseSize % ARRAY_SIZE_INCR == 0)
+ { // need to expand array
+ m_arraySize += ARRAY_SIZE_INCR;
+ m_factorArray = (FactorArray*) realloc(m_factorArray, m_arraySize * sizeof(FactorArray));
+ }
+
+ FactorArray &factorArray = m_factorArray[m_phraseSize];
+ Word::Initialize(factorArray);
+
+ m_phraseSize++;
+
+ return factorArray;
+}
+
+vector< vector<string> > Phrase::Parse(const std::string &phraseString)
+{
+ // parse
+ vector< vector<string> > phraseVector;
+ vector<string> annotatedWordVector = Tokenize(phraseString);
+ // KOMMA|none ART|Def.Z NN|Neut.NotGen.Sg VVFIN|none
+ // to
+ // "KOMMA|none" "ART|Def.Z" "NN|Neut.NotGen.Sg" "VVFIN|none"
+
+ for (size_t phrasePos = 0 ; phrasePos < annotatedWordVector.size() ; phrasePos++)
+ {
+ string &annotatedWord = annotatedWordVector[phrasePos];
+ vector<string> factorStrVector = Tokenize(annotatedWord, "|");
+ // KOMMA|none
+ // to
+ // "KOMMA" "none"
+ phraseVector.push_back(factorStrVector);
+ }
+ return phraseVector;
+}
+
+void Phrase::CreateFromString(const std::vector<FactorType> &factorOrder
+ , const vector< vector<string> > &phraseVector
+ , FactorCollection &factorCollection)
+{
+ for (size_t phrasePos = 0 ; phrasePos < phraseVector.size() ; phrasePos++)
+ {
+ // add word this phrase
+ FactorArray &factorArray = AddWord();
+ for (size_t currFactorIndex= 0 ; currFactorIndex < factorOrder.size() ; currFactorIndex++)
+ {
+ FactorType factorType = factorOrder[currFactorIndex];
+ const string &factorStr = phraseVector[phrasePos][currFactorIndex];
+ const Factor *factor = factorCollection.AddFactor(m_language, factorType, factorStr);
+ factorArray[factorType] = factor;
+ }
+ }
+}
+
+void Phrase::CreateFromString(const std::vector<FactorType> &factorOrder
+ , const string &phraseString
+ , FactorCollection &factorCollection)
+{
+ vector< vector<string> > phraseVector = Parse(phraseString);
+ CreateFromString(factorOrder, phraseVector, factorCollection);
+}
+
+bool Phrase::operator< (const Phrase &compare) const
+{
+#ifdef min
+#undef min
+#endif
+ size_t thisSize = GetSize()
+ ,compareSize = compare.GetSize();
+
+ // decide by using length. quick decision
+ if (thisSize != compareSize)
+ {
+ return thisSize < compareSize;
+ }
+ else
+ {
+ size_t minSize = std::min( thisSize , compareSize );
+
+ // taken from word.Compare()
+ for (size_t i = 0 ; i < NUM_FACTORS ; i++)
+ {
+ FactorType factorType = static_cast<FactorType>(i);
+
+ for (size_t currPos = 0 ; currPos < minSize ; currPos++)
+ {
+ const Factor *thisFactor = GetFactor(currPos, factorType)
+ ,*compareFactor = compare.GetFactor(currPos, factorType);
+
+ if (thisFactor != NULL && compareFactor != NULL)
+ {
+ const int result = thisFactor->Compare(*compareFactor);
+ if (result == 0)
+ {
+ continue;
+ }
+ else
+ {
+ return (result < 0);
+ }
+ }
+ }
+ }
+
+ // identical
+ return false;
+ }
+}
+
+bool Phrase::Contains(const vector< vector<string> > &subPhraseVector
+ , const vector<FactorType> &inputFactor) const
+{
+ const size_t subSize = subPhraseVector.size()
+ ,thisSize= GetSize();
+ if (subSize > thisSize)
+ return false;
+
+ // try to match word-for-word
+ for (size_t currStartPos = 0 ; currStartPos < (thisSize - subSize + 1) ; currStartPos++)
+ {
+ bool match = true;
+
+ for (size_t currFactorIndex = 0 ; currFactorIndex < inputFactor.size() ; currFactorIndex++)
+ {
+ FactorType factorType = inputFactor[currFactorIndex];
+ for (size_t currSubPos = 0 ; currSubPos < subSize ; currSubPos++)
+ {
+ size_t currThisPos = currSubPos + currStartPos;
+ const string &subStr = subPhraseVector[currSubPos][currFactorIndex]
+ ,&thisStr = GetFactor(currThisPos, factorType)->GetString();
+ if (subStr != thisStr)
+ {
+ match = false;
+ break;
+ }
+ }
+ if (!match)
+ break;
+ }
+
+ if (match)
+ return true;
+ }
+ return false;
+}
+//
+//bool Phrase::Contains(const Phrase &subPhrase) const
+//{
+// const size_t subSize = subPhrase.GetSize()
+// ,thisSize= GetSize();
+// if (subSize > thisSize)
+// return false;
+//
+// // try to match word-for-word
+// for (size_t currStartPos = 0 ; currStartPos < (thisSize - subSize + 1) ; currStartPos++)
+// {
+// bool match = true;
+//
+// for (size_t currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+// {
+// FactorType factorType = static_cast<FactorType>(currFactor);
+// // curr factor, 1st word
+// const Factor *subFactor = subPhrase.GetFactor(0, factorType)
+// ,*thisFactor = GetFactor(currStartPos, factorType);
+// if (subFactor != NULL && thisFactor != NULL)
+// {
+// if (subFactor != thisFactor)
+// {
+// match = false;
+// break;
+// }
+// else
+// {
+// // subsequent words
+// for (size_t currSubPos = 1 ; currSubPos < subSize ; currSubPos++)
+// {
+// size_t currThisPos = currSubPos + currStartPos;
+// const Factor *subFactor = subPhrase.GetFactor(currSubPos, factorType)
+// ,*thisFactor = GetFactor(currThisPos, factorType);
+// if (subFactor != thisFactor)
+// {
+// match = false;
+// break;
+// }
+// }
+// if (!match)
+// break;
+// }
+// }
+// }
+//
+// if (match)
+// return true;
+// }
+// return false;
+//}
+
+// friend
+ostream& operator<<(ostream& out, const Phrase& phrase)
+{
+ for (size_t pos = 0 ; pos < phrase.GetSize() ; pos++)
+ {
+ const FactorArray &factorArray = phrase.GetFactorArray(pos);
+ out << Word::ToString(factorArray);
+ }
+ return out;
+}
+
diff --git a/moses/src/Phrase.h b/moses/src/Phrase.h
new file mode 100755
index 000000000..7f99cd95f
--- /dev/null
+++ b/moses/src/Phrase.h
@@ -0,0 +1,109 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+#include <vector>
+#include <list>
+#include <string>
+#include "Word.h"
+#include "WordsBitmap.h"
+#include "TypeDef.h"
+#include "Util.h"
+
+class Phrase
+{
+ friend std::ostream& operator<<(std::ostream&, const Phrase&);
+protected:
+ Language m_language;
+ size_t m_phraseSize, m_arraySize;
+ FactorArray *m_factorArray;
+
+public:
+ inline Phrase()
+ : m_phraseSize(0)
+ , m_arraySize(0)
+ , m_factorArray(NULL)
+ { // shouldn't be used. only for map
+ }
+ Phrase(const Phrase &copy);
+
+ inline Phrase(Language language)
+ :m_language(language)
+ , m_phraseSize(0)
+ , m_arraySize(0)
+ , m_factorArray(NULL)
+ {
+ }
+
+ virtual ~Phrase();
+
+ static std::vector< std::vector<std::string> > Parse(const std::string &phraseString);
+ void CreateFromString(const std::vector<FactorType> &factorOrder
+ , const std::string &phraseString
+ , FactorCollection &factorCollection);
+ void CreateFromString(const std::vector<FactorType> &factorOrder
+ , const std::vector< std::vector<std::string> > &phraseVector
+ , FactorCollection &factorCollection);
+
+ inline Language GetLanguage() const
+ {
+ return m_language;
+ }
+
+ inline size_t GetSize() const
+ {
+ return m_phraseSize;
+ }
+ inline const FactorArray &GetFactorArray(size_t pos) const
+ {
+ return m_factorArray[pos];
+ }
+ inline FactorArray &GetFactorArray(size_t pos)
+ {
+ return m_factorArray[pos];
+ }
+ inline const Factor *GetFactor(size_t pos, FactorType factorType) const
+ {
+ FactorArray &ptr = m_factorArray[pos];
+ return ptr[factorType];
+ }
+ inline void SetFactor(size_t pos, FactorType factorType, const Factor *factor)
+ {
+ FactorArray &ptr = m_factorArray[pos];
+ ptr[factorType] = factor;
+ }
+
+ bool Contains(const std::vector< std::vector<std::string> > &subPhraseVector
+ , const std::vector<FactorType> &inputFactor) const;
+
+ FactorArray &AddWord();
+ void AddWords(const Phrase &copy);
+
+ Phrase GetSubString(const WordsRange &wordsRange);
+
+ TO_STRING
+
+ // used to insert & find phrase in dictionary
+ bool operator< (const Phrase &compare) const;
+};
+
diff --git a/moses/src/PhraseDictionary.cpp b/moses/src/PhraseDictionary.cpp
new file mode 100755
index 000000000..c770e2382
--- /dev/null
+++ b/moses/src/PhraseDictionary.cpp
@@ -0,0 +1,230 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <fstream>
+#include <string>
+#include <iterator>
+#include <sys/stat.h>
+#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
+#include "PhraseDictionary.h"
+#include "FactorCollection.h"
+#include "Word.h"
+#include "Util.h"
+#include "InputFileStream.h"
+
+using namespace std;
+
+void PhraseDictionary::Load(const std::vector<FactorType> &input
+ , const std::vector<FactorType> &output
+ , FactorCollection &factorCollection
+ , const string &filePath
+ , const string &hashFilePath
+ , const vector<float> &weight
+ , size_t maxTargetPhrase
+ , size_t id
+ , bool filter
+ , const list< Phrase > &inputPhraseList)
+{
+ m_id = id;
+
+ //factors
+ m_factorsUsed[Source] = new FactorTypeSet(input);
+ m_factorsUsed[Target] = new FactorTypeSet(output);
+
+ // data from file
+ InputFileStream inFile(filePath);
+
+ // create hash file if necessary
+ ofstream tempFile;
+ string tempFilePath;
+ if (filter)
+ {
+ CreateTempFile(tempFile, tempFilePath);
+ TRACE_ERR(filePath << " -> " << tempFilePath << " -> " << hashFilePath << endl);
+ }
+
+ vector< vector<string> > phraseVector;
+ string line, prevSourcePhrase = "";
+ bool addPhrase = !filter;
+ size_t count = 0;
+ while(getline(inFile, line))
+ {
+ vector<string> token = TokenizeMultiCharSeparator( line , "|||" );
+
+ if (!filter)
+ {
+ if (token[0] != prevSourcePhrase)
+ phraseVector = Phrase::Parse(token[0]);
+ }
+ else if (token[0] == prevSourcePhrase)
+ { // same source phrase as prev line.
+ }
+ else
+ {
+ phraseVector = Phrase::Parse(token[0]);
+ prevSourcePhrase = token[0];
+
+ if (Contains(phraseVector, inputPhraseList, input))
+ addPhrase = true;
+ else
+ addPhrase = false;
+ }
+
+ if (addPhrase)
+ {
+ vector<float> scoreVector = Tokenize<float>(token[2]);
+ // source
+ Phrase sourcePhrase(Source);
+ sourcePhrase.CreateFromString( input, phraseVector, factorCollection);
+ //target
+ TargetPhrase targetPhrase(Target, m_id);
+ targetPhrase.CreateFromString( output, token[1], factorCollection);
+
+ // component score, for n-best output
+ targetPhrase.SetScore(scoreVector, weight);
+
+ AddEquivPhrase(sourcePhrase, targetPhrase, maxTargetPhrase);
+
+ // add to hash file
+ if (filter)
+ tempFile << line << endl;
+ }
+ count++;
+ }
+
+ // move temp file to hash file
+ if (filter)
+ {
+ tempFile.close();
+ using namespace boost::filesystem;
+ try
+ {
+ rename( path(tempFilePath, native) , path(hashFilePath, native) );
+ }
+ catch (...)
+ { // copy instead
+ copy_file(path(tempFilePath, native) , path(hashFilePath, native) );
+ remove(tempFilePath);
+ }
+#ifndef _WIN32
+ // change permission to let everyone use chached file
+ chmod(hashFilePath.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
+#endif
+ TRACE_ERR("Size " << count << " -> " << GetSize() << endl);
+ }
+ else
+ {
+ TRACE_ERR("Size " << GetSize() << endl);
+ }
+}
+
+void PhraseDictionary::AddEquivPhrase(const Phrase &source
+ , const TargetPhrase &targetPhrase
+ , size_t maxTargetPhrase)
+{
+ if (maxTargetPhrase == 0)
+ { // don't need keep list sorted
+ m_collection[source].push_back(targetPhrase);
+ }
+ else
+ { // must keep list in sorted order
+ TargetPhraseCollection &phraseColl = m_collection[source];
+ TargetPhraseCollection::iterator iter;
+ for (iter = phraseColl.begin() ; iter != phraseColl.end() ; ++iter)
+ {
+ TargetPhrase &insertPhrase = *iter;
+ if (targetPhrase.GetScore() < insertPhrase.GetScore())
+ {
+ break;
+ }
+ }
+ phraseColl.insert(iter, targetPhrase);
+
+ // get rid of least probably phrase if we have enough
+ if (phraseColl.size() > maxTargetPhrase)
+ {
+ phraseColl.erase(phraseColl.begin());
+ }
+ }
+}
+
+const TargetPhraseCollection *PhraseDictionary::FindEquivPhrase(const Phrase &source) const
+{
+ std::map<Phrase , TargetPhraseCollection >::const_iterator iter = m_collection.find(source);
+ if (iter == m_collection.end())
+ { // can't find source phrase
+ return NULL;
+ }
+
+ return &(*iter).second;
+}
+
+PhraseDictionary::~PhraseDictionary()
+{
+ for (size_t i = 0 ; i < m_factorsUsed.size() ; i++)
+ {
+ delete m_factorsUsed[i];
+ }
+}
+
+void PhraseDictionary::SetWeightTransModel(const vector<float> &weightT)
+{
+ std::map<Phrase , TargetPhraseCollection >::iterator iterDict;
+ for (iterDict = m_collection.begin() ; iterDict != m_collection.end() ; ++iterDict)
+ {
+ TargetPhraseCollection &targetPhraseCollection = (*iterDict).second;
+
+ TargetPhraseCollection::iterator iterPhrase;
+ for (iterPhrase = targetPhraseCollection.begin() ; iterPhrase != targetPhraseCollection.end() ; ++iterPhrase)
+ {
+ TargetPhrase &targetPhrase = *iterPhrase;
+ targetPhrase.SetWeight(weightT);
+ }
+ }
+}
+
+bool PhraseDictionary::Contains(const vector< vector<string> > &phraseVector
+ , const list<Phrase> &inputPhraseList
+ , const vector<FactorType> &inputFactorType)
+{
+ std::list<Phrase>::const_iterator iter;
+ for (iter = inputPhraseList.begin() ; iter != inputPhraseList.end() ; ++iter)
+ {
+ const Phrase &inputPhrase = *iter;
+ if (inputPhrase.Contains(phraseVector, inputFactorType))
+ return true;
+ }
+ return false;
+}
+
+// friend
+ostream& operator<<(ostream& out, const PhraseDictionary& phraseDict)
+{
+ const map<Phrase , TargetPhraseCollection > &coll = phraseDict.m_collection;
+ map<Phrase , TargetPhraseCollection >::const_iterator iter;
+ for (iter = coll.begin() ; iter != coll.end() ; ++iter)
+ {
+ const Phrase &sourcePhrase = (*iter).first;
+ out << sourcePhrase;
+ }
+ return out;
+}
+
diff --git a/moses/src/PhraseDictionary.h b/moses/src/PhraseDictionary.h
new file mode 100755
index 000000000..9b2fd738e
--- /dev/null
+++ b/moses/src/PhraseDictionary.h
@@ -0,0 +1,89 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+#include <map>
+#include <list>
+#include <vector>
+#include <string>
+#include "Phrase.h"
+#include "TargetPhrase.h"
+
+typedef std::list < TargetPhrase > TargetPhraseCollection;
+
+class PhraseDictionary
+{
+ friend std::ostream& operator<<(std::ostream&, const PhraseDictionary&);
+
+protected:
+ size_t m_id;
+ std::map<Phrase , TargetPhraseCollection > m_collection;
+ // 1st = source
+ // 2nd = target
+
+ std::vector< FactorTypeSet* > m_factorsUsed;
+ // should index this by language
+
+ void AddEquivPhrase(const Phrase &source
+ , const TargetPhrase &targetPhrase
+ , size_t maxTargetPhrase);
+ bool Contains(const std::vector< std::vector<std::string> > &phraseVector
+ , const std::list<Phrase> &inputPhraseList
+ , const std::vector<FactorType> &inputFactorType);
+public:
+ PhraseDictionary()
+ :m_factorsUsed(2)
+ {
+ }
+ ~PhraseDictionary();
+
+ void Load(const std::vector<FactorType> &input
+ , const std::vector<FactorType> &output
+ , FactorCollection &factorCollection
+ , const std::string &filePath
+ , const std::string &hashFilePath
+ , const std::vector<float> &weight
+ , size_t maxTargetPhrase
+ , size_t id
+ , bool filter
+ , const std::list< Phrase > &inputPhraseList);
+
+ const FactorTypeSet &GetFactorsUsed(const Language &language) const
+ {
+ return *m_factorsUsed[language];
+ }
+ size_t GetSize() const
+ {
+ return m_collection.size();
+ }
+
+ const TargetPhraseCollection *FindEquivPhrase(const Phrase &source) const;
+
+ // for mert
+ void SetWeightTransModel(const std::vector<float> &weightT);
+ size_t GetId() const
+ {
+ return m_id;
+ }
+};
+
diff --git a/moses/src/PossibleTranslation.cpp b/moses/src/PossibleTranslation.cpp
new file mode 100755
index 000000000..4550e8617
--- /dev/null
+++ b/moses/src/PossibleTranslation.cpp
@@ -0,0 +1,101 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "PossibleTranslation.h"
+#include "WordsBitmap.h"
+
+using namespace std;
+
+PossibleTranslation::PossibleTranslation(const WordsRange &wordsRange
+ , const TargetPhrase &targetPhrase
+ , float transScore
+ , float weightWP)
+: m_targetPhrase(targetPhrase)
+,m_wordsRange (wordsRange)
+,m_transScore (transScore)
+,m_futureScore (0)
+,m_ngramScore(0)
+#ifdef N_BEST
+,m_transScoreComponent(targetPhrase.GetScoreComponents())
+#endif
+{
+}
+
+PossibleTranslation::PossibleTranslation(const WordsRange &wordsRange
+ , const TargetPhrase &targetPhrase
+ , float transScore
+ , const LMList &lmList
+ , float weightWP)
+: m_targetPhrase(targetPhrase)
+,m_wordsRange (wordsRange)
+,m_transScore (transScore)
+#ifdef N_BEST
+,m_transScoreComponent(targetPhrase.GetScoreComponents())
+#endif
+{
+ CalcFutureScore(lmList, weightWP);
+}
+
+bool PossibleTranslation::Overlap(const Hypothesis &hypothesis) const
+{
+ const WordsBitmap &bitmap = hypothesis.GetWordsBitmap();
+ return bitmap.Overlap(GetWordsRange());
+}
+
+void PossibleTranslation::CalcFutureScore(const LMList &lmList, float weightWP)
+{
+ m_futureScore = 0;
+ m_ngramScore= 0;
+
+ LMList::const_iterator iterLM;
+ for (iterLM = lmList.begin() ; iterLM != lmList.end() ; ++iterLM)
+ {
+ const LanguageModel &languageModel = **iterLM;
+ const float weightLM = languageModel.GetWeight();
+ float fullScore, nGramScore;
+#ifdef N_BEST
+ languageModel.CalcScore(m_targetPhrase, fullScore, nGramScore, m_trigramComponent);
+#endif
+#ifndef N_BEST
+ languageModel.CalcScore(m_targetPhrase, fullScore, nGramScore, *static_cast< list< pair<size_t, float> >* > (NULL));
+#endif
+
+ // total LM score so far
+ m_futureScore += fullScore * weightLM;
+ m_ngramScore += nGramScore * weightLM;
+ }
+
+ size_t phraseSize = m_targetPhrase.GetSize();
+ m_futureScore += m_transScore - phraseSize * weightWP;
+}
+
+// friend
+ostream& operator<<(ostream& out, const PossibleTranslation& possibleTranslation)
+{
+ out << "("
+ << possibleTranslation.GetPhrase()
+ << ") "
+ << possibleTranslation.GetFutureScore()
+ << ", "
+ << possibleTranslation.GetNgramScore();
+ return out;
+}
+
diff --git a/moses/src/PossibleTranslation.h b/moses/src/PossibleTranslation.h
new file mode 100755
index 000000000..74c9a29f8
--- /dev/null
+++ b/moses/src/PossibleTranslation.h
@@ -0,0 +1,108 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include "WordsBitmap.h"
+#include "TargetPhrase.h"
+#include "Hypothesis.h"
+#include "Util.h"
+#include "TypeDef.h"
+#include "TransScoreComponent.h"
+
+class PossibleTranslation
+{
+ friend std::ostream& operator<<(std::ostream& out, const PossibleTranslation& possibleTranslation);
+
+protected:
+ const Phrase &m_targetPhrase;
+ WordsRange m_wordsRange;
+ float m_transScore, m_futureScore, m_ngramScore;
+#ifdef N_BEST
+ TransScoreComponent m_transScoreComponent;
+ std::list< std::pair<size_t, float> > m_lmScoreComponent;
+ std::list< std::pair<size_t, float> > m_trigramComponent;
+#endif
+
+ void CalcFutureScore(const LMList &lmList, float weightWP);
+public:
+ PossibleTranslation(const WordsRange &wordsRange
+ , const TargetPhrase &targetPhrase
+ , float transScore
+ , float weightWP);
+ PossibleTranslation(const WordsRange &wordsRange
+ , const TargetPhrase &targetPhrase
+ , float transScore
+ , const LMList &lmList
+ , float weightWP);
+
+ bool Overlap(const Hypothesis &hypothesis) const;
+ inline size_t GetStartPos() const
+ {
+ return m_wordsRange.GetStartPos();
+ }
+ inline size_t GetEndPos() const
+ {
+ return m_wordsRange.GetEndPos();
+ }
+ inline size_t GetSize() const
+ {
+ return m_wordsRange.GetEndPos() - m_wordsRange.GetStartPos() + 1;
+ }
+ inline const WordsRange &GetWordsRange() const
+ {
+ return m_wordsRange;
+ }
+ inline const Phrase &GetPhrase() const
+ {
+ return m_targetPhrase;
+ }
+ inline float GetTranslationScore() const
+ {
+ return m_transScore;
+ }
+ inline float GetFutureScore() const
+ {
+ return m_futureScore;
+ }
+ inline float GetNgramScore() const
+ {
+ return m_ngramScore;
+ }
+
+#ifdef N_BEST
+ inline const TransScoreComponent &GetScoreComponents() const
+ {
+ return m_transScoreComponent;
+ }
+ inline const std::list< std::pair<size_t, float> > &GetLMScoreComponent() const
+ {
+ return m_lmScoreComponent;
+ }
+ inline const std::list< std::pair<size_t, float> > &GetTrigramComponent() const
+ {
+ return m_trigramComponent;
+ }
+#endif
+
+
+};
+
diff --git a/moses/src/PossibleTranslationCollection.h b/moses/src/PossibleTranslationCollection.h
new file mode 100755
index 000000000..9e58c41bf
--- /dev/null
+++ b/moses/src/PossibleTranslationCollection.h
@@ -0,0 +1,44 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <list>
+#include "PossibleTranslation.h"
+
+class PossibleTranslationCollection : public std::list< PossibleTranslation >
+{
+public:
+ PossibleTranslationCollection()
+ {
+ }
+};
+
+inline std::ostream& operator<<(std::ostream& out, const PossibleTranslationCollection& coll)
+{
+ PossibleTranslationCollection::const_iterator iter;
+ for (iter = coll.begin() ; iter != coll.end() ; ++iter)
+ {
+ TRACE_ERR (*iter << std::endl);
+ }
+ return out;
+}
+
diff --git a/moses/src/ScoreColl.h b/moses/src/ScoreColl.h
new file mode 100644
index 000000000..39ced76ed
--- /dev/null
+++ b/moses/src/ScoreColl.h
@@ -0,0 +1,53 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+#include <map>
+#include <assert.h>
+
+class ScoreColl : public std::map<size_t, float>
+{
+public:
+ float GetValue(size_t index) const
+ {
+ const_iterator iter = find(index);
+ assert(iter != end());
+ return iter->second;
+ }
+
+};
+
+inline std::ostream& operator<<(std::ostream &out, const ScoreColl &coll)
+{
+ ScoreColl::const_iterator iter;
+ out << "<";
+ for (iter = coll.begin() ; iter != coll.end() ; iter++)
+ {
+ size_t id = iter->first;
+ float score = iter->second;
+ out << id << "=" << score << ", ";
+ }
+ out << "> ";
+ return out;
+}
+
diff --git a/moses/src/Sentence.cpp b/moses/src/Sentence.cpp
new file mode 100755
index 000000000..04139d137
--- /dev/null
+++ b/moses/src/Sentence.cpp
@@ -0,0 +1,20 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
diff --git a/moses/src/Sentence.h b/moses/src/Sentence.h
new file mode 100755
index 000000000..4e2c152e7
--- /dev/null
+++ b/moses/src/Sentence.h
@@ -0,0 +1,53 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <vector>
+#include <string>
+#include "Word.h"
+#include "Phrase.h"
+
+class Sentence : public Phrase
+{
+protected:
+ long m_translationId;
+
+ Sentence()
+ {
+ }
+public:
+ Sentence(Language language)
+ :Phrase(language)
+ {
+ }
+
+ // for db stuff
+ long GetTranslationId()
+ {
+ return m_translationId;;
+ }
+ void SetTranslationId(long translationId)
+ { // for db stuff;
+ m_translationId = translationId;
+ }
+};
+
diff --git a/moses/src/StaticData.cpp b/moses/src/StaticData.cpp
new file mode 100755
index 000000000..0b8afafde
--- /dev/null
+++ b/moses/src/StaticData.cpp
@@ -0,0 +1,357 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <string>
+#include <assert.h>
+
+#include "StaticData.h"
+#include "Util.h"
+#include "FactorCollection.h"
+#include "HypothesisCollection.h"
+#include "Timer.h"
+
+#include "boost/filesystem/operations.hpp" // boost::filesystem::exists
+
+using namespace std;
+
+extern Timer timer;
+
+StaticData::StaticData()
+:m_languageModel(2)
+,m_inputOutput(NULL)
+{
+}
+
+bool StaticData::LoadParameters(int argc, char* argv[])
+{
+ if (!m_parameter.LoadParam(argc, argv))
+ return false;
+
+ // mysql
+ m_mySQLParam = m_parameter.GetParam("mysql");
+
+ if (m_parameter.GetParam("cache-path").size() == 1)
+ m_cachePath = m_parameter.GetParam("cache-path")[0];
+ else
+ m_cachePath = GetTempFolder();
+
+ // n-best
+ if (m_parameter.GetParam("n-best-list").size() == 2)
+ {
+ m_nBestFilePath = m_parameter.GetParam("n-best-list")[0];
+ m_nBestSize = Scan<size_t>( m_parameter.GetParam("n-best-list")[1] );
+ }
+ else
+ {
+ m_nBestSize = 0;
+ }
+
+ //input-factors
+ const vector<string> &inputFactorVector = m_parameter.GetParam("input-factors");
+ for(size_t i=0; i<inputFactorVector.size(); i++)
+ {
+ m_inputFactorOrder.push_back(Scan<FactorType>(inputFactorVector[i]));
+ }
+
+ // mapping
+ const vector<string> &mappingVector = m_parameter.GetParam("mapping");
+ for(size_t i=0; i<mappingVector.size(); i++)
+ {
+ vector<string> token = Tokenize(mappingVector[i]);
+ if (token.size() == 2)
+ {
+ DecodeStep decodeStep (
+ token[0] == "T" ? Translate : Generate
+ ,Scan<int>(token[1]));
+ m_decodeStepList.push_back(decodeStep);
+ }
+ }
+
+ // load language models
+ if (m_parameter.GetParam("lmodel-file").size() > 0)
+ {
+ // weights
+ vector<float> weightAll = Scan<float>(m_parameter.GetParam("weight-l"));
+
+ TRACE_ERR("weight-l: ");
+ for (size_t i = 0 ; i < weightAll.size() ; i++)
+ {
+ TRACE_ERR(weightAll[i] << "\t");
+ }
+ TRACE_ERR(endl);
+
+
+ size_t nGramMaxOrder = 0;
+ const vector<string> &lmVector = m_parameter.GetParam("lmodel-file");
+
+ for(size_t i=0; i<lmVector.size(); i++)
+ {
+ vector<string> token = Tokenize(lmVector[i]);
+ int type = Scan<int>(token[0]);
+ FactorType factorType = Scan<FactorType>(token[1]);
+ size_t nGramOrder = Scan<int>(token[2]);
+ nGramMaxOrder = (std::max)(nGramMaxOrder, nGramOrder);
+ string &languageModelFile = token[3];
+
+ LanguageModel *lm = new LanguageModel();
+ lm->Load(i, languageModelFile, m_factorCollection, factorType, weightAll[i], nGramOrder);
+ m_languageModel[type].push_back(lm);
+
+ /*
+ const Factor *f0 = m_factorCollection.AddFactor(Target, Surface, "it")
+ ,*f1 = m_factorCollection.AddFactor(Target, Surface, "market")
+ ,*f2 = m_factorCollection.AddFactor(Target, Surface, "economy");
+ vector<const Factor*> contextFactor(3);
+ contextFactor[0] = f0;
+ contextFactor[1] = f1;
+ contextFactor[2] = f2;
+ float v = UntransformSRIScore(lm->GetValue(contextFactor));
+ TRACE_ERR(v << endl);
+ */
+ }
+ CompareHypothesisCollection::SetMaxNGramOrder(nGramMaxOrder);
+ }
+
+ timer.check("Finished loading language models");
+
+ // generation tables
+ if (m_parameter.GetParam("generation-file").size() > 0)
+ {
+ const vector<string> &generationVector = m_parameter.GetParam("generation-file");
+ const vector<float> &weight = Scan<float>(m_parameter.GetParam("weight-generation"));
+
+ TRACE_ERR("weight-generation: ");
+ for (size_t i = 0 ; i < weight.size() ; i++)
+ {
+ TRACE_ERR(weight[i] << "\t");
+ }
+ TRACE_ERR(endl);
+
+ for(size_t currDict = 0 ; currDict < generationVector.size(); currDict++)
+ {
+ vector<string> token = Tokenize(generationVector[currDict]);
+ vector<FactorType> input = Tokenize<FactorType>(token[0], ",")
+ ,output = Tokenize<FactorType>(token[1], ",");
+ string filePath= token[2];
+
+ TRACE_ERR(filePath << endl);
+ m_generationDictionary.push_back(new GenerationDictionary());
+ m_generationDictionary.back()->Load(input
+ , output
+ , m_factorCollection
+ , filePath
+ , weight[currDict]
+ , Target // always target, for now
+ , currDict);
+ }
+ }
+
+ timer.check("Finished loading generation tables");
+
+ // score weights
+ m_weightDistortion = Scan<float>( m_parameter.GetParam("weight-d")[0] );
+ m_weightWordPenalty = Scan<float>( m_parameter.GetParam("weight-w")[0] );
+
+ TRACE_ERR("weight-d: " << m_weightDistortion << endl);
+ TRACE_ERR("weight-w: " << m_weightWordPenalty << endl);
+
+ // misc
+ m_maxDistortion = (m_parameter.GetParam("distortion-limit").size() > 0) ?
+ Scan<int>(m_parameter.GetParam("distortion-limit")[0])
+ : -1;
+ m_beamThreshold = (m_parameter.GetParam("beam-threshold").size() > 0) ?
+ TransformScore(Scan<float>(m_parameter.GetParam("beam-threshold")[0]))
+ : TransformScore(DEFAULT_BEAM_THRESHOLD);
+
+ return true;
+}
+
+StaticData::~StaticData()
+{
+ delete m_inputOutput;
+ for (size_t i = 0 ; i < m_phraseDictionary.size() ; i++)
+ {
+ delete m_phraseDictionary[i];
+ }
+ for (size_t i = 0 ; i < m_generationDictionary.size() ; i++)
+ {
+ delete m_generationDictionary[i];
+ }
+
+ LMList &lmList = m_languageModel[0];
+ LMList::const_iterator iterLM;
+ for (iterLM = lmList.begin() ; iterLM != lmList.end() ; ++iterLM)
+ {
+ delete *iterLM;
+ }
+ lmList = m_languageModel[1];
+ for (iterLM = lmList.begin() ; iterLM != lmList.end() ; ++iterLM)
+ {
+ delete *iterLM;
+ }
+}
+
+IOMethod StaticData::GetIOMethod()
+{
+ if (m_mySQLParam.size() == 6)
+ return IOMethodMySQL;
+ else if (m_parameter.GetParam("input-file").size() == 1)
+ return IOMethodFile;
+ else
+ return IOMethodCommandLine;
+}
+
+void StaticData::SetWeightTransModel(const vector<float> &weight)
+{
+ assert(weight.size() == NUM_PHRASE_SCORES * GetPhraseDictionarySize());
+
+ size_t currWeight = 0;
+ vector<PhraseDictionary*>::iterator iter;
+ for(iter = m_phraseDictionary.begin() ; iter != m_phraseDictionary.end(); ++iter)
+ {
+ // weights for this particular dictionary
+ vector<float> dictWeight(NUM_PHRASE_SCORES);
+ for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
+ {
+ dictWeight[i] = weight[currWeight++];
+ }
+ PhraseDictionary *phraseDict = *iter;
+ phraseDict->SetWeightTransModel(dictWeight);
+ }
+}
+
+void StaticData::SetWeightLM(const std::vector<float> &weight)
+{
+ assert(weight.size() == m_languageModel[Initial].size() + m_languageModel[Other].size());
+
+ size_t currIndex = 0;
+ LMList::iterator iter;
+ for (iter = m_languageModel[Initial].begin() ; iter != m_languageModel[Initial].end() ; ++iter)
+ {
+ LanguageModel *languageModel = *iter;
+ languageModel->SetWeight(weight[currIndex++]);
+ }
+ for (iter = m_languageModel[Other].begin() ; iter != m_languageModel[Other].end() ; ++iter)
+ {
+ LanguageModel *languageModel = *iter;
+ languageModel->SetWeight(weight[currIndex++]);
+ }
+}
+
+void StaticData::SetWeightGeneration(const std::vector<float> &weight)
+{
+ assert(weight.size() == GetGenerationDictionarySize());
+
+ size_t currWeight = 0;
+ vector<GenerationDictionary*>::iterator iter;
+ for(iter = m_generationDictionary.begin() ; iter != m_generationDictionary.end(); ++iter)
+ {
+ GenerationDictionary *dict = *iter;
+ dict->SetWeight(weight[currWeight++]);
+ }
+}
+
+const LMList StaticData::GetAllLM() const
+{
+ LMList allLM;
+ std::copy(m_languageModel[Initial].begin(), m_languageModel[Initial].end()
+ , std::inserter(allLM, allLM.end()));
+ std::copy(m_languageModel[Other].begin(), m_languageModel[Other].end()
+ , std::inserter(allLM, allLM.end()));
+
+ return allLM;
+}
+
+void StaticData::LoadPhraseTables(bool filter
+ , const string &inputFileHash
+ , const list< Phrase > &inputPhraseList)
+{
+ // load phrase translation tables
+ if (m_parameter.GetParam("ttable-file").size() > 0)
+ {
+ // weights
+ vector<float> weightAll = Scan<float>(m_parameter.GetParam("weight-t"));
+
+ TRACE_ERR("weight-t: ");
+ for (size_t i = 0 ; i < weightAll.size() ; i++)
+ {
+ TRACE_ERR(weightAll[i] << "\t");
+ }
+ TRACE_ERR(endl);
+
+ const vector<string> &translationVector = m_parameter.GetParam("ttable-file");
+ size_t maxTargetPhrase = Scan<size_t>(m_parameter.GetParam("ttable-limit")[0]);
+
+ for(size_t currDict = 0 ; currDict < translationVector.size(); currDict++)
+ {
+ vector<string> token = Tokenize(translationVector[currDict]);
+ vector<FactorType> input = Tokenize<FactorType>(token[0], ",")
+ ,output = Tokenize<FactorType>(token[1], ",");
+ string filePath= token[2];
+ // weights for this phrase dictionary
+ vector<float> weight(NUM_PHRASE_SCORES);
+ for (size_t currScore = 0 ; currScore < NUM_PHRASE_SCORES ; currScore++)
+ {
+ weight[currScore] = weightAll[currDict * NUM_PHRASE_SCORES + currScore];
+ }
+
+ string phraseTableHash = GetMD5Hash(filePath);
+ string hashFilePath = GetCachePath()
+ + PROJECT_NAME + "--"
+ + inputFileHash + "--"
+ + phraseTableHash + ".txt";
+ bool filterPhrase;
+ if (filter)
+ {
+ if (boost::filesystem::exists(hashFilePath))
+ { // load filtered file instead
+ filterPhrase = false;
+ filePath = hashFilePath;
+ }
+ else
+ { // load original file & create has file
+ filterPhrase = true;
+ }
+ }
+ else
+ { // load original file
+ filterPhrase = false;
+ }
+ TRACE_ERR(filePath << endl);
+
+ m_phraseDictionary.push_back(new PhraseDictionary());
+ timer.check("Start loading");
+ m_phraseDictionary[currDict]->Load(input
+ , output
+ , m_factorCollection
+ , filePath
+ , hashFilePath
+ , weight
+ , maxTargetPhrase
+ , currDict
+ , filterPhrase
+ , inputPhraseList);
+ timer.check("Finished loading");
+ }
+ }
+
+ timer.check("Finished loading phrase tables");
+}
diff --git a/moses/src/StaticData.h b/moses/src/StaticData.h
new file mode 100755
index 000000000..cbdb2a09e
--- /dev/null
+++ b/moses/src/StaticData.h
@@ -0,0 +1,172 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <list>
+#include <vector>
+#include "TypeDef.h"
+#include "PhraseDictionary.h"
+#include "GenerationDictionary.h"
+#include "FactorCollection.h"
+#include "Parameter.h"
+#include "LanguageModel.h"
+#include "InputOutput.h"
+
+class StaticData
+{
+protected:
+ FactorCollection m_factorCollection;
+ std::vector<PhraseDictionary*> m_phraseDictionary;
+ std::vector<GenerationDictionary*> m_generationDictionary;
+ std::list < DecodeStep > m_decodeStepList;
+ Parameter m_parameter;
+ std::vector<FactorType> m_inputFactorOrder;
+ std::vector<LMList> m_languageModel;
+ // Initial = 0 = can be used when creating poss trans
+ // Other = 1 = used to calculate LM score once all steps have been processed
+ float m_beamThreshold
+ ,m_weightDistortion, m_weightWordPenalty;
+ // PhraseTrans, Generation & LanguageModelScore has multiple weights.
+ int m_maxDistortion;
+ // do it differently from old pharaoh
+ // -ve = no limit on distortion
+ // 0 = no disortion (monotone in old pharaoh)
+ size_t m_nBestSize;
+ std::string m_nBestFilePath, m_cachePath;
+ std::vector<std::string> m_mySQLParam;
+ InputOutput *m_inputOutput;
+
+public:
+ StaticData();
+ ~StaticData();
+
+ bool LoadParameters(int argc, char* argv[]);
+
+ void LoadPhraseTables(bool filter
+ , const std::string &inputFileHash
+ , const std::list< Phrase > &inputPhraseList);
+ void LoadPhraseTables()
+ {
+ LoadPhraseTables(false, "", std::list< Phrase >());
+ }
+
+ const PARAM_VEC &GetParam(const std::string &paramName)
+ {
+ return m_parameter.GetParam(paramName);
+ }
+
+ InputOutput &GetInputOutput()
+ {
+ return *m_inputOutput;
+ }
+
+ const std::vector<FactorType> &GetInputFactorOrder() const
+ {
+ return m_inputFactorOrder;
+ }
+
+ std::list < DecodeStep > &GetDecodeStepList()
+ {
+ return m_decodeStepList;
+ }
+
+ FactorCollection &GetFactorCollection()
+ {
+ return m_factorCollection;
+ }
+
+ const PhraseDictionary &GetPhraseDictionary(const DecodeStep &decodeStep) const
+ {
+ return *m_phraseDictionary[decodeStep.second];
+ }
+ const GenerationDictionary &GetGenerationDictionary(const DecodeStep &decodeStep) const
+ {
+ return *m_generationDictionary[decodeStep.second];
+ }
+ const LMList &GetLanguageModel(LMListType type) const
+ {
+ return m_languageModel[type];
+ }
+ float GetWeightDistortion() const
+ {
+ return m_weightDistortion;
+ }
+ float GetWeightWordPenalty() const
+ {
+ return m_weightWordPenalty;
+ }
+ int GetMaxDistortion() const
+ {
+ return m_maxDistortion;
+ }
+ float GetBeamThreshold() const
+ {
+ return m_beamThreshold;
+ }
+
+ IOMethod GetIOMethod();
+ const std::vector<std::string> &GetMySQLParam()
+ {
+ return m_mySQLParam;
+ }
+
+ size_t GetLMSize() const
+ {
+ return m_languageModel[Initial].size() + m_languageModel[Other].size();
+ }
+ const LMList GetAllLM() const;
+
+ size_t GetPhraseDictionarySize() const
+ {
+ return m_phraseDictionary.size();
+ }
+ size_t GetGenerationDictionarySize() const
+ {
+ return m_generationDictionary.size();
+ }
+ const std::string GetCachePath() const
+ {
+ return m_cachePath;
+ }
+
+ // for mert
+ size_t GetNBestSize() const
+ {
+ return m_nBestSize;
+ }
+ const std::string &GetNBestFilePath() const
+ {
+ return m_nBestFilePath;
+ }
+ void SetWeightDistortion(float weightDistortion)
+ {
+ m_weightDistortion = weightDistortion;
+ }
+ void SetWeightWordPenalty(float weightWordPenalty)
+ {
+ m_weightWordPenalty = weightWordPenalty;
+ }
+ void SetWeightTransModel(const std::vector<float> &weight);
+ void SetWeightLM(const std::vector<float> &weight);
+ void SetWeightGeneration(const std::vector<float> &weight);
+};
+
diff --git a/moses/src/TargetPhrase.cpp b/moses/src/TargetPhrase.cpp
new file mode 100644
index 000000000..a11a4cf9e
--- /dev/null
+++ b/moses/src/TargetPhrase.cpp
@@ -0,0 +1,62 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <assert.h>
+#include "TargetPhrase.h"
+
+using namespace std;
+
+void TargetPhrase::SetScore(const vector<float> &scoreVector, const vector<float> &weightT)
+{
+ assert(scoreVector.size() == NUM_PHRASE_SCORES);
+ assert(weightT.size() == scoreVector.size());
+
+ // calc average score if non-best
+ m_score = 0;
+ for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
+ {
+ float score = TransformScore(scoreVector[i]);
+#ifdef N_BEST
+ m_scoreComponent[i] = score;
+#endif
+ m_score += score * weightT[i];
+ }
+}
+
+void TargetPhrase::SetWeight(const vector<float> &weightT)
+{
+#ifdef N_BEST
+ m_score = 0;
+ for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
+ {
+ m_score += m_scoreComponent[i] * weightT[i];
+ }
+#endif
+}
+
+void TargetPhrase::ResetScore()
+{
+ m_score = 0;
+#ifdef N_BEST
+ m_scoreComponent.Reset();
+#endif
+}
+
diff --git a/moses/src/TargetPhrase.h b/moses/src/TargetPhrase.h
new file mode 100644
index 000000000..e7ff7d50f
--- /dev/null
+++ b/moses/src/TargetPhrase.h
@@ -0,0 +1,60 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <vector>
+#include "Phrase.h"
+#include "TransScoreComponent.h"
+
+class TargetPhrase: public Phrase
+{
+protected:
+ float m_score;
+#ifdef N_BEST
+ TransScoreComponent m_scoreComponent;
+#endif
+
+public:
+ TargetPhrase(Language language, size_t idPhraseDictionary)
+ :Phrase(language)
+#ifdef N_BEST
+ ,m_scoreComponent(idPhraseDictionary)
+#endif
+ {
+ }
+ float GetScore() const
+ {
+ return m_score;
+ }
+ void SetScore(const std::vector<float> &scoreVector, const std::vector<float> &weightT);
+ void ResetScore();
+ void SetWeight(const std::vector<float> &weightT);
+
+#ifdef N_BEST
+ inline const TransScoreComponent &GetScoreComponents() const
+ {
+ return m_scoreComponent;
+ }
+#endif
+
+};
+
diff --git a/moses/src/Timer.h b/moses/src/Timer.h
new file mode 100644
index 000000000..6dd977e39
--- /dev/null
+++ b/moses/src/Timer.h
@@ -0,0 +1,128 @@
+#ifndef TIMER_H
+#define TIMER_H
+
+#include <ctime>
+#include <iostream>
+#include <iomanip>
+#include "Util.h"
+
+class Timer
+{
+ friend std::ostream& operator<<(std::ostream& os, Timer& t);
+
+ private:
+ bool running;
+ time_t start_time;
+
+ double elapsed_time();
+
+ public:
+ // 'running' is initially false. A timer needs to be explicitly started
+ // using 'start' or 'restart'
+ Timer() : running(false), start_time(0) { }
+
+ void start(const char* msg = 0);
+// void restart(const char* msg = 0);
+// void stop(const char* msg = 0);
+ void check(const char* msg = 0);
+
+}; // class timer
+
+//===========================================================================
+// Return the total time that the timer has been in the "running"
+// state since it was first "started" or last "restarted". For
+// "short" time periods (less than an hour), the actual cpu time
+// used is reported instead of the elapsed time.
+
+inline double Timer::elapsed_time()
+{
+ time_t now;
+ time(&now);
+ return difftime(now, start_time);
+} // timer::elapsed_time
+
+//===========================================================================
+// Start a timer. If it is already running, let it continue running.
+// Print an optional message.
+
+inline void Timer::start(const char* msg)
+{
+ // Print an optional message, something like "Starting timer t";
+ if (msg) TRACE_ERR(msg << std::endl);
+
+ // Return immediately if the timer is already running
+ if (running) return;
+
+ // Change timer status to running
+ running = true;
+
+ // Set the start time;
+ time(&start_time);
+
+} // timer::start
+
+//===========================================================================
+// Turn the timer off and start it again from 0. Print an optional message.
+/*
+inline void Timer::restart(const char* msg)
+{
+ // Print an optional message, something like "Restarting timer t";
+ if (msg) TRACE_ERR(msg << std::endl);
+
+ // Set the timer status to running
+ running = true;
+
+ // Set the accumulated time to 0 and the start time to now
+ acc_time = 0;
+ start_clock = clock();
+ start_time = time(0);
+
+} // timer::restart
+*/
+
+//===========================================================================
+// Stop the timer and print an optional message.
+/*
+inline void Timer::stop(const char* msg)
+{
+ // Print an optional message, something like "Stopping timer t";
+ check(msg);
+
+ // Recalculate and store the total accumulated time up until now
+ if (running) acc_time += elapsed_time();
+
+ running = false;
+
+} // timer::stop
+*/
+//===========================================================================
+// Print out an optional message followed by the current timer timing.
+
+inline void Timer::check(const char* msg)
+{
+ // Print an optional message, something like "Checking timer t";
+ if (msg) TRACE_ERR(msg << " : ");
+
+ TRACE_ERR("[" << std::setiosflags(std::ios::fixed) << std::setprecision(2)
+ << (running ? elapsed_time() : 0) << "] seconds\n");
+
+} // timer::check
+
+//===========================================================================
+// Allow timers to be printed to ostreams using the syntax 'os << t'
+// for an ostream 'os' and a timer 't'. For example, "cout << t" will
+// print out the total amount of time 't' has been "running".
+
+inline std::ostream& operator<<(std::ostream& os, Timer& t)
+{
+#ifdef TRACE_ENABLE
+ os << std::setprecision(2) << std::setiosflags(std::ios::fixed)
+ << (t.running ? t.elapsed_time() : 0);
+#endif
+ return os;
+}
+
+//===========================================================================
+
+#endif // TIMER_H
+
diff --git a/moses/src/TransScoreComponent.h b/moses/src/TransScoreComponent.h
new file mode 100644
index 000000000..8539f4747
--- /dev/null
+++ b/moses/src/TransScoreComponent.h
@@ -0,0 +1,88 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+
+//typedef float TransScoreComponent[NUM_PHRASE_SCORES];
+
+class TransScoreComponent
+{
+protected:
+ size_t m_idPhraseDictionary;
+ float m_scoreComponent[NUM_PHRASE_SCORES];
+public:
+ TransScoreComponent()
+ {
+ }
+ TransScoreComponent(size_t idPhraseDictionary)
+ {
+ m_idPhraseDictionary = idPhraseDictionary;
+ }
+ TransScoreComponent(const TransScoreComponent &copy)
+ {
+ m_idPhraseDictionary = copy.m_idPhraseDictionary;
+ for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
+ {
+ m_scoreComponent[i] = copy[i];
+ }
+ }
+
+ inline size_t GetPhraseDictionaryId() const
+ {
+ return m_idPhraseDictionary;
+ }
+
+ float operator[](size_t index) const
+ {
+ return m_scoreComponent[index];
+ }
+ float &operator[](size_t index)
+ {
+ return m_scoreComponent[index];
+ }
+
+ void Reset()
+ {
+ for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
+ {
+ m_scoreComponent[i] = 0;
+ }
+ }
+
+ inline bool operator< (const TransScoreComponent &compare) const
+ {
+ return GetPhraseDictionaryId() < compare.GetPhraseDictionaryId();
+ }
+
+};
+
+inline std::ostream& operator<<(std::ostream &out, const TransScoreComponent &transScoreComponent)
+{
+ out << transScoreComponent[0];
+ for (size_t i = 1 ; i < NUM_PHRASE_SCORES ; i++)
+ {
+ out << "," << transScoreComponent[i];
+ }
+ return out;
+}
+
diff --git a/moses/src/TransScoreComponentCollection.h b/moses/src/TransScoreComponentCollection.h
new file mode 100644
index 000000000..bfe1d3f01
--- /dev/null
+++ b/moses/src/TransScoreComponentCollection.h
@@ -0,0 +1,64 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+#include <map>
+#include <assert.h>
+#include "TransScoreComponent.h"
+
+class TransScoreComponentCollection : public std::map<size_t, TransScoreComponent>
+{
+public:
+ TransScoreComponent &GetTransScoreComponent(size_t index)
+ {
+ TransScoreComponentCollection::iterator iter = find(index);
+ assert(iter != end());
+ return iter->second;
+ }
+ const TransScoreComponent &GetTransScoreComponent(size_t index) const
+ {
+ return const_cast<TransScoreComponentCollection*>(this)->GetTransScoreComponent(index);
+ }
+ TransScoreComponent &Add(const TransScoreComponent &transScoreComponent)
+ {
+ size_t idPhraseDictionary = transScoreComponent.GetPhraseDictionaryId();
+ return operator[](idPhraseDictionary) = transScoreComponent;
+ }
+ TransScoreComponent &Add(size_t idPhraseDictionary)
+ {
+ return Add(TransScoreComponent(idPhraseDictionary));
+ }
+};
+
+inline std::ostream& operator<<(std::ostream &out, const TransScoreComponentCollection &transScoreComponentColl)
+{
+ TransScoreComponentCollection::const_iterator iter;
+ for (iter = transScoreComponentColl.begin() ; iter != transScoreComponentColl.end() ; ++iter)
+ {
+ size_t idTrans = iter->first;
+ const TransScoreComponent &transScoreComponent = iter->second;
+ out << "[" << idTrans << "=" << transScoreComponent << "] ";
+ }
+ return out;
+}
+
diff --git a/moses/src/TypeDef.h b/moses/src/TypeDef.h
new file mode 100755
index 000000000..9c409850b
--- /dev/null
+++ b/moses/src/TypeDef.h
@@ -0,0 +1,135 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <list>
+
+#define PROJECT_NAME "moses"
+
+#define SENTENCE_START "<s>"
+#define SENTENCE_END "</s>"
+#define UNKNOWN_FACTOR "UNK"
+
+#define NOT_FOUND std::numeric_limits<size_t>::max()
+
+const size_t MAXIMUM_HYPO_COLL_SIZE = 200;
+const size_t ARRAY_SIZE_INCR = 20;
+const float LOWEST_SCORE = -100.0f;
+const float DEFAULT_BEAM_THRESHOLD = 0.00001f;
+
+/////////////////////////////////////////////////
+// for those using autoconf/automake
+#if HAVE_CONFIG_H
+#include "config.h"
+
+#define TRACE_ENABLE 1 // REMOVE after we figure this out
+
+# ifdef HAVE_SRILM
+# define LM_SRI 1
+# undef LM_INTERNAL
+# else
+# undef LM_SRI
+# define LM_INTERNAL 1
+# endif
+
+#endif
+/////////////////////////////////////////////////
+
+#ifdef LM_SRI
+typedef unsigned int LmId;
+#endif
+#ifdef LM_INTERNAL
+class NGramNode;
+typedef const NGramNode* LmId;
+#endif
+
+// enums.
+// must be 0, 1, 2, ..., unless otherwise stated
+enum Language
+{
+ Source = 0
+ ,Target = 1
+};
+
+// can only be 2 at the moment
+const int NUM_LANGUAGES = 2;
+
+enum FactorType
+{
+ Surface = 0
+ ,POS = 1
+ ,Stem = 2
+ ,Morphology = 3
+};
+
+// count of above
+const size_t NUM_FACTORS = 4;
+
+enum FactorDirection
+{
+ Input = 0
+ ,Output = 1
+};
+
+enum DecodeType
+{
+ Translate
+ ,Generate
+};
+
+enum ScoreType
+{
+ PhraseTrans
+ ,Generation
+ ,LanguageModelScore
+ ,Distortion
+ ,WordPenalty
+ ,FutureScoreEnum
+ ,Total
+};
+// count of above
+const size_t NUM_SCORES = 7;
+
+const size_t NUM_PHRASE_SCORES = 5;
+
+enum IOMethod
+{
+ IOMethodCommandLine
+ ,IOMethodFile
+ ,IOMethodMySQL
+};
+
+enum LMListType
+{
+ Initial
+ ,Other
+};
+
+// typedef
+class Factor;
+typedef const Factor * FactorArray[NUM_FACTORS];
+
+class LanguageModel;
+typedef std::list < LanguageModel* > LMList;
+
+typedef std::pair < DecodeType , int > DecodeStep;
+ // 2nd = index into m_phraseDictionary or m_generationDictionary
diff --git a/moses/src/UserMessage.cpp b/moses/src/UserMessage.cpp
new file mode 100644
index 000000000..6b1444e95
--- /dev/null
+++ b/moses/src/UserMessage.cpp
@@ -0,0 +1,59 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <sstream>
+#include <iostream>
+#include "UserMessage.h"
+
+using namespace std;
+
+const int MAX_MSG_QUEUE = 5;
+
+bool UserMessage::m_toStderr = true;
+bool UserMessage::m_toQueue = false;
+queue<string> UserMessage::m_msgQueue;
+
+void UserMessage::Add(const string &msg)
+{
+ if (m_toStderr)
+ {
+ cerr << "ERROR:" << msg << endl;
+ }
+ if (m_toQueue)
+ {
+ if (m_msgQueue.size() >= MAX_MSG_QUEUE)
+ m_msgQueue.pop();
+ m_msgQueue.push(msg);
+ }
+}
+
+string UserMessage::GetQueue()
+{
+ stringstream strme("");
+ while (!m_msgQueue.empty())
+ {
+ strme << m_msgQueue.front() << endl;
+ m_msgQueue.pop();
+ }
+ return strme.str();
+}
+
+
diff --git a/moses/src/UserMessage.h b/moses/src/UserMessage.h
new file mode 100644
index 000000000..b2104ab1f
--- /dev/null
+++ b/moses/src/UserMessage.h
@@ -0,0 +1,43 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <string>
+#include <queue>
+
+class UserMessage
+{
+protected:
+ static bool m_toStderr, m_toQueue;
+ static std::queue<std::string> m_msgQueue;
+
+public:
+ static void SetOutput(bool toStderr, bool toQueue)
+ {
+ m_toStderr = toStderr;
+ m_toQueue = toQueue;
+ }
+
+ static void Add(const std::string &msg);
+ static std::string GetQueue();
+};
+
diff --git a/moses/src/Util.cpp b/moses/src/Util.cpp
new file mode 100644
index 000000000..ba423c9a2
--- /dev/null
+++ b/moses/src/Util.cpp
@@ -0,0 +1,93 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+#include <stdio.h>
+#include <iostream>
+#include <iomanip>
+#include "TypeDef.h"
+#include "Util.h"
+#include "md5.h"
+
+using namespace std;
+
+string GetTempFolder()
+{
+#ifdef _WIN32
+ char *tmpPath = getenv("TMP");
+ string str(tmpPath);
+ if (str.substr(str.size() - 1, 1) != "\\")
+ str += "\\";
+ return str;
+#else
+ return "/tmp/";
+#endif
+}
+
+void CreateTempFile(ofstream &fileStream, string &filePath)
+{
+#ifdef _WIN32
+ char buffer[BUFSIZ];
+ ::GetTempFileNameA(GetTempFolder().c_str(), "", 0, buffer);
+ filePath = buffer;
+#else
+ char buffer[L_tmpnam];
+ strcpy(buffer, GetTempFolder().c_str());
+ strcat(buffer, PROJECT_NAME);
+ strcat(buffer, "--XXXXXX");
+ mkstemp(buffer);
+ filePath = buffer;
+#endif
+ fileStream.open(filePath.c_str(), ofstream::out | ofstream::app);
+}
+
+string GetMD5Hash(const string &filePath)
+{
+ unsigned char buffer[16384], signature[16];
+ struct MD5Context md5c;
+
+ FILE *in;
+ if ((in = fopen(filePath.c_str(), "rb")) == NULL)
+ {
+ return "";
+ }
+
+ MD5Init(&md5c);
+ size_t j;
+ while ((j = fread(buffer, 1, sizeof buffer, in)) > 0)
+ {
+ MD5Update(&md5c, buffer, (unsigned) j);
+ }
+ MD5Final(signature, &md5c);
+
+ std::stringstream stream("");
+ stream.setf(std::ios_base::hex,std::ios_base::basefield);
+ for (j = 0; j < sizeof signature; j++)
+ {
+ stream << setw(2) << setfill('0') << (int) signature[j];
+ }
+
+ return stream.str();
+}
+
diff --git a/moses/src/Util.h b/moses/src/Util.h
new file mode 100644
index 000000000..d9295927e
--- /dev/null
+++ b/moses/src/Util.h
@@ -0,0 +1,190 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <fstream>
+#include <sstream>
+#include <string>
+#include <vector>
+#include <math.h>
+
+#ifdef TRACE_ENABLE
+#define TRACE_ERR(str) { std::cerr << str; }
+#else
+#define TRACE_ERR(str) { }
+#endif
+
+template<typename T>
+inline std::string SPrint(const T &input)
+{
+ std::stringstream stream("");
+ stream << input;
+ return stream.str();
+}
+
+template<typename T>
+inline T Scan(const std::string &input)
+{
+ std::stringstream stream(input);
+ T ret;
+ stream >> ret;
+ return ret;
+}
+
+template<>
+inline int Scan<int>(const std::string &input)
+{
+ return atoi(input.c_str());
+}
+
+template<>
+inline float Scan<float>(const std::string &input)
+{
+ return (float) atof(input.c_str());
+}
+
+template<>
+inline FactorType Scan<FactorType>(const std::string &input)
+{
+ return static_cast<FactorType>(Scan<int>(input));
+}
+
+// convert vectors
+template<typename T>
+inline std::vector<T> Scan(const std::vector< std::string > &input)
+{
+ std::vector<T> output(input.size());
+ for (size_t i = 0 ; i < input.size() ; i++)
+ {
+ output[i] = Scan<T>( input[i] );
+ }
+ return output;
+}
+
+inline std::vector<std::string> Tokenize(const std::string& str,
+ const std::string& delimiters = " \t")
+{
+ std::vector<std::string> tokens;
+ // Skip delimiters at beginning.
+ std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
+ // Find first "non-delimiter".
+ std::string::size_type pos = str.find_first_of(delimiters, lastPos);
+
+ while (std::string::npos != pos || std::string::npos != lastPos)
+ {
+ // Found a token, add it to the vector.
+ tokens.push_back(str.substr(lastPos, pos - lastPos));
+ // Skip delimiters. Note the "not_of"
+ lastPos = str.find_first_not_of(delimiters, pos);
+ // Find next "non-delimiter"
+ pos = str.find_first_of(delimiters, lastPos);
+ }
+
+ return tokens;
+}
+
+// tokenize then convert each element into another type
+template<typename T>
+inline std::vector<T> Tokenize( const std::string &input
+ , const std::string& delimiters = " \t")
+{
+ std::vector<std::string> stringVector = Tokenize(input, delimiters);
+ return Scan<T>( stringVector );
+}
+
+inline std::vector<std::string> TokenizeMultiCharSeparator(
+ const std::string& str,
+ const std::string& separator)
+{
+ std::vector<std::string> tokens;
+
+ size_t pos = 0;
+ // Find first "non-delimiter".
+ std::string::size_type nextPos = str.find(separator, pos);
+
+ while (nextPos != std::string::npos)
+ {
+ // Found a token, add it to the vector.
+ tokens.push_back(str.substr(pos, nextPos - pos));
+ // Skip delimiters. Note the "not_of"
+ pos = nextPos + separator.size();
+ // Find next "non-delimiter"
+ nextPos = str.find(separator, pos);
+ }
+ tokens.push_back(str.substr(pos, nextPos - pos));
+
+ return tokens;
+
+}
+
+// transform prob to natural log score
+inline float TransformScore(float prob)
+{
+ return log(prob);
+}
+
+// transform natural log score to prob.
+// not sure if needed
+inline float UntransformScore(float score)
+{
+ return exp(score);
+}
+
+inline float TransformSRIScore(float sriScore)
+{ // sri number are in log 10
+ // transform to natural log
+ return sriScore * 2.30258509299405f;
+}
+
+inline float UntransformSRIScore(float logNScore)
+{ // opposite of above
+ return logNScore / 2.30258509299405f;
+}
+
+inline float FloorSRIScore(float sriScore)
+{
+ return (std::max)(sriScore , LOWEST_SCORE);
+}
+
+#define TO_STRING \
+ std::string ToString() const \
+ { \
+ std::stringstream out; \
+ out << *this; \
+ return out.str(); \
+ } \
+
+template<class ITER, class COLL>
+void RemoveAllInColl(COLL &coll)
+{
+ ITER iter;
+ for (iter = coll.begin() ; iter != coll.end() ; ++iter)
+ {
+ delete (*iter);
+ }
+ coll.clear();
+
+}
+
+std::string GetTempFolder();
+void CreateTempFile(std::ofstream &fileStream, std::string &filePath);
+std::string GetMD5Hash(const std::string &filePath);
diff --git a/moses/src/WeightOptimization.cpp b/moses/src/WeightOptimization.cpp
new file mode 100755
index 000000000..52102f814
--- /dev/null
+++ b/moses/src/WeightOptimization.cpp
@@ -0,0 +1,75 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "WeightOptimization.h"
+#include "StaticData.h"
+
+using namespace std;
+
+WeightOptimizationImpl::WeightOptimizationImpl(StaticData &staticData)
+:m_staticData(staticData)
+{
+}
+
+void WeightOptimizationImpl::SetWeight(const std::vector<float> &weight)
+{
+ m_staticData.SetWeightDistortion(weight[0]);
+
+ size_t currIndex = 1;
+
+ // LM
+ {
+ size_t numLM = m_staticData.GetLMSize();
+ std::vector<float> lmWeight(numLM);
+ for (size_t i = 0 ; i < numLM ; i++)
+ {
+ lmWeight[i] = weight[currIndex++];
+ }
+ m_staticData.SetWeightLM(lmWeight);
+ }
+
+ // phrase trans
+ {
+ size_t numPhraseDict = NUM_PHRASE_SCORES * m_staticData.GetPhraseDictionarySize();
+ std::vector<float> transModelWeight(numPhraseDict);
+
+ for (size_t i = 0 ; i < numPhraseDict ; i++)
+ {
+ transModelWeight[i] = weight[currIndex++];
+ }
+ m_staticData.SetWeightTransModel(transModelWeight);
+ }
+
+ // WP
+ m_staticData.SetWeightWordPenalty(weight[currIndex++]);
+
+ // generation
+ {
+ size_t numGenerationDict = m_staticData.GetGenerationDictionarySize();
+ std::vector<float> generationWeight(numGenerationDict);
+
+ for (size_t i = 0 ; i < numGenerationDict ; i++)
+ {
+ generationWeight[i] = weight[currIndex++];
+ }
+ m_staticData.SetWeightGeneration(generationWeight);
+ }
+}
diff --git a/moses/src/WeightOptimization.h b/moses/src/WeightOptimization.h
new file mode 100755
index 000000000..74fad2365
--- /dev/null
+++ b/moses/src/WeightOptimization.h
@@ -0,0 +1,44 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <vector>
+
+class StaticData;
+
+class WeightOptimization
+{
+public:
+ //virtual std::vector<float> GetComponentScore() = 0;
+ virtual void SetWeight(const std::vector<float> &weight) = 0;
+};
+
+class WeightOptimizationImpl : public WeightOptimization
+{
+ StaticData &m_staticData;
+
+ WeightOptimizationImpl(); // not implemented
+public:
+ WeightOptimizationImpl(StaticData &staticData);
+ //std::vector<float> GetComponentScore();
+ void SetWeight(const std::vector<float> &weight);
+};
diff --git a/moses/src/Word.cpp b/moses/src/Word.cpp
new file mode 100755
index 000000000..11383bdba
--- /dev/null
+++ b/moses/src/Word.cpp
@@ -0,0 +1,124 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include <sstream>
+#include "memory.h"
+#include "Word.h"
+
+using namespace std;
+
+Word::Word(const Word &copy)
+{ // automatically points to orig's factors
+ Word::Copy(m_factorArray, copy.m_factorArray);
+}
+
+Word::Word()
+{
+ Word::Initialize(m_factorArray);
+}
+
+int Word::Compare(const Word &compare) const
+{
+ return Compare(GetFactorArray(), compare.GetFactorArray());
+}
+
+// static
+int Word::Compare(const FactorArray &targetWord, const FactorArray &sourceWord)
+{
+ for (size_t factorType = 0 ; factorType < NUM_FACTORS ; factorType++)
+ {
+ const Factor *targetFactor = targetWord[factorType]
+ ,*sourceFactor = sourceWord[factorType];
+
+ if (targetFactor == NULL || sourceFactor == NULL)
+ {
+ continue;
+ }
+ int result = targetFactor->Compare(*sourceFactor);
+ if ( result )
+ return result;
+ }
+ return 0;
+
+}
+
+void Word::Copy(FactorArray &target, const FactorArray &source)
+{
+ memcpy(target, source, sizeof(FactorArray));
+}
+
+void Word::Initialize(FactorArray &factorArray)
+{
+ memset(factorArray, 0, sizeof(FactorArray));
+}
+
+void Word::Merge(FactorArray &targetWord, const FactorArray &sourceWord)
+{
+ for (unsigned int currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+ {
+ const Factor *sourcefactor = sourceWord[currFactor]
+ ,*targetFactor = targetWord[currFactor];
+ if (targetFactor == NULL && sourcefactor != NULL)
+ {
+ targetWord[currFactor] = sourcefactor;
+ }
+ }
+}
+
+std::string Word::ToString(const FactorArray &factorArray)
+{
+ stringstream strme;
+
+ strme << "(";
+ for (unsigned int currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+ {
+ const Factor *factor = factorArray[currFactor];
+ if (factor != NULL)
+ {
+ strme << *factor << ",";
+ }
+ }
+ string str = strme.str();
+ str = str.substr(0, str.size() - 1) + ") ";
+ return str;
+}
+
+// friend
+ostream& operator<<(ostream& out, const Word& word)
+{
+ stringstream strme;
+
+ strme << "(";
+ for (unsigned int currFactor = 0 ; currFactor < NUM_FACTORS ; currFactor++)
+ {
+ FactorType factorType = static_cast<FactorType>(currFactor);
+ const Factor *factor = word.GetFactor(factorType);
+ if (factor != NULL)
+ {
+ strme << *factor << ",";
+ }
+ }
+ string str = strme.str();
+ str = str.substr(0, str.size() - 1);
+ out << str << ") ";
+ return out;
+}
+
diff --git a/moses/src/Word.h b/moses/src/Word.h
new file mode 100755
index 000000000..5bb95032a
--- /dev/null
+++ b/moses/src/Word.h
@@ -0,0 +1,89 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <iostream>
+#include <vector>
+#include <list>
+#include "TypeDef.h"
+#include "Factor.h"
+#include "FactorTypeSet.h"
+#include "Util.h"
+
+class Phrase;
+
+class Word
+{
+ friend std::ostream& operator<<(std::ostream&, const Word&);
+
+protected:
+ FactorArray m_factorArray;
+
+public:
+ Word(const Word &copy);
+ //Word(const FactorTypeSet *factorsUsed);
+ Word();
+
+ ~Word()
+ {
+ }
+
+ inline FactorArray &GetFactorArray()
+ {
+ return m_factorArray;
+ }
+ inline const FactorArray &GetFactorArray() const
+ {
+ return m_factorArray;
+ }
+ inline const Factor *GetFactor(FactorType factorType) const
+ {
+ return m_factorArray[factorType];
+ }
+ inline void SetFactor(FactorType factorType, const Factor *factor)
+ {
+ m_factorArray[factorType] = factor;
+ }
+
+ int Compare(const Word &compare) const;
+ // -1 = less than
+ // +1 = more than
+ // 0 = same
+
+ inline bool operator< (const Word &compare) const
+ { // needed to store word in GenerationDictionary map
+ // uses comparison of FactorKey
+ // 'proper' comparison, not address/id comparison
+ return Compare(compare) < 0;
+ }
+
+ TO_STRING
+
+ // FactorArray
+ static void Copy(FactorArray &target, const FactorArray &source);
+ static void Initialize(FactorArray &factorArray);
+ static void Merge(FactorArray &targetWord, const FactorArray &sourceWord);
+ static std::string ToString(const FactorArray &factorArray);
+ static int Compare(const FactorArray &targetWord, const FactorArray &sourceWord);
+
+};
+
diff --git a/moses/src/WordsBitmap.cpp b/moses/src/WordsBitmap.cpp
new file mode 100755
index 000000000..ee9f21396
--- /dev/null
+++ b/moses/src/WordsBitmap.cpp
@@ -0,0 +1,22 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#include "WordsBitmap.h"
diff --git a/moses/src/WordsBitmap.h b/moses/src/WordsBitmap.h
new file mode 100755
index 000000000..6ffdffeac
--- /dev/null
+++ b/moses/src/WordsBitmap.h
@@ -0,0 +1,173 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include <limits>
+#include <vector>
+#include <iostream>
+#include "TypeDef.h"
+#include "WordsRange.h"
+
+class WordsBitmap
+{
+ friend std::ostream& operator<<(std::ostream& out, const WordsBitmap& wordsBitmap);
+protected:
+ const size_t m_size;
+ bool *m_bitmap;
+ // ticks of words that have been done;
+
+ WordsBitmap(); // not implemented
+
+ void Initialize()
+ {
+ for (size_t pos = 0 ; pos < m_size ; pos++)
+ {
+ m_bitmap[pos] = false;
+ }
+ }
+
+public:
+ WordsBitmap(size_t size)
+ :m_size (size)
+ {
+ m_bitmap = (bool*) malloc(sizeof(bool) * size);
+ Initialize();
+ }
+
+ WordsBitmap(const WordsBitmap &copy)
+ :m_size (copy.m_size)
+ {
+ m_bitmap = (bool*) malloc(sizeof(bool) * m_size);
+ for (size_t pos = 0 ; pos < m_size ; pos++)
+ {
+ m_bitmap[pos] = copy.GetValue(pos);
+ }
+ }
+ ~WordsBitmap()
+ {
+ free(m_bitmap);
+ }
+
+ size_t GetWordsCount() const
+ {
+ size_t count = 0;
+ for (size_t pos = 0 ; pos < m_size ; pos++)
+ {
+ if (m_bitmap[pos])
+ count++;
+ }
+ return count;
+ }
+
+ size_t GetFirstGapPos() const
+ {
+ for (size_t pos = 0 ; pos < m_size ; pos++)
+ {
+ if (m_bitmap[pos] == 0)
+ {
+ return pos;
+ }
+ }
+ // no starting pos
+ return NOT_FOUND;
+ }
+ size_t GetLastPos() const
+ {
+ for (int pos = (int) m_size - 1 ; pos >= 0 ; pos--)
+ {
+ if (m_bitmap[pos])
+ {
+ return pos;
+ }
+ }
+ // no starting pos
+ return NOT_FOUND;
+ }
+ bool GetValue(size_t pos) const
+ {
+ return m_bitmap[pos];
+ }
+ void SetValue( size_t startPos, size_t endPos, bool value )
+ {
+ for(size_t pos = startPos ; pos <= endPos ; pos++)
+ {
+ m_bitmap[pos] = value;
+ }
+ }
+ bool IsComplete() const
+ {
+ return GetSize() == GetWordsCount();
+ }
+
+ bool Overlap(const WordsRange &compare) const
+ {
+ for (size_t pos = compare.GetStartPos() ; pos <= compare.GetEndPos() ; pos++)
+ {
+ if (m_bitmap[pos])
+ return true;
+ }
+ return false;
+ }
+
+ size_t GetSize() const
+ {
+ return m_size;
+ }
+
+ inline int Compare (const WordsBitmap &compare) const
+ {
+ // -1 = less than
+ // +1 = more than
+ // 0 = same
+
+ size_t thisSize = GetSize()
+ ,compareSize = compare.GetSize();
+
+ if (thisSize != compareSize)
+ {
+ return (thisSize < compareSize) ? -1 : 1;
+ }
+
+ for (int pos = (int) thisSize - 1 ; pos >= 0 ; pos--)
+ {
+ bool thisValue = GetValue(pos);
+ bool compareValue = compare.GetValue(pos);
+ if (thisValue != compareValue)
+ {
+ return compareValue ? -1 : 1;
+ }
+ }
+ // identical
+ return 0;
+ }
+};
+
+// friend
+inline std::ostream& operator<<(std::ostream& out, const WordsBitmap& wordsBitmap)
+{
+ for (size_t i = 0 ; i < wordsBitmap.m_size ; i++)
+ {
+ out << (wordsBitmap.GetValue(i) ? 1 : 0);
+ }
+ return out;
+}
+
diff --git a/moses/src/WordsRange.h b/moses/src/WordsRange.h
new file mode 100755
index 000000000..56fc44f4a
--- /dev/null
+++ b/moses/src/WordsRange.h
@@ -0,0 +1,56 @@
+// $Id$
+
+/***********************************************************************
+Moses - factored phrase-based language decoder
+Copyright (C) 2006 University of Edinburgh
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library 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
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+***********************************************************************/
+
+#pragma once
+
+#include "TypeDef.h"
+
+class WordsRange
+{ // slimmed down, contiguous version of WordsBitmap
+ size_t m_startPos, m_endPos;
+public:
+ inline size_t GetStartPos() const
+ {
+ return m_startPos;
+ }
+ inline size_t GetEndPos() const
+ {
+ return m_endPos;
+ }
+ inline WordsRange(size_t startPos, size_t endPos)
+ {
+ m_startPos = startPos;
+ m_endPos = endPos;
+ }
+
+ inline int CalcDistortion(const WordsRange &prevRange) const
+ {
+ int dist = (int)prevRange.GetEndPos() - (int)GetStartPos() + 1 ;
+ return abs(dist);
+ }
+
+ inline size_t GetWordsCount() const
+ {
+ return (m_startPos == NOT_FOUND) ? 0 : m_endPos - m_startPos + 1;
+ }
+
+};
+
diff --git a/moses/src/md5.cpp b/moses/src/md5.cpp
new file mode 100644
index 000000000..a802c6f09
--- /dev/null
+++ b/moses/src/md5.cpp
@@ -0,0 +1,259 @@
+/*
+ * This code implements the MD5 message-digest algorithm.
+ * The algorithm is due to Ron Rivest. This code was
+ * written by Colin Plumb in 1993, no copyright is claimed.
+ * This code is in the public domain; do with it what you wish.
+ *
+ * Equivalent code is available from RSA Data Security, Inc.
+ * This code has been tested against that, and is equivalent,
+ * except that you don't need to include two pages of legalese
+ * with every copy.
+ *
+ * To compute the message digest of a chunk of bytes, declare an
+ * MD5Context structure, pass it to MD5Init, call MD5Update as
+ * needed on buffers full of bytes, and then call MD5Final, which
+ * will fill a supplied 16-byte array with the digest.
+ */
+
+/* Brutally hacked by John Walker back from ANSI C to K&R (no
+ prototypes) to maintain the tradition that Netfone will compile
+ with Sun's original "cc". */
+
+#include <memory.h> /* for memcpy() */
+#include "md5.h"
+
+#ifdef sgi
+#define HIGHFIRST
+#endif
+
+#ifdef sun
+#define HIGHFIRST
+#endif
+
+#ifndef HIGHFIRST
+#define byteReverse(buf, len) /* Nothing */
+#else
+/*
+ * Note: this code is harmless on little-endian machines.
+ */
+void byteReverse(buf, longs)
+ unsigned char *buf; unsigned longs;
+{
+ uint32 t;
+ do {
+ t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+ ((unsigned) buf[1] << 8 | buf[0]);
+ *(uint32 *) buf = t;
+ buf += 4;
+ } while (--longs);
+}
+#endif
+
+/*
+ * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
+ * initialization constants.
+ */
+void MD5Init(struct MD5Context *ctx)
+{
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
+
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
+}
+
+/*
+ * Update context to reflect the concatenation of another buffer full
+ * of bytes.
+ */
+void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len)
+{
+ uint32 t;
+
+ /* Update bitcount */
+
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((uint32) len << 3)) < t)
+ ctx->bits[1]++; /* Carry from low to high */
+ ctx->bits[1] += len >> 29;
+
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
+
+ /* Handle any leading odd-sized chunks */
+
+ if (t) {
+ unsigned char *p = (unsigned char *) ctx->in + t;
+
+ t = 64 - t;
+ if (len < t) {
+ memcpy(p, buf, len);
+ return;
+ }
+ memcpy(p, buf, t);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ buf += t;
+ len -= t;
+ }
+ /* Process data in 64-byte chunks */
+
+ while (len >= 64) {
+ memcpy(ctx->in, buf, 64);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ buf += 64;
+ len -= 64;
+ }
+
+ /* Handle any remaining bytes of data. */
+
+ memcpy(ctx->in, buf, len);
+}
+
+/*
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
+ * 1 0* (64-bit count of bits processed, MSB-first)
+ */
+void MD5Final(unsigned char digest[16], struct MD5Context *ctx)
+{
+ unsigned count;
+ unsigned char *p;
+
+ /* Compute number of bytes mod 64 */
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ /* Set the first char of padding to 0x80. This is safe since there is
+ always at least one byte free */
+ p = ctx->in + count;
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 64 bytes */
+ count = 64 - 1 - count;
+
+ /* Pad out to 56 mod 64 */
+ if (count < 8) {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ memset(p, 0, count);
+ byteReverse(ctx->in, 16);
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+
+ /* Now fill the next block with 56 bytes */
+ memset(ctx->in, 0, 56);
+ } else {
+ /* Pad block to 56 bytes */
+ memset(p, 0, count - 8);
+ }
+ byteReverse(ctx->in, 14);
+
+ /* Append length in bits and transform */
+ ((uint32 *) ctx->in)[14] = ctx->bits[0];
+ ((uint32 *) ctx->in)[15] = ctx->bits[1];
+
+ MD5Transform(ctx->buf, (uint32 *) ctx->in);
+ byteReverse((unsigned char *) ctx->buf, 4);
+ memcpy(digest, ctx->buf, 16);
+ memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+}
+
+
+/* The four core functions - F1 is optimized somewhat */
+
+/* #define F1(x, y, z) (x & y | ~x & z) */
+#define F1(x, y, z) (z ^ (x & (y ^ z)))
+#define F2(x, y, z) F1(z, x, y)
+#define F3(x, y, z) (x ^ y ^ z)
+#define F4(x, y, z) (y ^ (x | ~z))
+
+/* This is the central step in the MD5 algorithm. */
+#define MD5STEP(f, w, x, y, z, data, s) \
+ ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
+
+/*
+ * The core of the MD5 algorithm, this alters an existing MD5 hash to
+ * reflect the addition of 16 longwords of new data. MD5Update blocks
+ * the data and converts bytes into longwords for this routine.
+ */
+void MD5Transform(uint32 buf[4], uint32 in[16])
+{
+ register uint32 a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+ MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+ MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
+ MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+ MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+ MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+ MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
+ MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
+ MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
+ MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+ MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+ MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+ MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
+ MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
+ MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
+ MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+ MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+ MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
+ MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+ MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+ MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+ MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
+ MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+ MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+ MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+ MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+ MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+ MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+ MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+ MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+ MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+ MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+ MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+ MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
+ MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+ MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+ MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+ MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+ MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+ MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+ MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+ MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+ MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+ MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
+ MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+ MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+ MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+ MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+ MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
+ MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
+ MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+ MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+ MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+ MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+ MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+ MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+ MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+ MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+ MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
+ MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+ MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+ MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+ MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+ MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
+}
diff --git a/moses/src/md5.h b/moses/src/md5.h
new file mode 100644
index 000000000..ff5f7a775
--- /dev/null
+++ b/moses/src/md5.h
@@ -0,0 +1,26 @@
+#ifndef MD5_H
+#define MD5_H
+
+#ifdef __alpha
+typedef unsigned int uint32;
+#else
+typedef unsigned long uint32;
+#endif
+
+struct MD5Context {
+ uint32 buf[4];
+ uint32 bits[2];
+ unsigned char in[64];
+};
+
+void MD5Init(struct MD5Context *ctx);
+void MD5Update(struct MD5Context *ctx, unsigned char *buf, unsigned len);
+extern void MD5Final(unsigned char digest[16], struct MD5Context *ctx);
+void MD5Transform(uint32 buf[4], uint32 in[16]);
+
+/*
+ * This is needed to make RSAREF happy on some MS-DOS compilers.
+ */
+typedef struct MD5Context MD5_CTX;
+
+#endif /* !MD5_H */
diff --git a/moses/templates/cpp b/moses/templates/cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/moses/templates/cpp
diff --git a/moses/templates/h b/moses/templates/h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/moses/templates/h