windows build fixed
[public/netxms.git] / configure.ac
CommitLineData
8e76f8aa 1# $Id$
d16cf8a5 2#
ef0c727b
VK
3# NetXMS - Network Management System
4# Configure script
d16cf8a5
AK
5#
6
467c489f 7AC_INIT([NetXMS], [1.1.0], [NetXMS Team <bugs@netxms.org>])
ba1d810c
AK
8AC_CONFIG_AUX_DIR(config)
9AM_CONFIG_HEADER(config.h)
d16cf8a5
AK
10AM_INIT_AUTOMAKE
11
aa24418a 12AC_CONFIG_MACRO_DIR([m4])
5387ff75 13
ef0c727b
VK
14#--------------------------------------------------------------------
15# Functions
16#--------------------------------------------------------------------
5387ff75 17
ef0c727b
VK
18check_substr()
19{
1010cff7 20 for w in $1; do
ef0c727b
VK
21 if test "x$w" = "x$2"; then
22 return 0;
23 fi
24 done
25 return 1
26}
16dff090 27
d3c8926d 28
ef0c727b
VK
29#--------------------------------------------------------------------
30# Initialize variables
31#--------------------------------------------------------------------
d3c8926d 32
ef0c727b
VK
33PLATFORM=`uname -s`
34COMPONENTS=""
35DISABLE_ICONV="no"
36DISABLE_ENCRYPTION="no"
37ENABLE_UNSTABLE="no"
f974a50a 38ENABLE_DEBUG="no"
ef0c727b
VK
39STATIC_BUILD="no"
40DBDRIVER_SELECTED="no"
41USE_PTH="no"
42BUILD_SERVER="no"
43BUILD_AGENT="no"
44BUILD_CLIENT="no"
45BUILD_NXHTTPD="no"
46BUILD_STATIC_AGENT="no"
47NEED_ZLIB="no"
d99ee887 48NEED_WXWIDGETS="no"
f65df2b1 49MODULES="libnetxms tools install"
ef0c727b
VK
50STATIC_SUBAGENT_LIST=""
51SUBAGENT_DIRS=""
52SUBAGENT_LIBS=""
53UNSTABLE_SUBAGENT_DIRS=""
54SERVER_TOOLS=""
55TOP_LEVEL_MODULES=""
56CONTRIB_MODULES=""
c2612d83 57CLIENT_COMPONENTS=""
8b86c5dc 58BUILD_UNICODE="no"
273da39a 59WX_UNICODE="no"
7d8c91ef 60ORACLE_LIBS=""
6fce76d8
VK
61PGSQL_LIBS=""
62MYSQL_LIBS=""
63ODBC_LIBS=""
467c489f 64FORCE_INTERNAL_EXPAT="no"
cc297a70 65FORCE_32BIT_BUILD="no"
d3c8926d 66
16dff090 67
ef0c727b 68#--------------------------------------------------------------------
fecf6a2b
VK
69# Common compilation flags
70#--------------------------------------------------------------------
71
72CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
73
74
75#--------------------------------------------------------------------
ef0c727b
VK
76# Parse command line parameters
77#--------------------------------------------------------------------
7c9c94a7 78
ef0c727b
VK
79AC_ARG_WITH(server,
80[AS_HELP_STRING(--with-server,build server)],
81[
8817f620 82 COMPONENTS="$COMPONENTS sqlite snmp server agent"
c5c0f362
VK
83])
84
85AC_ARG_WITH(snmp,
86[AS_HELP_STRING(--with-snmp,build SNMP library and tools)],
87[
88 COMPONENTS="$COMPONENTS snmp"
ef0c727b 89])
7c9c94a7 90
ef0c727b
VK
91AC_ARG_WITH(client,
92[AS_HELP_STRING(--with-client,build client library and tools)],
93[
94 COMPONENTS="$COMPONENTS client"
95])
d16cf8a5 96
c2612d83 97AC_ARG_WITH(agent,
ef0c727b
VK
98[AS_HELP_STRING(--with-agent,build agent)],
99[
8817f620 100 COMPONENTS="$COMPONENTS sqlite agent"
ef0c727b 101])
d16cf8a5 102
ef0c727b
VK
103AC_ARG_WITH(static-agent,
104[AS_HELP_STRING(--with-static-agent,build statically linked agent)],
105[
8817f620 106 COMPONENTS="$COMPONENTS sqlite static-agent"
ef0c727b 107])
d16cf8a5 108
ef0c727b
VK
109AC_ARG_WITH(ipso-agent,
110[AS_HELP_STRING(--with-ipso-agent,build statically linked IPSO agent)],
111[
8817f620 112 COMPONENTS="$COMPONENTS sqlite ipso-agent"
ef0c727b 113])
521d90e7 114
e02b69b9
VK
115AC_ARG_WITH(webui,
116[AS_HELP_STRING(--with-webui,build web interface)],
ef0c727b 117[
e02b69b9 118 COMPONENTS="$COMPONENTS webui"
ef0c727b 119])
d16cf8a5 120
ef0c727b
VK
121AC_ARG_WITH(mdebug,
122[AS_HELP_STRING(--with-mdebug,use debug version of memory allocation functions)],
123[
124 CPPFLAGS="$CPPFLAGS -DNETXMS_MEMORY_DEBUG"
125])
d16cf8a5 126
467c489f
VK
127AC_ARG_WITH(internal-libexpat,
128[AS_HELP_STRING(--with-internal-libexpat,force use of bundled libexpat)],
129[
130 FORCE_INTERNAL_EXPAT="yes"
131])
132
9486b324
VK
133AC_ARG_WITH(sqlite,
134[AS_HELP_STRING(--with-sqlite,build SQLite database driver)],
135[ if test "x$withval" != "xno" ; then
8817f620 136 COMPONENTS="$COMPONENTS sqlite_drv"
ef0c727b 137 DBDRIVER_SELECTED="yes"
9486b324
VK
138fi ])
139
c4b88c3d
VK
140AC_ARG_WITH(odbc,
141[AS_HELP_STRING(--with-odbc,build ODBC database driver)],
142[ if test "x$withval" != "xno" ; then
143 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
144 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
145 LDFLAGS="$LDFLAGS -L${withval}/lib"
146 CPPFLAGS="$CPPFLAGS -I${withval}/include"
ef0c727b
VK
147 fi
148 COMPONENTS="$COMPONENTS odbc"
149 DBDRIVER_SELECTED="yes"
c4b88c3d
VK
150fi ])
151
41b4790d
VK
152AC_ARG_WITH(oracle,
153[AS_HELP_STRING(--with-oracle,build Oracle database driver)],
154[ if test "x$withval" != "xno" ; then
155 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
7d8c91ef
VK
156 if test -x "$withval/lib" ; then
157 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
158 LDFLAGS="$LDFLAGS -L${withval}/lib"
159 else
160 LD_RUN_PATH="${withval}${LD_RUN_PATH:+:}${LD_RUN_PATH}"
161 LDFLAGS="$LDFLAGS -L${withval}"
162 fi
163 if test -x "$withval/include" ; then
164 CPPFLAGS="$CPPFLAGS -I${withval}/include"
165 fi
166 if test -x "$withval/sdk/include" ; then
167 CPPFLAGS="$CPPFLAGS -I${withval}/sdk/include"
168 fi
41b4790d
VK
169 fi
170 COMPONENTS="$COMPONENTS oracle"
171 DBDRIVER_SELECTED="yes"
172fi ])
173
d16cf8a5 174AC_ARG_WITH(mysql,
c4b88c3d 175[AS_HELP_STRING(--with-mysql,build MySQL database driver)],
d16cf8a5
AK
176[ if test "x$withval" != "xno" ; then
177 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
178 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
179 LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/mysql -L${withval}/mysql/lib"
6693a1d0 180 CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/mysql -I${withval}/mysql/include"
d16cf8a5 181 else
007ae516
VK
182 LD_RUN_PATH="/usr/local/mysql/lib:/usr/local/mysql/lib/mysql:/usr/lib64/mysql:/usr/lib/mysql:/usr/mysql/lib:/usr/mysql/lib/mysql:/usr/local/lib/mysql:${LD_RUN_PATH:+:}${LD_RUN_PATH}"
183 LDFLAGS="$LDFLAGS -L/usr/local/mysql/lib -L/usr/lib64/mysql -L/usr/lib/mysql -L/usr/mysql/lib -L/usr/local/lib/mysql -L/usr/local/mysql/lib/mysql -L/usr/mysql/lib/mysql"
6693a1d0 184 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"
d16cf8a5 185 fi
ef0c727b
VK
186 COMPONENTS="$COMPONENTS mysql"
187 DBDRIVER_SELECTED="yes"
6693a1d0 188fi ])
d16cf8a5
AK
189
190AC_ARG_WITH(pgsql,
c4b88c3d 191[AS_HELP_STRING(--with-pgsql,build PostgreSQL database driver)],
d16cf8a5 192[ if test "x$withval" != "xno" ; then
6693a1d0
AK
193 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
194 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
195 LDFLAGS="$LDFLAGS -L${withval}/lib -L${withval}/lib/pgsql -L${withval}/lib/postgresql -L${withval}/pgsql/lib -L${withval}/postgresql/lib"
196 CPPFLAGS="$CPPFLAGS -I${withval}/include -I${withval}/include/pgsql -I${withval}/include/postgresql -I${withval}/pgsql/include -I${withval}/postgresql/include"
197 else
007ae516
VK
198 LD_RUN_PATH="/usr/local/pgsql/lib:/usr/local/pgsql/lib/pgsql:/usr/lib64/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}"
199 LDFLAGS="$LDFLAGS -L/usr/local/pgsql/lib -L/usr/lib64/pgsql -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"
6693a1d0
AK
200 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"
201 fi
ef0c727b
VK
202 COMPONENTS="$COMPONENTS pgsql"
203 DBDRIVER_SELECTED="yes"
6693a1d0 204fi ])
d16cf8a5 205
84277a0f
AK
206AC_ARG_WITH(db2,
207[AS_HELP_STRING(--with-db2,build DB2 database driver)],
208[ if test "x$withval" != "xno" ; then
209 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
210 if test `uname -m` = 'i386' || test `uname -m` = 'i686'; then
211 DB2_LIB_DIR=lib32
212 else
213 DB2_LIB_DIR=lib64
214 fi
215 if test -x "$withval/${DB2_LIB_DIR}" ; then
216 LD_RUN_PATH="${withval}/${DB2_LIB_DIR}${LD_RUN_PATH:+:}${LD_RUN_PATH}"
217 LDFLAGS="$LDFLAGS -L${withval}/${DB2_LIB_DIR}"
218 else
219 LD_RUN_PATH="${withval}${LD_RUN_PATH:+:}${LD_RUN_PATH}"
220 LDFLAGS="$LDFLAGS -L${withval}"
221 fi
222 if test -x "$withval/include" ; then
223 CPPFLAGS="$CPPFLAGS -I${withval}/include"
224 fi
225
226 unset DB2_LIB_DIR
227 fi
228 COMPONENTS="$COMPONENTS db2"
229 DBDRIVER_SELECTED="yes"
230fi ])
231
ef0c727b 232AC_ARG_WITH(openssl,
1010cff7
VK
233[AS_HELP_STRING(--with-openssl,specify OpenSSL location)],
234[
235 if test "x$withval" != "xno" ; then
236 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
237 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
238 LDFLAGS="$LDFLAGS -L${withval}/lib"
239 CPPFLAGS="$CPPFLAGS -I${withval}/include"
240 else
241 LD_RUN_PATH="/usr/local/lib:/opt/openssl/lib:/usr/local/ssl/lib:${LD_RUN_PATH:+:}${LD_RUN_PATH}"
242 LDFLAGS="$LDFLAGS -L/usr/local/lib -L/opt/openssl/lib"
4d37b0c5 243 CPPFLAGS="$CPPFLAGS -I/opt/openssl/include"
ef0c727b 244 fi
1010cff7
VK
245 fi
246 REQUIRE_ENCRYPTION="yes"
247])
ef0c727b 248
c3cfc039
VK
249AC_ARG_WITH(gd,
250[AS_HELP_STRING(--with-gd,specify GD location)],
251[
252 if test "x$withval" != "x" && test "x$withval" != "xyes" ; then
253 LD_RUN_PATH="${withval}/lib${LD_RUN_PATH:+:}${LD_RUN_PATH}"
254 LDFLAGS="$LDFLAGS -L${withval}/lib"
255 CPPFLAGS="$CPPFLAGS -I${withval}/include"
256 fi
257])
258
ef0c727b
VK
259AC_ARG_ENABLE(iconv,
260[AS_HELP_STRING(--disable-iconv,do not use iconv() for text conversions)],
3a7ce527 261[
ef0c727b 262 DISABLE_ICONV="yes"
3a7ce527 263])
3a7ce527 264
ef0c727b
VK
265AC_ARG_ENABLE(encryption,
266[AS_HELP_STRING(--disable-encryption,disable encryption support)],
e0760102 267[
ef0c727b 268 DISABLE_ENCRYPTION="yes"
e0760102
VK
269])
270
ef0c727b
VK
271AC_ARG_ENABLE(unstable,
272[AS_HELP_STRING(--enable-unstable,build experimental/unstable components)],
d8ca9c03 273[
ef0c727b 274 ENABLE_UNSTABLE="yes"
d8ca9c03
VK
275])
276
f974a50a
VK
277AC_ARG_ENABLE(debug,
278[AS_HELP_STRING(--enable-debug,enable additional debugging functionality)],
279[
280 ENABLE_DEBUG="yes"
281])
282
cc297a70
VK
283AC_ARG_ENABLE(64bit,
284[AS_HELP_STRING(--disable-64bit,disable 64bit build (force 32bit build event on 64bit machine))],
285[
286 FORCE_32BIT_BUILD="yes"
287])
288
ef0c727b
VK
289AC_ARG_WITH(dist,
290[AS_HELP_STRING(--with-dist,for maintainers only)],
84277a0f 291 DB_DRIVERS=" mysql pgsql odbc mssql sqlite oracle db2"
f65df2b1 292 MODULES="libexpat libnetxms install sqlite snmp libnxsl libnxlp db server agent libnxmap libnxcl client nxscript tools webui"
ad0f1ada 293 SUBAGENT_DIRS="linux freebsd openbsd netbsd sunos aix ipso hpux"
ef0c727b
VK
294 NXCONFIG="nxconfig"
295 TOP_LEVEL_MODULES="sql images"
296 CONTRIB_MODULES="mibs backgrounds"
aa24418a 297 CLIENT_COMPONENTS="nxalarm nxevent nxpush nxsms"
24f89c3a 298 UNSTABLE_SUBAGENT_DIRS="odbcquery"
ef0c727b
VK
299 SERVER_TOOLS="nxconfig"
300)
301
d8ca9c03 302
ef0c727b
VK
303#--------------------------------------------------------------------
304# Validate command line parameters and set various checking options
305#--------------------------------------------------------------------
306
8817f620
VK
307check_substr "$COMPONENTS" "sqlite"
308if test $? = 0; then
309 MODULES="$MODULES sqlite"
310fi
311
ef0c727b 312check_substr "$COMPONENTS" "static-agent"
1010cff7 313if test $? = 0; then
ef0c727b
VK
314 if test "x$COMPONENTS" != "x static-agent"; then
315 AC_MSG_ERROR(Static agent and other components are mutally exclusive.)
316 fi
317 STATIC_BUILD="yes"
318 BUILD_STATIC_AGENT="yes"
aa8d6795 319 MODULES="$MODULES libnxlp agent"
3a6979cf 320 DISABLE_ICONV="yes"
ef0c727b 321 CPPFLAGS="$CPPFLAGS -D_STATIC_AGENT"
e8636669 322
ef0c727b 323 case "$PLATFORM" in
e8636669
VK
324 Linux)
325 SUBAGENT_DIRS="linux"
d0b5a098
VK
326 SUBAGENT_LIBS="../subagents/linux/libnsm_linux.la"
327 STATIC_SUBAGENT_LIST="linux $STATIC_SUBAGENT_LIST"
e8636669
VK
328 ;;
329 FreeBSD)
330 SUBAGENT_DIRS="freebsd"
d0b5a098
VK
331 SUBAGENT_LIBS="../subagents/freebsd/libnsm_freebsd.la"
332 STATIC_SUBAGENT_LIST="freebsd $STATIC_SUBAGENT_LIST"
e8636669 333 ;;
992ba479
AK
334 OpenBSD)
335 SUBAGENT_DIRS="openbsd"
336 SUBAGENT_LIBS="../subagents/openbsd/libnsm_openbsd.la"
337 STATIC_SUBAGENT_LIST="openbsd $STATIC_SUBAGENT_LIST"
338 ;;
ad0f1ada
VK
339 NetBSD)
340 SUBAGENT_DIRS="netbsd"
341 SUBAGENT_LIBS="../subagents/netbsd/libnsm_netbsd.la"
342 STATIC_SUBAGENT_LIST="netbsd $STATIC_SUBAGENT_LIST"
343 ;;
e8636669
VK
344 SunOS)
345 SUBAGENT_DIRS="sunos"
d0b5a098
VK
346 SUBAGENT_LIBS="../subagents/sunos/libnsm_sunos.la"
347 STATIC_SUBAGENT_LIST="sunos $STATIC_SUBAGENT_LIST"
348 ;;
349 AIX)
350 SUBAGENT_DIRS="aix"
351 SUBAGENT_LIBS="../subagents/aix/libnsm_aix.la"
352 STATIC_SUBAGENT_LIST="aix $STATIC_SUBAGENT_LIST"
e8636669 353 ;;
c29360a9
VK
354 HP-UX)
355 SUBAGENT_DIRS="hpux"
356 SUBAGENT_LIBS="../subagents/hpux/libnsm_hpux.la"
357 STATIC_SUBAGENT_LIST="hpux $STATIC_SUBAGENT_LIST"
358 ;;
e8636669
VK
359 *)
360 # unknown
361 ;;
362 esac
ef0c727b 363fi
2b23dc1e 364
ef0c727b 365check_substr "$COMPONENTS" "ipso-agent"
1010cff7 366if test $? = 0; then
fd5a401b 367 if test "x$COMPONENTS" != "x ipso-agent"; then
ef0c727b
VK
368 AC_MSG_ERROR(IPSO agent and other components are mutally exclusive.)
369 fi
370 STATIC_BUILD="yes"
371 BUILD_STATIC_AGENT="yes"
3a6979cf 372 DISABLE_ICONV="yes"
ef0c727b 373 USE_PTH="yes"
aa8d6795 374 MODULES="$MODULES libnxlp agent"
aa24418a 375 CPPFLAGS="$CPPFLAGS -D_STATIC_AGENT -D_IPSO -D_USE_GNU_PTH -DSQLITE_THREADSAFE=0 -I/usr/local/include"
ef0c727b
VK
376 LDFLAGS="$LDFLAGS -all-static"
377 STATIC_SUBAGENT_LIST="ipso ping portcheck ups"
378 SUBAGENT_DIRS="ipso"
379 SUBAGENT_LIBS="../subagents/ipso/libnsm_ipso.la ../subagents/ping/libnsm_ping.la ../subagents/portCheck/libnsm_portCheck.la ../subagents/ups/libnsm_ups.la"
380fi
c688d2a7 381
c5c0f362
VK
382check_substr "$COMPONENTS" "snmp"
383if test $? = 0; then
384 NEED_ZLIB="yes"
385 MODULES="$MODULES snmp"
386fi
387
ef0c727b 388check_substr "$COMPONENTS" "server"
1010cff7 389if test $? = 0; then
ef0c727b
VK
390 if test "x$DBDRIVER_SELECTED" != "xyes"; then
391 AC_MSG_ERROR(You must select at least one database driver when building server.)
392 fi
393 BUILD_SERVER="yes"
d1834406 394 MODULES="$MODULES libnxmap libnxsl libnxlp db server nxscript"
ef0c727b
VK
395 TOP_LEVEL_MODULES="$TOP_LEVEL_MODULES sql images"
396 CONTRIB_MODULES="$CONTRIB_MODULES mibs backgrounds"
397fi
dff54fed 398
e44986e5
VK
399check_substr "$COMPONENTS" "client"
400if test $? = 0; then
401 BUILD_CLIENT="yes"
402 NEED_ZLIB="yes"
aa24418a 403 MODULES="$MODULES libnxmap libnxcl client"
36ad9f45 404 CLIENT_COMPONENTS="$CLIENT_COMPONENTS nxalarm nxevent nxpush nxsms"
e44986e5
VK
405fi
406
ef0c727b 407check_substr "$COMPONENTS" "agent"
1010cff7 408if test $? = 0; then
ef0c727b 409 BUILD_AGENT="yes"
28ba6824 410 MODULES="$MODULES libnxlp db agent"
ef0c727b 411 if test "x$ENABLE_UNSTABLE" = "xyes"; then
24f89c3a 412 UNSTABLE_SUBAGENT_DIRS="odbcquery"
987b646a 413 fi
1010cff7
VK
414
415 case "$PLATFORM" in
416 Linux)
417 SUBAGENT_DIRS="linux"
418 ;;
419 FreeBSD)
420 SUBAGENT_DIRS="freebsd"
421 ;;
422 OpenBSD)
423 SUBAGENT_DIRS="openbsd"
424 ;;
ad0f1ada
VK
425 NetBSD)
426 SUBAGENT_DIRS="netbsd"
427 ;;
1010cff7
VK
428 SunOS)
429 SUBAGENT_DIRS="sunos"
430 ;;
431 AIX)
432 SUBAGENT_DIRS="aix"
433 ;;
434 HP-UX)
435 SUBAGENT_DIRS="hpux"
436 ;;
437 *)
438 # unknown
439 ;;
440 esac
ef0c727b 441fi
b97191d2 442
e02b69b9 443check_substr "$COMPONENTS" "webui"
1010cff7 444if test $? = 0; then
ef0c727b 445 BUILD_NXHTTPD="yes"
e02b69b9 446 MODULES="$MODULES libnxmap libnxcl webui"
ef0c727b 447fi
b67a9e12 448
ef0c727b 449check_substr "$COMPONENTS" "mysql"
1010cff7 450if test $? = 0; then
ef0c727b 451 DB_DRIVERS="$DB_DRIVERS mysql"
b67a9e12 452fi
6619a6b0 453
ef0c727b 454check_substr "$COMPONENTS" "pgsql"
1010cff7 455if test $? = 0; then
ef0c727b
VK
456 DB_DRIVERS="$DB_DRIVERS pgsql"
457fi
e8636669 458
8817f620 459check_substr "$COMPONENTS" "sqlite_drv"
1010cff7 460if test $? = 0; then
ef0c727b 461 DB_DRIVERS="$DB_DRIVERS sqlite"
e8636669
VK
462fi
463
ef0c727b 464check_substr "$COMPONENTS" "odbc"
1010cff7 465if test $? = 0; then
ef0c727b
VK
466 DB_DRIVERS="$DB_DRIVERS odbc"
467fi
468
41b4790d
VK
469check_substr "$COMPONENTS" "oracle"
470if test $? = 0; then
471 DB_DRIVERS="$DB_DRIVERS oracle"
472fi
473
84277a0f
AK
474check_substr "$COMPONENTS" "db2"
475if test $? = 0; then
476 DB_DRIVERS="$DB_DRIVERS db2"
477fi
478
ef0c727b
VK
479
480#--------------------------------------------------------------------
481# Check for programs
482#--------------------------------------------------------------------
483
484if test "x$PLATFORM" = "xHP-UX"; then
e7d9c4ae 485 AC_CHECK_PROG([CCC], [aCC], [aCC])
ef0c727b
VK
486fi
487AC_PROG_CC(aCC gcc cc cl)
488AC_PROG_CPP
489AC_PROG_CXX
c3cfc039 490if test "x$CXX" = "xg++"; then
753206b5
AK
491 AC_CHECK_PROG([GPLUSPLUS], [g++], [yes], [no])
492 if test "x$GPLUSPLUS" = "xno"; then
c3cfc039
VK
493 AC_MSG_ERROR([*** FATAL: Cannot find any usable C++ compiler])
494 fi
495fi
ef0c727b
VK
496AC_PROG_INSTALL
497AC_PROG_LEX
76154a95 498AC_CHECK_PROGS(YACC,bison byacc,yacc)
ef0c727b
VK
499AC_PROG_LN_S
500
501AC_ARG_VAR(PERL,local path to the perl interpreter)
502perl_possible_path="/usr/bin:/usr/local/bin:/bin:/opt/perl/bin:/opt/perl/usr/bin:/opt/perl/usr/local/bin"
503AC_PATH_PROG(PERL,perl,/usr/bin/env perl,$perl_possible_path)
504
505
506#--------------------------------------------------------------------
507# Initialize libtool
508#--------------------------------------------------------------------
509
510if test "x$STATIC_BUILD" = "xyes"; then
511 enable_shared=no
512 enable_static=yes
513else
514 enable_shared=yes
515 enable_static=no
516fi
e8636669
VK
517AC_LIBTOOL_DLOPEN
518AC_PROG_LIBTOOL
3a7ce527 519
d16cf8a5 520
ef0c727b
VK
521#--------------------------------------------------------------------
522# C/C++ capabilities
523#--------------------------------------------------------------------
524
525AC_C_CONST
526AC_PROG_GCC_TRADITIONAL
1d9cc60e 527AC_C_BIGENDIAN
ef0c727b
VK
528
529
530#--------------------------------------------------------------------
531# Platform-dependent settings
532#--------------------------------------------------------------------
533
534case "$PLATFORM" in
535 AIX)
9fedef8b 536 LDFLAGS="-no-undefined -Wl,-brtl $LDFLAGS"
ef0c727b
VK
537 ;;
538 HP-UX)
5a5957b2 539 CPPFLAGS="$CPPFLAGS -D_HPUX -D_HPUX_SOURCE -D_POSIX_PTHREAD_SEMANTICS -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED=1 -D_REENTRANT"
ef0c727b
VK
540 if test "x$CXX" = "xaCC"; then
541 CXXFLAGS="-mt $CXXFLAGS +W749 +W829"
542 LDFLAGS="$LDFLAGS -mt"
543 fi
544 ;;
75c30ed4 545 SunOS)
27ed5b1d 546 CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
75c30ed4
VK
547 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
548 export LD_LIBRARY_PATH
549 ;;
56b2f755
VK
550 Linux)
551 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
552 ;;
ef0c727b
VK
553 *)
554 ;;
555esac
556
557
558#--------------------------------------------------------------------
c90d3610 559# C++ compiler tuning:
cc297a70 560# * Disable C++ exceptions and RTTI
779ce551 561# * Turn on 64bit mode on HP-UX/Itanium
cc297a70 562# * Turn on 64bit mode on AIX
ef0c727b
VK
563#--------------------------------------------------------------------
564
565if test "x$CC" = "xgcc" ; then
566
567 AC_LANG_PUSH([C++])
568
569 AC_MSG_CHECKING(whether C++ compiler accepts -fno-rtti)
570 OLD_CXXFLGAS="$CXXFLAGS"
571 CXXFLAGS="$CXXFLAGS -fno-rtti"
572 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
573 [ AC_MSG_RESULT(yes) ],
574 [
575 CXXFLAGS="$OLD_CXXFLAGS"
576 AC_MSG_RESULT(no)
577 ])
578
579 AC_MSG_CHECKING(whether C++ compiler accepts -fno-exceptions)
580 OLD_CXXFLGAS="$CXXFLAGS"
581 CXXFLAGS="$CXXFLAGS -fno-exceptions"
582 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
583 [ AC_MSG_RESULT(yes) ],
584 [
585 CXXFLAGS="$OLD_CXXFLAGS"
586 AC_MSG_RESULT(no)
587 ])
588
589 AC_LANG_POP([C++])
590
779ce551 591 if test "x$PLATFORM" = "xHP-UX"; then
cc297a70
VK
592 if test "x$FORCE_32BIT_BUILD" = "xyes"; then
593 AC_MSG_CHECKING(whether C compiler accepts -milp32)
594 OLD_CPPFLAGS="$CPPFLAGS"
595 CPPFLAGS="$CPPFLAGS -milp32"
596 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
597 [
598 LDFLAGS="-milp32 $LDFLAGS"
599 AC_MSG_RESULT(yes)
600 ],
601 [
602 CPPFLAGS="$OLD_CPPFLAGS"
603 AC_MSG_RESULT(no)
604 ])
605 else
606 AC_MSG_CHECKING(whether C compiler accepts -mlp64)
607 OLD_CPPFLAGS="$CPPFLAGS"
608 CPPFLAGS="$CPPFLAGS -mlp64"
609 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
610 [
611 LDFLAGS="-mlp64 -L/usr/lib/hpux64 -L/usr/local/lib/hpux64 $LDFLAGS"
612 AC_MSG_RESULT(yes)
613 ],
614 [
615 CPPFLAGS="$OLD_CPPFLAGS"
616 AC_MSG_RESULT(no)
617 ])
618 fi
619 fi
620
621 if test "x$PLATFORM" = "xAIX"; then
622 if test "x$FORCE_32BIT_BUILD" = "xyes"; then
623 AC_MSG_CHECKING(whether C compiler accepts -maix32)
624 OLD_CPPFLAGS="$CPPFLAGS"
625 CPPFLAGS="$CPPFLAGS -maix32"
fecf6a2b 626 AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
cc297a70
VK
627 [
628 LDFLAGS="-maix32 $LDFLAGS"
1c45282c
VK
629 OBJECT_MODE=32
630 AC_SUBST(OBJECT_MODE)
cc297a70
VK
631 AC_MSG_RESULT(yes)
632 ],
633 [
634 CPPFLAGS="$OLD_CPPFLAGS"
635 AC_MSG_RESULT(no)
636 ])
637 else
638 AC_MSG_CHECKING(whether C compiler accepts -maix64)
639 OLD_CPPFLAGS="$CPPFLAGS"
640 CPPFLAGS="$CPPFLAGS -maix64"
fecf6a2b 641 AC_RUN_IFELSE([AC_LANG_PROGRAM([[ ]], [[ ]])],
cc297a70
VK
642 [
643 LDFLAGS="-maix64 $LDFLAGS"
1c45282c
VK
644 OBJECT_MODE=64
645 AC_SUBST(OBJECT_MODE)
cc297a70
VK
646 AC_MSG_RESULT(yes)
647 ],
648 [
649 CPPFLAGS="$OLD_CPPFLAGS"
650 AC_MSG_RESULT(no)
651 ])
652 fi
779ce551
VK
653 fi
654
ce5592b2
VK
655 if test "x$ENABLE_DEBUG" = "xyes"; then
656 CPPFLAGS="$CPPFLAGS -ggdb3"
657 fi
ef0c727b
VK
658fi
659
660
661#--------------------------------------------------------------------
662# Additional include and library directories
663#--------------------------------------------------------------------
664
665if test -d /usr/local/include; then
4d37b0c5
VK
666 if test "x$CC" = "xgcc"; then
667 AC_MSG_CHECKING(whether -I/usr/local/include needed)
668 OLD_CPPFLAGS="$CPPFLAGS"
669 CPPFLAGS="$CPPFLAGS -Werror -I/usr/local/include"
670 AC_TRY_COMPILE([],[],
671 [
672 CPPFLAGS="$OLD_CPPFLAGS -I/usr/local/include"
673 AC_MSG_RESULT(yes)
674 ],
675 [
676 CPPFLAGS="$OLD_CPPFLAGS"
677 AC_MSG_RESULT(no)
678 ]
679 )
680 else
681 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
682 fi
ef0c727b
VK
683fi
684
685if test -d /usr/kerberos/include; then
686 CPPFLAGS="$CPPFLAGS -I/usr/kerberos/include"
687fi
688
689if test -d /usr/local/lib; then
690 LDFLAGS="$LDFLAGS -L/usr/local/lib"
691fi
692
693
694#--------------------------------------------------------------------
695# Check for threads library - either POSIX or GNU
696#--------------------------------------------------------------------
697
698if test "x$USE_PTH" = "xyes"; then
699 AC_CHECK_HEADER(pth.h,,AC_MSG_ERROR([*** GNU Pth thread support not installed - please install first ***]))
700else
701 AC_CHECK_HEADER(pthread.h,,AC_MSG_ERROR([*** POSIX thread support not installed - please install first ***]))
702
703 if test "x$CXX" = "xaCC"; then
704 PTHREAD_LIBS=""
705 else
706 PTHREAD_LIBS="error"
707 AC_MSG_CHECKING(for old style FreeBSD -pthread flag)
708 AC_EGREP_CPP(yes,
709 [#if defined(__FreeBSD_cc_version) || defined(__OpenBSD__)
710 yes
711 #endif
712 ], AC_MSG_RESULT(yes)
fecf6a2b 713 PTHREAD_LIBS="-pthread",
ef0c727b
VK
714 AC_MSG_RESULT(no))
715 if test "x$PTHREAD_LIBS" = "xerror"; then
716 AC_CHECK_LIB(pthread, pthread_attr_init,
717 PTHREAD_LIBS="-lpthread")
718 fi
f725c1b7 719 # On HP-UX (at least 11.00) pthread library contains
b041c587 720 # __pthread_attr_init_system instead of pthread_attr_init
f725c1b7 721 if test "x$PTHREAD_LIBS" = "xerror"; then
b041c587 722 AC_CHECK_LIB(pthread, __pthread_attr_init_system,
f725c1b7
VK
723 PTHREAD_LIBS="-lpthread")
724 fi
ef0c727b
VK
725 if test "x$PTHREAD_LIBS" = "xerror"; then
726 AC_CHECK_LIB(pthreads, pthread_attr_init,
727 PTHREAD_LIBS="-lpthreads")
728 fi
729 if test "x$PTHREAD_LIBS" = "xerror"; then
730 AC_CHECK_FUNC(pthread_attr_init,
731 PTHREAD_LIBS="")
732 fi
733 fi
734
735 if test "x$PTHREAD_LIBS" = "xerror"; then
736 AC_MSG_ERROR(*** Unable to locate working posix thread library ***)
737 fi
8d131dda 738 LIBS="$LIBS $PTHREAD_LIBS"
ef0c727b
VK
739
740 # Extensions to posix threads
741 AC_CHECK_HEADERS([pthread_np.h],,,[
9c29f76e 742#include <pthread.h>
ef0c727b
VK
743 ])
744 AC_CHECK_FUNCS([pthread_cond_reltimedwait_np])
745
746 # Check for recursive mutexes
39086394
VK
747 AC_CHECK_FUNCS([pthread_mutexattr_settype __pthread_mutexattr_settype pthread_mutexattr_setkind_np])
748 AC_CHECK_DECLS([pthread_mutexattr_settype, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_RECURSIVE_NP, MUTEX_TYPE_COUNTING_FAST],,,[
9c29f76e
VK
749#include <pthread.h>
750#if HAVE_PTHREAD_NP_H
751#include <pthread_np.h>
752#endif
ef0c727b
VK
753 ])
754
755 # Check for read/write locks
756 # On Linux, rwlock functions declared always, but pthread_rwlock_t may need
757 # additional defines
758 AC_CHECK_FUNCS([pthread_rwlock_init pthread_rwlock_timedrdlock pthread_rwlock_timedwrlock])
759 if test "$ac_cv_func_pthread_rwlock_init" = "yes"; then
760 AC_CACHE_CHECK([for pthread_rwlock_t], ac_cv_struct_pthread_rw,
9c29f76e
VK
761 [AC_TRY_COMPILE([
762#include <sys/types.h>
763#include <pthread.h>
764 ],
ef0c727b
VK
765 [pthread_rwlock_t rwlock=PTHREAD_RWLOCK_INITIALIZER;],
766 ac_cv_struct_pthread_rw=yes, [
9c29f76e
VK
767 AC_TRY_COMPILE([
768#define _XOPEN_SOURCE 500
769#include <sys/types.h>
770#include <pthread.h>
771 ],
ef0c727b
VK
772 [pthread_rwlock_t rwlock=PTHREAD_RWLOCK_INITIALIZER;],
773 ac_cv_struct_pthread_rw=yes, ac_cv_struct_pthread_rw=no)
774 if test "$ac_cv_struct_pthread_rw" = "yes"; then
775 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
776 fi
777 ])])
778 if test "$ac_cv_struct_pthread_rw" = "yes"; then
779 AC_DEFINE(HAVE_PTHREAD_RWLOCK, 1, Define to 1 if you have working pthread read/write locks)
780 fi
781 fi
782
783fi
784
785
786#--------------------------------------------------------------------
787# Checks for OpenSSL
788#--------------------------------------------------------------------
789
790if test "x$DISABLE_ENCRYPTION" != "xyes" ; then
791 AC_CHECK_LIB(crypto, RSA_new,
792 [
793 AC_DEFINE(WITH_OPENSSL,,[with openssl])
794 AC_CHECK_LIB(crypto, EVP_aes_256_cbc,
795 [], [AC_DEFINE(NETXMS_NO_AES,,[desc])])
796 AC_CHECK_LIB(crypto, EVP_bf_cbc,
797 [], [AC_DEFINE(NETXMS_NO_BF,,[desc])])
798 AC_CHECK_LIB(crypto, EVP_idea_cbc,
799 [], [AC_DEFINE(NETXMS_NO_IDEA,,[desc])])
800 AC_CHECK_LIB(crypto, EVP_des_ede3_cbc,
801 [], [AC_DEFINE(NETXMS_NO_DES,,[desc])])
802 ],
803 [
804 if test "x$REQUIRE_ENCRYPTION" = "xyes"; then
805 AC_MSG_ERROR(libcrypto is required for encryption support)
806 else
807 AC_MSG_RESULT(libcrypto is required for encryption support)
808 fi
809 ])
810fi
811
812
813#--------------------------------------------------------------------
0322eed7
VK
814# Checks for header files
815#--------------------------------------------------------------------
816
817AC_CHECK_HEADERS([sys/types.h sys/stat.h unistd.h stdarg.h fcntl.h alloca.h])
818AC_CHECK_HEADERS([sys/int_types.h time.h sys/time.h sys/utsname.h])
819AC_CHECK_HEADERS([arpa/inet.h netdb.h netinet/in.h net/nh.h sys/socket.h])
820AC_CHECK_HEADERS([fcntl.h dirent.h sys/ioctl.h sys/sockio.h poll.h termios.h])
821AC_CHECK_HEADERS([inttypes.h memory.h stdint.h stdlib.h strings.h string.h])
822AC_CHECK_HEADERS([readline/readline.h byteswap.h sys/select.h dlfcn.h])
823AC_CHECK_HEADERS([sys/sysctl.h sys/param.h sys/user.h vm/vm_param.h syslog.h getopt.h])
f09c2d05 824AC_CHECK_HEADERS([net/if.h net/if_arp.h net/if_dl.h net/if_types.h],,,
0322eed7
VK
825[[#ifdef HAVE_SYS_TYPES_H
826# include <sys/types.h>
827#endif
828#ifdef HAVE_SYS_TIME_H
829# include <sys/time.h>
830#endif
831#ifdef HAVE_SYS_SOCKET_H
832# include <sys/socket.h>
833#endif
834]])
835
836
837#--------------------------------------------------------------------
ef0c727b
VK
838# Checks for other libs.
839#--------------------------------------------------------------------
d16cf8a5 840
779ce551 841AC_CHECK_LIB(xnet, accept)
521d90e7 842AC_CHECK_LIB(socket, if_nameindex)
87bb64a7 843AC_CHECK_LIB(dl, dlopen)
1b3c0ef0 844AC_CHECK_LIB(kstat, kstat_open)
b821526a 845AC_CHECK_LIB(gnugetopt, getopt_long)
d16cf8a5 846
e0760102
VK
847if test "x$BUILD_SERVER" = "xyes" ; then
848 AC_CHECK_LIB(termcap, tgetstr, [], [AC_CHECK_LIB(ncurses, tgetstr, [], AC_CHECK_LIB(curses, tgetstr))])
0322eed7
VK
849 AC_CHECK_LIB(readline, readline, [], [AC_CHECK_LIB(edit, readline)])
850 AC_CHECK_FUNCS([readline])
851
852 # Check if passing rl_insert to rl_bind_key needs cast
853 if test "$ac_cv_func_readline" = "yes"; then
854 AC_LANG_PUSH([C++])
855
856 AC_MSG_CHECKING(for rl_insert cast)
857
858 AC_TRY_COMPILE(
859 [
860#include <stdio.h>
861#include <readline/readline.h>
862 ],[ rl_bind_key('\t', (Function *)rl_insert); ],
863 [
864 AC_MSG_RESULT((Function *))
865 AC_DEFINE(RL_INSERT_CAST,(Function *),Required cast for rl_insert)
866 ],[
867 AC_TRY_COMPILE(
868 [
869#include <stdio.h>
870#include <readline/readline.h>
871 ],[ rl_bind_key('\t', (rl_command_func_t *)rl_insert); ],
872 [
873 AC_MSG_RESULT((rl_command_func_t *))
874 AC_DEFINE(RL_INSERT_CAST,(rl_command_func_t *),Required cast for rl_insert)
875 ],[
876 AC_MSG_RESULT(not needed)
877 AC_DEFINE(RL_INSERT_CAST,,Required cast for rl_insert)
878 ]
879 )
880 ]
881 )
882
883 AC_LANG_POP([C++])
884 fi
e0760102
VK
885fi
886
ef0c727b
VK
887if test "x$NEED_ZLIB" = "xyes"; then
888 AC_CHECK_HEADER(zlib.h,,AC_MSG_ERROR([*** ZLib development package not installed - please install first ***]))
889 AC_CHECK_LIB(z, deflate)
890fi
891
467c489f
VK
892if test "x$FORCE_INTERNAL_EXPAT" = "xyes"; then
893 HAVE_LIBEXPAT=no
894else
895 HAVE_LIBEXPAT=yes
896 AC_CHECK_HEADER(expat.h,,HAVE_LIBEXPAT=no)
897 AC_CHECK_LIB(expat, XML_Parse, [], [ HAVE_LIBEXPAT=no ])
898fi
80ce37ac
VK
899if test "x$HAVE_LIBEXPAT" = "xno"; then
900 MODULES="libexpat $MODULES"
901 CPPFLAGS="$CPPFLAGS "
1bb6b449 902fi
ef0c727b 903
da9e62bc
AK
904AC_CHECK_HEADER(tre/tre.h,,AC_MSG_ERROR([*** libtre-dev not installed - please install first ***]))
905AC_CHECK_LIB(tre, tre_compile, [], [
906 AC_MSG_ERROR(libtre is required)
907 ])
ef0c727b
VK
908
909#--------------------------------------------------------------------
910# Checks for data types
911#--------------------------------------------------------------------
912
d16cf8a5
AK
913AC_CHECK_SIZEOF(short)
914AC_CHECK_SIZEOF(int)
915AC_CHECK_SIZEOF(long)
916AC_CHECK_SIZEOF(long long)
917
918AC_TYPE_PID_T
919AC_TYPE_SIGNAL
920AC_TYPE_SIZE_T
921AC_STRUCT_TIMEZONE
922
51128b42
VK
923AC_CHECK_TYPES([long long, unsigned long long, int64_t, uint64_t, u_int64_t])
924AC_CHECK_TYPES([mode_t, off_t, socklen_t],,,[
4c779d83
VK
925#if HAVE_SYS_TYPES_H
926#include <sys/types.h>
927#endif
928#if HAVE_SYS_SOCKET_H
929#include <sys/socket.h>
930#endif
931])
e0293f7f
VK
932AC_CHECK_TYPES([struct stat64],,,[
933#if HAVE_SYS_STAT_H
934#include <sys/stat.h>
935#endif
936])
521d90e7 937
e25cadc9 938
ef0c727b
VK
939#--------------------------------------------------------------------
940# Checks for functions
941#--------------------------------------------------------------------
d16cf8a5
AK
942
943AC_FUNC_ERROR_AT_LINE
d16cf8a5 944AC_FUNC_MEMCMP
d16cf8a5
AK
945AC_FUNC_SELECT_ARGTYPES
946AC_FUNC_STRFTIME
947AC_FUNC_STRTOD
948AC_FUNC_VPRINTF
949
80ce37ac 950AC_CHECK_FUNCS([gettimeofday memmove memset bcopy strchr strcspn strdup strerror])
b50f1100 951AC_CHECK_FUNCS([strrchr strtol strtoul strtoll strtoull])
467e30e1 952AC_CHECK_FUNCS([if_nametoindex daemon mmap strerror_r scandir uname poll])
aa24418a
VK
953AC_CHECK_FUNCS([usleep nanosleep getopt_long gmtime_r localtime_r lstat64])
954
955AC_CHECK_DECLS([nanosleep])
be6467e9 956
b0823d06
VK
957# Check if strerror_r is POSIX-compliant
958if test "$ac_cv_func_strerror_r" = "yes"; then
959 AC_MSG_CHECKING(if strerror_r is POSIX compliant)
960 AC_LANG_PUSH([C++])
961 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
7f9423af
VK
962#if HAVE_STRING_H
963#include <string.h>
964#endif
965#if HAVE_ERRNO_H
966#include <errno.h>
967#endif
b0823d06 968 ]],[[
7f9423af
VK
969 int e;
970 char buffer[256];
971 e = strerror_r(1, buffer, 256);
972 return e;
b0823d06
VK
973 ]])
974 ],[
975 AC_MSG_RESULT(yes)
976 AC_DEFINE(HAVE_POSIX_STRERROR_R,1,Define to 1 if strerror_r function is POSIX compliant)
977 ],[
978 AC_MSG_RESULT(no)
979 AC_DEFINE(HAVE_POSIX_STRERROR_R,0,Define to 1 if strerror_r function is POSIX compliant)
980 ])
981 AC_LANG_POP([C++])
982fi
983
be6467e9
VK
984# Check if timezone is a function
985AC_MSG_CHECKING(for timezone function)
986AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
987#if HAVE_TIME_H
988#include <time.h>
989#endif
990#if HAVE_SYS_TIME_H
991#include <sys/time.h>
992#endif
993]],[[
be6467e9 994 timezone(0, 0);
be6467e9
VK
995]])
996],[
997AC_MSG_RESULT(yes)
998AC_DEFINE(HAVE_TIMEZONE,1,Define to 1 if timezone function is available)
999],[
1000AC_MSG_RESULT(no)
445cba33
VK
1001AC_CHECK_DECLS([timezone],,,[
1002#if HAVE_TIME_H
1003#include <time.h>
1004#endif
1005#if HAVE_SYS_TIME_H
1006#include <sys/time.h>
1007#endif
1008])
be6467e9
VK
1009])
1010
1011# Check if struct tm has tm_gmtoff member
1012AC_MSG_CHECKING(for struct tm.tm_gmtoff)
1013AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1014#if HAVE_TIME_H
1015#include <time.h>
1016#endif
1017#if HAVE_SYS_TIME_H
1018#include <sys/time.h>
1019#endif
1020]],[[
be6467e9
VK
1021 struct tm t;
1022 return t.tm_gmtoff;
be6467e9
VK
1023]])
1024],[
1025AC_MSG_RESULT(yes)
1026AC_DEFINE(HAVE_TM_GMTOFF,1,Define to 1 if struct tm has tm_gmtoff member)
1027],[
1028AC_MSG_RESULT(no)
1029])
d16cf8a5 1030
99e50bb7
VK
1031AC_CHECK_DECLS([getopt_long],,,[
1032#if HAVE_GETOPT_H
1033#include <getopt.h>
1034#endif
1035])
73d7fbdb 1036
f91feddc 1037AC_CHECK_FUNCS([sysctlbyname sysctlnametomib])
70fed300
AK
1038AC_CHECK_FUNCS([tcgetattr tcsetattr cfsetospeed cfsetispeed])
1039
d16cf8a5
AK
1040# sockets/resolver (probably for solaris)
1041AC_CHECK_FUNC(connect, , [AC_CHECK_LIB(socket, connect)])
1042AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(resolv, gethostbyname)])
1043AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(nsl, gethostbyname)])
1044
1045if test "x$ac_cv_lib_nsl_gethostbyname" != "xyes" && test "x$ac_cv_func_gethostbyname" != "xyes" ; then
1046 AC_CHECK_FUNC(gethostbyname, , [AC_CHECK_LIB(socket, gethostbyname)])
1047fi
1048
1049if test "$ac_cv_lib_nsl_gethostbyname" = "$ac_cv_func_gethostbyname" ; then
1050 AC_MSG_CHECKING([if we can include libnsl + libsocket])
1051 LIBS="-lnsl -lsocket $LIBS"
1052 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[(void) gethostbyname]])],[my_ac_link_result=yes],[my_ac_link_result=no ])
1053 if test "$my_ac_link_result" = "no" ; then
1054 AC_MSG_RESULT([failure])
1055 AC_MSG_ERROR([unable to use gethostbyname()])
1056 else
1057 AC_MSG_RESULT([success])
1058 fi
1059fi
1060
c6491611
VK
1061# asprintf, scprintf, etc.
1062AC_CHECK_FUNCS([asprintf aswprintf vasprintf vaswprintf])
1063AC_CHECK_FUNCS([scprintf scwprintf vscprintf vscwprintf])
1064
1065AC_MSG_CHECKING(whether snprintf returns required buffer size)
1066AC_RUN_IFELSE(
1067 [AC_LANG_PROGRAM([
1068#include <stdio.h>
1069#include <string.h>
1070 ], [
1071 return !(snprintf(NULL, 0, "test: %d", 1000) >= 10);
1072 ])
1073 ],
1074 [ AC_MSG_RESULT(yes)
1075 AC_DEFINE(SNPRINTF_RETURNS_REQUIRED_SIZE, 1, Define to 1 if snprintf returns required buffer size in case of truncation)
1076 ],
1077 [ AC_MSG_RESULT(no) ],
1078 [ AC_MSG_RESULT(no) ]
1079)
1080
1081
dff54fed 1082
ef0c727b
VK
1083#--------------------------------------------------------------------
1084# Checks for macros and definitions
1085#--------------------------------------------------------------------
dff54fed 1086
ef0c727b
VK
1087AC_CHECK_DECLS([__bswap_32, __bswap_64, htonll, ntohll],,,[
1088#ifdef HAVE_SYS_TYPES_H
99e50bb7 1089#include <sys/types.h>
ef0c727b
VK
1090#endif
1091#if HAVE_BYTESWAP_H
1092#include <byteswap.h>
1093#endif
1094#if HAVE_NETINET_IN_H
1095#include <netinet/in.h>
1096#endif
1097#if HAVE_NET_NH_H
1098#include <net/nh.h>
1099#endif
1100])
aa24418a
VK
1101AC_CHECK_DECLS([RTLD_NOW, RTLD_GLOBAL],,,[
1102#ifdef HAVE_UNISTD_H
1103#include <unistd.h>
1104#endif
1105#ifdef HAVE_DLFCN_H
1106#include <dlfcn.h>
1107#endif
1108])
ce7565e7
VK
1109AC_CHECK_DECLS([va_copy, __va_copy],,,[
1110#ifdef HAVE_UNISTD_H
1111#include <unistd.h>
1112#endif
1113#ifdef HAVE_STDARG_H
1114#include <stdarg.h>
1115#endif
1116#ifdef HAVE_STDLIB_H
1117#include <stdlib.h>
1118#endif
1119])
dff54fed 1120
dff54fed 1121
ef0c727b
VK
1122#--------------------------------------------------------------------
1123# AIX specific checks
1124#--------------------------------------------------------------------
d16cf8a5 1125
ef0c727b
VK
1126if test "x$PLATFORM" = "xAIX"; then
1127 AC_CHECK_HEADERS([procinfo.h],,,[[ ]])
1128 AC_CHECK_DECLS([getkerninfo])
1129 AC_CHECK_FUNCS([getprocs64],,,[
1130#if HAVE_PROCINFO_H
1131#include <procinfo.h>
6cd41ceb 1132#endif
ef0c727b 1133 ])
7e56bf2e
VK
1134fi
1135
cd4c8ca3 1136
ef0c727b 1137#--------------------------------------------------------------------
ba8db57b
VK
1138# HP-UX specific checks
1139#--------------------------------------------------------------------
1140
1141if test "x$PLATFORM" = "xHP-UX"; then
f09c2d05
VK
1142 AC_CHECK_HEADERS([sys/mib.h],,,[[ ]])
1143 AC_CHECK_DECLS([SIOCGIFNAME, SIOCGIFINDEX],,,[
1144#if HAVE_NET_IF_H
1145#include <net/if.h>
1146#endif
1147 ])
1148 AC_CHECK_DECLS([ID_ifXEntry, open_mib_64],,,[
1149#if HAVE_SYS_MIB_H
1150#include <sys/mib.h>
1151#endif
1152 ])
ba8db57b
VK
1153fi
1154
1155
1156#--------------------------------------------------------------------
aa24418a
VK
1157# *BSD specific checks
1158#--------------------------------------------------------------------
1159
1160AC_CHECK_LIB(kvm, kvm_open)
1161AC_CHECK_FUNCS([kvm_getswapinfo])
1162AC_CHECK_TYPES([struct kinfo_proc2],,,[
1163#if HAVE_SYS_SYSCTL_H
1164#include <sys/sysctl.h>
1165#endif
1166])
1167
1168
28ba6824
VK
1169
1170#--------------------------------------------------------------------
1171# FreeBSD specific checks
1172#--------------------------------------------------------------------
1173
1174if test "x$PLATFORM" = "xFreeBSD"; then
61f58c11
VK
1175 AC_CHECK_DECLS([RTF_WASCLONED],[],[],[
1176#if HAVE_SYS_TYPES_H
1177#include <sys/types.h>
1178#endif
1179#if HAVE_SYS_SOCKET_H
1180#include <sys/socket.h>
1181#endif
1182#include <net/route.h>
1183 ])
28ba6824
VK
1184fi
1185
1186
aa24418a 1187#--------------------------------------------------------------------
8b86c5dc
VK
1188# Check for wxWidgets
1189#--------------------------------------------------------------------
1190
1191if test "x$NEED_WXWIDGETS" = "xyes"; then
1192 AC_PATH_PROGS([WXCONF], [wx-config wxgtk2-2.8-config], [no], [$PATH:/usr/local/bin])
1193 if test "x$WXCONF" = "xno"; then
1194 AC_MSG_ERROR([*** wxWidgets not installed - unable to build GUI components ***])
1195 else
1196 AC_PATH_PROGS([WXRC], [wxrc wxrc-gtk2-2.8], [no], [$PATH:/usr/local/bin])
1197 if test "x$WXRC" = "xno"; then
1198 AC_MSG_ERROR([*** wxWidgets resource compiler not found - unable to build GUI components ***])
1199 else
1200 NEED_UNICODE=`$WXCONF --selected-config | grep unicode | wc -l`
1201 if test $NEED_UNICODE -eq 1; then
1202 BUILD_UNICODE="yes"
273da39a 1203 WX_UNICODE="yes"
8b86c5dc
VK
1204 fi
1205 CXXFLAGS="$CXXFLAGS `$WXCONF --cxxflags --debug=$ENABLE_DEBUG`"
1206 LDFLAGS="$LDFLAGS `$WXCONF --libs --debug=$ENABLE_DEBUG`"
1207 fi
1208 fi
bfc410a1
VK
1209 $WXCONF --cxxflags | grep error >/dev/null
1210 if test $? = 0; then
1211 echo "wx-config output:"
1212 echo "*** BEGIN ***"
1213 $WXCONF --cxxflags
1214 echo "*** END ***"
1215 AC_MSG_ERROR([*** wxWidgets is not configured properly - see wx-config output above ***])
1216 fi
8b86c5dc
VK
1217fi
1218
1219
1220#--------------------------------------------------------------------
ef0c727b
VK
1221# Check for UNICODE stuff
1222#--------------------------------------------------------------------
3e39fcde 1223
8b86c5dc 1224AC_CHECK_HEADERS([wchar.h wctype.h iconv.h])
aa24418a 1225AC_CHECK_TYPES([wchar_t, wint_t],,,[
6b93c954
VK
1226#if HAVE_WCHAR_H
1227#include <wchar.h>
1228#endif
1229])
3e39fcde 1230AC_CHECK_SIZEOF(wchar_t)
aa24418a
VK
1231AC_CHECK_FUNCS([wcslen wcsdup wcsncpy wcstoll wcstoull towupper wcserror wcserror_r])
1232AC_CHECK_FUNCS([wfopen wopen wstat wgetenv wrename wunlink])
ba8db57b 1233AC_CHECK_FUNCS([wfopen wopen wstat wgetenv wrename wunlink])
dff54fed 1234
3265ba38 1235if test "x$DISABLE_ICONV" != "xyes"; then
75c30ed4 1236 AC_CHECK_LIB(iconv, libiconv_open,
dff54fed 1237 [ ac_found_iconv=yes
8d131dda 1238 LIBS="$LIBS -liconv"
75c30ed4
VK
1239 AC_CHECK_FUNCS(libiconv, ac_found_iconv=yes, ac_found_iconv=no)
1240 ],
1241 [
1242 AC_CHECK_LIB(iconv, iconv,
1243 [ ac_found_iconv=yes
8d131dda 1244 LIBS="$LIBS -liconv"
75c30ed4
VK
1245 ])
1246 AC_CHECK_FUNCS(iconv, ac_found_iconv=yes, ac_found_iconv=no)
1247 ])
dff54fed
VK
1248else
1249 ac_found_iconv=no
ef0c727b 1250 CPPFLAGS="$CPPFLAGS -D__DISABLE_ICONV"
dff54fed 1251fi
93571e7f
VK
1252
1253AC_MSG_CHECKING(whether iconv supports UCS-2-INTERNAL)
1254AC_RUN_IFELSE(
1255 [AC_LANG_PROGRAM([
1256#if HAVE_ICONV_H
1257#include <iconv.h>
1258#endif
1259 ], [
1260 return iconv_open("UTF-8","UCS-2-INTERNAL")==(iconv_t)(-1);
1261 ])
1262 ],
1263 [ AC_MSG_RESULT(yes)
1264 AC_DEFINE(HAVE_ICONV_UCS_2_INTERNAL, 1, Define to 1 if iconv supports UCS-2-INTERNAL)
1265 valid_ucs2_code="UCS-2-INTERNAL"
1266 ],
1267 [ AC_MSG_RESULT(no) ],
1268 [ AC_MSG_RESULT(no) ]
1269)
1270
1271AC_MSG_CHECKING(whether iconv supports UCS-2)
1272AC_RUN_IFELSE(
1273 [AC_LANG_PROGRAM([
1274#if HAVE_ICONV_H
1275#include <iconv.h>
1276#endif
1277 ], [
1278 return iconv_open("UTF-8","UCS-2")==(iconv_t)(-1);
1279 ])
1280 ],
1281 [ AC_MSG_RESULT(yes)
1282 AC_DEFINE(HAVE_ICONV_UCS_2, 1, Define to 1 if iconv supports UCS-2)
1283 valid_ucs2_code="UCS-2"
1284 ],
1285 [ AC_MSG_RESULT(no) ],
8b86c5dc 1286 [ AC_MSG_RESULT(no) ]
93571e7f
VK
1287)
1288
1289AC_MSG_CHECKING(whether iconv supports UCS2)
1290AC_RUN_IFELSE(
1291 [AC_LANG_PROGRAM([
1292#if HAVE_ICONV_H
1293#include <iconv.h>
1294#endif
1295 ], [
1296 return iconv_open("UTF-8","UCS2")==(iconv_t)(-1);
1297 ])
1298 ],
1299 [ AC_MSG_RESULT(yes)
1300 AC_DEFINE(HAVE_ICONV_UCS2, 1, Define to 1 if iconv supports UCS2)
1301 valid_ucs2_code="UCS2"
1302 ],
1303 [ AC_MSG_RESULT(no) ],
1304 [ AC_MSG_RESULT(no) ]
1305)
1306
44bccbbc
VK
1307AC_MSG_CHECKING(whether iconv supports UCS-2BE)
1308AC_RUN_IFELSE(
1309 [AC_LANG_PROGRAM([
1310#if HAVE_ICONV_H
1311#include <iconv.h>
1312#endif
1313 ], [
1314 return iconv_open("UTF-8","UCS-2BE")==(iconv_t)(-1);
1315 ])
1316 ],
1317 [ AC_MSG_RESULT(yes)
1318 AC_DEFINE(HAVE_ICONV_UCS_2BE, 1, Define to 1 if iconv supports UCS-2BE)
1319 valid_ucs2_code="UCS-2BE"
1320 ],
1321 [ AC_MSG_RESULT(no) ],
1322 [ AC_MSG_RESULT(no) ]
1323)
1324
6e17f325
VK
1325AC_MSG_CHECKING(whether iconv supports UCS-2LE)
1326AC_RUN_IFELSE(
1327 [AC_LANG_PROGRAM([
1328#if HAVE_ICONV_H
1329#include <iconv.h>
1330#endif
1331 ], [
1332 return iconv_open("UTF-8","UCS-2LE")==(iconv_t)(-1);
1333 ])
1334 ],
1335 [ AC_MSG_RESULT(yes)
1336 AC_DEFINE(HAVE_ICONV_UCS_2LE, 1, Define to 1 if iconv supports UCS-2LE)
1337 valid_ucs2_code="UCS-2LE"
1338 ],
1339 [ AC_MSG_RESULT(no) ],
1340 [ AC_MSG_RESULT(no) ]
1341)
1342
8b86c5dc
VK
1343AC_MSG_CHECKING(whether iconv supports UCS-4-INTERNAL)
1344AC_RUN_IFELSE(
1345 [AC_LANG_PROGRAM([
1346#if HAVE_ICONV_H
1347#include <iconv.h>
1348#endif
1349 ], [
1350 return iconv_open("UTF-8","UCS-4-INTERNAL")==(iconv_t)(-1);
1351 ])
1352 ],
1353 [ AC_MSG_RESULT(yes)
1354 AC_DEFINE(HAVE_ICONV_UCS_4_INTERNAL, 1, Define to 1 if iconv supports UCS-4-INTERNAL)
1355 valid_ucs4_code="UCS-4-INTERNAL"
1356 ],
1357 [ AC_MSG_RESULT(no) ],
1358 [ AC_MSG_RESULT(no) ]
1359)
1360
1361AC_MSG_CHECKING(whether iconv supports UCS-4)
1362AC_RUN_IFELSE(
1363 [AC_LANG_PROGRAM([
1364#if HAVE_ICONV_H
1365#include <iconv.h>
1366#endif
1367 ], [
1368 return iconv_open("UTF-8","UCS-4")==(iconv_t)(-1);
1369 ])
1370 ],
1371 [ AC_MSG_RESULT(yes)
1372 AC_DEFINE(HAVE_ICONV_UCS_4, 1, Define to 1 if iconv supports UCS-4)
1373 valid_ucs4_code="UCS-4"
1374 ],
1375 [ AC_MSG_RESULT(no) ],
1376 [ AC_MSG_RESULT(no) ]
1377)
1378
1379AC_MSG_CHECKING(whether iconv supports UCS4)
1380AC_RUN_IFELSE(
1381 [AC_LANG_PROGRAM([
1382#if HAVE_ICONV_H
1383#include <iconv.h>
1384#endif
1385 ], [
1386 return iconv_open("UTF-8","UCS4")==(iconv_t)(-1);
1387 ])
1388 ],
1389 [ AC_MSG_RESULT(yes)
1390 AC_DEFINE(HAVE_ICONV_UCS4, 1, Define to 1 if iconv supports UCS4)
1391 valid_ucs4_code="UCS4"
1392 ],
1393 [ AC_MSG_RESULT(no) ],
1394 [ AC_MSG_RESULT(no) ]
1395)
1396
1397AC_MSG_CHECKING(whether iconv supports UCS-4BE)
1398AC_RUN_IFELSE(
1399 [AC_LANG_PROGRAM([
1400#if HAVE_ICONV_H
1401#include <iconv.h>
1402#endif
1403 ], [
1404 return iconv_open("UTF-8","UCS-4BE")==(iconv_t)(-1);
1405 ])
1406 ],
1407 [ AC_MSG_RESULT(yes)
1408 AC_DEFINE(HAVE_ICONV_UCS_4BE, 1, Define to 1 if iconv supports UCS-4BE)
1409 valid_ucs4_code="UCS-4BE"
1410 ],
1411 [ AC_MSG_RESULT(no) ],
1412 [ AC_MSG_RESULT(no) ]
1413)
1414
6e17f325
VK
1415AC_MSG_CHECKING(whether iconv supports UCS-4LE)
1416AC_RUN_IFELSE(
1417 [AC_LANG_PROGRAM([
1418#if HAVE_ICONV_H
1419#include <iconv.h>
1420#endif
1421 ], [
1422 return iconv_open("UTF-8","UCS-4LE")==(iconv_t)(-1);
1423 ])
1424 ],
1425 [ AC_MSG_RESULT(yes)
1426 AC_DEFINE(HAVE_ICONV_UCS_4LE, 1, Define to 1 if iconv supports UCS-4LE)
1427 valid_ucs4_code="UCS-4LE"
1428 ],
1429 [ AC_MSG_RESULT(no) ],
1430 [ AC_MSG_RESULT(no) ]
1431)
1432
5e40a69e
VK
1433AC_MSG_CHECKING(whether iconv supports ISO8859-1)
1434AC_RUN_IFELSE(
1435 [AC_LANG_PROGRAM([
1436#if HAVE_ICONV_H
1437#include <iconv.h>
1438#endif
1439 ], [
1440 return iconv_open("UTF-8","ISO8859-1")==(iconv_t)(-1);
1441 ])
1442 ],
1443 [ AC_MSG_RESULT(yes)
1444 AC_DEFINE(HAVE_ICONV_ISO8859_1, 1, Define to 1 if iconv supports ISO8859-1)
1445 ],
1446 [ AC_MSG_RESULT(no) ],
1447 [ AC_MSG_RESULT(no) ]
1448)
1449
1450AC_MSG_CHECKING(whether iconv supports ISO-8859-1)
1451AC_RUN_IFELSE(
1452 [AC_LANG_PROGRAM([
1453#if HAVE_ICONV_H
1454#include <iconv.h>
1455#endif
1456 ], [
1457 return iconv_open("UTF-8","ISO-8859-1")==(iconv_t)(-1);
1458 ])
1459 ],
1460 [ AC_MSG_RESULT(yes)
1461 AC_DEFINE(HAVE_ICONV_ISO_8859_1, 1, Define to 1 if iconv supports ISO-8859-1)
1462 ],
1463 [ AC_MSG_RESULT(no) ],
1464 [ AC_MSG_RESULT(no) ]
1465)
1466
1467AC_MSG_CHECKING(whether iconv supports ASCII)
1468AC_RUN_IFELSE(
1469 [AC_LANG_PROGRAM([
1470#if HAVE_ICONV_H
1471#include <iconv.h>
1472#endif
1473 ], [
1474 return iconv_open("UTF-8","ASCII")==(iconv_t)(-1);
1475 ])
1476 ],
1477 [ AC_MSG_RESULT(yes)
1478 AC_DEFINE(HAVE_ICONV_ASCII, 1, Define to 1 if iconv supports ASCII)
1479 ],
1480 [ AC_MSG_RESULT(no) ],
1481 [ AC_MSG_RESULT(no) ]
1482)
1483
93571e7f
VK
1484AC_MSG_CHECKING(whether iconv supports //IGNORE)
1485AC_RUN_IFELSE(
1486 [AC_LANG_PROGRAM([
1487#if HAVE_ICONV_H
1488#include <iconv.h>
1489#endif
1490 ], [
1491 return iconv_open("UTF-8//IGNORE","$valid_ucs2_code")==(iconv_t)(-1);
1492 ])
1493 ],
1494 [ AC_MSG_RESULT(yes)
1495 AC_DEFINE(HAVE_ICONV_IGNORE, 1, Define to 1 if iconv supports //IGNORE option)
1496 ],
1497 [ AC_MSG_RESULT(no) ],
1498 [ AC_MSG_RESULT(no) ]
1499)
3e39fcde 1500
19619a35
AK
1501# taken from ZSH's configure
1502# Check if iconv uses const in prototype declaration
24b1570c 1503if test "x$ac_found_iconv" = "xyes"; then
19619a35 1504 AC_CACHE_CHECK(for iconv declaration, ac_cv_iconv_const,
7f9423af
VK
1505 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1506#include <stdlib.h>
1507#include <iconv.h>
1508 ]],
1509 [[
1510#ifdef __cplusplus
1511"C"
1512#endif
1513#if defined(__STDC__) || defined(__cplusplus)
1514 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
1515#else
1516 size_t iconv();
1517#endif
1518 ]])],
19619a35
AK
1519 [ac_cv_iconv_const=],
1520 [ac_cv_iconv_const=const])])
1521 AC_DEFINE_UNQUOTED([ICONV_CONST], $ac_cv_iconv_const,
1522 [Define as const if the declaration of iconv() needs const.])
1523fi
1524
93571e7f 1525if test $ac_cv_sizeof_wchar_t -eq 2; then
8b86c5dc
VK
1526 AC_DEFINE(UNICODE_UCS2, 1, Define to 1 if you have 2-byte wchar_t)
1527fi
1528
1529if test $ac_cv_sizeof_wchar_t -eq 4; then
1530 AC_DEFINE(UNICODE_UCS4, 1, Define to 1 if you have 4-byte wchar_t)
1531fi
1532
c29360a9 1533
ef0c727b 1534#--------------------------------------------------------------------
ca0f4ea3
VK
1535# MySQL
1536#--------------------------------------------------------------------
1537
1538check_substr "$COMPONENTS" "mysql"
1539if test $? = 0; then
6fce76d8 1540 AC_CHECK_LIB(mysqlclient, mysql_init, [MYSQL_LIBS="-lmysqlclient"],
ca0f4ea3 1541 [AC_MSG_ERROR(libmysqlclient is requred for MySQL support)])
aa7794f0 1542
8d131dda
VK
1543 OLD_LIBS="$LIBS"
1544 LIBS="$LIBS $MYSQL_LIBS"
aa7794f0 1545
9c29f76e
VK
1546 AC_MSG_CHECKING(whether mysql clients can run)
1547 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1548#include <stdio.h>
1549#include <mysql.h>
1550int main(void)
1551{
1552 MYSQL *a = mysql_init(NULL);
1553 return 0;
1554}
1555 ]])],[],[
1556 AC_MSG_RESULT(no)
1557 AC_MSG_ERROR(Your MySQL client libraries aren't properly installed)
1558 ],[])
ca0f4ea3 1559 AC_MSG_RESULT(yes)
6fce76d8 1560
ca0f4ea3 1561 AC_CHECK_FUNCS(mysql_real_escape_string)
8d131dda 1562 LIBS="$OLD_LIBS"
ca0f4ea3
VK
1563fi
1564
1565
1566#--------------------------------------------------------------------
58ed4897
VK
1567# PostgreSQL
1568#--------------------------------------------------------------------
1569
203458b7 1570check_substr "$COMPONENTS" "pgsql"
58ed4897
VK
1571if test $? = 0; then
1572 AC_CHECK_LIB(m, floor)
6fce76d8 1573 AC_CHECK_LIB(pq, PQconnectdb, [PGSQL_LIBS="-lpq"],
58ed4897 1574 [AC_MSG_ERROR(libpq is required for PostgreSQL support)])
6fce76d8
VK
1575
1576 AC_MSG_CHECKING(whether postgresql clients can run)
8d131dda
VK
1577 OLD_LIBS="$LIBS"
1578 LIBS="$LIBS $PGSQL_LIBS"
6fce76d8
VK
1579 AC_RUN_IFELSE([AC_LANG_SOURCE([[
1580 #include <stdio.h>
1581 #include <libpq-fe.h>
1582 int main(void)
1583 {
1584 PGconn *a = PQconnectdb("");
1585 return 0;
1586 }
1587 ]])],[AC_MSG_RESULT(yes)],[
58ed4897
VK
1588 AC_MSG_RESULT(no)
1589 AC_MSG_ERROR(Your PostgreSQL client libraries aren't properly installed)
1590 ],[])
8d131dda 1591 LIBS="$OLD_LIBS"
7070538d 1592 AC_CHECK_LIB(pq, PQfformat, [ AC_DEFINE(HAVE_PQFFORMAT, 1, PQfformat not exist in 7.3) ])
58ed4897
VK
1593fi
1594
1595
1596#--------------------------------------------------------------------
9c29f76e
VK
1597# ODBC
1598#--------------------------------------------------------------------
1599
1600check_substr "$COMPONENTS" "odbc"
1601if test $? = 0; then
6fce76d8 1602 AC_CHECK_LIB(odbc, SQLAllocHandle, [ODBC_LIBS="-lodbc"],
9c29f76e
VK
1603 [AC_MSG_ERROR(libodbc is required for ODBC support)])
1604fi
1605
1606
1607#--------------------------------------------------------------------
41b4790d
VK
1608# Oracle
1609#--------------------------------------------------------------------
1610
1611check_substr "$COMPONENTS" "oracle"
1612if test $? = 0; then
1613 AC_CHECK_HEADER(oci.h,,AC_MSG_ERROR([*** Cannot find oci.h - check your Oracle client installation ***]))
7d8c91ef
VK
1614 AC_CHECK_LIB(nnz11, nzstrcpy, [NNZ_LIB=-lnnz11],
1615 [
1616 AC_CHECK_LIB(nnz10, nzstrcpy, [NNZ_LIB=-lnnz10], [], [-lclntsh])
1617 ], [-lclntsh])
1618 AC_CHECK_LIB(clntsh, OCIHandleAlloc, [ORACLE_LIBS="-lclntsh $NNZ_LIB"],
1619 [AC_MSG_ERROR(libclntsh is required for Oracle support)], [$NNZ_LIB])
41b4790d
VK
1620fi
1621
84277a0f
AK
1622#--------------------------------------------------------------------
1623# DB2
1624#--------------------------------------------------------------------
1625
1626check_substr "$COMPONENTS" "db2"
1627if test $? = 0; then
1628 AC_CHECK_HEADER(sql.h,,AC_MSG_ERROR([*** Cannot find sql.h - check your DB2 client installation ***]))
1629 AC_CHECK_LIB(db2, SQLAllocHandle, [DB2_LIBS="-ldb2"],
1630 [AC_MSG_ERROR(libdb2 is required for DB2 support)])
1631fi
41b4790d
VK
1632
1633#--------------------------------------------------------------------
c3cfc039
VK
1634# nxhttpd
1635#--------------------------------------------------------------------
1636
e02b69b9 1637check_substr "$COMPONENTS" "webui"
c3cfc039
VK
1638if test $? = 0; then
1639 AC_CHECK_HEADER(gd.h,,AC_MSG_ERROR([*** GD support not installed - please install first ***]))
1640 AC_CHECK_LIB(gd, gdImageCreate, [], [
1641 AC_MSG_ERROR(libgd is required for web interface)
1642 ])
1643
1644fi
1645
1646
1647#--------------------------------------------------------------------
ca0f4ea3
VK
1648# Other settings
1649#--------------------------------------------------------------------
1650
fecf6a2b 1651CPPFLAGS="$CPPFLAGS -DPREFIX=\\\"\${prefix}\\\" -DPREFIXW=L\\\"\${prefix}\\\" -DDATADIR=\\\"\${pkgdatadir}\\\" -DBINDIR=\\\"\${bindir}\\\" -DLIBDIR=\\\"\${libdir}\\\""
ca0f4ea3 1652
8b86c5dc 1653AM_CONDITIONAL([BUILD_UNICODE_LIBS], [test "x$BUILD_UNICODE" = "xyes"])
551ec9ca 1654AM_CONDITIONAL([USE_INTERNAL_EXPAT], [test "x$HAVE_LIBEXPAT" = "xno"])
8b86c5dc 1655
ca0f4ea3
VK
1656
1657#--------------------------------------------------------------------
ef0c727b
VK
1658# Substitute variables
1659#--------------------------------------------------------------------
82fa7c5d 1660
ef0c727b
VK
1661AC_SUBST(DB_DRIVERS)
1662AC_SUBST(MODULES)
1663AC_SUBST(SUBAGENT_DIRS)
1664AC_SUBST(SERVER_TOOLS)
1665AC_SUBST(TOP_LEVEL_MODULES)
1666AC_SUBST(CONTRIB_MODULES)
c2612d83 1667AC_SUBST(CLIENT_COMPONENTS)
ef0c727b
VK
1668AC_SUBST(STATIC_SUBAGENT_LIST)
1669AC_SUBST(SUBAGENT_LIBS)
1670AC_SUBST(BUILD_SERVER)
1671AC_SUBST(UNSTABLE_SUBAGENT_DIRS)
db91456f 1672AC_SUBST(WXRC)
6fce76d8
VK
1673AC_SUBST(MYSQL_LIBS)
1674AC_SUBST(PGSQL_LIBS)
7d8c91ef 1675AC_SUBST(ORACLE_LIBS)
6fce76d8 1676AC_SUBST(ODBC_LIBS)
84277a0f 1677AC_SUBST(DB2_LIBS)
d16cf8a5 1678
ef0c727b
VK
1679#--------------------------------------------------------------------
1680# Shared libs versions
d16cf8a5
AK
1681#
1682# versioning scheme: current:revision:age
1683#
1684# current
1685# The number of the current interface exported by the library. A current
1686# value of `0', means that you are calling the interface exported by this
1687# library interface 0.
1688#
1689# revision
1690# The implementation number of the most recent interface exported by this
1691# library. In this case, a revision value of `0' means that this is the
1692# first implementation of the interface.
1693# If the next release of this library exports the same interface, but has a
1694# different implementation (perhaps some bugs have been fixed), the revision
1695# number will be higher, but current number will be the same. In that case,
1696# when given a choice, the library with the highest revision will always
1697# be used by the runtime loader.
1698#
1699# age
1700# The number of previous additional interfaces supported by this library.
1701# If age were `2', then this library can be linked into executables which
1702# were built with a release of this library that exported the current
1703# interface number, current, or any of the previous two interfaces.
1704# By definition age must be less than or equal to current. At the outset,
1705# only the first ever interface is implemented, so age can only be `0'.
ef0c727b 1706#--------------------------------------------------------------------
d16cf8a5 1707
8c5adf3a 1708NETXMS_LIBRARY_VERSION=0:2:0
c7d14846 1709AC_SUBST(NETXMS_LIBRARY_VERSION)
d16cf8a5 1710
ef0c727b
VK
1711
1712#--------------------------------------------------------------------
1713# Generate output files
1714#--------------------------------------------------------------------
d16cf8a5
AK
1715
1716AC_CONFIG_FILES([
ef0c727b 1717 README
0c3c0c39
AK
1718 Makefile
1719 contrib/Makefile
0c3c0c39 1720 contrib/startup/Makefile
fa66d60c 1721 contrib/startup/debian/Makefile
daaefaaf 1722 contrib/startup/gentoo/Makefile
0c3c0c39 1723 contrib/startup/redhat/Makefile
5de3893d 1724 contrib/startup/suse/Makefile
9993edf4 1725 contrib/startup/ubuntu/Makefile
82fa7c5d 1726 contrib/mibs/Makefile
3f2f9f2b 1727 contrib/backgrounds/Makefile
0c3c0c39 1728 doc/Makefile
a48203d2
VK
1729 doc/internal/Makefile
1730 doc/manuals/Makefile
1731 doc/misc/Makefile
0c3c0c39
AK
1732 images/Makefile
1733 include/Makefile
1734 m4/Makefile
1735 netware/Makefile
0c3c0c39 1736 src/Makefile
9191f6ad
VK
1737 src/agent/Makefile
1738 src/agent/core/Makefile
1739 src/agent/install/Makefile
1740 src/agent/subagents/Makefile
1741 src/agent/subagents/linux/Makefile
1742 src/agent/subagents/sunos/Makefile
1743 src/agent/subagents/aix/Makefile
1744 src/agent/subagents/hpux/Makefile
1745 src/agent/subagents/skeleton/Makefile
1746 src/agent/subagents/freebsd/Makefile
1747 src/agent/subagents/openbsd/Makefile
1748 src/agent/subagents/netbsd/Makefile
1749 src/agent/subagents/ipso/Makefile
1750 src/agent/subagents/netware/Makefile
1751 src/agent/subagents/winnt/Makefile
1752 src/agent/subagents/win9x/Makefile
1753 src/agent/subagents/winperf/Makefile
1754 src/agent/subagents/wmi/Makefile
1755 src/agent/subagents/portCheck/Makefile
1756 src/agent/subagents/ping/Makefile
1757 src/agent/subagents/sms/Makefile
1758 src/agent/subagents/ups/Makefile
1759 src/agent/subagents/ecs/Makefile
1760 src/agent/subagents/odbcquery/Makefile
1761 src/agent/subagents/logwatch/Makefile
c2612d83 1762 src/client/Makefile
551592f4 1763 src/client/install/Makefile
c94fa5c2 1764 src/client/nxalarm/Makefile
e84701c5
VK
1765 src/client/nxevent/Makefile
1766 src/client/nxpush/Makefile
59ffa5b7 1767 src/client/nxsms/Makefile
23c8c53e
AK
1768 src/client/windows/nxuilib/Makefile
1769 src/client/windows/nxuilib/res/Makefile
1770 src/client/windows/nxuilib/sounds/Makefile
d9db1c72 1771 src/client/nxlexer/Makefile
23c8c53e
AK
1772 src/client/windows/nxcon/Makefile
1773 src/client/windows/nxcon/icons/Makefile
1774 src/client/windows/nxcon/res/Makefile
23c8c53e
AK
1775 src/client/windows/nxav/Makefile
1776 src/client/windows/nxav/res/Makefile
1777 src/client/windows/nxnotify/Makefile
1778 src/client/windows/nxnotify/res/Makefile
d1834406
VK
1779 src/db/Makefile
1780 src/db/dbdrv/Makefile
1781 src/db/dbdrv/odbc/Makefile
1782 src/db/dbdrv/mssql/Makefile
1783 src/db/dbdrv/mysql/Makefile
1784 src/db/dbdrv/pgsql/Makefile
1785 src/db/dbdrv/sqlite/Makefile
1786 src/db/dbdrv/oracle/Makefile
84277a0f 1787 src/db/dbdrv/db2/Makefile
d1834406 1788 src/db/libnxdb/Makefile
9191f6ad
VK
1789 src/install/Makefile
1790 src/install/windows/Makefile
1791 src/libexpat/Makefile
1792 src/libexpat/libexpat/Makefile
1793 src/libnetxms/Makefile
1794 src/libnxcl/Makefile
1795 src/libnxlp/Makefile
1796 src/libnxmap/Makefile
1797 src/libnxsl/Makefile
1798 src/nxscript/Makefile
0c3c0c39
AK
1799 src/server/Makefile
1800 src/server/core/Makefile
d770a97c
VK
1801 src/server/include/Makefile
1802 src/server/libnxsrv/Makefile
1803 src/server/netxmsd/Makefile
d8f2e39b
VK
1804 src/server/smsdrv/Makefile
1805 src/server/smsdrv/generic/Makefile
91369aca 1806 src/server/smsdrv/nxagent/Makefile
0c3c0c39 1807 src/server/tools/Makefile
0c3c0c39
AK
1808 src/server/tools/nxaction/Makefile
1809 src/server/tools/nxadm/Makefile
9191f6ad 1810 src/server/tools/nxap/Makefile
5b0c7d0d
VK
1811 src/server/tools/nxconfig/Makefile
1812 src/server/tools/nxconfig/res/Makefile
f90d7fc5 1813 src/server/tools/nxdbmgr/Makefile
4e2debcc 1814 src/server/tools/nxencpasswd/Makefile
9191f6ad 1815 src/server/tools/nxget/Makefile
d24fdaf4 1816 src/server/tools/nxupload/Makefile
c5c0f362
VK
1817 src/snmp/Makefile
1818 src/snmp/libnxsnmp/Makefile
1819 src/snmp/nxmibc/Makefile
1820 src/snmp/nxsnmpget/Makefile
1821 src/snmp/nxsnmpset/Makefile
1822 src/snmp/nxsnmpwalk/Makefile
9191f6ad 1823 src/sqlite/Makefile
f65df2b1
VK
1824 src/tools/Makefile
1825 src/tools/nxcptest/Makefile
1826 src/tools/nxdevcfg/Makefile
e02b69b9 1827 src/webui/Makefile
420d9ecf
AK
1828 src/webui/nxhttpd/Makefile
1829 src/webui/nxhttpd/static/Makefile
1830 src/webui/nxhttpd/static/images/Makefile
1831 src/webui/nxhttpd/static/images/buttons/Makefile
1832 src/webui/nxhttpd/static/images/buttons/normal/Makefile
1833 src/webui/nxhttpd/static/images/buttons/pressed/Makefile
1834 src/webui/nxhttpd/static/images/ctrlpanel/Makefile
1835 src/webui/nxhttpd/static/images/objects/Makefile
1836 src/webui/nxhttpd/static/images/status/Makefile
9191f6ad 1837 sql/Makefile
0c3c0c39 1838 tools/Makefile
d16cf8a5
AK
1839])
1840
12249937
VK
1841AC_OUTPUT
1842
ef0c727b 1843echo "Updating libtool"
5cecf50e
AK
1844sed 's,$SED -e "/${host}-//g",$SED -e "s/${host}-//g",g' < ./libtool > libtool.new && mv libtool.new libtool && chmod +x ./libtool
1845
779ce551
VK
1846# On HP-UX, libtool passes +b instead of -Wl,+b even if gcc/g++ used as linker
1847if test "x$CC" = "xgcc" && test "x$PLATFORM" = "xHP-UX"; then
1848 sed "s,hardcode_libdir_flag_spec_ld=,#hardcode_libdir_flag_spec_ld=,g" < ./libtool > libtool.new && mv libtool.new libtool && chmod +x ./libtool
1849fi
1850
ef0c727b
VK
1851#--------------------------------------------------------------------
1852# Print summary
1853#--------------------------------------------------------------------
a7442678 1854
a7442678
AK
1855echo
1856echo
1857echo
1858echo '---------------------------------------------------------------------'
1859echo ' Configure results'
1860echo '---------------------------------------------------------------------'
1861echo
8b86c5dc 1862 echo "Prefix : ${prefix}"
a7442678 1863if test "x${BUILD_SERVER}" = "xyes"; then
8b86c5dc 1864 echo "Build Server : YES"
a7442678 1865else
8b86c5dc 1866 echo "Build Server : NO"
a7442678
AK
1867fi
1868if test "x${ac_cv_lib_crypto_RSA_new}" = "xyes"; then
8b86c5dc 1869 echo "Encryption enabled : YES"
a7442678 1870else
8b86c5dc 1871 echo "Encryption enabled : NO"
a7442678
AK
1872fi
1873if test "x${DB_DRIVERS}" != "x"; then
8b86c5dc 1874 echo "Build DB-Drivers :${DB_DRIVERS}"
a7442678 1875else
8b86c5dc 1876 echo "Build DB-Drivers : NO"
a7442678
AK
1877fi
1878if test "x${BUILD_CLIENT}" = "xyes"; then
8b86c5dc 1879 echo "Build Clients : YES"
a7442678 1880else
8b86c5dc 1881 echo "Build Clients : NO"
a7442678 1882fi
ef0c727b 1883if test "x${BUILD_NXHTTPD}" = "xyes"; then
8b86c5dc 1884 echo "Build Web Interface : YES"
2654e540 1885else
8b86c5dc 1886 echo "Build Web Interface : NO"
2654e540 1887fi
a7442678 1888if test "x${BUILD_AGENT}" = "xyes"; then
8b86c5dc
VK
1889 echo "Build Agent : YES"
1890 echo "Subagents list : ${SUBAGENT_DIRS}"
a7442678 1891else
8b86c5dc 1892 echo "Build Agent : NO"
a7442678 1893fi
e8636669 1894if test "x${BUILD_STATIC_AGENT}" = "xyes"; then
8b86c5dc
VK
1895 echo "Build Static Agent : YES"
1896 echo "Subagents list : ${STATIC_SUBAGENT_LIST}"
e8636669 1897else
8b86c5dc 1898 echo "Build Static Agent : NO"
e8636669 1899fi
8b86c5dc
VK
1900if test "x${BUILD_UNICODE}" = "xyes"; then
1901 echo "Build UNICODE libraries : YES"
1902else
1903 echo "Build UNICODE libraries : NO"
1904fi
551ec9ca
VK
1905if test "x${HAVE_LIBEXPAT}" = "xno"; then
1906 echo "Use internal libexpat : YES"
1bb6b449 1907else
551ec9ca 1908 echo "Use internal libexpat : NO"
1bb6b449 1909fi
cc297a70
VK
1910if test "x${FORCE_32BIT_BUILD}" = "xyes"; then
1911 echo "Force 32bit build : YES"
1912else
1913 echo "Force 32bit build : NO"
1914fi
7d8c91ef
VK
1915
1916echo "CPPFLAGS : ${CPPFLAGS}"
1917echo "CXXFLAGS : ${CXXFLAGS}"
1918echo "CFLAGS : ${CFLAGS}"
1919echo "LDFLAGS : ${LDFLAGS}"
8d131dda 1920echo "LIBS : ${LIBS}"
7d8c91ef 1921
6fce76d8
VK
1922if test "x${MYSQL_LIBS}" != "x"; then
1923 echo "MySQL libs : ${MYSQL_LIBS}"
1924fi
1925if test "x${PGSQL_LIBS}" != "x"; then
1926 echo "PostgreSQL libs : ${PGSQL_LIBS}"
1927fi
7d8c91ef
VK
1928if test "x${ORACLE_LIBS}" != "x"; then
1929 echo "Oracle libs : ${ORACLE_LIBS}"
1930fi
6fce76d8
VK
1931if test "x${ODBC_LIBS}" != "x"; then
1932 echo "ODBC libs : ${ODBC_LIBS}"
1933fi
84277a0f
AK
1934if test "x${DB2_LIBS}" != "x"; then
1935 echo "DB2 libs : ${DB2_LIBS}"
1936fi