condTimedWait fixed
[public/netxms.git] / configure.ac
1 # $Id: configure.ac,v 1.62 2005-02-02 13:35:02 victor Exp $
2 #
3 # Process this file with autoconf to produce a configure script.
4 #
5
6 AC_INIT([NetXMS], [0.1.12], [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 # command line options
57
58 AC_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"
64 CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/mysql -I${withval}/mysql/include"
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"
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"
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])
74 DB_DRIVERS="$DB_DRIVERS mysql"
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)
92 fi ])
93
94 AC_ARG_WITH(pgsql,
95 [AS_HELP_STRING(--with-pgsql,enable postgres backend)],
96 [ if test "x$withval" != "xno" ; then
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)
127 fi ])
128
129 AC_ARG_WITH(server,
130 [AS_HELP_STRING(--with-server,build server)],
131 [
132 MODULES="$MODULES server"
133 BUILD_SERVER="yes"
134 ])
135
136
137 AC_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
145 SUBAGENT_DIRS=""
146 AC_ARG_WITH(agent,
147 [AS_HELP_STRING(--with-agent,build agent)],
148 [
149 MODULES="$MODULES agent"
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 ])
165
166 AC_ARG_WITH(dist,
167 [AS_HELP_STRING(--with-dist,for maintainers only)],
168 DB_DRIVERS="mysql pgsql odbc mssql"
169 MODULES="server agent libnxcl nxevent console"
170 SUBAGENT_DIRS="linux freebsd sunos"
171 )
172
173 AC_SUBST(DB_DRIVERS)
174 AC_SUBST(MODULES)
175 AC_SUBST(SUBAGENT_DIRS)
176
177 # --------------------------------------------------------------------------
178 # checks for libs.
179
180 #AC_CHECK_LIB([socket], [socket])
181 #AC_CHECK_LIB([nsl], [gethostbyname])
182
183 AC_CHECK_LIB(socket, if_nameindex)
184 AC_CHECK_LIB(dl, dlopen)
185 AC_CHECK_LIB(kstat, kstat_open)
186
187 if 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)
190 fi
191
192 # --------------------------------------------------------------------------
193 # checks for headers.
194
195 AC_HEADER_STDC
196 AC_HEADER_STAT
197 AC_HEADER_TIME
198 AC_CHECK_HEADERS([sys/int_types.h])
199 AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h])
200 AC_CHECK_HEADERS([fcntl.h dirent.h sys/ioctl.h sys/sockio.h])
201 AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h])
202 AC_CHECK_HEADERS([readline/readline.h])
203 AC_CHECK_HEADERS([byteswap.h])
204 AC_CHECK_HEADERS([sys/mman.h])
205 AC_CHECK_HEADERS([sys/utsname.h])
206
207 # --------------------------------------------------------------------------
208 # types
209 AC_CHECK_SIZEOF(short)
210 AC_CHECK_SIZEOF(int)
211 AC_CHECK_SIZEOF(long)
212 AC_CHECK_SIZEOF(long long)
213
214 AC_TYPE_PID_T
215 AC_TYPE_SIGNAL
216 AC_TYPE_SIZE_T
217 AC_STRUCT_TIMEZONE
218
219 AC_CHECK_TYPES([int64_t, uint64_t, u_int64_t])
220 AC_CHECK_TYPES([off_t])
221
222 # --------------------------------------------------------------------------
223 # C/CPP caps
224
225 AC_PROG_GCC_TRADITIONAL
226 AC_C_CONST
227 AC_C_BIGENDIAN
228
229 # --------------------------------------------------------------------------
230 # macros
231
232 AC_CHECK_DECLS([__bswap_64],,,[
233 #if HAVE_BYTESWAP_H
234 #include <byteswap.h>
235 #endif
236 ])
237 AC_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 ])
245
246 # --------------------------------------------------------------------------
247 # library functions
248
249 AC_FUNC_ERROR_AT_LINE
250 AC_FUNC_MALLOC
251 AC_FUNC_MEMCMP
252 AC_FUNC_REALLOC
253 AC_FUNC_SELECT_ARGTYPES
254 AC_FUNC_STRFTIME
255 AC_FUNC_STRTOD
256 AC_FUNC_VPRINTF
257
258 AC_CHECK_FUNCS([gettimeofday memmove memset strchr strcspn strdup strerror])
259 AC_CHECK_FUNCS([strrchr strtol strtoul strtoll strtoull])
260 AC_CHECK_FUNCS([if_nametoindex daemon mmap strerror_r scandir uname])
261
262 # sockets/resolver (probably for solaris)
263 AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
264 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
265 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
266
267 if 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)])
269 fi
270
271 if 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
281 fi
282
283 #ALK: CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
284 # posix threads
285 AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***]))
286
287 PTHREAD_LIBS=error
288 AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
289 AC_EGREP_CPP(yes,
290 [#if (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version <= 500001) || defined(__OpenBSD__)
291 yes
292 #endif
293 ], AC_MSG_RESULT(yes)
294 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
295 AC_MSG_RESULT(no))
296 if test "x$PTHREAD_LIBS" = xerror; then
297 AC_CHECK_LIB(pthread, pthread_attr_init,
298 PTHREAD_LIBS="-lpthread")
299 fi
300 if test "x$PTHREAD_LIBS" = xerror; then
301 AC_CHECK_LIB(pthreads, pthread_attr_init,
302 PTHREAD_LIBS="-lpthreads")
303 fi
304 if test "x$PTHREAD_LIBS" = xerror; then
305 AC_CHECK_LIB(c_r, pthread_attr_init,
306 PTHREAD_LIBS="-lc_r")
307 fi
308 if test "x$PTHREAD_LIBS" = xerror; then
309 AC_CHECK_FUNC(pthread_attr_init,
310 PTHREAD_LIBS="")
311 fi
312 if test "x$PTHREAD_LIBS" = xerror; then
313 AC_MSG_ERROR(*** Unable to locate working posix thread library ***)
314 fi
315 AC_SUBST(PTHREAD_LIBS)
316
317 # Extensions to posix threads
318 AC_CHECK_FUNCS([pthread_cond_reltimedwait_np])
319
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
352 LIBNETXMS_LIBRARY_VERSION=0:1:0
353 LIBNXCSCP_LIBRARY_VERSION=0:1:0
354 LIBNXSNMP_LIBRARY_VERSION=0:1:0
355 LIBNXSRV_LIBRARY_VERSION=0:1:0
356 LIBNXCORE_LIBRARY_VERSION=0:1:0
357 DBDRV_LIBRARY_VERSION=0:1:0
358 AC_SUBST(LIBNETXMS_LIBRARY_VERSION)
359 AC_SUBST(LIBNXCSCP_LIBRARY_VERSION)
360 AC_SUBST(LIBNXSNMP_LIBRARY_VERSION)
361 AC_SUBST(LIBNXSRV_LIBRARY_VERSION)
362 AC_SUBST(LIBNXCORE_LIBRARY_VERSION)
363 AC_SUBST(DBDRV_LIBRARY_VERSION)
364
365 # --------------------------------------------------------------------------
366
367 AC_CONFIG_FILES([
368 README
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
381 src/Makefile
382 src/libnetxms/Makefile
383 src/libnxcscp/Makefile
384 src/libnxsnmp/Makefile
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
394 src/server/netxmsd/Makefile
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
404 src/server/tools/nxdbmgr/Makefile
405 src/server/tools/nxsnmpget/Makefile
406 src/server/tools/nxsnmpwalk/Makefile
407 src/server/tools/nxupload/Makefile
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
418 src/agent/subagents/portCheck/Makefile
419 tools/Makefile
420 ])
421
422 AC_OUTPUT
423
424 echo "Updating libtool-1"
425 sed 's/-lc_r/-lc_rXXX/' < ./libtool > libtool.new && mv libtool.new libtool && chmod +x ./libtool
426
427 echo "Updating libtool-2"
428 sed 's,$SED -e "/${host}-//g",$SED -e "s/${host}-//g",g' < ./libtool > libtool.new && mv libtool.new libtool && chmod +x ./libtool
429
430 if test ! "x$BUILD_SERVER" = "xyes" ; then
431 echo "Updating libtool-3"
432 $PERL tools/patch_libtool.pl <libtool >libtool.new
433 mv libtool.new libtool
434 chmod 755 libtool
435 fi