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