- Version changed to 0.1.11
[public/netxms.git] / configure.ac
1 # $Id: configure.ac,v 1.57 2005-01-18 18:40:17 alk Exp $
2 #
3 # Process this file with autoconf to produce a configure script.
4 #
5
6 AC_INIT([NetXMS], [0.1.10], [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
186 if 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)
189 fi
190
191 # --------------------------------------------------------------------------
192 # checks for headers.
193
194 AC_HEADER_STDC
195 AC_HEADER_STAT
196 AC_HEADER_TIME
197 AC_CHECK_HEADERS([sys/int_types.h])
198 AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h])
199 AC_CHECK_HEADERS([fcntl.h dirent.h sys/ioctl.h sys/sockio.h])
200 AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h])
201 AC_CHECK_HEADERS([readline/readline.h])
202 AC_CHECK_HEADERS([byteswap.h])
203 AC_CHECK_HEADERS([sys/mman.h])
204 AC_CHECK_HEADERS([sys/utsname.h])
205
206 # --------------------------------------------------------------------------
207 # types
208 AC_CHECK_SIZEOF(short)
209 AC_CHECK_SIZEOF(int)
210 AC_CHECK_SIZEOF(long)
211 AC_CHECK_SIZEOF(long long)
212
213 AC_TYPE_PID_T
214 AC_TYPE_SIGNAL
215 AC_TYPE_SIZE_T
216 AC_STRUCT_TIMEZONE
217
218 AC_CHECK_TYPES([int64_t, uint64_t, u_int64_t])
219 AC_CHECK_TYPES([off_t])
220
221 # --------------------------------------------------------------------------
222 # C/CPP caps
223
224 AC_PROG_GCC_TRADITIONAL
225 AC_C_CONST
226 AC_C_BIGENDIAN
227
228 # --------------------------------------------------------------------------
229 # macros
230
231 AC_CHECK_DECLS([__bswap_64],,,[
232 #if HAVE_BYTESWAP_H
233 #include <byteswap.h>
234 #endif
235 ])
236 AC_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 ])
244
245 # --------------------------------------------------------------------------
246 # library functions
247
248 AC_FUNC_ERROR_AT_LINE
249 AC_FUNC_MALLOC
250 AC_FUNC_MEMCMP
251 AC_FUNC_REALLOC
252 AC_FUNC_SELECT_ARGTYPES
253 AC_FUNC_STRFTIME
254 AC_FUNC_STRTOD
255 AC_FUNC_VPRINTF
256
257 AC_CHECK_FUNCS([gettimeofday memmove memset strchr strcspn strdup strerror])
258 AC_CHECK_FUNCS([strrchr strtol strtoul strtoll strtoull])
259 AC_CHECK_FUNCS([if_nametoindex daemon mmap strerror_r scandir uname])
260
261 # sockets/resolver (probably for solaris)
262 AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
263 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
264 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
265
266 if 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)])
268 fi
269
270 if 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
280 fi
281
282 #ALK: CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
283 # posix threads
284 AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***]))
285
286 PTHREAD_LIBS=error
287 AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
288 AC_EGREP_CPP(yes,
289 [#if (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version <= 500001) || defined(__OpenBSD__)
290 yes
291 #endif
292 ], AC_MSG_RESULT(yes)
293 CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
294 AC_MSG_RESULT(no))
295 if test "x$PTHREAD_LIBS" = xerror; then
296 AC_CHECK_LIB(pthread, pthread_attr_init,
297 PTHREAD_LIBS="-lpthread")
298 fi
299 if test "x$PTHREAD_LIBS" = xerror; then
300 AC_CHECK_LIB(pthreads, pthread_attr_init,
301 PTHREAD_LIBS="-lpthreads")
302 fi
303 if test "x$PTHREAD_LIBS" = xerror; then
304 AC_CHECK_LIB(c_r, pthread_attr_init,
305 PTHREAD_LIBS="-lc_r")
306 fi
307 if test "x$PTHREAD_LIBS" = xerror; then
308 AC_CHECK_FUNC(pthread_attr_init,
309 PTHREAD_LIBS="")
310 fi
311 if test "x$PTHREAD_LIBS" = xerror; then
312 AC_MSG_ERROR(*** Unable to locate working posix thread library ***)
313 fi
314 AC_SUBST(PTHREAD_LIBS)
315
316 # Extensions to posix threads
317 AC_CHECK_FUNCS([pthread_cond_reltimedwait_np])
318
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
351 LIBNETXMS_LIBRARY_VERSION=0:1:0
352 LIBNXCSCP_LIBRARY_VERSION=0:1:0
353 LIBNXSNMP_LIBRARY_VERSION=0:1:0
354 LIBNXSRV_LIBRARY_VERSION=0:1:0
355 LIBNXCORE_LIBRARY_VERSION=0:1:0
356 DBDRV_LIBRARY_VERSION=0:1:0
357 AC_SUBST(LIBNETXMS_LIBRARY_VERSION)
358 AC_SUBST(LIBNXCSCP_LIBRARY_VERSION)
359 AC_SUBST(LIBNXSNMP_LIBRARY_VERSION)
360 AC_SUBST(LIBNXSRV_LIBRARY_VERSION)
361 AC_SUBST(LIBNXCORE_LIBRARY_VERSION)
362 AC_SUBST(DBDRV_LIBRARY_VERSION)
363
364 # --------------------------------------------------------------------------
365
366 AC_CONFIG_FILES([
367 README
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
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 if test ! "x$BUILD_SERVER" = "xyes" ; then
427 echo "Updating libtool-2"
428 $PERL tools/patch_libtool.pl <libtool >libtool.new
429 mv libtool.new libtool
430 chmod 755 libtool
431 fi