Changes supposed to detect libc_r on FreeBSD
[public/netxms.git] / configure.ac
CommitLineData
ee40037f 1# $Id: configure.ac,v 1.50 2005-01-10 11:44:00 victor Exp $
d16cf8a5
AK
2#
3# Process this file with autoconf to produce a configure script.
4#
5
20bbb42e 6AC_INIT([NetXMS], [0.1.10], [NetXMS Team <bugs@netxms.org>])
d16cf8a5
AK
7AC_CONFIG_AUX_DIR([config])
8AM_CONFIG_HEADER([config.h])
9AM_INIT_AUTOMAKE
10
e0760102
VK
11# --------------------------------------------------------------------------
12# disable C++ exceptions
063e34ad 13CFLAGS="$CFLAGS -fno-exceptions"
e0760102 14CPPFLAGS="$CPPFLAGS -fno-exceptions"
ee40037f
VK
15LDFLAGS="-nodefaultlibs $LDFLAGS"
16
17AC_CHECK_LIB(c_r, pthread_create, [], [LDFLAGS="$LDFLAGS -lc"])
e0760102 18
d16cf8a5
AK
19# --------------------------------------------------------------------------
20# misc
21
22AC_ARG_VAR(PERL,local path to the perl interpreter)
23perl_possible_path="/usr/bin:/usr/local/bin:/bin:/opt/perl/bin:/opt/perl/usr/bin:/opt/perl/usr/local/bin"
24AC_PATH_PROG(PERL,perl,/usr/bin/env perl,$perl_possible_path)
25
26if test -d /usr/local/include; then
27 CFLAGS="$CFLAGS -I/usr/local/include"
2cb1fb26 28 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
d16cf8a5
AK
29fi
30
31if test -d /usr/kerberos/include; then
32 CFLAGS="$CFLAGS -I/usr/kerberos/include"
2cb1fb26 33 CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
d16cf8a5 34fi
521d90e7 35
d16cf8a5
AK
36if test -d /usr/local/lib; then
37 LDFLAGS="$LDFLAGS -L/usr/local/lib"
38fi
39
40# --------------------------------------------------------------------------
41# command line options
42
43AC_ARG_WITH(mysql,
44[AS_HELP_STRING(--with-mysql,enable mysql backend)],
45[ if test "x$withval" != "xno" ; then
46 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
47 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
48 LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/mysql -L${withval}/mysql/lib"
6693a1d0 49 CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/mysql -I${withval}/mysql/include"
d16cf8a5
AK
50 else
51 LD_RUN_PATH="/usr/local/mysql/lib:/usr/local/mysql/lib/mysql:/usr/lib/mysql:/usr/mysql/lib:/usr/mysql/lib/mysql:/usr/local/lib/mysql:${LD_RUN_PATH:+:}${LD_RUN_PATH}"
52 LDFLAGS="$LDFLAGS -L/usr/local/mysql/lib -L/usr/lib/mysql -L/usr/mysql/lib -L/usr/local/lib/mysql -L/usr/local/mysql/lib/mysql -L/usr/mysql/lib/mysql"
6693a1d0 53 CPPFLAGS="$CPPFLAGS -I/usr/local/mysql/include -I/usr/include/mysql -I/usr/mysql/include -I/usr/local/include/mysql -I/usr/local/mysql/include/mysql -I/usr/mysql/include/mysql"
d16cf8a5
AK
54 fi
55 AC_CHECK_LIB(m, floor)
56 AC_CHECK_LIB(z, gzclose)
57 with_mysql="yes"
58 AC_DEFINE(WITH_MYSQL,,[with mysql])
6693a1d0 59 DB_DRIVERS="$DB_DRIVERS mysql"
d16cf8a5
AK
60 AC_CHECK_LIB(mysqlclient, mysql_init, ,
61 [AC_MSG_ERROR(libmysqlclient is needed for MySQL support)])
62 AC_MSG_CHECKING(whether mysql clients can run)
63 AC_RUN_IFELSE([AC_LANG_SOURCE([[
64 #include <stdio.h>
65 #include <mysql.h>
66 int main(void)
67 {
68 MYSQL *a = mysql_init(NULL);
69 return 0;
70 }
71 ]])],[],[
72 AC_MSG_RESULT(no)
73 AC_MSG_ERROR(Your MySQL client libraries aren't properly installed)
74 ],[])
75 AC_MSG_RESULT(yes)
76 AC_CHECK_FUNCS(mysql_real_escape_string)
6693a1d0 77fi ])
d16cf8a5
AK
78
79AC_ARG_WITH(pgsql,
80[AS_HELP_STRING(--with-pgsql,enable postgres backend)],
81[ if test "x$withval" != "xno" ; then
6693a1d0
AK
82 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
83 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
84 LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/pgsql -L${withval}/lib/postgresql -L${withval}/pgsql/lib -L${withval}/postgresql/lib"
85 CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/pgsql -I${withval}/include/postgresql -I${withval}/pgsql/include -I${withval}/postgresql/include"
86 else
87 LD_RUN_PATH="/usr/local/pgsql/lib:/usr/local/pgsql/lib/pgsql:/usr/lib/pgsql:/usr/pgsql/lib:/usr/pgsql/lib/pgsql:/usr/local/lib/pgsql:/usr/local/postgresql/lib:/usr/local/postgresql/lib/postgresql:/usr/lib/postgresql:/usr/postgresql/lib:/usr/postgresql/lib/postgresql:/usr/local/lib/postgresql:${LD_RUN_PATH:+:}${LD_RUN_PATH}"
88 LDFLAGS="$LDFLAGS -L/usr/local/pgsql/lib -L/usr/lib/pgsql -L/usr/pgsql/lib -L/usr/local/lib/pgsql -L/usr/local/pgsql/lib/pgsql -L/usr/pgsql/lib/pgsql -L/usr/local/postgresql/lib -L/usr/lib/postgresql -L/usr/postgresql/lib -L/usr/local/lib/postgresql -L/usr/local/postgresql/lib/postgresql -L/usr/postgresql/lib/postgresql"
89 CPPFLAGS="$CPPFLAGS -I/usr/local/pgsql/include -I/usr/include/pgsql -I/usr/pgsql/include -I/usr/local/include/pgsql -I/usr/local/pgsql/include/pgsql -I/usr/pgsql/include/pgsql -I/usr/local/postgresql/include -I/usr/include/postgresql -I/usr/postgresql/include -I/usr/local/include/postgresql -I/usr/local/postgresql/include/postgresql -I/usr/postgresql/include/postgresql"
90 fi
91 AC_CHECK_LIB(m, floor)
92 AC_CHECK_LIB(z, gzclose)
93 with_pgsql="yes"
94 DB_DRIVERS="$DB_DRIVERS pgsql"
95 AC_DEFINE(WITH_PGSQL,,[with pgsql])
96 AC_CHECK_LIB(pq, PQconnectdb, ,
97 [AC_MSG_ERROR(libpq is needed for PostgreSQL support)])
98 AC_MSG_CHECKING(whether postgresql clients can run)
99 AC_RUN_IFELSE([AC_LANG_SOURCE([[
100 #include <stdio.h>
101 #include <libpq-fe.h>
102 int main(void)
103 {
104 PGconn *a = PQconnectdb("");
105 return 0;
106 }
107 ]])],[],[
108 AC_MSG_RESULT(no)
109 AC_MSG_ERROR(Your PostgreSQL client libraries aren't properly installed)
110 ],[])
111 AC_MSG_RESULT(yes)
112fi ])
d16cf8a5 113
3a7ce527
AK
114AC_ARG_WITH(server,
115[AS_HELP_STRING(--with-server,build server)],
116[
117 MODULES="$MODULES server"
08ffa53e 118 BUILD_SERVER="yes"
3a7ce527 119])
3a7ce527
AK
120
121
e0760102
VK
122AC_ARG_WITH(client,
123[AS_HELP_STRING(--with-client,build client library and tools)],
124[
125 MODULES="$MODULES libnxcl nxevent console"
126 BUILD_CLIENT="yes"
127])
128
129
3a7ce527
AK
130SUBAGENT_DIRS=""
131AC_ARG_WITH(agent,
132[AS_HELP_STRING(--with-agent,build agent)],
133[
0c3c0c39 134 MODULES="$MODULES agent"
3a7ce527
AK
135 case `uname -s` in
136 Linux)
137 SUBAGENT_DIRS="linux"
138 ;;
139 FreeBSD)
140 SUBAGENT_DIRS="freebsd"
141 ;;
142 SunOS)
143 SUBAGENT_DIRS="sunos"
144 ;;
145 *)
146 # unknown
147 ;;
148 esac
149])
0c3c0c39
AK
150
151AC_ARG_WITH(dist,
152[AS_HELP_STRING(--with-dist,for maintainers only)],
153 DB_DRIVERS="mysql pgsql odbc mssql"
e0760102 154 MODULES="server agent libnxcl nxevent console"
0c3c0c39
AK
155 SUBAGENT_DIRS="linux freebsd sunos"
156)
157
158AC_SUBST(DB_DRIVERS)
159AC_SUBST(MODULES)
3a7ce527
AK
160AC_SUBST(SUBAGENT_DIRS)
161
162
d16cf8a5
AK
163# --------------------------------------------------------------------------
164# checks for programs.
165
166AC_PROG_CC
167AC_PROG_CPP
e0760102 168AC_PROG_CXX
d16cf8a5
AK
169AC_PROG_INSTALL
170
171AC_LIBTOOL_DLOPEN
172AC_PROG_LIBTOOL
173
174# --------------------------------------------------------------------------
175# checks for libs.
176
177#AC_CHECK_LIB([socket], [socket])
178#AC_CHECK_LIB([nsl], [gethostbyname])
179
521d90e7 180AC_CHECK_LIB(socket, if_nameindex)
87bb64a7 181AC_CHECK_LIB(dl, dlopen)
d16cf8a5 182
e0760102
VK
183if test "x$BUILD_SERVER" = "xyes" ; then
184 AC_CHECK_LIB(termcap, tgetstr, [], [AC_CHECK_LIB(ncurses, tgetstr, [], AC_CHECK_LIB(curses, tgetstr))])
185 AC_CHECK_LIB(readline, readline)
186fi
187
d16cf8a5
AK
188# --------------------------------------------------------------------------
189# checks for headers.
190
191AC_HEADER_STDC
192AC_HEADER_STAT
193AC_HEADER_TIME
521d90e7 194AC_CHECK_HEADERS([sys/int_types.h])
d16cf8a5 195AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h])
cc4c6659 196AC_CHECK_HEADERS([fcntl.h dirent.h sys/ioctl.h sys/sockio.h])
85303064 197AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h])
14ab1131 198AC_CHECK_HEADERS([readline/readline.h])
f52be742 199AC_CHECK_HEADERS([byteswap.h])
eca0b061 200AC_CHECK_HEADERS([sys/mman.h])
31a11006 201AC_CHECK_HEADERS([sys/utsname.h])
d16cf8a5 202
d16cf8a5
AK
203# --------------------------------------------------------------------------
204# types
205AC_CHECK_SIZEOF(short)
206AC_CHECK_SIZEOF(int)
207AC_CHECK_SIZEOF(long)
208AC_CHECK_SIZEOF(long long)
209
210AC_TYPE_PID_T
211AC_TYPE_SIGNAL
212AC_TYPE_SIZE_T
213AC_STRUCT_TIMEZONE
214
521d90e7 215AC_CHECK_TYPES([int64_t, uint64_t, u_int64_t])
eca0b061 216AC_CHECK_TYPES([off_t])
521d90e7 217
d16cf8a5
AK
218# --------------------------------------------------------------------------
219# C/CPP caps
220
221AC_PROG_GCC_TRADITIONAL
222AC_C_CONST
223AC_C_BIGENDIAN
224
f52be742
VK
225# --------------------------------------------------------------------------
226# macros
227
228AC_CHECK_DECLS([__bswap_64],,,[
229#if HAVE_BYTESWAP_H
230#include <byteswap.h>
231#endif
232])
85303064
VK
233AC_CHECK_DECLS([SIOCGIFADDR, SIOCGIFNETMASK, SIOCGIFHWADDR],,,[
234#if HAVE_SYS_IOCTL_H
235#include <sys/ioctl.h>
236#endif
237#if HAVE_SYS_SOCKIO_H
238#include <sys/sockio.h>
239#endif
240])
f52be742 241
d16cf8a5
AK
242# --------------------------------------------------------------------------
243# library functions
244
245AC_FUNC_ERROR_AT_LINE
246AC_FUNC_MALLOC
247AC_FUNC_MEMCMP
248AC_FUNC_REALLOC
249AC_FUNC_SELECT_ARGTYPES
250AC_FUNC_STRFTIME
251AC_FUNC_STRTOD
252AC_FUNC_VPRINTF
253
b50f1100
VK
254AC_CHECK_FUNCS([gettimeofday memmove memset strchr strcspn strdup strerror])
255AC_CHECK_FUNCS([strrchr strtol strtoul strtoll strtoull])
19acf449 256AC_CHECK_FUNCS([if_nametoindex daemon mmap strerror_r scandir uname])
d16cf8a5 257
d16cf8a5
AK
258# sockets/resolver (probably for solaris)
259AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
260AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
261AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
262
263if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then
264 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(socket, gethostbyname)])
265fi
266
267if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then
268 AC_MSG_CHECKING([if we can include libnsl + libsocket])
269 LIBS="-lnsl -lsocket $LIBS"
270 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes],[my_ac_link_result=no ])
271 if test "$my_ac_link_result" = "no" ; then
272 AC_MSG_RESULT([failure])
273 AC_MSG_ERROR([unable to use gethostbyname()])
274 else
275 AC_MSG_RESULT([success])
276 fi
277fi
278
279# posix threads
280AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***]))
281
282PTHREAD_LIBS=error
283AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
284AC_EGREP_CPP(yes,
285 [#if (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version <= 500001) || defined(__OpenBSD__)
286 yes
287 #endif
288 ], AC_MSG_RESULT(yes)
6693a1d0 289 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
d16cf8a5
AK
290 AC_MSG_RESULT(no))
291if test "x$PTHREAD_LIBS" = xerror; then
292 AC_CHECK_LIB(pthread, pthread_attr_init,
6693a1d0 293 PTHREAD_LIBS="-lpthread")
d16cf8a5
AK
294fi
295if test "x$PTHREAD_LIBS" = xerror; then
296 AC_CHECK_LIB(pthreads, pthread_attr_init,
6693a1d0 297 PTHREAD_LIBS="-lpthreads")
d16cf8a5
AK
298fi
299if test "x$PTHREAD_LIBS" = xerror; then
300 AC_CHECK_LIB(c_r, pthread_attr_init,
6693a1d0 301 PTHREAD_LIBS="-lc_r")
d16cf8a5
AK
302fi
303if test "x$PTHREAD_LIBS" = xerror; then
6693a1d0
AK
304 AC_CHECK_FUNC(pthread_attr_init,
305 PTHREAD_LIBS="")
d16cf8a5
AK
306fi
307if test "x$PTHREAD_LIBS" = xerror; then
308 AC_MSG_ERROR(*** Unable to locate working posix thread library ***)
309fi
310AC_SUBST(PTHREAD_LIBS)
311
696fc54f
VK
312# Extensions to posix threads
313AC_CHECK_FUNCS([pthread_cond_reltimedwait_np])
314
d16cf8a5
AK
315# --------------------------------------------------------------------------
316
317# shared libs versions
318#
319# versioning scheme: current:revision:age
320#
321# current
322# The number of the current interface exported by the library. A current
323# value of `0', means that you are calling the interface exported by this
324# library interface 0.
325#
326# revision
327# The implementation number of the most recent interface exported by this
328# library. In this case, a revision value of `0' means that this is the
329# first implementation of the interface.
330# If the next release of this library exports the same interface, but has a
331# different implementation (perhaps some bugs have been fixed), the revision
332# number will be higher, but current number will be the same. In that case,
333# when given a choice, the library with the highest revision will always
334# be used by the runtime loader.
335#
336# age
337# The number of previous additional interfaces supported by this library.
338# If age were `2', then this library can be linked into executables which
339# were built with a release of this library that exported the current
340# interface number, current, or any of the previous two interfaces.
341# By definition age must be less than or equal to current. At the outset,
342# only the first ever interface is implemented, so age can only be `0'.
343#
344#
345#
346
347LIBNETXMS_LIBRARY_VERSION=0:1:0
e896a639 348LIBNXCSCP_LIBRARY_VERSION=0:1:0
d853cd74 349LIBNXSNMP_LIBRARY_VERSION=0:1:0
aa3b26fd 350LIBNXSRV_LIBRARY_VERSION=0:1:0
17a48052 351LIBNXCORE_LIBRARY_VERSION=0:1:0
b900a78b 352DBDRV_LIBRARY_VERSION=0:1:0
d16cf8a5 353AC_SUBST(LIBNETXMS_LIBRARY_VERSION)
3e7f0791 354AC_SUBST(LIBNXCSCP_LIBRARY_VERSION)
d853cd74 355AC_SUBST(LIBNXSNMP_LIBRARY_VERSION)
aa3b26fd 356AC_SUBST(LIBNXSRV_LIBRARY_VERSION)
17a48052 357AC_SUBST(LIBNXCORE_LIBRARY_VERSION)
b900a78b 358AC_SUBST(DBDRV_LIBRARY_VERSION)
d16cf8a5
AK
359
360# --------------------------------------------------------------------------
361
362AC_CONFIG_FILES([
d16cf8a5 363 README
0c3c0c39
AK
364 Makefile
365 contrib/Makefile
366 contrib/config/Makefile
367 contrib/dct/Makefile
368 contrib/startup/Makefile
369 contrib/startup/redhat/Makefile
370 doc/Makefile
371 images/Makefile
372 include/Makefile
373 m4/Makefile
374 netware/Makefile
375 sql/Makefile
376 sql/upgrade/Makefile
377 src/Makefile
378 src/libnetxms/Makefile
379 src/libnxcscp/Makefile
d853cd74 380 src/libnxsnmp/Makefile
0c3c0c39
AK
381 src/libnxcl/Makefile
382 src/console/Makefile
383 src/console/win32/Makefile
384 src/console/win32/icons/Makefile
385 src/console/win32/res/Makefile
386 src/console/win32starter/Makefile
387 src/nxevent/Makefile
388 src/server/Makefile
389 src/server/core/Makefile
a551fe4d 390 src/server/netxmsd/Makefile
0c3c0c39
AK
391 src/server/dbdrv/Makefile
392 src/server/dbdrv/odbc/Makefile
393 src/server/dbdrv/mssql/Makefile
394 src/server/dbdrv/mysql/Makefile
395 src/server/dbdrv/pgsql/Makefile
396 src/server/tools/Makefile
397 src/server/tools/nxget/Makefile
398 src/server/tools/nxaction/Makefile
399 src/server/tools/nxadm/Makefile
f90d7fc5 400 src/server/tools/nxdbmgr/Makefile
d853cd74 401 src/server/tools/nxsnmpget/Makefile
734c670f 402 src/server/tools/nxsnmpwalk/Makefile
d24fdaf4 403 src/server/tools/nxupload/Makefile
0c3c0c39
AK
404 src/server/libnxsrv/Makefile
405 src/agent/Makefile
406 src/agent/core/Makefile
407 src/agent/subagents/Makefile
408 src/agent/subagents/linux/Makefile
409 src/agent/subagents/sunos/Makefile
410 src/agent/subagents/skeleton/Makefile
411 src/agent/subagents/freebsd/Makefile
412 src/agent/subagents/netware/Makefile
413 src/agent/subagents/winperf/Makefile
414 tools/Makefile
d16cf8a5
AK
415])
416
063e34ad 417AC_OUTPUT( , [ $PERL tools/patch_libtool.pl <libtool >libtool.new; mv libtool.new libtool; chmod 755 libtool ])