- Fixed issue #0000017 (server crash after DCI copy)
[public/netxms.git] / configure.ac
1 # $Id: configure.ac,v 1.71 2005-03-01 13:14:59 victor Exp $
2 #
3 # Process this file with autoconf to produce a configure script.
4 #
5
6 AC_INIT([NetXMS], [0.1.15], [NetXMS Team <bugs@netxms.org>])
7 AC_CONFIG_AUX_DIR([config])
8 AM_CONFIG_HEADER([config.h])
9 AM_INIT_AUTOMAKE
10
11
12 # --------------------------------------------------------------------------
13 # checks for programs.
14
15 AC_PROG_CC
16 AC_PROG_CPP
17 AC_PROG_CXX
18 AC_PROG_INSTALL
19
20 AC_DISABLE_STATIC
21 AC_LIBTOOL_DLOPEN
22 AC_PROG_LIBTOOL
23
24
25 # --------------------------------------------------------------------------
26 # disable C++ exceptions
27 CFLAGS="$CFLAGS -fno-exceptions"
28 CPPFLAGS="$CPPFLAGS -fno-exceptions"
29 LDFLAGS="-nodefaultlibs $LDFLAGS"
30
31 AC_CHECK_LIB(c_r, pthread_create, LDFLAGS="$LDFLAGS -lc_r", LDFLAGS="$LDFLAGS -lc")
32
33
34 # --------------------------------------------------------------------------
35 # misc
36
37 AC_ARG_VAR(PERL,local path to the perl interpreter)
38 perl_possible_path="/usr/bin:/usr/local/bin:/bin:/opt/perl/bin:/opt/perl/usr/bin:/opt/perl/usr/local/bin"
39 AC_PATH_PROG(PERL,perl,/usr/bin/env perl,$perl_possible_path)
40
41 if test -d /usr/local/include; then
42 CFLAGS="$CFLAGS -I/usr/local/include"
43 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
44 fi
45
46 if test -d /usr/kerberos/include; then
47 CFLAGS="$CFLAGS -I/usr/kerberos/include"
48 CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
49 fi
50
51 if test -d /usr/local/lib; then
52 LDFLAGS="$LDFLAGS -L/usr/local/lib"
53 fi
54
55 # --------------------------------------------------------------------------
56 # check for system pthread.h
57
58 AC_CHECK_HEADERS([/usr/include/pthread.h])
59
60 # --------------------------------------------------------------------------
61 # command line options
62
63 AC_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"
69 CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/mysql -I${withval}/mysql/include"
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"
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"
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])
79 DB_DRIVERS="$DB_DRIVERS mysql"
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)
97 fi ])
98
99 AC_ARG_WITH(pgsql,
100 [AS_HELP_STRING(--with-pgsql,enable postgres backend)],
101 [ if test "x$withval" != "xno" ; then
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)
132 fi ])
133
134 AC_ARG_WITH(server,
135 [AS_HELP_STRING(--with-server,build server)],
136 [
137 MODULES="$MODULES server"
138 BUILD_SERVER="yes"
139 ])
140
141
142 AC_ARG_WITH(client,
143 [AS_HELP_STRING(--with-client,build client library and tools)],
144 [
145 MODULES="$MODULES libnxcl nxevent nxreport console"
146 BUILD_CLIENT="yes"
147 ])
148
149
150 SUBAGENT_DIRS=""
151 AC_ARG_WITH(agent,
152 [AS_HELP_STRING(--with-agent,build agent)],
153 [
154 MODULES="$MODULES agent"
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 ])
170
171 AC_ARG_WITH(dist,
172 [AS_HELP_STRING(--with-dist,for maintainers only)],
173 DB_DRIVERS="mysql pgsql odbc mssql"
174 MODULES="server agent libnxcl nxevent nxreport console"
175 SUBAGENT_DIRS="linux freebsd sunos"
176 )
177
178 AC_SUBST(DB_DRIVERS)
179 AC_SUBST(MODULES)
180 AC_SUBST(SUBAGENT_DIRS)
181
182 # --------------------------------------------------------------------------
183 # checks for libs.
184
185 #AC_CHECK_LIB([socket], [socket])
186 #AC_CHECK_LIB([nsl], [gethostbyname])
187
188 AC_CHECK_LIB([gcc], [__muldi3])
189
190 AC_CHECK_LIB(socket, if_nameindex)
191 AC_CHECK_LIB(dl, dlopen)
192 AC_CHECK_LIB(kstat, kstat_open)
193
194 if 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)
197 fi
198
199 # --------------------------------------------------------------------------
200 # checks for headers.
201
202 AC_HEADER_STDC
203 AC_HEADER_STAT
204 AC_HEADER_TIME
205 AC_CHECK_HEADERS([sys/int_types.h])
206 AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h])
207 AC_CHECK_HEADERS([fcntl.h dirent.h sys/ioctl.h sys/sockio.h])
208 AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h])
209 AC_CHECK_HEADERS([readline/readline.h])
210 AC_CHECK_HEADERS([byteswap.h])
211 AC_CHECK_HEADERS([sys/mman.h])
212 AC_CHECK_HEADERS([sys/utsname.h])
213
214 # --------------------------------------------------------------------------
215 # types
216 AC_CHECK_SIZEOF(short)
217 AC_CHECK_SIZEOF(int)
218 AC_CHECK_SIZEOF(long)
219 AC_CHECK_SIZEOF(long long)
220
221 AC_TYPE_PID_T
222 AC_TYPE_SIGNAL
223 AC_TYPE_SIZE_T
224 AC_STRUCT_TIMEZONE
225
226 AC_CHECK_TYPES([int64_t, uint64_t, u_int64_t])
227 AC_CHECK_TYPES([off_t])
228
229 # --------------------------------------------------------------------------
230 # C/CPP caps
231
232 AC_PROG_GCC_TRADITIONAL
233 AC_C_CONST
234 AC_C_BIGENDIAN
235
236 # --------------------------------------------------------------------------
237 # macros
238
239 AC_CHECK_DECLS([__bswap_64],,,[
240 #if HAVE_BYTESWAP_H
241 #include <byteswap.h>
242 #endif
243 ])
244 AC_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 ])
252
253 # --------------------------------------------------------------------------
254 # library functions
255
256 AC_FUNC_ERROR_AT_LINE
257 AC_FUNC_MALLOC
258 AC_FUNC_MEMCMP
259 AC_FUNC_REALLOC
260 AC_FUNC_SELECT_ARGTYPES
261 AC_FUNC_STRFTIME
262 AC_FUNC_STRTOD
263 AC_FUNC_VPRINTF
264
265 AC_CHECK_FUNCS([gettimeofday memmove memset strchr strcspn strdup strerror])
266 AC_CHECK_FUNCS([strrchr strtol strtoul strtoll strtoull])
267 AC_CHECK_FUNCS([if_nametoindex daemon mmap strerror_r scandir uname])
268
269 # sockets/resolver (probably for solaris)
270 AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
271 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
272 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
273
274 if 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)])
276 fi
277
278 if 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
288 fi
289
290 #ALK: CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
291 # posix threads
292 AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***]))
293
294 PTHREAD_LIBS=error
295 AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
296 AC_EGREP_CPP(yes,
297 [#if (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version <= 500001) || defined(__OpenBSD__)
298 yes
299 #endif
300 ], AC_MSG_RESULT(yes)
301 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
302 AC_MSG_RESULT(no))
303 if test "x$PTHREAD_LIBS" = xerror; then
304 AC_CHECK_LIB(pthread, pthread_attr_init,
305 PTHREAD_LIBS="-lpthread")
306 fi
307 if test "x$PTHREAD_LIBS" = xerror; then
308 AC_CHECK_LIB(pthreads, pthread_attr_init,
309 PTHREAD_LIBS="-lpthreads")
310 fi
311 if test "x$PTHREAD_LIBS" = xerror; then
312 AC_CHECK_LIB(c_r, pthread_attr_init,
313 PTHREAD_LIBS="-lc_r")
314 fi
315 if test "x$PTHREAD_LIBS" = xerror; then
316 AC_CHECK_FUNC(pthread_attr_init,
317 PTHREAD_LIBS="")
318 fi
319 if test "x$PTHREAD_LIBS" = xerror; then
320 AC_MSG_ERROR(*** Unable to locate working posix thread library ***)
321 fi
322 AC_SUBST(PTHREAD_LIBS)
323
324 # Extensions to posix threads
325 AC_CHECK_FUNCS([pthread_cond_reltimedwait_np])
326
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
359 LIBNETXMS_LIBRARY_VERSION=0:1:0
360 LIBNXCSCP_LIBRARY_VERSION=0:1:0
361 LIBNXSNMP_LIBRARY_VERSION=0:1:0
362 LIBNXSRV_LIBRARY_VERSION=0:1:0
363 LIBNXCORE_LIBRARY_VERSION=0:1:0
364 DBDRV_LIBRARY_VERSION=0:1:0
365 AC_SUBST(LIBNETXMS_LIBRARY_VERSION)
366 AC_SUBST(LIBNXCSCP_LIBRARY_VERSION)
367 AC_SUBST(LIBNXSNMP_LIBRARY_VERSION)
368 AC_SUBST(LIBNXSRV_LIBRARY_VERSION)
369 AC_SUBST(LIBNXCORE_LIBRARY_VERSION)
370 AC_SUBST(DBDRV_LIBRARY_VERSION)
371
372 # --------------------------------------------------------------------------
373
374 AC_CONFIG_FILES([
375 README
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
388 src/Makefile
389 src/libnetxms/Makefile
390 src/libnxcscp/Makefile
391 src/libnxsnmp/Makefile
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
398 src/console/nxav/Makefile
399 src/console/cmdline/Makefile
400 src/nxevent/Makefile
401 src/nxreport/Makefile
402 src/server/Makefile
403 src/server/core/Makefile
404 src/server/netxmsd/Makefile
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
414 src/server/tools/nxdbmgr/Makefile
415 src/server/tools/nxsnmpget/Makefile
416 src/server/tools/nxsnmpwalk/Makefile
417 src/server/tools/nxupload/Makefile
418 src/server/libnxsrv/Makefile
419 src/agent/Makefile
420 src/agent/core/Makefile
421 src/agent/install/Makefile
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
429 src/agent/subagents/portCheck/Makefile
430 tools/Makefile
431 ])
432
433 AC_OUTPUT
434
435 echo "Updating libtool-1"
436 sed 's/-lc_r/-lc_rXXX/' < ./libtool > libtool.new && mv libtool.new libtool && chmod +x ./libtool
437
438 echo "Updating libtool-2"
439 sed 's,$SED -e "/${host}-//g",$SED -e "s/${host}-//g",g' < ./libtool > libtool.new && mv libtool.new libtool && chmod +x ./libtool
440
441 if test ! "x$BUILD_SERVER" = "xyes" ; then
442 echo "Updating libtool-3"
443 $PERL tools/patch_libtool.pl <libtool >libtool.new
444 mv libtool.new libtool
445 chmod 755 libtool
446 fi