File: configure.ac

package info (click to toggle)
dsyslog 0.6.0
  • links: PTS
  • area: main
  • in suites: squeeze, wheezy
  • size: 1,064 kB
  • ctags: 387
  • sloc: sh: 3,528; ansic: 3,183; makefile: 301; php: 109
file content (484 lines) | stat: -rwxr-xr-x 13,909 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(dsyslog, 0.6.0, nenolod@dereferenced.org)

AC_CONFIG_AUX_DIR(autoconf)
AC_CONFIG_HEADER(include/sysconf.h)

AC_GNU_SOURCE

dnl Automake compatibility. --nenolod
AC_SUBST([PACKAGE], [AC_PACKAGE_TARNAME])
AC_SUBST([VERSION], [AC_PACKAGE_VERSION])

AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])

dnl GNU gettext

dnl Uncomment this if we choose to provide our own libintl.
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.16.1])

if test "$prefix" = "NONE"; then
	prefix="${ac_default_prefix}"
fi

dnl the following is wrong! -- jilles
dnl AC_DEFINE_UNQUOTED([PREFIX], "${prefix}", [Installation prefix.])

dnl Checks for programs.
AC_ISC_POSIX
AC_PROG_CC
AC_PROG_INSTALL
AC_EXEEXT
AC_PATH_PROG(RM, rm)
AC_PATH_PROG(MV, mv)
AC_PATH_PROG(CP, cp)
AC_PATH_PROG(LN, ln)
AC_PATH_PROG(TAR, tar)
AC_PATH_PROG(AR, ar)
AC_PATH_PROG(RANLIB, ranlib)
AC_C_INLINE
AC_PROG_MAKE_SET

AC_MSG_CHECKING(how to generate dependancy info)
if test "$SunWorkShop" = "yes"; then
  AC_MSG_RESULT(Sun WorkShop/Forte using $CC -xM)
  MKDEP="$CC -xM"
fi
if test "$HPUX" = "yes"; then
  AC_MSG_RESULT(HP-UX C Compiler using makedepend)
  MKDEP="makedepend"
fi
if test "x$MKDEP" = "x"; then
  AC_MSG_RESULT(assuming $CC -MM)
  MKDEP="$CC -MM"
fi

AC_SUBST(MKDEP)

dnl Checks for header files.
AC_CHECK_HEADERS(link.h,,,[-])

dnl Checks for library functions.
AC_FUNC_STRFTIME
AC_CHECK_FUNCS([strdup strlcpy strlcat inet_pton inet_ntop gettimeofday umask mmap arc4random getrlimit fork getpid execve])
AC_CHECK_FUNC(socket,, AC_CHECK_LIB(socket, socket))
AC_CHECK_FUNC(gethostbyname,, AC_CHECK_LIB(nsl, gethostbyname))

AC_SUBST(SOCKET_ENGINE)

DOCDIR='${prefix}/doc'
MODDIR='${exec_prefix}'
SHAREDIR='${prefix}'
LOGDIR='${prefix}/var'
DATADIR='${prefix}/etc'
RUNDIR='${prefix}/var'

ABSPATHS="#"
AC_MSG_CHECKING(if you want to use absolute paths when building)
AC_ARG_ENABLE(absolute-paths,
AC_HELP_STRING([--enable-absolute-paths],[ Use absolute paths when building.]),
[
   case "$enableval" in
   yes)
      case "$srcdir" in
         /*)
         ;;
         *)
            oldsrcdir="$srcdir"
            srcdir="`cd \"$srcdir\";pwd`"
         ;;
      esac
      ABSPATHS=""
      ;;
   no)
      ABSPATHS="#"
      ;;
   esac
])
AC_MSG_RESULT($ABSPATHS)

SRCDIR="$srcdir"
BUILDDIR=`pwd`

FHSPATHS="yes"
DOCDIR='${datadir}/doc/dsyslog'
MODDIR='${libdir}/dsyslog'
SHAREDIR='${datadir}/dsyslog'
LOGDIR='${localstatedir}/log/dsyslog'
DATADIR='${localstatedir}/lib/dsyslog'
RUNDIR='${localstatedir}/run/dsyslog'

AC_SUBST(DOCDIR)
AC_SUBST(MODDIR)
AC_SUBST(SHAREDIR)
AC_SUBST(DATADIR)
AC_SUBST(LOGDIR)
AC_SUBST(RUNDIR)
AC_SUBST(ABSPATHS)
AC_SUBST(SRCDIR)
AC_SUBST(BUILDDIR)
dnl the following is wrong! -- jilles
dnl AC_DEFINE_UNQUOTED([MODDIR], "${MODDIR}", [Module root directory.])

dnl gettext
LOCALEDIR='${datadir}/locale'
AC_SUBST(LOCALEDIR)

shared_modules="yes"
dnl Second stage: check for functions and headers.
if test "$shared_modules" = yes; then
	AC_CHECK_HEADERS(dlfcn.h,,,[-])
	AC_SEARCH_LIBS(dlopen, [dl c_r],
	[
	    AC_DEFINE(HAVE_DLOPEN, 1, [Define if the dlopen function is available.])
	    AC_CHECK_FUNC(dlsym, ,
	    [
	      AC_ERROR([shared modules unavailable, Atheme will not work on your system])
	    ])
	    AC_CHECK_FUNCS(dlfunc)
	    AC_CHECK_FUNCS(dlinfo)
	],
	[
	    AC_ERROR([shared modules unavailable, Atheme will not work on your system])
	])
fi

dnl Third stage - wrangling the linker.
if test "$shared_modules" = yes; then
	# The GNU linker requires the -export-dynamic option to make
	# all symbols visible in the dynamic symbol table.
	hold_ldflags=$LDFLAGS
	AC_MSG_CHECKING(for the ld -export-dynamic flag)
	LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
	AC_LINK_IFELSE(AC_LANG_PROGRAM([],[int i;]), found=yes, found=no)
	LDFLAGS=$hold_ldflags

	if expr "`uname -s`" : ^IRIX >/dev/null 2>&1; then
		found="no, IRIX ld uses -B,dynamic"
		LDFLAGS="${LDFLAGS} -Wl,-B,dynamic"
	fi

	AC_MSG_RESULT($found)

	if test "$found" = yes; then
		LDFLAGS="${LDFLAGS} -Wl,-export-dynamic"
	fi

	if test "$ac_cv_c_compiler_gnu" = yes; then
		AC_MSG_CHECKING(if $CC is Apple GCC)
		if expr "`$CC -v 2>&1 | tail -n 1`" : ".*Apple" >/dev/null; then
			AppleGCC=yes
		else
			AppleGCC=no
		fi
	
		AC_MSG_RESULT($AppleGCC)
	fi

	AC_MSG_CHECKING(for compiler option to produce PIC)

	if test "$SGS" = "yes"; then
		AC_MSG_RESULT([SVR4 SGS interfaces: -KPIC -DPIC -G])
		PICFLAGS="-KPIC -DPIC -G"
	fi
	
	if test "$AppleGCC" = "yes"; then
		AC_MSG_RESULT([Darwin Mach-O bundles: -fno-common -bundle -flat_namespace -undefined suppress])
		PICFLAGS="-fno-common -bundle -flat_namespace -undefined suppress"
	fi

	if test "$HPUX" = "yes" -a "$CC" != gcc; then
		AC_MSG_RESULT(HP-UX cc: +z -r -q -n)
		PICFLAGS="+z -r -q -n -c"
		AC_MSG_CHECKING([if +ESfic is required on this platform])
		
		if expr "`$CC +ESfic 2>&1`" : ".*neither supported.*" >/dev/null; then 
			AC_MSG_RESULT(no)
		else
			AC_MSG_RESULT(yes)
			PICFLAGS="$PICFLAGS +ESfic"
		fi

		LDFLAGS="${LDFLAGS} -Wl,-E"
	fi

	if test "$Tru" = yes -a "$CC" != gcc; then
		AC_MSG_RESULT([Tru64: -shared -expect_unresolved '*'])
		PICFLAGS="-shared -expect_unresolved '*' "
		LDFLAGS="-call_shared"
	fi

	if test "$CC" = tcc -a "$TenDRA" = no; then
		AC_MSG_RESULT([TinyCC: static only.])
	        AC_ERROR([your compiler is unable to compile Atheme's modules.])
		shared_modules=no
	fi

	if test "$CC" = icc -a "$ICC" = yes; then
		AC_MSG_RESULT(intel: -fPIC -DPIC -shared)
		PICFLAGS="-fPIC -DPIC -shared"
	fi

	if test -z "$PICFLAGS"; then
		if test "$ac_cv_c_compiler_gnu" = "yes"; then
			AC_MSG_RESULT(gcc: -fPIC -DPIC -shared)
			PICFLAGS="-fPIC -DPIC -shared"
		else
			AC_MSG_RESULT(no)
		        AC_ERROR([your compiler is unable to compile Atheme's modules.])
		fi
	fi
fi

if test "$shared_modules" = yes; then

	AC_CHECK_FUNC(nlist,,
		AC_CHECK_LIB(dl, nlist, nlist_lib="-ldl",
			AC_CHECK_LIB(elf, nlist, nlist_lib="-lelf",)
		)
	)

	dnl We need to find out whether underscores are appended to symbol
	dnl names in executable files.  First, though, we need to see
	dnl where nlist.h is hiding.
	AC_CHECK_HEADER(libelf/nlist.h, [ nlist_h="libelf/nlist.h" ], ,[-])
	AC_CHECK_HEADER(elf/nlist.h, [ nlist_h="elf/nlist.h" ], ,[-])
	AC_CHECK_HEADER(nlist.h, [ nlist_h="nlist.h" ], ,[-])
	if test x"$nlist_h" = "x"; then
		AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "",
			[String containing extra underscores prepended to symbols loaded from modules.])
	else
		AC_MSG_CHECKING(for extra underscores prepended to symbol names)
		AC_CACHE_VAL(symbol_underscores,
		[
cat << EOF > conftest.c
#include <$nlist_h>
#include <stdio.h>
#include <stdlib.h>
void _modinit(void);
int main(int argc, char *argv[[]]) {
	int i;
	struct nlist nl[[5]];

	/* fill the names in this way, so it'll work almost everywhere */
	nl[[0]].n_name = "_modinit";
	nl[[1]].n_name = "__modinit";
	nl[[2]].n_name = "___modinit";
	nl[[3]].n_name = "____modinit";
	nl[[0]].n_value = nl[[1]].n_value = nl[[2]].n_value = nl[[3]].n_value = nl[[4]].n_name = NULL;

	if(argc < 2 || (nlist(argv[[1]], nl)) == -1) exit(-1);
	for(i = 0; i < 4; i++) {
		if(nl[[i]].n_value != NULL)
		{
			int j;
			for(j = 0; j < i; j++)
				printf("_");
			exit(i);
		}
	}
	exit(-1);
}
void _modinit(void) { return; }
EOF
		$CC $CPPFLAGS $CFLAGS -o conftest conftest.c $nlist_lib >/dev/null 2>&1
		symbol_underscores=`./conftest conftest`
		AC_MSG_RESULT($symbol_underscores)
		$RM -f conftest conftest.c
		])
		AC_DEFINE_UNQUOTED(SYMBOL_PREFIX, "${symbol_underscores}", 
			[String containing extra underscores prepended to symbols loaded from modules.])
	fi
fi

AC_SUBST(PICFLAGS)

ATHEME_C_GCC_TRY_FLAGS([-std=gnu99], atheme_cv_c_gcc_c99)
ATHEME_C_GCC_TRY_FLAGS([-Wall], atheme_cv_c_gcc_w_all)

AC_ARG_ENABLE(warnings,
AC_HELP_STRING([--enable-warnings],[ Enable compiler warnings]),
[
dnl See what warnings we can get away with
ATHEME_C_GCC_TRY_FLAGS([-Wpointer-arith], atheme_cv_c_gcc_w_pointer_arith)
ATHEME_C_GCC_TRY_FLAGS([-Wimplicit -Wnested-externs], atheme_cv_c_gcc_w_implicit)
ATHEME_C_GCC_TRY_FLAGS([-Wcast-align], atheme_cv_c_gcc_w_cast_align)
ATHEME_C_GCC_TRY_FLAGS([-Wcast-qual], atheme_cv_c_gcc_w_cast_qual)
ATHEME_C_GCC_TRY_FLAGS([-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations], atheme_cv_c_gcc_prototypes)
ATHEME_C_GCC_TRY_FLAGS([-Wparenthesis], atheme_cv_c_gcc_parenthesis)
ATHEME_C_GCC_TRY_FLAGS([-W -Wno-unused], atheme_cv_c_gcc_w)
ATHEME_C_GCC_TRY_FLAGS([-Wextra], atheme_cv_c_gcc_w_extra)
ATHEME_C_GCC_TRY_FLAGS([-Wshadow], atheme_cv_c_gcc_w_shadow)
ATHEME_C_GCC_TRY_FLAGS([-Wmissing-noreturn], atheme_cv_c_gcc_w_missing_noreturn)
ATHEME_C_GCC_TRY_FLAGS([-Wundef], atheme_cv_c_gcc_w_undef)
ATHEME_C_GCC_TRY_FLAGS([-Wpacked], atheme_cv_c_gcc_w_packed)
ATHEME_C_GCC_TRY_FLAGS([-Wnested-externs], atheme_cv_c_gcc_w_nested_externs)
ATHEME_C_GCC_TRY_FLAGS([-Wbad-function-cast], atheme_cv_c_gcc_w_bad_function_cast)
ATHEME_C_GCC_TRY_FLAGS([-Wunused-function -Wunused-label -Wunused-value -Wunused-variable], atheme_cv_c_gcc_w_unused)
ATHEME_C_GCC_TRY_FLAGS([-Wredundant-decls], atheme_cv_c_gcc_w_redundant_decls)
ATHEME_C_GCC_TRY_FLAGS([-Wfloat-equal], atheme_cv_c_gcc_w_float_equal)
ATHEME_C_GCC_TRY_FLAGS([-Wformat=2], atheme_cv_c_gcc_w_format)
ATHEME_C_GCC_TRY_FLAGS([-Wdisabled-optimization], atheme_cv_c_gcc_w_format)
ATHEME_C_GCC_TRY_FLAGS([-pedantic], atheme_cv_c_gcc_pedantic)

dnl Too unreliable to be useful at this time.
dnl ATHEME_C_GCC_TRY_FLAGS([-Wunreachable-code], atheme_cv_c_gcc_w_unreachable_code)

dnl Maintainer flags.
dnl ATHEME_C_GCC_TRY_FLAGS([-Wconversion], atheme_cv_c_gcc_w_conversion)
dnl ATHEME_C_GCC_TRY_FLAGS([-Wwrite-strings], atheme_cv_c_gcc_w_strings)
dnl ATHEME_C_GCC_TRY_FLAGS([-Werror], atheme_cv_c_gcc_w_error)
])

AC_ARG_ENABLE(propolice,
AC_HELP_STRING([--disable-propolice],[ Disable propolice protections (for debugging.)]),
[
ATHEME_C_GCC_TRY_FLAGS([-fno-stack-protector-all], atheme_nspa)
ATHEME_C_GCC_TRY_FLAGS([-fno-pie], atheme_npie)
ATHEME_C_GCC_TRY_FLAGS([-nonow], atheme_nonow)
ATHEME_C_GCC_TRY_FLAGS([-norelro], atheme_no_relro)
])

AC_ARG_ENABLE(profile,
AC_HELP_STRING([--enable-profile],[ Enable profiling extensions]),
[
ATHEME_C_GCC_TRY_FLAGS([-pg], atheme_pg)
ac_save_LDFLAGS="${LDFLAGS} -pg"
LDFLAGS=${ac_save_LDFLAGS}
])

ac_save_CFLAGS="${CFLAGS} ${orig_CFLAGS} ${CWARNS} -DPREFIX=\\\"\${prefix}\\\" -DLOCALEDIR=\\\"\${LOCALEDIR}\\\" -DMODDIR=\\\"\${MODDIR}\\\" -DSHAREDIR=\\\"${SHAREDIR}\\\" -DSYSCONFDIR=\\\"${sysconfdir}\\\" -DLOGDIR=\\\"${LOGDIR}\\\" -DRUNDIR=\\\"${RUNDIR}\\\" -DDATADIR=\\\"${DATADIR}\\\""
CFLAGS=${ac_save_CFLAGS}
dnl export CFLAGS

enablerpath="yes"
AC_ARG_ENABLE(rpath,
AC_HELP_STRING([--disable-rpath],[Disable use of -Wl,-rpath= during linking.]),
   [enablerpath="$enableval"], [enablerpath="yes"])
RPATH=""
if test "x$enablerpath" = "xyes"; then
    RPATH="-Wl,-rpath,${libdir}"
fi

AC_SUBST(RPATH)

AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug],[Enable debug logging.]),
   [CFLAGS="$CFLAGS"], [CFLAGS="$CFLAGS -DNDEBUG"])

PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.14 gthread-2.0], , [AC_MSG_ERROR([*** glib2 is needed. ***])])

CFLAGS="$CFLAGS $GLIB_CFLAGS"
LIBS="$LIBS $GLIB_LIBS"

PKG_CHECK_MODULES(GNUTLS, [gnutls], [
	CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
	LIBS="$LIBS $GNUTLS_LIBS"
	TLSMOD="output_tls.c"
	TLS="yes"
], [
	AC_MSG_WARN([*** gnutls is needed for TLS modules! ***])
	TLS="no"
])

AC_SUBST(TLSMOD)

MYSQL="yes"
MYINC=""
MYSQL_C=""

AC_MSG_CHECKING(for MySQL include directory)
if test -d /usr/include/mysql; then
        my_inc_dir="/usr/include/mysql"
elif test -d /usr/local/include/mysql; then
        my_inc_dir="/usr/local/include/mysql"
elif test -d /usr/local/mysql/include; then
        my_inc_dir="/usr/local/mysql/include"
elif test -d /opt/mysql/include; then
        my_inc_dir="/opt/mysql/include"
else
        my_inc_dir="no"
        MYLIB=""
        MYSQL="no"
fi

AC_MSG_RESULT($my_inc_dir)

if test "$MYINC" != "no" || test "$my_inc_dir" != "no"; then
        AC_CHECK_HEADER($my_inc_dir/mysql.h, [
                MYINC="-I$my_inc_dir"
                AC_CHECK_LIB(mysqlclient_r, mysql_real_connect, [MYLIB="-lmysqlclient_r"
                        MYSQL_C="output_mysql.c"])
        ])
else
        MYSQL="no"
fi

AC_SUBST(MYSQL_C)
AC_SUBST(MYINC)
AC_SUBST(MYLIB)

PQSQL="yes"
PQINC=""
PQSQL_C=""

AC_MSG_CHECKING(for PostGres include directory)
if test -d /usr/include/postgresql; then
        pq_inc_dir="/usr/include/postgresql"
elif test -d /usr/local/include/postgresql; then
        pq_inc_dir="/usr/local/include/postgresql"
elif test -d /usr/local/postgresql/include; then
        pq_inc_dir="/usr/local/postgresql/include"
elif test -d /opt/postgresql/include; then
        pq_inc_dir="/opt/postgresql/include"
else
        pq_inc_dir="no"
        PQLIB=""
        PQSQL="no"
fi

AC_MSG_RESULT($pq_inc_dir)

if test "$PQINC" != "no" || test "$pq_inc_dir" != "no"; then
        AC_CHECK_HEADER($pq_inc_dir/libpq-fe.h, [
                PQINC="-I$pq_inc_dir"
                AC_CHECK_LIB(pq, PQsendQueryPrepared, [PQLIB="-lpq"
                        PQSQL_C="output_postgres.c"])
        ])
else
        PQSQL="no"
fi

AC_SUBST(PQSQL_C)
AC_SUBST(PQINC)
AC_SUBST(PQLIB)

BUILDROOT=`pwd`
AC_SUBST(BUILDROOT)

AC_OUTPUT([
	Makefile
	modules/Makefile
	dsyslog/Makefile
])

d=`eval echo ${MODDIR}`
d=`eval echo $d`
echo "
Configuration:
	dsyslog version      : ${PACKAGE_VERSION}
	Installation prefix  : ${prefix}
	Module root directory: `eval echo $d`
	Config directory     : ${sysconfdir}
	Logfile directory    : ${LOGDIR}
	Data directory       : ${DATADIR}
	PID directory        : ${RUNDIR}
	MySQL support        : ${MYSQL}
	PostGres support     : ${PQSQL}
	TLS support          : ${TLS}
	CFLAGS               : ${CFLAGS}

Type make to build dsyslog, and make install to install it."