Intermediate commit (unfinished changes in object browser code)
[public/netxms.git] / configure.ac
CommitLineData
2cb1fb26 1# $Id: configure.ac,v 1.2 2004-05-11 14:39:56 alk Exp $
d16cf8a5
AK
2#
3# Process this file with autoconf to produce a configure script.
4#
5
6AC_INIT([NetXMS], [0.1.0], [NetXMS Team <bugs@netxms.org>])
7AC_CONFIG_AUX_DIR([config])
8AM_CONFIG_HEADER([config.h])
9AM_INIT_AUTOMAKE
10
11# --------------------------------------------------------------------------
12# misc
13
14AC_ARG_VAR(PERL,local path to the perl interpreter)
15perl_possible_path="/usr/bin:/usr/local/bin:/bin:/opt/perl/bin:/opt/perl/usr/bin:/opt/perl/usr/local/bin"
16AC_PATH_PROG(PERL,perl,/usr/bin/env perl,$perl_possible_path)
17
18if test -d /usr/local/include; then
19 CFLAGS="$CFLAGS -I/usr/local/include"
2cb1fb26 20 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
d16cf8a5
AK
21fi
22
23if test -d /usr/kerberos/include; then
24 CFLAGS="$CFLAGS -I/usr/kerberos/include"
2cb1fb26 25 CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
d16cf8a5
AK
26fi
27if test -d /usr/local/lib; then
28 LDFLAGS="$LDFLAGS -L/usr/local/lib"
29fi
30
31# --------------------------------------------------------------------------
32# command line options
33
34AC_ARG_WITH(mysql,
35[AS_HELP_STRING(--with-mysql,enable mysql backend)],
36[ if test "x$withval" != "xno" ; then
37 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
38 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
39 LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/mysql -L${withval}/mysql/lib"
40 CFLAGS="$CFLAGS -I${withval}/include -I${withval}/include/mysql -I${withval}/mysql/include"
41 else
42 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}"
43 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"
44 CFLAGS="$CFLAGS -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"
45 fi
46 AC_CHECK_LIB(m, floor)
47 AC_CHECK_LIB(z, gzclose)
48 with_mysql="yes"
49 AC_DEFINE(WITH_MYSQL,,[with mysql])
50 AC_CHECK_LIB(mysqlclient, mysql_init, ,
51 [AC_MSG_ERROR(libmysqlclient is needed for MySQL support)])
52 AC_MSG_CHECKING(whether mysql clients can run)
53 AC_RUN_IFELSE([AC_LANG_SOURCE([[
54 #include <stdio.h>
55 #include <mysql.h>
56 int main(void)
57 {
58 MYSQL *a = mysql_init(NULL);
59 return 0;
60 }
61 ]])],[],[
62 AC_MSG_RESULT(no)
63 AC_MSG_ERROR(Your MySQL client libraries aren't properly installed)
64 ],[])
65 AC_MSG_RESULT(yes)
66 AC_CHECK_FUNCS(mysql_real_escape_string)
67 fi ])
68
69AC_ARG_WITH(pgsql,
70[AS_HELP_STRING(--with-pgsql,enable postgres backend)],
71[ if test "x$withval" != "xno" ; then
72 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
73 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
74 LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/pgsql -L${withval}/lib/postgresql -L${withval}/pgsql/lib -L${withval}/postgresql/lib"
75 CFLAGS="$CFLAGS -I${withval}/include -I${withval}/include/pgsql -I${withval}/include/postgresql -I${withval}/pgsql/include -I${withval}/postgresql/include"
76 else
77 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}"
78 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"
79 CFLAGS="$CFLAGS -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"
80 fi
81 AC_CHECK_LIB(m, floor)
82 AC_CHECK_LIB(z, gzclose)
83 with_pgsql="yes"
84 AC_DEFINE(WITH_PGSQL,,[with pgsql])
85 AC_CHECK_LIB(pq, PQconnectdb, ,
86 [AC_MSG_ERROR(libpq is needed for PostgreSQL support)])
87 AC_MSG_CHECKING(whether postgresql clients can run)
88 AC_RUN_IFELSE([AC_LANG_SOURCE([[
89 #include <stdio.h>
90 #include <libpq-fe.h>
91 int main(void)
92 {
93 PGconn *a = PQconnectdb("");
94 return 0;
95 }
96 ]])],[],[
97 AC_MSG_RESULT(no)
98 AC_MSG_ERROR(Your PostgreSQL client libraries aren't properly installed)
99
100 ],[])
101 AC_MSG_RESULT(yes)
102 fi ])
103
104
105
106
107# --------------------------------------------------------------------------
108# checks for programs.
109
110AC_PROG_CC
111AC_PROG_CPP
112AC_PROG_INSTALL
113
114AC_LIBTOOL_DLOPEN
115AC_PROG_LIBTOOL
116
117# --------------------------------------------------------------------------
118# checks for libs.
119
120#AC_CHECK_LIB([socket], [socket])
121#AC_CHECK_LIB([nsl], [gethostbyname])
122
123AC_CHECK_LIB(crypto, DH_new)
124AC_CHECK_LIB(ssl, SSL_accept)
125
126# --------------------------------------------------------------------------
127# checks for headers.
128
129AC_HEADER_STDC
130AC_HEADER_STAT
131AC_HEADER_TIME
132AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h sys/socket.h])
133AC_CHECK_HEADERS([openssl/ssl.h])
134
135if test "x$ac_cv_header_openssl_ssl_h" != "xyes" ; then
136 AC_MSG_ERROR(OpenSSL headers not found.)
137fi
138
139# --------------------------------------------------------------------------
140# types
141AC_CHECK_SIZEOF(short)
142AC_CHECK_SIZEOF(int)
143AC_CHECK_SIZEOF(long)
144AC_CHECK_SIZEOF(long long)
145
146AC_TYPE_PID_T
147AC_TYPE_SIGNAL
148AC_TYPE_SIZE_T
149AC_STRUCT_TIMEZONE
150
151# --------------------------------------------------------------------------
152# C/CPP caps
153
154AC_PROG_GCC_TRADITIONAL
155AC_C_CONST
156AC_C_BIGENDIAN
157
158# --------------------------------------------------------------------------
159# library functions
160
161AC_FUNC_ERROR_AT_LINE
162AC_FUNC_MALLOC
163AC_FUNC_MEMCMP
164AC_FUNC_REALLOC
165AC_FUNC_SELECT_ARGTYPES
166AC_FUNC_STRFTIME
167AC_FUNC_STRTOD
168AC_FUNC_VPRINTF
169
170AC_CHECK_FUNCS([gettimeofday memmove memset strchr strcspn strdup strerror strrchr strtol strtoul])
171
172
173# sockets/resolver (probably for solaris)
174AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
175AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
176AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
177
178if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then
179 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(socket, gethostbyname)])
180fi
181
182if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then
183 AC_MSG_CHECKING([if we can include libnsl + libsocket])
184 LIBS="-lnsl -lsocket $LIBS"
185 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes],[my_ac_link_result=no ])
186 if test "$my_ac_link_result" = "no" ; then
187 AC_MSG_RESULT([failure])
188 AC_MSG_ERROR([unable to use gethostbyname()])
189 else
190 AC_MSG_RESULT([success])
191 fi
192fi
193
194# posix threads
195AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***]))
196
197PTHREAD_LIBS=error
198AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
199AC_EGREP_CPP(yes,
200 [#if (defined(__FreeBSD_cc_version) && __FreeBSD_cc_version <= 500001) || defined(__OpenBSD__)
201 yes
202 #endif
203 ], AC_MSG_RESULT(yes)
204 CFLAGS="$CFLAGS -D_THREAD_SAFE" PTHREAD_LIBS="-pthread",
205 AC_MSG_RESULT(no))
206if test "x$PTHREAD_LIBS" = xerror; then
207 AC_CHECK_LIB(pthread, pthread_attr_init,
208 PTHREAD_LIBS="-lpthread")
209fi
210if test "x$PTHREAD_LIBS" = xerror; then
211 AC_CHECK_LIB(pthreads, pthread_attr_init,
212 PTHREAD_LIBS="-lpthreads")
213fi
214if test "x$PTHREAD_LIBS" = xerror; then
215 AC_CHECK_LIB(c_r, pthread_attr_init,
216 PTHREAD_LIBS="-lc_r")
217fi
218if test "x$PTHREAD_LIBS" = xerror; then
219 AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
220fi
221if test "x$PTHREAD_LIBS" = xerror; then
222 AC_MSG_ERROR(*** Unable to locate working posix thread library ***)
223fi
224AC_SUBST(PTHREAD_LIBS)
225
226# --------------------------------------------------------------------------
227
228# shared libs versions
229#
230# versioning scheme: current:revision:age
231#
232# current
233# The number of the current interface exported by the library. A current
234# value of `0', means that you are calling the interface exported by this
235# library interface 0.
236#
237# revision
238# The implementation number of the most recent interface exported by this
239# library. In this case, a revision value of `0' means that this is the
240# first implementation of the interface.
241# If the next release of this library exports the same interface, but has a
242# different implementation (perhaps some bugs have been fixed), the revision
243# number will be higher, but current number will be the same. In that case,
244# when given a choice, the library with the highest revision will always
245# be used by the runtime loader.
246#
247# age
248# The number of previous additional interfaces supported by this library.
249# If age were `2', then this library can be linked into executables which
250# were built with a release of this library that exported the current
251# interface number, current, or any of the previous two interfaces.
252# By definition age must be less than or equal to current. At the outset,
253# only the first ever interface is implemented, so age can only be `0'.
254#
255#
256#
257
258LIBNETXMS_LIBRARY_VERSION=0:1:0
259AC_SUBST(LIBNETXMS_LIBRARY_VERSION)
260
261# --------------------------------------------------------------------------
262
263AC_CONFIG_FILES([
264 Makefile
265 README
266 doc/Makefile
267 m4/Makefile
268 sql/Makefile
269 include/Makefile
270 src/Makefile
271 src/libnetxms/Makefile
272 src/server/Makefile
273 src/server/core/Makefile
274])
275
276AC_OUTPUT