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