another libtool bugfix
[public/netxms.git] / configure.ac
CommitLineData
5cecf50e 1# $Id: configure.ac,v 1.60 2005-01-24 17:34:21 alk 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)
d16cf8a5 185
e0760102
VK
186if test "x$BUILD_SERVER" = "xyes" ; then
187 AC_CHECK_LIB(termcap, tgetstr, [], [AC_CHECK_LIB(ncurses, tgetstr, [], AC_CHECK_LIB(curses, tgetstr))])
188 AC_CHECK_LIB(readline, readline)
189fi
190
d16cf8a5
AK
191# --------------------------------------------------------------------------
192# checks for headers.
193
194AC_HEADER_STDC
195AC_HEADER_STAT
196AC_HEADER_TIME
521d90e7 197AC_CHECK_HEADERS([sys/int_types.h])
d16cf8a5 198AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h])
cc4c6659 199AC_CHECK_HEADERS([fcntl.h dirent.h sys/ioctl.h sys/sockio.h])
85303064 200AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h])
14ab1131 201AC_CHECK_HEADERS([readline/readline.h])
f52be742 202AC_CHECK_HEADERS([byteswap.h])
eca0b061 203AC_CHECK_HEADERS([sys/mman.h])
31a11006 204AC_CHECK_HEADERS([sys/utsname.h])
d16cf8a5 205
d16cf8a5
AK
206# --------------------------------------------------------------------------
207# types
208AC_CHECK_SIZEOF(short)
209AC_CHECK_SIZEOF(int)
210AC_CHECK_SIZEOF(long)
211AC_CHECK_SIZEOF(long long)
212
213AC_TYPE_PID_T
214AC_TYPE_SIGNAL
215AC_TYPE_SIZE_T
216AC_STRUCT_TIMEZONE
217
521d90e7 218AC_CHECK_TYPES([int64_t, uint64_t, u_int64_t])
eca0b061 219AC_CHECK_TYPES([off_t])
521d90e7 220
d16cf8a5
AK
221# --------------------------------------------------------------------------
222# C/CPP caps
223
224AC_PROG_GCC_TRADITIONAL
225AC_C_CONST
226AC_C_BIGENDIAN
227
f52be742
VK
228# --------------------------------------------------------------------------
229# macros
230
231AC_CHECK_DECLS([__bswap_64],,,[
232#if HAVE_BYTESWAP_H
233#include <byteswap.h>
234#endif
235])
85303064
VK
236AC_CHECK_DECLS([SIOCGIFADDR, SIOCGIFNETMASK, SIOCGIFHWADDR],,,[
237#if HAVE_SYS_IOCTL_H
238#include <sys/ioctl.h>
239#endif
240#if HAVE_SYS_SOCKIO_H
241#include <sys/sockio.h>
242#endif
243])
f52be742 244
d16cf8a5
AK
245# --------------------------------------------------------------------------
246# library functions
247
248AC_FUNC_ERROR_AT_LINE
249AC_FUNC_MALLOC
250AC_FUNC_MEMCMP
251AC_FUNC_REALLOC
252AC_FUNC_SELECT_ARGTYPES
253AC_FUNC_STRFTIME
254AC_FUNC_STRTOD
255AC_FUNC_VPRINTF
256
b50f1100
VK
257AC_CHECK_FUNCS([gettimeofday memmove memset strchr strcspn strdup strerror])
258AC_CHECK_FUNCS([strrchr strtol strtoul strtoll strtoull])
19acf449 259AC_CHECK_FUNCS([if_nametoindex daemon mmap strerror_r scandir uname])
d16cf8a5 260
d16cf8a5
AK
261# sockets/resolver (probably for solaris)
262AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
263AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
264AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
265
266if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then
267 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(socket, gethostbyname)])
268fi
269
270if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then
271 AC_MSG_CHECKING([if we can include libnsl + libsocket])
272 LIBS="-lnsl -lsocket $LIBS"
273 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes],[my_ac_link_result=no ])
274 if test "$my_ac_link_result" = "no" ; then
275 AC_MSG_RESULT([failure])
276 AC_MSG_ERROR([unable to use gethostbyname()])
277 else
278 AC_MSG_RESULT([success])
279 fi
280fi
281
3d9b275c 282#ALK: CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
d16cf8a5
AK
283# posix threads
284AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***]))
285
286PTHREAD_LIBS=error
287AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
288AC_EGREP_CPP(yes,
289 [#if (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version <= 500001) || defined(__OpenBSD__)
290 yes
291 #endif
292 ], AC_MSG_RESULT(yes)
6693a1d0 293 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
d16cf8a5
AK
294 AC_MSG_RESULT(no))
295if test "x$PTHREAD_LIBS" = xerror; then
296 AC_CHECK_LIB(pthread, pthread_attr_init,
6693a1d0 297 PTHREAD_LIBS="-lpthread")
d16cf8a5
AK
298fi
299if test "x$PTHREAD_LIBS" = xerror; then
300 AC_CHECK_LIB(pthreads, pthread_attr_init,
6693a1d0 301 PTHREAD_LIBS="-lpthreads")
d16cf8a5
AK
302fi
303if test "x$PTHREAD_LIBS" = xerror; then
304 AC_CHECK_LIB(c_r, pthread_attr_init,
6693a1d0 305 PTHREAD_LIBS="-lc_r")
d16cf8a5
AK
306fi
307if test "x$PTHREAD_LIBS" = xerror; then
6693a1d0
AK
308 AC_CHECK_FUNC(pthread_attr_init,
309 PTHREAD_LIBS="")
d16cf8a5
AK
310fi
311if test "x$PTHREAD_LIBS" = xerror; then
312 AC_MSG_ERROR(*** Unable to locate working posix thread library ***)
313fi
314AC_SUBST(PTHREAD_LIBS)
315
696fc54f
VK
316# Extensions to posix threads
317AC_CHECK_FUNCS([pthread_cond_reltimedwait_np])
318
d16cf8a5
AK
319# --------------------------------------------------------------------------
320
321# shared libs versions
322#
323# versioning scheme: current:revision:age
324#
325# current
326# The number of the current interface exported by the library. A current
327# value of `0', means that you are calling the interface exported by this
328# library interface 0.
329#
330# revision
331# The implementation number of the most recent interface exported by this
332# library. In this case, a revision value of `0' means that this is the
333# first implementation of the interface.
334# If the next release of this library exports the same interface, but has a
335# different implementation (perhaps some bugs have been fixed), the revision
336# number will be higher, but current number will be the same. In that case,
337# when given a choice, the library with the highest revision will always
338# be used by the runtime loader.
339#
340# age
341# The number of previous additional interfaces supported by this library.
342# If age were `2', then this library can be linked into executables which
343# were built with a release of this library that exported the current
344# interface number, current, or any of the previous two interfaces.
345# By definition age must be less than or equal to current. At the outset,
346# only the first ever interface is implemented, so age can only be `0'.
347#
348#
349#
350
351LIBNETXMS_LIBRARY_VERSION=0:1:0
e896a639 352LIBNXCSCP_LIBRARY_VERSION=0:1:0
d853cd74 353LIBNXSNMP_LIBRARY_VERSION=0:1:0
aa3b26fd 354LIBNXSRV_LIBRARY_VERSION=0:1:0
17a48052 355LIBNXCORE_LIBRARY_VERSION=0:1:0
b900a78b 356DBDRV_LIBRARY_VERSION=0:1:0
d16cf8a5 357AC_SUBST(LIBNETXMS_LIBRARY_VERSION)
3e7f0791 358AC_SUBST(LIBNXCSCP_LIBRARY_VERSION)
d853cd74 359AC_SUBST(LIBNXSNMP_LIBRARY_VERSION)
aa3b26fd 360AC_SUBST(LIBNXSRV_LIBRARY_VERSION)
17a48052 361AC_SUBST(LIBNXCORE_LIBRARY_VERSION)
b900a78b 362AC_SUBST(DBDRV_LIBRARY_VERSION)
d16cf8a5
AK
363
364# --------------------------------------------------------------------------
365
366AC_CONFIG_FILES([
d16cf8a5 367 README
0c3c0c39
AK
368 Makefile
369 contrib/Makefile
370 contrib/config/Makefile
371 contrib/dct/Makefile
372 contrib/startup/Makefile
373 contrib/startup/redhat/Makefile
374 doc/Makefile
375 images/Makefile
376 include/Makefile
377 m4/Makefile
378 netware/Makefile
379 sql/Makefile
380 sql/upgrade/Makefile
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