1#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10#   http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
20AC_PREREQ(2.65)
21AC_CONFIG_MACRO_DIR([./aclocal])
22
23AC_INIT([thrift], [0.18.0])
24
25AC_CONFIG_AUX_DIR([.])
26
27AM_INIT_AUTOMAKE([1.13 subdir-objects tar-ustar foreign])
28PKG_PROG_PKG_CONFIG
29
30AC_ARG_VAR([PY_PREFIX], [Prefix for installing Python modules.
31                         (Normal --prefix is ignored for Python because
32                         Python has different conventions.)
33                         Default = "/usr"])
34AS_IF([test "x$PY_PREFIX" = x], [PY_PREFIX="/usr"])
35
36AC_ARG_VAR([JAVA_PREFIX], [Prefix for installing the Java lib jar.
37                           Default = "/usr/local/lib"])
38AS_IF([test "x$JAVA_PREFIX" != x], [JAVA_PREFIX="$JAVA_PREFIX/usr/local/lib"],
39      [test "x$PREFIX" != x], [JAVA_PREFIX="$PREFIX/usr/local/lib"],
40      [JAVA_PREFIX="/usr/local/lib"])
41
42AC_ARG_VAR([RUBY_PREFIX], [Prefix for installing Ruby modules.
43                           (Normal --prefix is ignored for Ruby because
44                           Ruby has different conventions.)
45                           Default = none, let ruby setup decide])
46
47AC_ARG_VAR([PHP_PREFIX], [Prefix for installing PHP modules.
48                         (Normal --prefix is ignored for PHP because
49                         PHP has different conventions.)
50                         Default = "/usr/lib/php"])
51AS_IF([test "x$PHP_PREFIX" = x], [PHP_PREFIX="/usr/lib/php"])
52
53AC_ARG_VAR([PHP_CONFIG_PREFIX],
54           [Prefix for installing PHP extension module .ini file.
55            (Normal --prefix is ignored for PHP because PHP has
56             different conventions.)
57           Default = "/etc/php.d"])
58AS_IF([test "x$PHP_CONFIG_PREFIX" = x], [PHP_CONFIG_PREFIX="/etc/php.d"])
59
60AC_ARG_VAR([INSTALLDIRS], [When installing Perl modules, specifies which
61                           of the sets of installation directories
62                           to choose: perl, site or vendor.
63                           Default = "vendor"])
64AS_IF([test "x$INSTALLDIRS" = x], [INSTALLDIRS="vendor"])
65
66AC_ARG_VAR([PERL_PREFIX], [Prefix for installing Perl modules.
67                           (Normal --prefix is ignored for Perl because
68                           Perl has different conventions.)
69                           Ignored, when INSTALLDIRS set to site or vendor.
70                           Default = "/usr/local/lib"])
71AS_IF([test "x$PERL_PREFIX" = x], [PERL_PREFIX="/usr/local"])
72
73AC_ARG_VAR([D_IMPORT_PREFIX], [Prefix for installing D modules.
74                           [INCLUDEDIR/d2]])
75AS_IF([test "x$D_IMPORT_PREFIX" = x], [D_IMPORT_PREFIX="${includedir}/d2"])
76
77AC_ARG_VAR([DMD_LIBEVENT_FLAGS], [DMD flags for linking libevent (auto-detected if not set).])
78AC_ARG_VAR([DMD_OPENSSL_FLAGS], [DMD flags for linking OpenSSL (auto-detected if not set).])
79
80AC_ARG_VAR([THRIFT], [Path to the thrift tool (needed for cross-compilation).])
81AS_IF([test "x$THRIFT" = x], [THRIFT=`pwd`/compiler/cpp/thrift])
82
83AC_PROG_CC
84AC_PROG_CPP
85AC_PROG_CXX
86AC_PROG_INSTALL
87AC_PROG_LIBTOOL
88AC_PROG_MAKE_SET
89AC_PROG_BISON(2.5)
90AC_PROG_YACC
91AC_PROG_LEX
92AM_PROG_LEX
93AC_PROG_LN_S
94AC_PROG_MKDIR_P
95AC_PROG_AWK
96AC_PROG_RANLIB
97
98AC_LANG([C++])
99AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
100
101AM_EXTRA_RECURSIVE_TARGETS([style])
102AC_SUBST(CPPSTYLE_CMD, 'find . -type f \( -iname "*.h" -or -iname "*.cpp" -or -iname "*.cc" -or -iname "*.tcc" \) -printf "Reformatting: %h/%f\n" -exec clang-format -i {} \;')
103# '
104# The above comment is to fix editor syntax highlighting
105
106AC_ARG_ENABLE([libs],
107  AS_HELP_STRING([--enable-libs], [build the Apache Thrift libraries [default=yes]]),
108  [], enable_libs=yes
109)
110have_libs=yes
111if test "$enable_libs" = "no"; then
112  have_libs="no"
113  with_cpp="no"
114  with_c_glib="no"
115  with_cl="no"
116  with_java="no"
117  with_kotlin="no"
118  with_python="no"
119  with_py3="no"
120  with_ruby="no"
121  with_haxe="no"
122  with_netstd="no"
123  with_perl="no"
124  with_php="no"
125  with_php_extension="no"
126  with_dart="no"
127  with_erlang="no"
128  with_go="no"
129  with_d="no"
130  with_nodejs="no"
131  with_nodets="no"
132  with_lua="no"
133  with_rs="no"
134  with_swift="no"
135fi
136
137AX_THRIFT_LIB(cpp, [C++], yes)
138have_cpp=no
139if test "$with_cpp" = "yes";  then
140  AX_BOOST_BASE([1.56.0])
141  if test "x$succeeded" = "xyes" ; then
142    AC_SUBST([BOOST_LIB_DIR], [$(echo "$BOOST_LDFLAGS" | sed -e 's/^\-L//')])
143    AC_SUBST([BOOST_CHRONO_LDADD], [$(echo "$BOOST_LIB_DIR/libboost_chrono.a")])
144    AC_SUBST([BOOST_FILESYSTEM_LDADD], [$(echo "$BOOST_LIB_DIR/libboost_filesystem.a")])
145    AC_SUBST([BOOST_SYSTEM_LDADD], [$(echo "$BOOST_LIB_DIR/libboost_system.a")])
146    AC_SUBST([BOOST_TEST_LDADD], [$(echo "$BOOST_LIB_DIR/libboost_unit_test_framework.a")])
147    AC_SUBST([BOOST_THREAD_LDADD], [$(echo "$BOOST_LIB_DIR/libboost_thread.a")])
148    have_cpp="yes"
149  fi
150
151  AX_LIB_EVENT([2.0])
152  have_libevent=$success
153
154  AX_LIB_ZLIB([1.2.3])
155  have_zlib=$success
156
157  AX_THRIFT_LIB(qt5, [Qt5], yes)
158  have_qt5=no
159  qt_reduce_reloc=""
160  if test "$with_qt5" = "yes";  then
161    PKG_CHECK_MODULES([QT5], [Qt5Core >= 5.0, Qt5Network >= 5.0],
162                      [have_qt5=yes;qt_reduce_reloc=`$PKG_CONFIG --variable=qt_config Qt5Core | grep "reduce_relocations"`],
163                      [have_qt5=no])
164  fi
165  if test "$have_qt5" = "yes"; then
166    AC_PATH_PROGS([QT5_MOC], [moc-qt5 moc], "fail")
167    if test "$QT5_MOC" = "fail"; then
168      have_qt5=no
169    fi
170  fi
171fi
172AM_CONDITIONAL([WITH_CPP], [test "$have_cpp" = "yes"])
173AM_CONDITIONAL([AMX_HAVE_LIBEVENT], [test "$have_libevent" = "yes"])
174AM_CONDITIONAL([AMX_HAVE_ZLIB], [test "$have_zlib" = "yes"])
175AM_CONDITIONAL([AMX_HAVE_QT5], [test "$have_qt5" = "yes"])
176AM_CONDITIONAL([QT5_REDUCE_RELOCATIONS], [test "x$qt_reduce_reloc" != "x"])
177
178AX_THRIFT_LIB(c_glib, [C (GLib)], yes)
179if test "$with_c_glib" = "yes"; then
180  PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.0], have_glib2=yes, have_glib2=no)
181  PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.0], have_gobject2=yes, have_gobject2=no)
182  if test "$have_glib2" = "yes" -a "$have_gobject2" = "yes" ; then
183    AC_PATH_PROG([GSETTINGS], [gsettings])
184    have_c_glib="yes"
185  fi
186fi
187AM_CONDITIONAL(WITH_C_GLIB, [test "$have_glib2" = "yes" -a "$have_gobject2" = "yes"])
188
189# echo "OpenSSL check"
190if test "$have_cpp" = "yes" -o "$have_c_glib" = "yes";  then
191  # echo "Have cpp or c so we check for OpenSSL"
192  AX_CHECK_OPENSSL()
193fi
194
195
196AX_THRIFT_LIB(java, [Java], yes)
197if test "$with_java" = "yes";  then
198  AX_JAVAC_AND_JAVA
199  AC_PATH_PROG([ANT], [ant])
200  AC_PATH_PROG([GRADLE], [gradle])
201  AX_CHECK_ANT_VERSION($ANT, 1.7)
202  AC_SUBST(CLASSPATH)
203  AC_SUBST(ANT_FLAGS)
204  AC_SUBST(GRADLE_OPTS)
205  if test "x$JAVA" != "x" && test "x$JAVAC" != "x" && test "x$ANT" != "x" && test "x$GRADLE" != "x" ; then
206    have_java="yes"
207  fi
208fi
209AM_CONDITIONAL([WITH_JAVA], [test "$have_java" = "yes"])
210
211AX_THRIFT_LIB(kotlin, [Kotlin], yes)
212if test "$with_kotlin" = "yes";  then
213  AX_JAVAC_AND_JAVA
214  AC_PATH_PROG([GRADLE], [gradle])
215  AC_SUBST(CLASSPATH)
216  AC_SUBST(GRADLE_OPTS)
217  if test "x$JAVA" != "x" && test "x$JAVAC" != "x" && "x$GRADLE" != "x" ; then
218    have_kotlin="yes"
219  fi
220fi
221AM_CONDITIONAL([WITH_KOTLIN], [test "$have_kotlin" = "yes"])
222
223AX_THRIFT_LIB(erlang, [Erlang], yes)
224if test "$with_erlang" = "yes";  then
225  AC_ERLANG_PATH_ERL
226  AC_ERLANG_PATH_ERLC
227  AC_PATH_PROG([REBAR], [rebar3])
228  if test -n "$ERLC" ; then
229    AC_ERLANG_SUBST_LIB_DIR
230    # Install into the detected Erlang directory instead of $libdir/erlang/lib
231    ERLANG_INSTALL_LIB_DIR="$ERLANG_LIB_DIR"
232    AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
233  fi
234  if test -n "$ERL" -a -n "$ERLC" && test "x$REBAR" != "x" ; then
235    have_erlang="yes"
236
237  fi
238fi
239AM_CONDITIONAL(WITH_ERLANG, [test "$have_erlang" = "yes"])
240
241AX_THRIFT_LIB(nodejs, [Nodejs], yes)
242have_nodejs=no
243if test "$with_nodejs" = "yes"; then
244  AC_PATH_PROGS([NODEJS], [nodejs node])
245  AC_PATH_PROG([NPM], [npm])
246  if test "x$NODEJS" != "x" -a "x$NPM" != "x"; then
247    have_nodejs="yes"
248  fi
249fi
250AM_CONDITIONAL(WITH_NODEJS, [test "$have_nodejs" = "yes"])
251AM_CONDITIONAL(HAVE_NPM, [test "x$NPM" != "x"])
252
253AX_THRIFT_LIB(nodets, [Nodets], yes)
254have_nodets=no
255if test "$with_nodets" = "yes"; then
256  AC_PATH_PROGS([NODETS], [nodets node])
257  AC_PATH_PROG([NPM], [npm])
258  if test "x$NODETS" != "x" -a "x$NPM" != "x"; then
259    have_nodets="yes"
260  fi
261fi
262AM_CONDITIONAL(WITH_NODETS, [test "$have_nodets" = "yes"])
263AM_CONDITIONAL(HAVE_NPM, [test "x$NPM" != "x"])
264
265AX_THRIFT_LIB(lua, [Lua], yes)
266have_lua=no
267if test "$with_lua" = "yes"; then
268  AX_PROG_LUA(5.2,, have_lua="yes", have_lua="no")
269  if test "$have_lua" = "yes"; then
270    AX_LUA_HEADERS(, have_lua="no")
271    AX_LUA_LIBS(, have_lua="no")
272  fi
273fi
274AM_CONDITIONAL(WITH_LUA, [test "$have_lua" = "yes"])
275
276# Find python regardless of with_python value, because it's needed by make cross
277AM_PATH_PYTHON(2.6,, :)
278AX_THRIFT_LIB(python, [Python], yes)
279if test "$with_python" = "yes";  then
280  if test -n "$PYTHON"; then
281    have_python="yes"
282  fi
283  AC_PATH_PROG([TRIAL], [trial])
284  if test -n "$TRIAL"; then
285    have_trial="yes"
286  fi
287fi
288AM_CONDITIONAL(WITH_PYTHON, [test "$have_python" = "yes"])
289AM_CONDITIONAL(WITH_TWISTED_TEST, [test "$have_trial" = "yes"])
290
291# Find "python3" executable.
292# It's distro specific and far from ideal but needed to cross test py2-3 at once.
293# TODO: find "python2" if it's 3.x
294have_py3="no"
295AX_THRIFT_LIB(py3, [Py3], yes)
296if test "$with_py3" = "yes"; then
297  # if $PYTHON is 2.x then search for python 3. otherwise, $PYTHON is already 3.x
298  if $PYTHON --version 2>&1 | grep -q "Python 2"; then
299    AC_PATH_PROGS([PYTHON3], [python3 python3.8 python38 python3.7 python37 python3.6 python36 python3.5 python35 python3.4 python34])
300    if test -n "$PYTHON3"; then
301      have_py3="yes"
302    fi
303  elif $PYTHON --version 2>&1 | grep -q "Python 3"; then
304    have_py3="yes"
305    PYTHON3=$PYTHON
306  fi
307fi
308AM_CONDITIONAL(WITH_PY3, [test "$have_py3" = "yes"])
309
310AX_THRIFT_LIB(perl, [Perl], yes)
311if test "$with_perl" = "yes"; then
312  AC_PATH_PROG([PERL], [perl])
313  if test -n "$PERL" ; then
314    AC_PROG_PERL_MODULES([Bit::Vector], success="yes", success="no")
315    have_perl_bit_vector="$success"
316    AC_PROG_PERL_MODULES([Class::Accessor], success="yes", success="no")
317    have_perl_class_accessor="$success"
318  fi
319  if test -n "$PERL" -a "$have_perl_bit_vector" = "yes" ; then
320    if test -n "$PERL" -a "$have_perl_class_accessor" = "yes" ; then
321      have_perl="yes"
322    fi
323  fi
324fi
325AM_CONDITIONAL(WITH_PERL, [test "$have_perl" = "yes"])
326
327AX_THRIFT_LIB(php, [PHP], yes)
328if test "$with_php" = "yes"; then
329  AC_PATH_PROG([PHP], [php])
330  if test -n "$PHP" ; then
331    have_php="yes"
332  fi
333fi
334AM_CONDITIONAL(WITH_PHP, [test "$have_php" = "yes"])
335
336AX_THRIFT_LIB(php_extension, [PHP_EXTENSION], yes)
337if test "$with_php_extension" = "yes"; then
338  if test -f "lib/php/src/ext/thrift_protocol/configure"; then
339    AC_PATH_PROG([PHP_CONFIG], [php-config])
340    if test -n "$PHP_CONFIG" ; then
341      AC_CONFIG_SUBDIRS([lib/php/src/ext/thrift_protocol])
342      have_php_extension="yes"
343    fi
344  fi
345fi
346AM_CONDITIONAL(WITH_PHP_EXTENSION, [test "$have_php_extension" = "yes"])
347
348AX_THRIFT_LIB(dart, [DART], yes)
349if test "$with_dart" = "yes"; then
350  AC_PATH_PROG([DART], [dart])
351  AC_PATH_PROG([DARTPUB], [pub])
352  if test "x$DART" != "x" -a "x$DARTPUB" != "x"; then
353    have_dart="yes"
354  fi
355fi
356AM_CONDITIONAL(WITH_DART, [test "$have_dart" = "yes"])
357
358AX_THRIFT_LIB(ruby, [Ruby], yes)
359have_ruby=no
360if test "$with_ruby" = "yes"; then
361  AC_PATH_PROG([RUBY], [ruby])
362  AC_PATH_PROG([BUNDLER], [bundle])
363  if test "x$RUBY" != "x" -a "x$BUNDLER" != "x"; then
364    have_ruby="yes"
365  fi
366fi
367AM_CONDITIONAL(WITH_RUBY, [test "$have_ruby" = "yes"])
368AM_CONDITIONAL(HAVE_BUNDLER, [test "x$BUNDLER" != "x"])
369
370AX_THRIFT_LIB(go, [Go], yes)
371if test "$with_go" = "yes";  then
372  AC_PATH_PROG([GO], [go])
373  if [[ -x "$GO" ]] ; then
374    AS_IF([test -n "$GO"],[
375      ax_go_version="1.4"
376      ax_go17_version="1.7"
377      ax_go118_version="1.18"
378
379      AC_MSG_CHECKING([for Go version])
380      golang_version=`$GO version 2>&1 | $SED -e 's/\(go \)\(version \)\(go\)\(@<:@0-9@:>@.@<:@0-9@:>@.@<:@0-9@:>@\)\(@<:@\*@:>@*\).*/\4/'`
381      AC_MSG_RESULT($golang_version)
382      AC_SUBST([golang_version],[$golang_version])
383      AX_COMPARE_VERSION([$ax_go_version],[le],[$golang_version],[
384      :
385        have_go="yes"
386      ],[
387      :
388        have_go="no"
389      ])
390      AX_COMPARE_VERSION([$golang_version],[lt],[$ax_go17_version],[
391      :
392        go_version_lt_17="yes"
393      ],[
394      :
395        go_version_lt_17="no"
396      ])
397      AX_COMPARE_VERSION([$golang_version],[ge],[$ax_go118_version],[
398      :
399        go_version_ge_118="yes"
400      ],[
401      :
402        go_version_ge_118="no"
403      ])
404    ],[
405      AC_MSG_WARN([could not find Go ])
406      have_go="no"
407    ])
408  fi
409fi
410AM_CONDITIONAL(WITH_GO, [test "$have_go" = "yes"])
411AM_CONDITIONAL([GOVERSION_LT_17], [test "$go_version_lt_17" = "yes"])
412AM_CONDITIONAL([GOVERSION_GE_118], [test "$go_version_ge_118" = "yes"])
413
414AX_THRIFT_LIB(swift, [Swift], yes)
415have_swift="no"
416if test "$with_swift" = "yes"; then
417  AC_PATH_PROG([SWIFT], [swift])
418  if test "x$SWIFT" != "x" -a "x$SWIFT" != "x"; then
419    have_swift="yes"
420  fi
421fi
422AM_CONDITIONAL([WITH_SWIFT], [test "$have_swift" = "yes"])
423
424AX_THRIFT_LIB(rs, [Rust], yes)
425have_rs="no"
426if test "$with_rs" = "yes";  then
427  AC_PATH_PROG([CARGO], [cargo])
428  AC_PATH_PROG([RUSTC], [rustc])
429  if [[ -x "$CARGO" ]] && [[ -x "$RUSTC" ]]; then
430      min_rustc_version="1.13"
431
432      AC_MSG_CHECKING([for rustc version])
433      rustc_version=`$RUSTC --version 2>&1 | $SED -e 's/\(rustc \)\([0-9]\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\2.\3/'`
434      AC_MSG_RESULT($rustc_version)
435      AC_SUBST([rustc_version],[$rustc_version])
436
437      AX_COMPARE_VERSION([$min_rustc_version],[le],[$rustc_version],[
438      :
439        have_rs="yes"
440      ],[
441      :
442        have_rs="no"
443      ])
444  fi
445fi
446AM_CONDITIONAL(WITH_RS, [test "$have_rs" = "yes"])
447
448AX_THRIFT_LIB(cl, [Common Lisp], yes)
449have_cl="no"
450if test "$with_cl" = "yes";  then
451  AC_PATH_PROG([SBCL], [sbcl])
452  if test "x$SBCL" != "x"; then
453    have_cl="yes"
454  fi
455fi
456AM_CONDITIONAL(WITH_CL, [test "$have_cl" = "yes"])
457
458AX_THRIFT_LIB(haxe, [Haxe], yes)
459if test "$with_haxe" = "yes";  then
460  AC_PATH_PROG([HAXE], [haxe])
461  if [[ -x "$HAXE" ]] ; then
462    AX_PROG_HAXE_VERSION( [4.2.1], have_haxe="yes", have_haxe="no")
463  fi
464fi
465AM_CONDITIONAL(WITH_HAXE, [test "$have_haxe" = "yes"])
466
467
468AX_THRIFT_LIB(netstd, [.NET Core], yes)
469if test "$with_netstd" = "yes";  then
470  AC_PATH_PROG([DOTNETCORE], [dotnet])
471  if [[ -x "$DOTNETCORE" ]] ; then
472    AX_PROG_DOTNETCORE_VERSION( [3.1.0], have_netstd="yes", have_netstd="no")
473  fi
474fi
475AM_CONDITIONAL(WITH_DOTNET, [test "$have_netstd" = "yes"])
476
477
478AX_THRIFT_LIB(d, [D], yes)
479if test "$with_d" = "yes";  then
480  AX_DMD
481  AC_SUBST(DMD)
482  if test "x$DMD" != "x"; then
483    have_d="yes"
484  fi
485fi
486
487# Determine actual name of the generated D library for use in the command line
488# when compiling tests. This is needed because the -l<lib> syntax doesn't work
489# with OPTLINK (Windows).
490lib_prefix=lib
491lib_suffix=a
492case "$host_os" in
493  cygwin* | mingw* | pw32* | cegcc*)
494    lib_prefix=""
495    lib_suffix=lib
496    ;;
497esac
498D_LIB_NAME="${lib_prefix}thriftd.${lib_suffix}"
499AC_SUBST(D_LIB_NAME)
500D_EVENT_LIB_NAME="${lib_prefix}thriftd-event.${lib_suffix}"
501AC_SUBST(D_EVENT_LIB_NAME)
502D_SSL_LIB_NAME="${lib_prefix}thriftd-ssl.${lib_suffix}"
503AC_SUBST(D_SSL_LIB_NAME)
504
505if test "$have_d" = "yes"; then
506  AX_CHECK_D_MODULE(deimos.event2.event)
507  have_deimos_event2=$success
508
509  with_d_event_tests="no"
510  if test "$have_deimos_event2" = "yes"; then
511    if test "x$DMD_LIBEVENT_FLAGS" = "x"; then
512      if test "$dmd_optlink" = "yes"; then
513        AC_MSG_WARN([D libevent interface found, but cannot auto-detect \
514linker flags for OPTLINK. Please set DMD_LIBEVENT_FLAGS manually.])
515      else
516        AX_LIB_EVENT([2.0])
517        if test "$success" = "yes"; then
518          DMD_LIBEVENT_FLAGS=$(echo "-fuse-ld=gold $LIBEVENT_LDFLAGS $LIBEVENT_LIBS" | \
519            sed -e 's/^ *//g;s/ *$//g;s/^\(.\)/-L\1/g;s/  */ -L/g')
520          with_d_event_tests="yes"
521        else
522          AC_MSG_WARN([D libevent interface present, but libevent library not found.])
523        fi
524      fi
525    else
526      with_d_event_tests="yes"
527    fi
528  fi
529
530  AX_CHECK_D_MODULE(deimos.openssl.ssl)
531  have_deimos_openssl=$success
532
533  with_d_ssl_tests="no"
534  if test "$have_deimos_openssl" = "yes"; then
535    if test "x$DMD_OPENSSL_FLAGS" = "x"; then
536      if test "$dmd_optlink" = "yes"; then
537        AC_MSG_WARN([D OpenSSL interface found, but cannot auto-detect \
538linker flags for OPTLINK. Please set DMD_OPENSSL_FLAGS manually.])
539      else
540        AX_CHECK_OPENSSL([with_d_ssl_tests="yes"])
541        if test "$with_d_ssl_tests" = "yes"; then
542          DMD_OPENSSL_FLAGS=$(echo "-fuse-ld=gold $OPENSSL_LDFLAGS $OPENSSL_LIBS" | \
543            sed -e 's/^ *//g;s/ *$//g;s/^\(.\)/-L\1/g;s/  */ -L/g')
544        else
545          AC_MSG_WARN([D OpenSSL interface present, but OpenSSL library not found.])
546        fi
547      fi
548    else
549      with_d_ssl_tests="yes"
550    fi
551  fi
552fi
553
554AM_CONDITIONAL(WITH_D, [test "$have_d" = "yes"])
555AM_CONDITIONAL(DMD_OPTLINK, [test "$dmd_optlink" = "yes"])
556AC_SUBST(DMD_OF_DIRSEP, "$dmd_of_dirsep")
557AM_CONDITIONAL(HAVE_DEIMOS_EVENT2, [test "$have_deimos_event2" = "yes"])
558AM_CONDITIONAL(WITH_D_EVENT_TESTS, [test "$with_d_event_tests" = "yes"])
559AC_SUBST(DMD_LIBEVENT_FLAGS)
560AM_CONDITIONAL(HAVE_DEIMOS_OPENSSL, [test "$have_deimos_openssl" = "yes"])
561AM_CONDITIONAL(WITH_D_SSL_TESTS, [test "$with_d_ssl_tests" = "yes"])
562AC_SUBST(DMD_OPENSSL_FLAGS)
563
564AC_ARG_ENABLE([tests],
565  AS_HELP_STRING([--enable-tests], [build tests [default=yes]]),
566  [], enable_tests=yes
567)
568have_tests=yes
569if test "$enable_tests" = "no"; then
570  have_tests="no"
571fi
572AM_CONDITIONAL(WITH_TESTS, [test "$have_tests" = "yes"])
573
574AC_ARG_ENABLE([tutorial],
575  AS_HELP_STRING([--enable-tutorial], [build tutorial [default=yes]]),
576  [], enable_tutorial=yes
577)
578have_tutorial=yes
579if test "$enable_tutorial" = "no"; then
580  have_tutorial="no"
581fi
582AM_CONDITIONAL(WITH_TUTORIAL, [test "$have_tutorial" = "yes"])
583
584AM_CONDITIONAL(MINGW, false)
585case "${host_os}" in
586*mingw*)
587  mingw32_support="yes"
588  AC_CHECK_HEADER(windows.h)
589  AM_CONDITIONAL(MINGW, true)
590  ;;
591*)
592  AC_ISC_POSIX
593  ;;
594esac
595
596AC_C_CONST
597AC_C_INLINE
598AC_C_VOLATILE
599
600AC_HEADER_STDBOOL
601AC_HEADER_STDC
602AC_HEADER_TIME
603AC_HEADER_SYS_WAIT
604AC_TYPE_SIGNAL
605AC_CHECK_HEADERS([arpa/inet.h])
606AC_CHECK_HEADERS([fcntl.h])
607AC_CHECK_HEADERS([inttypes.h])
608AC_CHECK_HEADERS([libintl.h])
609AC_CHECK_HEADERS([limits.h])
610AC_CHECK_HEADERS([malloc.h])
611AC_CHECK_HEADERS([netdb.h])
612AC_CHECK_HEADERS([netinet/in.h])
613AC_CHECK_HEADERS([openssl/rand.h])
614AC_CHECK_HEADERS([openssl/ssl.h])
615AC_CHECK_HEADERS([openssl/x509v3.h])
616AC_CHECK_HEADERS([poll.h])
617AC_CHECK_HEADERS([pthread.h])
618AC_CHECK_HEADERS([sched.h])
619AC_CHECK_HEADERS([signal.h])
620AC_CHECK_HEADERS([stddef.h])
621AC_CHECK_HEADERS([stdint.h])
622AC_CHECK_HEADERS([stdlib.h])
623AC_CHECK_HEADERS([strings.h])
624AC_CHECK_HEADERS([sys/ioctl.h])
625AC_CHECK_HEADERS([sys/param.h])
626AC_CHECK_HEADERS([sys/poll.h])
627AC_CHECK_HEADERS([sys/resource.h])
628AC_CHECK_HEADERS([sys/socket.h])
629AC_CHECK_HEADERS([sys/time.h])
630AC_CHECK_HEADERS([sys/un.h])
631AC_CHECK_HEADERS([unistd.h])
632AC_CHECK_HEADERS([wchar.h])
633
634AC_CHECK_LIB(pthread, pthread_create)
635dnl NOTE(dreiss): I haven't been able to find any really solid docs
636dnl on what librt is and how it fits into various Unix systems.
637dnl My best guess is that it is where glibc stashes its implementation
638dnl of the POSIX Real-Time Extensions.  This seems necessary on Linux,
639dnl and we haven't yet found a system where this is a problem.
640AC_CHECK_LIB(rt, clock_gettime)
641AC_CHECK_LIB(socket, setsockopt)
642
643AC_TYPE_INT16_T
644AC_TYPE_INT32_T
645AC_TYPE_INT64_T
646AC_TYPE_INT8_T
647AC_TYPE_MODE_T
648AC_TYPE_OFF_T
649AC_TYPE_SIZE_T
650AC_TYPE_SSIZE_T
651AC_TYPE_UINT16_T
652AC_TYPE_UINT32_T
653AC_TYPE_UINT64_T
654AC_TYPE_UINT8_T
655AC_CHECK_TYPES([ptrdiff_t], [], [echo "ptrdiff_t not found or g++ not installed - cannot continue" && exit 1])
656
657AC_STRUCT_TM
658
659dnl NOTE(dreiss): AI_ADDRCONFIG is not defined on OpenBSD.
660AC_CHECK_DECL([AI_ADDRCONFIG], [],
661              [AC_DEFINE([AI_ADDRCONFIG], 0,
662                         [Define if the AI_ADDRCONFIG symbol is unavailable])],
663              [
664  #include <sys/types.h>
665  #include <sys/socket.h>
666  #include <netdb.h>
667])
668
669AC_FUNC_ALLOCA
670AC_FUNC_FORK
671AC_FUNC_MALLOC
672AC_FUNC_MEMCMP
673AC_FUNC_REALLOC
674AC_FUNC_SELECT_ARGTYPES
675AC_FUNC_STAT
676AC_FUNC_STRERROR_R
677AC_FUNC_STRFTIME
678AC_FUNC_VPRINTF
679AC_CHECK_FUNCS([strtoul])
680AC_CHECK_FUNCS([bzero])
681AC_CHECK_FUNCS([ftruncate])
682AC_CHECK_FUNCS([gethostbyname])
683AC_CHECK_FUNCS([gethostbyname_r])
684AC_CHECK_FUNCS([gettimeofday])
685AC_CHECK_FUNCS([memmove])
686AC_CHECK_FUNCS([memset])
687AC_CHECK_FUNCS([mkdir])
688AC_CHECK_FUNCS([realpath])
689AC_CHECK_FUNCS([select])
690AC_CHECK_FUNCS([setlocale])
691AC_CHECK_FUNCS([socket])
692AC_CHECK_FUNCS([strchr])
693AC_CHECK_FUNCS([strdup])
694AC_CHECK_FUNCS([strerror])
695AC_CHECK_FUNCS([strstr])
696AC_CHECK_FUNCS([strtol])
697AC_CHECK_FUNCS([sqrt])
698dnl The following functions are optional.
699AC_CHECK_FUNCS([alarm])
700AC_CHECK_FUNCS([clock_gettime])
701AC_CHECK_FUNCS([sched_get_priority_min])
702AC_CHECK_FUNCS([sched_get_priority_max])
703AC_CHECK_FUNCS([inet_ntoa])
704AC_CHECK_FUNCS([pow])
705
706if test "$cross_compiling" = "no" ; then
707  AX_SIGNED_RIGHT_SHIFT
708fi
709
710dnl autoscan thinks we need this macro because we have a member function
711dnl called "error".  Invoke the macro but don't run the check so autoscan
712dnl thinks we are in the clear.  It's highly unlikely that we will ever
713dnl actually use the function that this checks for.
714if false ; then
715  AC_FUNC_ERROR_AT_LINE
716fi
717
718# --- Coverage hooks ---
719
720AC_ARG_ENABLE(coverage,
721              [  --enable-coverage      turn on -fprofile-arcs -ftest-coverage],
722              [case "${enableval}" in
723                yes) ENABLE_COVERAGE=1 ;;
724                no) ENABLE_COVERAGE=0 ;;
725                *) AC_MSG_ERROR(bad value ${enableval} for --enable-cov) ;;
726              esac],
727              [ENABLE_COVERAGE=2])
728
729if test "x[$]ENABLE_COVERAGE" = "x1"; then
730  AC_MSG_WARN(enable coverage)
731  GCOV_CFLAGS="`echo \"[$]CFLAGS\" | perl -pe 's/-O\d+//g;'` -fprofile-arcs -ftest-coverage"
732  GCOV_CXXFLAGS="`echo \"[$]CXXFLAGS\" | perl -pe 's/-O\d+//g;'` -fprofile-arcs -ftest-coverage"
733  GCOV_LDFLAGS="-XCClinker -fprofile-arcs -XCClinker -ftest-coverage"
734fi
735
736AC_SUBST(ENABLE_COVERAGE)
737AC_SUBST(GCOV_CFLAGS)
738AC_SUBST(GCOV_CXXFLAGS)
739AC_SUBST(GCOV_LDFLAGS)
740
741AC_CONFIG_HEADERS(config.h:config.hin)
742AC_CONFIG_HEADERS(lib/cpp/src/thrift/config.h:config.hin)
743AC_CONFIG_HEADERS(lib/c_glib/src/thrift/config.h:config.hin)
744# guard against pre defined config.h
745AH_TOP([
746#ifndef CONFIG_H
747#define CONFIG_H
748])
749AH_BOTTOM([
750#endif
751])
752
753
754AC_CONFIG_FILES([
755  Makefile
756  compiler/cpp/Makefile
757  compiler/cpp/src/Makefile
758  compiler/cpp/test/Makefile
759  lib/Makefile
760  lib/cl/Makefile
761  lib/cpp/Makefile
762  lib/cpp/test/Makefile
763  lib/cpp/thrift-nb.pc
764  lib/cpp/thrift-z.pc
765  lib/cpp/thrift-qt5.pc
766  lib/cpp/thrift.pc
767  lib/c_glib/Makefile
768  lib/c_glib/thrift_c_glib.pc
769  lib/c_glib/test/Makefile
770  lib/d/Makefile
771  lib/d/test/Makefile
772  lib/erl/Makefile
773  lib/go/Makefile
774  lib/go/test/Makefile
775  lib/go/test/fuzz/Makefile
776  lib/haxe/test/Makefile
777  lib/java/Makefile
778  lib/js/Makefile
779  lib/js/test/Makefile
780  lib/json/Makefile
781  lib/json/test/Makefile
782  lib/kotlin/Makefile
783  lib/netstd/Makefile
784  lib/nodejs/Makefile
785  lib/nodets/Makefile
786  lib/perl/Makefile
787  lib/perl/t/Makefile
788  lib/php/Makefile
789  lib/php/test/Makefile
790  lib/dart/Makefile
791  lib/py/Makefile
792  lib/rb/Makefile
793  lib/rs/Makefile
794  lib/rs/test/Makefile
795  lib/rs/test_recursive/Makefile
796  lib/rs/test_recursive/src/Makefile
797  lib/rs/test_recursive/src/maintenance/Makefile
798  lib/rs/test_recursive/src/transit/Makefile
799  lib/rs/test_recursive/src/transit/light/Makefile
800  lib/rs/test_recursive/src/transit/services/Makefile
801  lib/lua/Makefile
802  lib/swift/Makefile
803  lib/ts/Makefile
804  lib/xml/Makefile
805  lib/xml/test/Makefile
806  test/Makefile
807  test/features/Makefile
808  test/c_glib/Makefile
809  test/cl/Makefile
810  test/cpp/Makefile
811  test/erl/Makefile
812  test/go/Makefile
813  test/haxe/Makefile
814  test/lua/Makefile
815  test/netstd/Makefile
816  test/php/Makefile
817  test/dart/Makefile
818  test/perl/Makefile
819  test/py/Makefile
820  test/py.twisted/Makefile
821  test/py.tornado/Makefile
822  test/rb/Makefile
823  test/rs/Makefile
824  test/swift/Makefile
825  test/swift/CrossTests/Makefile
826  tutorial/Makefile
827  tutorial/c_glib/Makefile
828  tutorial/cl/Makefile
829  tutorial/cpp/Makefile
830  tutorial/d/Makefile
831  tutorial/go/Makefile
832  tutorial/haxe/Makefile
833  tutorial/java/Makefile
834  tutorial/js/Makefile
835  tutorial/netstd/Makefile
836  tutorial/nodejs/Makefile
837  tutorial/dart/Makefile
838  tutorial/perl/Makefile
839  tutorial/php/Makefile
840  tutorial/py/Makefile
841  tutorial/py.twisted/Makefile
842  tutorial/py.tornado/Makefile
843  tutorial/rb/Makefile
844  tutorial/rs/Makefile
845  tutorial/swift/Makefile
846])
847
848if test "$have_cpp" = "yes" ; then MAYBE_CPP="cpp" ; else MAYBE_CPP="" ; fi
849AC_SUBST([MAYBE_CPP])
850if test "$have_c_glib" = "yes" ; then MAYBE_C_GLIB="c_glib" ; else MAYBE_C_GLIB="" ; fi
851AC_SUBST([MAYBE_C_GLIB])
852if test "$have_d" = "yes" -a "$have_deimos_event2" = "yes" -a "$have_deimos_openssl" = "yes"; then MAYBE_D="d" ; else MAYBE_D="" ; fi
853AC_SUBST([MAYBE_D])
854if test "$have_java" = "yes" ; then MAYBE_JAVA="java" ; else MAYBE_JAVA="" ; fi
855AC_SUBST([MAYBE_JAVA])
856if test "$have_kotlin" = "yes" ; then MAYBE_KOTLIN="kotlin" ; else MAYBE_KOTLIN="" ; fi
857AC_SUBST([MAYBE_KOTLIN])
858if test "$have_python" = "yes" ; then MAYBE_PYTHON="py" ; else MAYBE_PYTHON="" ; fi
859AC_SUBST([MAYBE_PYTHON])
860if test "$have_py3" = "yes" ; then MAYBE_PY3="py3" ; else MAYBE_PY3="" ; fi
861AC_SUBST([MAYBE_PY3])
862if test "$have_ruby" = "yes" ; then MAYBE_RUBY="rb" ; else MAYBE_RUBY="" ; fi
863AC_SUBST([MAYBE_RUBY])
864if test "$have_perl" = "yes" ; then MAYBE_PERL="perl" ; else MAYBE_PERL="" ; fi
865AC_SUBST([MAYBE_PERL])
866if test "$have_php" = "yes" ; then MAYBE_PHP="php" ; else MAYBE_PHP="" ; fi
867AC_SUBST([MAYBE_PHP])
868if test "$have_dart" = "yes" ; then MAYBE_DART="dart" ; else MAYBE_DART="" ; fi
869AC_SUBST([MAYBE_DART])
870if test "$have_go" = "yes" ; then MAYBE_GO="go" ; else MAYBE_GO="" ; fi
871AC_SUBST([MAYBE_GO])
872if test "$have_nodejs" = "yes" ; then MAYBE_NODEJS="nodejs" ; else MAYBE_NODEJS="" ; fi
873AC_SUBST([MAYBE_NODEJS])
874if test "$have_nodets" = "yes" ; then MAYBE_NODETS="nodets" ; else MAYBE_NODETS="" ; fi
875AC_SUBST([MAYBE_NODETS])
876if test "$have_erlang" = "yes" ; then MAYBE_ERLANG="erl" ; else MAYBE_ERLANG="" ; fi
877AC_SUBST([MAYBE_ERLANG])
878if test "$have_lua" = "yes" ; then MAYBE_LUA="lua" ; else MAYBE_LUA="" ; fi
879AC_SUBST([MAYBE_LUA])
880if test "$have_rs" = "yes" ; then MAYBE_RS="rs" ; else MAYBE_RS="" ; fi
881AC_SUBST([MAYBE_RS])
882if test "$have_swift" = "yes" ; then MAYBE_SWIFT="swift" ; else MAYBE_SWIFT="" ; fi
883AC_SUBST([MAYBE_SWIFT])
884if test "$have_netstd" = "yes" ; then MAYBE_NETSTD="netstd" ; else MAYBE_NETSTD="" ; fi
885AC_SUBST([MAYBE_NETSTD])
886if test "$have_cl" = "yes" ; then MAYBE_CL="cl" ; else MAYBE_CL="" ; fi
887AC_SUBST([MAYBE_CL])
888
889AC_OUTPUT
890
891
892echo
893echo "$PACKAGE $VERSION"
894echo
895echo "Building C (GLib) Library .... : $have_c_glib"
896echo "Building C++ Library ......... : $have_cpp"
897echo "Building Common Lisp Library.. : $have_cl"
898echo "Building D Library ........... : $have_d"
899echo "Building Dart Library ........ : $have_dart"
900echo "Building .NET Standard Library : $have_netstd"
901echo "Building Erlang Library ...... : $have_erlang"
902echo "Building Go Library .......... : $have_go"
903echo "Building Haxe Library ........ : $have_haxe"
904echo "Building Java Library ........ : $have_java"
905echo "Building Kotlin Library ...... : $have_kotlin"
906echo "Building Lua Library ......... : $have_lua"
907echo "Building NodeJS Library ...... : $have_nodejs"
908echo "Building Perl Library ........ : $have_perl"
909echo "Building PHP Library ......... : $have_php"
910echo "Building Python Library ...... : $have_python"
911echo "Building Py3 Library ......... : $have_py3"
912echo "Building Ruby Library ........ : $have_ruby"
913echo "Building Rust Library ........ : $have_rs"
914echo "Building Swift Library ....... : $have_swift"
915
916if test "$have_c_glib" = "yes" ; then
917  echo
918  echo "C (glib):"
919  echo "   Using glib version ........ : $($GSETTINGS --version)"
920fi
921if test "$have_cpp" = "yes" ; then
922  echo
923  echo "C++ Library:"
924  echo "   C++ compiler .............. : $CXX"
925  echo "   Build TZlibTransport ...... : $have_zlib"
926  echo "   Build TNonblockingServer .. : $have_libevent"
927  echo "   Build TQTcpServer (Qt5) ... : $have_qt5"
928  echo "   C++ compiler version ...... : $($CXX --version | head -1)"
929fi
930if test "$have_cl" = "yes" ; then
931  echo
932  echo "Common Lisp Library:"
933  echo "   Using Common Lisp ......... : $SBCL"
934  echo "   Using Common Lisp version . : $($SBCL --version)"
935fi
936if test "$have_d" = "yes" ; then
937  echo
938  echo "D Library:"
939  echo "   Using D Compiler .......... : $DMD"
940  echo "   Building D libevent tests . : $with_d_event_tests"
941  echo "   Building D SSL tests ...... : $with_d_ssl_tests"
942  echo "   Using D version ........... : $($DMD --version | head -1)"
943fi
944if test "$have_dart" = "yes" ; then
945  echo
946  echo "Dart Library:"
947  echo "   Using Dart ................ : $DART"
948  echo "   Using Pub ................. : $DARTPUB"
949  echo "   Using Dart version ........ : $($DART --version 2>&1)"
950fi
951if test "$have_netstd" = "yes" ; then
952  echo
953  echo ".NET Standard Library:"
954  echo "   Using dotnet .............. : $DOTNETCORE"
955  echo "   Using dotnet version ...... : $DOTNETCORE_VERSION"
956fi
957if test "$have_erlang" = "yes" ; then
958  echo
959  echo "Erlang Library:"
960  echo "   Using erlc ................ : $ERLC"
961  echo "   Using rebar ............... : $REBAR"
962  echo "   Using erlc version ........ : $($ERL -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell | tr -d '\"')"
963fi
964if test "$have_go" = "yes" ; then
965  echo
966  echo "Go Library:"
967  echo "   Using Go................... : $GO"
968  echo "   Using Go version........... : $($GO version)"
969fi
970if test "$have_haxe" = "yes" ; then
971  echo
972  echo "Haxe Library:"
973  echo "   Using Haxe ................ : $HAXE"
974  echo "   Using Haxe version ........ : $HAXE_VERSION"
975fi
976if test "$have_java" = "yes" ; then
977  echo
978  echo "Java Library:"
979  echo "   Using gradle .............. : $GRADLE"
980  echo "   Using java ................ : $JAVA"
981  echo "   Using javac ............... : $JAVAC"
982  echo "   Using Gradle version ...... : $($GRADLE --version --quiet | grep Gradle 2>&1)"
983  echo "   Using java version ........ : $($JAVA -version 2>&1 | grep 'version ')"
984fi
985if test "$have_kotlin" = "yes" ; then
986  echo
987  echo "Kotlin (Test Only) Library:"
988  echo "   Using gradle .............. : $GRADLE"
989  echo "   Using java ................ : $JAVA"
990  echo "   Using javac ............... : $JAVAC"
991  echo "   Using Gradle version ...... : $($GRADLE --version --quiet | grep Gradle 2>&1)"
992  echo "   Using java version ........ : $($JAVA -version 2>&1 | grep 'version ')"
993fi
994if test "$have_lua" = "yes" ; then
995  echo
996  echo "Lua Library:"
997  echo "   Using Lua ................. : $LUA"
998  echo "   Using Lua version.......... : $($LUA -v)"
999fi
1000if test "$have_nodejs" = "yes" ; then
1001  echo
1002  echo "NodeJS Library:"
1003  echo "   Using NodeJS .............. : $NODEJS"
1004  echo "   Using NodeJS version....... : $($NODEJS --version)"
1005fi
1006if test "$have_perl" = "yes" ; then
1007  echo
1008  echo "Perl Library:"
1009  echo "   Using Perl ................ : $PERL"
1010  echo "   Using Perl version ........ : $($PERL -v | grep 'version ')"
1011fi
1012if test "$have_php" = "yes" ; then
1013  echo
1014  echo "PHP Library:"
1015  echo "   Using php-config .......... : $PHP_CONFIG"
1016  echo "   Using php version ......... : $($PHP --version | head -1)"
1017fi
1018if test "$have_python" = "yes" ; then
1019  echo
1020  echo "Python Library:"
1021  echo "   Using Python .............. : $PYTHON"
1022  echo "   Using Python version ...... : $($PYTHON --version 2>&1)"
1023  if test "$have_py3" = "yes" ; then
1024  echo "   Using Python3 ............. : $PYTHON3"
1025  echo "   Using Python3 version ..... : $($PYTHON3 --version)"
1026  fi
1027  if test "$have_trial" = "yes"; then
1028  echo "   Using trial ............... : $TRIAL"
1029  fi
1030fi
1031if test "$have_ruby" = "yes" ; then
1032  echo
1033  echo "Ruby Library:"
1034  echo "   Using Ruby ................ : $RUBY"
1035  echo "   Using Ruby version ........ : $($RUBY --version)"
1036fi
1037if test "$have_rs" = "yes" ; then
1038  echo
1039  echo "Rust Library:"
1040  echo "   Using Cargo................ : $CARGO"
1041  echo "   Using rustc................ : $RUSTC"
1042  echo "   Using Rust version......... : $($RUSTC --version)"
1043fi
1044if test "$have_swift" = "yes" ; then
1045  echo
1046  echo "Swift Library:"
1047  echo "   Using Swift ............... : $SWIFT"
1048  echo "   Using Swift version ....... : $($SWIFT --version | head -1)"
1049fi
1050echo
1051echo "If something is missing that you think should be present,"
1052echo "please skim the output of configure to find the missing"
1053echo "component.  Details are present in config.log."
1054echo
1055