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