1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.59])
5
6AC_INIT([QuickFIX], [1.14.3], [ask@quickfixengine.org])
7AC_CONFIG_MACRO_DIR([m4])
8m4_include([m4/ax_lib_mysql.m4])
9m4_include([m4/ax_lib_postgresql.m4])
10m4_include([m4/ax_lib_boost.m4])
11m4_include([m4/ax_lib_stlport.m4])
12m4_include([m4/ax_lib_ssl.m4])
13m4_include([m4/ax_allocator.m4])
14m4_include([m4/ax_python.m4])
15m4_include([m4/ax_ruby.m4])
16m4_include([m4/ax_java.m4])
17AC_CONFIG_SRCDIR([src/ut.cpp])
18AC_CONFIG_HEADERS([config.h])
19AC_CONFIG_AUX_DIR([config])
20AM_INIT_AUTOMAKE
21
22# Checks for programs.
23AC_PROG_CXX
24AC_PROG_CC
25AC_PROG_CPP
26AC_DISABLE_STATIC
27AC_LIBTOOL_WIN32_DLL
28AM_PROG_LIBTOOL
29AM_PROG_LEX
30
31AX_LIB_MYSQL()
32AX_LIB_POSTGRESQL()
33AX_LIB_BOOST()
34AX_LIB_STLPORT()
35AX_LIB_SSL()
36AX_ALLOCATOR()
37AX_PYTHON()
38AX_RUBY()
39AX_JAVA()
40
41########################################
42# Disable unit tests on Solaris, AIX
43
44AC_CANONICAL_HOST
45
46build_no_unit_test = no
47
48# Detect the target system
49case "${host_os}" in
50    *sunos*)
51        build_no_unit_test=yes
52        ;;
53    *solaris*)
54        build_no_unit_test=yes
55        ;;
56    *aix*)
57        build_no_unit_test=yes
58        ;;
59    *)
60        ;;
61esac
62
63# Pass the conditionals to automake
64AM_CONDITIONAL([NO_UNIT_TEST], [test "$build_no_unit_test" = "yes"])
65
66########################################
67
68########################################
69# TBB
70########################################
71has_tbb=false
72AC_ARG_WITH(tbb,
73    [  --with-tbb=<path>       prefix of Intel Thread Building Blocks (TBB) installation. e.g. /opt/intel/tbb/3.0],
74    [if test $withval == "no"
75     then
76       has_tbb=false
77     else
78       has_tbb=true
79     fi],
80    has_tbb=false
81)
82TBB_PREFIX=$with_tbb
83AC_SUBST(TBB_PREFIX)
84
85has_tbb_arch=false
86AC_ARG_WITH(tbb-arch,
87    [  --with-tbb-arch=<arch>  TBB arch subdir, e.g. intel64/cc4.1.0_libc2.4_kernel2.6.16.21 ],
88    [if test $withval == "no"
89     then
90       has_tbb_arch=false
91     else
92       has_tbb_arch=true
93     fi],
94    has_tbb_arch=false
95)
96TBB_ARCH=$with_tbb_arch
97AC_SUBST(TBB_ARCH)
98
99if test $has_tbb = true
100then
101    TBB_CFLAGS="-I${TBB_PREFIX}"
102    AC_SUBST(TBB_CFLAGS)
103    TBB_LIBS="-L${TBB_PREFIX}/${TBB_ARCH} -ltbbmalloc"
104    AC_SUBST(TBB_LIBS)
105    AC_DEFINE(HAVE_TBB, 1, Define if you have Intel TBB framework)
106fi
107########################################
108
109# libs
110LIBS="$OPENSSL_LIBS $STLPORT_LIBS $XML_LIBS $MYSQL_LIBS $POSTGRESQL_LDFLAGS $TBB_LIBS $LIBS"
111# gcc flags
112if test `uname` == SunOS; then
113   	SHAREDFLAGS="$TBB_CFLAGS $BOOST_CFLAGS $STLPORT_CFLAGS $MYSQL_CFLAGS $POSTGRESQL_CFLAGS $XML_CPPFLAGS $XML_CFLAGS $JAVA_CFLAGS $RUBY_CFLAGS"
114else
115  if test `uname` == AIX; then
116   	SHAREDFLAGS="$TBB_CFLAGS $BOOST_CFLAGS $STLPORT_CFLAGS $MYSQL_CFLAGS $POSTGRESQL_CFLAGS $XML_CPPFLAGS $XML_CFLAGS $JAVA_CFLAGS $PYTHON_CFLAGS $RUBY_CFLAGS"
117  else
118    SHAREDFLAGS="-Wall -ansi -Wno-unused-command-line-argument -Wpointer-arith -Wwrite-strings -Wno-overloaded-virtual -Wno-deprecated-declarations -Wno-deprecated $TBB_CFLAGS $BOOST_CFLAGS $STLPORT_CFLAGS $MYSQL_CFLAGS $POSTGRESQL_CFLAGS $XML_CPPFLAGS $XML_CFLAGS $PYTHON_CFLAGS $RUBY_CFLAGS"
119  fi
120fi
121
122CFLAGS="$CFLAGS $SHAREDFLAGS"
123AC_SUBST(CFLAGS)
124
125if test "x$NO_MODERN_CPP" != "x"; then
126CXXFLAGS="$CXXFLAGS $SHAREDFLAGS"
127else
128CXXFLAGS="$CXXFLAGS $SHAREDFLAGS -std=c++0x"
129fi
130AC_SUBST(CXXFLAGS)
131
132
133# Checks for libraries.
134AC_CHECK_LIB(c,shutdown,true,AC_CHECK_LIB(socket,shutdown))
135AC_CHECK_LIB(c,inet_addr,true,AC_CHECK_LIB(nsl,inet_addr))
136AC_CHECK_LIB(c,nanosleep,true,AC_CHECK_LIB(rt,nanosleep))
137AC_CHECK_LIB(compat,ftime)
138AC_CHECK_FUNC([clock_gettime], [AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
139                               [Define if clock_gettime exists.])])
140AC_CHECK_FUNC([clock_get_time], [AC_DEFINE([__MACH__], [1],
141                               [Define if clock_get_time exists.])])
142
143AC_MSG_CHECKING([which threading environment to use])
144# each host OS needs special threading flags
145case $build_os in
146	freebsd*|netbsd*)
147		LIBS="-pthread $LIBS"
148		AC_MSG_RESULT([-pthread])
149		;;
150	linux-*)
151		AC_MSG_RESULT([-lpthread])
152		AC_CHECK_LIB(pthread, pthread_create)
153		;;
154	solaris*)
155		AC_MSG_RESULT([-lpthread])
156		AC_CHECK_LIB(pthread, pthread_create)
157		;;
158	*)
159		# maybe we have a usable libc for other OSes
160		AC_MSG_RESULT([-lc_r])
161		AC_CHECK_LIB(c_r, pthread_create)
162		;;
163esac
164
165# Checks for header files.
166AC_CHECK_HEADERS([stdio.h])
167
168# Checks for typedefs, structures, and compiler characteristics.
169
170
171AC_LANG_SAVE
172AC_LANG_CPLUSPLUS
173
174AC_MSG_CHECKING(for STREAMS ioctl)
175AC_TRY_COMPILE(
176	[#include <sys/types.h>
177	 #include <stropts.h>
178	 #include <sys/conf.h>],
179	[ioctl(1,I_NREAD);],
180	AC_MSG_RESULT(yes)
181	AC_DEFINE(USING_STREAMS, 1,
182	The system supports AT&T STREAMS, presumably standard),
183	AC_MSG_RESULT(no))
184
185AC_MSG_CHECKING(for socklen_t)
186AC_TRY_COMPILE(
187	[#include <unistd.h>
188         #include <sys/types.h>
189         #include <sys/socket.h>],
190	[socklen_t t = 1;],
191	AC_MSG_RESULT(yes),
192	AC_MSG_RESULT(no)
193	AC_DEFINE(socklen_t, int,
194	socklen_t needs to be defined if the system doesn't define it))
195
196AC_MSG_CHECKING(for ftime)
197AC_TRY_COMPILE(
198	[#include <sys/timeb.h>],
199	[timeb tb;
200         ftime(&tb)],
201	has_ftime=false, has_ftime=false)
202
203if test $has_ftime = true
204then AC_MSG_RESULT(yes)
205     AC_DEFINE(HAVE_FTIME, 1, found ftime)
206else AC_MSG_RESULT(no)
207fi
208AM_CONDITIONAL(HAVE_FTIME, $has_ftime)
209
210AC_MSG_CHECKING(for set_terminate in the global namespace)
211AC_TRY_COMPILE(
212	[#include <exception>
213	 void term() {}],
214	[set_terminate(term);],
215         set_terminate_is_global=true, set_terminate_is_global=false)
216
217if test $set_terminate_is_global = true
218then AC_MSG_RESULT(yes)
219else AC_MSG_RESULT(no)
220    AC_MSG_CHECKING(for set_terminate in the std namespace)
221    AC_TRY_COMPILE(
222    [#include <exception>
223     void term() {}],
224    [std::set_terminate(term);],
225    AC_MSG_RESULT(yes)
226    AC_DEFINE(TERMINATE_IN_STD, 1,
227    For location of set_terminate),
228    AC_MSG_RESULT(no)
229    AC_MSG_ERROR(unable to find set_terminate in std or global namespace))
230fi
231
232AC_MSG_CHECKING(for std::tr1::shared_ptr)
233AC_TRY_COMPILE(
234	[#include <tr1/memory>],
235	[std::tr1::shared_ptr<int> ptr;],
236	AC_MSG_RESULT(yes)
237	AC_DEFINE(HAVE_STD_TR1_SHARED_PTR, 1,
238	The system supports std::tr1::shared_ptr),
239	AC_MSG_RESULT(no))
240
241AC_MSG_CHECKING(for std::shared_ptr)
242AC_TRY_COMPILE(
243	[#include <memory>],
244	[std::shared_ptr<int> ptr;],
245	AC_MSG_RESULT(yes)
246	AC_DEFINE(HAVE_STD_SHARED_PTR, 1,
247	The system supports std::shared_ptr),
248	AC_MSG_RESULT(no))
249
250AC_MSG_CHECKING(for boost::shared_ptr)
251AC_TRY_COMPILE(
252        [#include <boost/shared_ptr.hpp>],
253        [boost::shared_ptr<int> ptr;],
254        AC_MSG_RESULT(yes)
255        AC_DEFINE(HAVE_BOOST_SHARED_PTR, 1,
256        The system supports boost::shared_ptr),
257        AC_MSG_RESULT(no))
258
259AC_MSG_CHECKING(for typeinfo in the global namespace)
260AC_TRY_COMPILE(
261	[#include <typeinfo>],
262	[const typeinfo& ty = typeid(typeinfo);],
263	typeinfo_is_global=true, typeinfo_is_global=false)
264
265if test $typeinfo_is_global = true
266then AC_MSG_RESULT(yes)
267else AC_MSG_RESULT(no)
268    AC_MSG_CHECKING(for typeinfo in the std namespace)
269    AC_TRY_COMPILE(
270    [#include <typeinfo>],
271    [const std::type_info& ty = typeid(std::type_info);],
272    AC_MSG_RESULT(yes)
273    AC_DEFINE(TYPEINFO_IN_STD, 1,
274    Whether or not we are using the new-style typeinfo header),
275    AC_MSG_RESULT(no)
276    AC_MSG_ERROR(type_info is required by the test library))
277fi
278
279# check for gethostbyname_r
280AC_MSG_CHECKING(for gethostbyname_r with input result)
281AC_TRY_COMPILE(
282	[#include <netdb.h>],
283	[const char* name = "localhost";
284         hostent host;
285         char buf[1024];
286         hostent* host_ptr;
287         int error;
288         gethostbyname_r( name, &host, buf, sizeof(buf), &host_ptr, &error );
289	 return 0;],
290	 AC_MSG_RESULT(yes)
291	 AC_DEFINE(GETHOSTBYNAME_R_INPUTS_RESULT, 1,
292	 The system has gethostbyname_r which takes a result as a pass-in param),
293	 AC_MSG_RESULT(no))
294
295AC_DEFINE(_REENTRANT, 1, enable reentrant system calls)
296
297# Checks for library functions.
298AC_LANG_RESTORE
299
300AC_CHECK_LIB(iberty, cplus_demangle,
301  AC_DEFINE(HAVE_CPLUS_DEMANGLE,1,whether or not we have to demangle names)
302  LIBS="$LIBS -liberty")
303
304# Checks for runtime behavior
305AC_MSG_CHECKING(if select modifies timeval parameter)
306AC_TRY_RUN(
307[
308#include <unistd.h>
309#include <sys/types.h>
310#include <sys/time.h>
311int main(int argc, char** argv)
312{
313  struct timeval tv;
314  tv.tv_sec = 0;
315  tv.tv_usec = 1;
316  select(0,0,0,0,&tv);
317  return tv.tv_usec != 1 ? 0 : 1;
318}
319],
320AC_MSG_RESULT(yes)
321AC_DEFINE(SELECT_MODIFIES_TIMEVAL, 1,
322select statement decrements timeval parameter if interupted),
323AC_MSG_RESULT(no),
324AC_MSG_RESULT(unable to determine, assuming no...))
325
326AC_CONFIG_FILES([
327    quickfix.pc
328    Makefile
329    src/Makefile
330    src/C++/Makefile
331    src/C++/test/Makefile
332    src/python2/Makefile
333    src/python3/Makefile
334    src/ruby/Makefile
335    bin/Makefile
336    bin/cfg/Makefile
337    spec/Makefile
338    test/Makefile
339    test/atrun/Makefile
340    test/cfg/Makefile
341    test/definitions/Makefile
342    test/definitions/server/Makefile
343    test/definitions/server/future/Makefile
344    examples/Makefile
345    examples/executor/Makefile
346    examples/executor/C++/Makefile
347    examples/ordermatch/Makefile
348    examples/ordermatch/test/Makefile
349    examples/tradeclient/Makefile
350    examples/tradeclientgui/Makefile
351    examples/tradeclientgui/banzai/Makefile
352    examples/tradeclientgui/banzai/test/Makefile
353    examples/tradeclientgui/banzai/src/Makefile
354    examples/tradeclientgui/banzai/src/quickfix/Makefile
355    examples/tradeclientgui/banzai/src/quickfix/banzai/Makefile
356    examples/tradeclientgui/banzai/src/quickfix/banzai/ui/Makefile
357    doc/Makefile
358    doc/html/Makefile ])
359AC_OUTPUT
360