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

Jamroot - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 54fd9882740c24938c6d3d6b1764a08e67edf260 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#BUILDING MOSES
#
#PACKAGES
#Language models (optional):
#--with-irstlm=/path/to/irstlm 
#--with-srilm=/path/to/srilm See moses/src/LM/Jamfile for more options.
#--with-randlm=/path/to/randlm
#KenLM is always compiled.  
#
#--with-boost=/path/to/boost
#If Boost is in a non-standard location, specify it here.  This directory is
#expected to contain include and lib or lib64.  
#
#--with-xmlrpc-c=/path/to/xmlrpc-c for libxmlrpc-c (used by server)
#Note that, like language models, this is the --prefix where the library was
#installed, not some executable within the library.  
#
#--with-giza=/path/to/giza 
#Indicates where binaries GIZA++, snt2cooc.out, and mkcls live.  
#Builds scripts/training/train-model.perl using these paths. 
#
#
#REGRESSION TESTING
#--with-regtest=/path/to/moses-reg-test-data
#
#
#INSTALLATION
#--prefix=/path/to/prefix sets the install prefix [dist].
#--bindir=/path/to/prefix/bin sets the bin directory [PREFIX/bin]
#--libdir=/path/to/prefix/lib sets the lib directory [PREFIX/lib]
#--install-scripts=/path/to/scripts copies scripts into a directory.
#--git appends the git revision to the prefix directory.
#
#
#BUILD OPTIONS
# By default, the build is multi-threaded, optimized, and statically linked.  
# Pass these to change the build:
#
# threading=single|multi         controls threading (default multi)
#
# variant=release|debug|profile  builds optimized (default), for debug, or for
#                                profiling
#
# link=static|shared             controls linking (default static)
#
# debug-symbols=on|off           include (default) or exclude debugging
#                                information also known as -g
# --notrace                      compiles without TRACE macros
#
# --enable-boost-pool            uses Boost pools for the memory SCFG table
#
# --enable-mpi                   switch on mpi
#
#CONTROLLING THE BUILD
#-a to build from scratch
#-j$NCPUS to compile in parallel
#--clean to clean

import option ;
import modules ;

path-constant TOP : . ;

# Shell with trailing line removed http://lists.boost.org/boost-build/2007/08/17051.php
rule trim-nl ( str extras * ) {
  return [ MATCH "([^
]*)" : $(str) ] $(extras) ;
}
rule _shell ( cmd : extras * ) {
  return [ trim-nl [ SHELL $(cmd) : $(extras) ] ] ;
}

local cleaning = [ option.get "clean" : : yes ] ;
cleaning ?= [ option.get "clean-all" : no : yes ] ;
if "clean" in [ modules.peek : ARGV ] {
  cleaning = yes ;
}
constant CLEANING : $(cleaning) ;

#Run g++ with empty main and these arguments to see if it passes.  
rule test_flags ( flags ) {
  if [ SHELL $(TOP)"/jam-files/test.sh "$(flags) ] = 0 {
    return true ;
  } else {
    return ;
  }
}

#Determine if a library can be compiled statically.  
rule auto_shared ( name : additional ? ) {
  additional ?= "" ;
  if [ test_flags $(additional)" -static -l"$(name) ] {
    return ;
  } else {
    return "<link>shared" ;
  }
}

with-boost = [ option.get "with-boost" ] ;
if $(with-boost) {
  L-boost-search = -L$(with-boost)/lib" "-L$(with-boost)/lib64 ;
  boost-search = <search>$(with-boost)/lib <search>$(with-boost)/lib64 ;
  I-boost-include = -I$(with-boost)/include ;
  boost-include = <include>$(with-boost)/include ;
} else {
  L-boost-search = "" ;
  boost-search = ;
  I-boost-include = "" ;
  boost-include = ;
}

boost-shell = [ SHELL "g++ "$(I-boost-include)" -dM -x c++ -E /dev/null -include boost/version.hpp 2>/dev/null |grep '#define BOOST_VERSION '" : exit-status ] ;
if $(boost-shell[2]) != 0 && $(CLEANING) = no {
  exit Boost does not seem to be installed or g++ is confused. : 1 ;
}
boost-version = [ MATCH "#define BOOST_VERSION ([0-9]*)" : $(boost-shell[1]) ] ;
if $(boost-version) < 103600 && $(cleaning) = no {
  exit You have Boost $(boost-version).  Moses requires at least 103600 (and preferably newer). : 1 ;
}
#Are we linking static binaries against shared boost?
boost-auto-shared = [ auto_shared "boost_program_options" : $(L-boost-search) ] ;
#Convenience rule for boost libraries.  Defines library boost_$(name).  
rule boost_lib ( name macro ) {
  #Link multi-threaded programs against the -mt version if available.  Old 
  #versions of boost do not have -mt tagged versions of all libraries.   Sadly,
  #boost.jam does not handle this correctly.  
  if [ test_flags $(L-boost-search)" -lboost_"$(name)"-mt" ] {
    lib inner_boost_$(name) : : <threading>single $(boost-search) <name>boost_$(name) ;
    lib inner_boost_$(name) : : <threading>multi $(boost-search) <name>boost_$(name)-mt ;
  } else {
    lib inner_boost_$(name) : : $(boost-search) <name>boost_$(name) ;
  }

  alias boost_$(name) : inner_boost_$(name) : $(boost-auto-shared) : : <link>shared:<define>BOOST_$(macro) $(boost-include) ;
}
#See tools/build/v2/contrib/boost.jam in a boost distribution for a table of macros to define.   
boost_lib thread THREAD_DYN_DLL ;
boost_lib program_options PROGRAM_OPTIONS_DYN_LINK ;
boost_lib unit_test_framework TEST_DYN_LINK ;
boost_lib mpi MPI_DYN_LINK ;
boost_lib serialization SERIALIZATION_DYN_LINK ;

#Link normally to a library, but sometimes static isn't installed so fall back to dynamic.
rule external_lib ( name ) {
  lib $(name) : : [ auto_shared $(name) ] ;
}

external_lib z ;

requirements = ;

#libSegFault prints a stack trace on segfault.  Link against it if available.  
if [ test_flags "-lSegfault" ] {
  external_lib SegFault ;
  requirements += <library>SegFault ;
}

if [ option.get "enable-mpi" : : "yes" ] {
  import mpi ;
  using mpi ;
  requirements += <define>MPI_ENABLE ;
  requirements += <library>mpi ;
  requirements += <library>boost_mpi ;
  requirements += <library>boost_serialization ;
}

requirements += [ option.get "notrace" : <define>TRACE_ENABLE=1 ] ;
requirements += [ option.get "enable-boost-pool" : : <define>USE_BOOST_POOL ] ;
import os ;


cxxflags = [ os.environ "CXXFLAGS" ] ;
cflags = [ os.environ "CFLAGS" ] ;
ldflags = [ os.environ "LDFLAGS" ] ;

project : default-build
  <threading>multi
  <warnings>on
  <debug-symbols>on
  <variant>release
  <link>static
  ;

project : requirements 
  <threading>multi:<define>WITH_THREADS
  <threading>multi:<library>boost_thread
  <define>_FILE_OFFSET_BITS=64 <define>_LARGE_FILES
  $(requirements)
  <cxxflags>$(cxxflags)
  <cflags>$(cflags)
  <linkflags>$(ldflags)
  ;

#Add directories here if you want their incidental targets too (i.e. tests).
build-project lm ; 
build-project util ;
#Trigger instllation into legacy paths.  
build-project mert ;
build-project moses-cmd/src ;
build-project moses-chart-cmd/src ;
build-project mira ;
build-project moses/src ;
#Scripts have their own binaries.
build-project scripts ;
#Regression tests (only does anything if --with-regtest is passed)
build-project regression-testing ;

if [ option.get "git" : : "yes" ] {
  local revision = [ _shell "git rev-parse --verify HEAD |head -c 7" ] ;
  constant GITTAG : "/"$(revision) ;
} else {
  constant GITTAG : "" ;
}

alias programs : lm//query lm//build_binary moses-chart-cmd/src//moses_chart moses-cmd/src//programs OnDiskPt//CreateOnDisk mert//programs contrib/server//mosesserver misc//programs mira//programs ;

prefix = [ option.get "prefix" : $(TOP)/dist$(GITTAG) ] ;
bindir = [ option.get "bindir" : $(prefix)/bin ] ;
libdir = [ option.get "libdir" : $(prefix)/lib ] ;
install prefix-bin : programs : <location>$(bindir) <install-dependencies>on <install-type>EXE <link>shared:<dll-path>$(libdir) ;
install prefix-lib : programs : <location>$(libdir) <install-dependencies>on <install-type>LIB <link>shared:<dll-path>$(libdir) ;