Imported Upstream version 1.7.7
[platform/upstream/openfst.git] / configure.ac
1 AC_INIT([OpenFst], [1.7.7], [help@www.openfst.org])
2 AM_INIT_AUTOMAKE([foreign nostdinc -Wall -Werror subdir-objects])
3 AM_PROG_AR
4
5 AC_PROG_CXX
6 # This library does not throw exceptions, so we do not generate exception
7 # handling code. However, users are free to re-enable exception handling.
8 CXX="$CXX -std=c++11 -fno-exceptions"
9
10 AC_DISABLE_STATIC
11 AC_PROG_LIBTOOL
12
13 AC_CONFIG_HEADERS([config.h src/include/fst/config.h])
14 AC_CONFIG_SRCDIR([src/lib/fst.cc])
15 AC_CONFIG_FILES([
16   Makefile
17   src/Makefile
18   src/include/Makefile
19   src/lib/Makefile
20   src/bin/Makefile
21   src/test/Makefile
22   src/extensions/Makefile
23   src/extensions/compact/Makefile
24   src/extensions/compress/Makefile
25   src/extensions/const/Makefile
26   src/extensions/far/Makefile
27   src/extensions/linear/Makefile
28   src/extensions/lookahead/Makefile
29   src/extensions/mpdt/Makefile
30   src/extensions/ngram/Makefile
31   src/extensions/pdt/Makefile
32   src/extensions/python/Makefile
33   src/extensions/special/Makefile
34   src/script/Makefile
35 ])
36 AC_CONFIG_MACRO_DIR([m4])
37 AC_LANG([C++])
38
39 AC_ARG_ENABLE([compact-fsts],
40               [AS_HELP_STRING([--enable-compact-fsts],
41               [enable CompactFst extensions])],
42               [],
43               [enable_compact_fsts=no])
44 AM_CONDITIONAL([HAVE_COMPACT], [test "x$enable_compact_fsts" != xno])
45
46 AC_ARG_ENABLE([compress],
47               [AS_HELP_STRING([--enable-compress],
48               [enable compression extension])],
49               [],
50               [enable_compress=no])
51 AM_CONDITIONAL([HAVE_COMPRESS], [test "x$enable_compress" != xno])
52
53 AC_ARG_ENABLE([const-fsts],
54               [AS_HELP_STRING([--enable-const-fsts],
55               [enable ConstFst extensions])],
56               [],
57               [enable_const_fsts=no])
58 AM_CONDITIONAL([HAVE_CONST], [test "x$enable_const_fsts" != xno])
59
60 AC_ARG_ENABLE([far],
61               [AS_HELP_STRING([--enable-far], [enable FAR extensions])],
62               [],
63               [enable_far=no])
64 AM_CONDITIONAL([HAVE_FAR], [test "x$enable_far" != xno])
65
66 AC_ARG_ENABLE([linear-fsts],
67               [AS_HELP_STRING([--enable-linear-fsts],
68               [enable LinearTagger/ClassifierFst extensions])],
69               [],
70               [enable_linear_fsts=no])
71 AM_CONDITIONAL([HAVE_LINEAR], [test "x$enable_linear_fsts" != xno])
72
73 AC_ARG_ENABLE([lookahead-fsts],
74               [AS_HELP_STRING([--enable-lookahead-fsts],
75               [enable LookAheadFst extensions])],
76               [],
77               [enable_lookahead_fsts=no])
78 AM_CONDITIONAL([HAVE_LOOKAHEAD], [test "x$enable_lookahead_fsts" != xno])
79
80 AC_ARG_ENABLE([mpdt],
81               [AS_HELP_STRING([--enable-mpdt],
82               [enable MPDT extensions])],
83               [],
84               [enable_mpdt=no])
85 AM_CONDITIONAL([HAVE_MPDT], [test "x$enable_mpdt" != xno])
86
87 AC_ARG_ENABLE([ngram-fsts],
88               [AS_HELP_STRING([--enable-ngram-fsts],
89               [enable NGramFst extension])],
90               [],
91               [enable_ngram_fsts=no])
92 AM_CONDITIONAL([HAVE_NGRAM], [test "x$enable_ngram_fsts" != xno])
93
94 AC_ARG_ENABLE([pdt],
95               [AS_HELP_STRING([--enable-pdt],
96               [enable PDT extensions])],
97               [],
98               [enable_pdt=no])
99 AM_CONDITIONAL([HAVE_PDT], [test "x$enable_pdt" != xno])
100
101 AC_ARG_ENABLE([python],
102               [AS_HELP_STRING([--enable-python],
103               [enable Python extensions])],
104               [],
105               [enable_python=no])
106 AM_CONDITIONAL([HAVE_PYTHON], [test "x$enable_python" != xno])
107 if test "x$enable_python" != xno; then
108   AM_PATH_PYTHON(2.7)
109   AC_PYTHON_DEVEL([>= '2.7'])
110 fi
111
112 AC_ARG_ENABLE([special],
113               [AS_HELP_STRING([--enable-special],
114               [enable special-matcher extensions])],
115               [],
116               [enable_special=no])
117 AM_CONDITIONAL([HAVE_SPECIAL], [test "x$enable_special" != xno])
118
119 # --enable-bin enables script and bin "extensions".
120 AC_ARG_ENABLE([bin],
121               [AS_HELP_STRING([--enable-bin],
122               [enable fst::script and command-line binaries])],
123               [],
124               [enable_bin=yes])
125 AM_CONDITIONAL([HAVE_BIN], [test "x$enable_bin" != xno])
126 AM_CONDITIONAL([HAVE_SCRIPT], [test "x$enable_bin" != xno])
127
128 # --enable-fsts is an alias to enable FST SO extensions: compact, const,
129 # linear, lookahead, and ngram.
130 AC_ARG_ENABLE([fsts],
131               [AS_HELP_STRING([--enable-fsts],
132               [enable all FST SOs])],
133               [],
134               [enable_fsts=no])
135 AM_CONDITIONAL([HAVE_FSTS], [test "x$enable_fsts" != xno])
136
137 # --enable-grm is an alias to enable all dependencies of OpenGrm: far, mpdt,
138 # and pdt.
139 AC_ARG_ENABLE([grm],
140               [AS_HELP_STRING([--enable-grm],
141               [enable all dependencies of OpenGrm])],
142               [],
143               [enable_grm=no])
144 AM_CONDITIONAL([HAVE_GRM], [test "x$enable_grm" != xno])
145
146 AC_ARG_WITH([libfstdir],
147 [--with-libfstdir[=DIR] fst dynamic extensions [[LIBDIR/fst]]],
148 [], [with_libfstdir=[${libdir}/fst]])
149
150 AC_SUBST([libfstdir], $with_libfstdir)
151
152 # Flags may be changed after configuring, so this is checked again by
153 # weight_test.cc.  The check here is to save time in the common case,
154 # or when someone does not run `make check`.
155 AC_RUN_IFELSE([AC_LANG_PROGRAM([
156                  #include <cstdio>
157
158                  template <typename T>
159                  bool FloatEqIsReflexive(T m) {
160                    volatile T x = 1.111;
161                    x *= m;
162
163                    T y = 1.111;
164                    y *= m;
165
166                    return x == y;
167                  }
168                ], [
169                  volatile double test_value = 1.1;
170                  if (!FloatEqIsReflexive(static_cast<float>(test_value))) {
171                    printf("float FAIL\n");
172                    return 1;
173                  }
174                  if (!FloatEqIsReflexive(test_value)) {
175                    printf("double FAIL\n");
176                    return 1;
177                  }
178                ])],
179               [echo "Float equality is good"],
180               [AC_MSG_FAILURE(m4_normalize([
181                    Test float equality failed!
182                    Compile with -msse -mfpmath=sse if using g++.
183               ]))])
184
185 AC_CHECK_LIB([dl], dlopen, [DL_LIBS=-ldl])
186 AC_SUBST([DL_LIBS])
187
188 AC_OUTPUT