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