zone.cpp added to CVS
[public/netxms.git] / configure.ac
CommitLineData
5b0c7d0d 1# $Id: configure.ac,v 1.80 2005-05-05 10:59:49 victor Exp $
d16cf8a5
AK
2#
3# Process this file with autoconf to produce a configure script.
4#
5
5ad2b3b7 6AC_INIT([NetXMS], [0.1.20], [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 175 SUBAGENT_DIRS="linux freebsd sunos"
5b0c7d0d 176 NXCONFIG="nxconfig"
0c3c0c39
AK
177)
178
b97191d2
AK
179AC_ARG_WITH(nxsm,
180[AS_HELP_STRING(--with-nxsm,build session manager for web interface)],
181[
182 MODULES="$MODULES www"
183 BUILD_CLIENT="yes"
184])
185
0c3c0c39
AK
186AC_SUBST(DB_DRIVERS)
187AC_SUBST(MODULES)
3a7ce527 188AC_SUBST(SUBAGENT_DIRS)
5b0c7d0d 189AC_SUBST(NXCONFIG)
3a7ce527 190
d16cf8a5
AK
191# --------------------------------------------------------------------------
192# checks for libs.
193
194#AC_CHECK_LIB([socket], [socket])
195#AC_CHECK_LIB([nsl], [gethostbyname])
196
4c16049c
VK
197AC_CHECK_LIB([gcc], [__muldi3])
198
521d90e7 199AC_CHECK_LIB(socket, if_nameindex)
87bb64a7 200AC_CHECK_LIB(dl, dlopen)
1b3c0ef0 201AC_CHECK_LIB(kstat, kstat_open)
d16cf8a5 202
e0760102
VK
203if test "x$BUILD_SERVER" = "xyes" ; then
204 AC_CHECK_LIB(termcap, tgetstr, [], [AC_CHECK_LIB(ncurses, tgetstr, [], AC_CHECK_LIB(curses, tgetstr))])
205 AC_CHECK_LIB(readline, readline)
206fi
207
d16cf8a5
AK
208# --------------------------------------------------------------------------
209# checks for headers.
210
211AC_HEADER_STDC
212AC_HEADER_STAT
213AC_HEADER_TIME
521d90e7 214AC_CHECK_HEADERS([sys/int_types.h])
d16cf8a5 215AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h])
467e30e1 216AC_CHECK_HEADERS([fcntl.h dirent.h sys/ioctl.h sys/sockio.h poll.h])
85303064 217AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h])
14ab1131 218AC_CHECK_HEADERS([readline/readline.h])
f52be742 219AC_CHECK_HEADERS([byteswap.h])
eca0b061 220AC_CHECK_HEADERS([sys/mman.h])
31a11006 221AC_CHECK_HEADERS([sys/utsname.h])
d16cf8a5 222
d16cf8a5
AK
223# --------------------------------------------------------------------------
224# types
225AC_CHECK_SIZEOF(short)
226AC_CHECK_SIZEOF(int)
227AC_CHECK_SIZEOF(long)
228AC_CHECK_SIZEOF(long long)
229
230AC_TYPE_PID_T
231AC_TYPE_SIGNAL
232AC_TYPE_SIZE_T
233AC_STRUCT_TIMEZONE
234
521d90e7 235AC_CHECK_TYPES([int64_t, uint64_t, u_int64_t])
eca0b061 236AC_CHECK_TYPES([off_t])
521d90e7 237
d16cf8a5
AK
238# --------------------------------------------------------------------------
239# C/CPP caps
240
241AC_PROG_GCC_TRADITIONAL
242AC_C_CONST
243AC_C_BIGENDIAN
244
f52be742
VK
245# --------------------------------------------------------------------------
246# macros
247
248AC_CHECK_DECLS([__bswap_64],,,[
249#if HAVE_BYTESWAP_H
250#include <byteswap.h>
251#endif
252])
85303064
VK
253AC_CHECK_DECLS([SIOCGIFADDR, SIOCGIFNETMASK, SIOCGIFHWADDR],,,[
254#if HAVE_SYS_IOCTL_H
255#include <sys/ioctl.h>
256#endif
257#if HAVE_SYS_SOCKIO_H
258#include <sys/sockio.h>
259#endif
260])
f52be742 261
d16cf8a5
AK
262# --------------------------------------------------------------------------
263# library functions
264
265AC_FUNC_ERROR_AT_LINE
266AC_FUNC_MALLOC
267AC_FUNC_MEMCMP
268AC_FUNC_REALLOC
269AC_FUNC_SELECT_ARGTYPES
270AC_FUNC_STRFTIME
271AC_FUNC_STRTOD
272AC_FUNC_VPRINTF
273
b50f1100
VK
274AC_CHECK_FUNCS([gettimeofday memmove memset strchr strcspn strdup strerror])
275AC_CHECK_FUNCS([strrchr strtol strtoul strtoll strtoull])
467e30e1 276AC_CHECK_FUNCS([if_nametoindex daemon mmap strerror_r scandir uname poll])
d16cf8a5 277
d16cf8a5
AK
278# sockets/resolver (probably for solaris)
279AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
280AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
281AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
282
283if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then
284 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(socket, gethostbyname)])
285fi
286
287if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then
288 AC_MSG_CHECKING([if we can include libnsl + libsocket])
289 LIBS="-lnsl -lsocket $LIBS"
290 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes],[my_ac_link_result=no ])
291 if test "$my_ac_link_result" = "no" ; then
292 AC_MSG_RESULT([failure])
293 AC_MSG_ERROR([unable to use gethostbyname()])
294 else
295 AC_MSG_RESULT([success])
296 fi
297fi
298
3d9b275c 299#ALK: CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
d16cf8a5
AK
300# posix threads
301AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***]))
302
303PTHREAD_LIBS=error
304AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
305AC_EGREP_CPP(yes,
306 [#if (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version <= 500001) || defined(__OpenBSD__)
307 yes
308 #endif
309 ], AC_MSG_RESULT(yes)
6693a1d0 310 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
d16cf8a5
AK
311 AC_MSG_RESULT(no))
312if test "x$PTHREAD_LIBS" = xerror; then
313 AC_CHECK_LIB(pthread, pthread_attr_init,
6693a1d0 314 PTHREAD_LIBS="-lpthread")
d16cf8a5
AK
315fi
316if test "x$PTHREAD_LIBS" = xerror; then
317 AC_CHECK_LIB(pthreads, pthread_attr_init,
6693a1d0 318 PTHREAD_LIBS="-lpthreads")
d16cf8a5
AK
319fi
320if test "x$PTHREAD_LIBS" = xerror; then
321 AC_CHECK_LIB(c_r, pthread_attr_init,
6693a1d0 322 PTHREAD_LIBS="-lc_r")
d16cf8a5
AK
323fi
324if test "x$PTHREAD_LIBS" = xerror; then
6693a1d0
AK
325 AC_CHECK_FUNC(pthread_attr_init,
326 PTHREAD_LIBS="")
d16cf8a5
AK
327fi
328if test "x$PTHREAD_LIBS" = xerror; then
329 AC_MSG_ERROR(*** Unable to locate working posix thread library ***)
330fi
331AC_SUBST(PTHREAD_LIBS)
332
696fc54f
VK
333# Extensions to posix threads
334AC_CHECK_FUNCS([pthread_cond_reltimedwait_np])
335
d16cf8a5
AK
336# --------------------------------------------------------------------------
337
338# shared libs versions
339#
340# versioning scheme: current:revision:age
341#
342# current
343# The number of the current interface exported by the library. A current
344# value of `0', means that you are calling the interface exported by this
345# library interface 0.
346#
347# revision
348# The implementation number of the most recent interface exported by this
349# library. In this case, a revision value of `0' means that this is the
350# first implementation of the interface.
351# If the next release of this library exports the same interface, but has a
352# different implementation (perhaps some bugs have been fixed), the revision
353# number will be higher, but current number will be the same. In that case,
354# when given a choice, the library with the highest revision will always
355# be used by the runtime loader.
356#
357# age
358# The number of previous additional interfaces supported by this library.
359# If age were `2', then this library can be linked into executables which
360# were built with a release of this library that exported the current
361# interface number, current, or any of the previous two interfaces.
362# By definition age must be less than or equal to current. At the outset,
363# only the first ever interface is implemented, so age can only be `0'.
364#
365#
366#
367
368LIBNETXMS_LIBRARY_VERSION=0:1:0
e896a639 369LIBNXCSCP_LIBRARY_VERSION=0:1:0
d853cd74 370LIBNXSNMP_LIBRARY_VERSION=0:1:0
aa3b26fd 371LIBNXSRV_LIBRARY_VERSION=0:1:0
17a48052 372LIBNXCORE_LIBRARY_VERSION=0:1:0
b900a78b 373DBDRV_LIBRARY_VERSION=0:1:0
d16cf8a5 374AC_SUBST(LIBNETXMS_LIBRARY_VERSION)
3e7f0791 375AC_SUBST(LIBNXCSCP_LIBRARY_VERSION)
d853cd74 376AC_SUBST(LIBNXSNMP_LIBRARY_VERSION)
aa3b26fd 377AC_SUBST(LIBNXSRV_LIBRARY_VERSION)
17a48052 378AC_SUBST(LIBNXCORE_LIBRARY_VERSION)
b900a78b 379AC_SUBST(DBDRV_LIBRARY_VERSION)
d16cf8a5
AK
380
381# --------------------------------------------------------------------------
382
383AC_CONFIG_FILES([
d16cf8a5 384 README
0c3c0c39
AK
385 Makefile
386 contrib/Makefile
387 contrib/config/Makefile
388 contrib/dct/Makefile
389 contrib/startup/Makefile
390 contrib/startup/redhat/Makefile
391 doc/Makefile
392 images/Makefile
393 include/Makefile
394 m4/Makefile
395 netware/Makefile
396 sql/Makefile
0c3c0c39
AK
397 src/Makefile
398 src/libnetxms/Makefile
399 src/libnxcscp/Makefile
d853cd74 400 src/libnxsnmp/Makefile
0c3c0c39 401 src/libnxcl/Makefile
1b1edd49
VK
402 src/install/Makefile
403 src/install/windows/Makefile
0c3c0c39
AK
404 src/console/Makefile
405 src/console/win32/Makefile
406 src/console/win32/icons/Makefile
407 src/console/win32/res/Makefile
408 src/console/win32starter/Makefile
672441ac
VK
409 src/console/nxav/Makefile
410 src/console/cmdline/Makefile
0c3c0c39 411 src/nxevent/Makefile
1e8eed7a 412 src/nxreport/Makefile
0c3c0c39
AK
413 src/server/Makefile
414 src/server/core/Makefile
a551fe4d 415 src/server/netxmsd/Makefile
0c3c0c39
AK
416 src/server/dbdrv/Makefile
417 src/server/dbdrv/odbc/Makefile
418 src/server/dbdrv/mssql/Makefile
419 src/server/dbdrv/mysql/Makefile
420 src/server/dbdrv/pgsql/Makefile
421 src/server/tools/Makefile
422 src/server/tools/nxget/Makefile
423 src/server/tools/nxaction/Makefile
424 src/server/tools/nxadm/Makefile
5b0c7d0d
VK
425 src/server/tools/nxconfig/Makefile
426 src/server/tools/nxconfig/res/Makefile
f90d7fc5 427 src/server/tools/nxdbmgr/Makefile
d853cd74 428 src/server/tools/nxsnmpget/Makefile
734c670f 429 src/server/tools/nxsnmpwalk/Makefile
d24fdaf4 430 src/server/tools/nxupload/Makefile
0c3c0c39
AK
431 src/server/libnxsrv/Makefile
432 src/agent/Makefile
433 src/agent/core/Makefile
5795bf90 434 src/agent/install/Makefile
0c3c0c39
AK
435 src/agent/subagents/Makefile
436 src/agent/subagents/linux/Makefile
437 src/agent/subagents/sunos/Makefile
438 src/agent/subagents/skeleton/Makefile
439 src/agent/subagents/freebsd/Makefile
440 src/agent/subagents/netware/Makefile
441 src/agent/subagents/winperf/Makefile
93f15c2a 442 src/agent/subagents/portCheck/Makefile
b97191d2
AK
443 src/www/Makefile
444 src/www/iis/Makefile
445 src/www/nxsm/Makefile
0c3c0c39 446 tools/Makefile
d16cf8a5
AK
447])
448
12249937
VK
449AC_OUTPUT
450
f86b0279
AK
451echo "Updating libtool-1"
452sed 's/-lc_r/-lc_rXXX/' < ./libtool > libtool.new && mv libtool.new libtool && chmod +x ./libtool
5cecf50e
AK
453
454echo "Updating libtool-2"
455sed 's,$SED -e "/${host}-//g",$SED -e "s/${host}-//g",g' < ./libtool > libtool.new && mv libtool.new libtool && chmod +x ./libtool
456
12249937 457if test ! "x$BUILD_SERVER" = "xyes" ; then
5cecf50e 458 echo "Updating libtool-3"
12249937
VK
459 $PERL tools/patch_libtool.pl <libtool >libtool.new
460 mv libtool.new libtool
461 chmod 755 libtool
462fi