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