1
dnl as-ac-expand.m4 0.2.0
2
dnl autostars m4 macro for expanding directories using configure's prefix
3
dnl thomas@apestaart.org
5
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
7
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
8
dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
10
AC_DEFUN([AS_AC_EXPAND],
15
dnl first expand prefix and exec_prefix if necessary
17
exec_prefix_save=$exec_prefix
19
dnl if no prefix given, then use /usr/local, the default prefix
20
if test "x$prefix" = "xNONE"; then
21
prefix="$ac_default_prefix"
23
dnl if no exec_prefix given, then use prefix
24
if test "x$exec_prefix" = "xNONE"; then
29
dnl loop until it doesn't change anymore
31
new_full_var="`eval echo $full_var`"
32
if test "x$new_full_var" = "x$full_var"; then break; fi
33
full_var=$new_full_var
37
full_var=$new_full_var
38
AC_SUBST([$1], "$full_var")
40
dnl restore prefix and exec_prefix
42
exec_prefix=$exec_prefix_save
45
dnl Checks for availability of various utmp fields
47
dnl Original code by Bernhard Rosenkraenzer (bero@linux.net.eu.org), 1998.
48
dnl Modifications by Timur Bakeyev (timur@gnu.org), 1999.
49
dnl Patched from http://bugzilla.gnome.org/show_bug.cgi?id=937
53
dnl Test for presence of the field and define HAVE_UT_UT_field macro
54
dnl Taken from vte/gnome-pty-helper's GPH_CHECK_UTMP
56
AC_DEFUN([GDM_CHECK_UTMP],[
58
AC_CHECK_HEADERS(sys/time.h utmp.h utmpx.h)
61
if test "$ac_cv_header_utmpx_h" = "yes"; then
62
AC_DEFINE(UTMP,[struct utmpx],[Define to the name of a structure which holds utmp data.])
64
AC_DEFINE(UTMP,[struct utmp],[Define to the name of a structure which holds utmp data.])
67
dnl some systems (BSD4.4-like) require time.h to be included before utmp.h :/
68
AC_MSG_CHECKING(for ut_host field in the utmp structure)
69
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
73
#ifdef HAVE_SYS_TIME_H
84
#endif],[UTMP ut; char *p; p=ut.ut_host;],result=yes,result=no)
85
if test "$result" = "yes"; then
86
AC_DEFINE(HAVE_UT_UT_HOST,1,[Define if your utmp struct contains a ut_host field.])
88
AC_MSG_RESULT($result)
90
AC_MSG_CHECKING(for ut_pid field in the utmp structure)
91
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
95
#ifdef HAVE_SYS_TIME_H
106
#endif],[UTMP ut; int i; i=ut.ut_pid;],result=yes,result=no)
107
if test "$result" = "yes"; then
108
AC_DEFINE(HAVE_UT_UT_PID,1,[Define if your utmp struct contains a ut_pid field.])
110
AC_MSG_RESULT($result)
112
AC_MSG_CHECKING(for ut_id field in the utmp structure)
113
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
114
#include <sys/time.h>
117
#ifdef HAVE_SYS_TIME_H
118
#include <sys/time.h>
128
#endif],[UTMP ut; char *p; p=ut.ut_id;],result=yes,result=no)
129
if test "$result" = "yes"; then
130
AC_DEFINE(HAVE_UT_UT_ID,1,[Define if your utmp struct contains a ut_id field.])
132
AC_MSG_RESULT($result)
134
AC_MSG_CHECKING(for ut_name field in the utmp structure)
135
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
136
#include <sys/time.h>
139
#ifdef HAVE_SYS_TIME_H
140
#include <sys/time.h>
150
#endif],[UTMP ut; char *p; p=ut.ut_name;],result=yes,result=no)
151
if test "$result" = "yes"; then
152
AC_DEFINE(HAVE_UT_UT_NAME,1,[Define if your utmp struct contains a ut_name field.])
154
AC_MSG_RESULT($result)
156
AC_MSG_CHECKING(for ut_type field in the utmp structure)
157
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
158
#include <sys/time.h>
161
#ifdef HAVE_SYS_TIME_H
162
#include <sys/time.h>
172
#endif],[UTMP ut; int i; i=(int) ut.ut_type;],result=yes,result=no)
173
if test "$result" = "yes"; then
174
AC_DEFINE(HAVE_UT_UT_TYPE,1,[Define if your utmp struct contains a ut_type field.])
176
AC_MSG_RESULT($result)
178
AC_MSG_CHECKING(for ut_exit.e_termination field in the utmp structure)
179
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
180
#include <sys/time.h>
183
#ifdef HAVE_SYS_TIME_H
184
#include <sys/time.h>
194
#endif],[UTMP ut; ut.ut_exit.e_termination=0;],result=yes,result=no)
195
if test "$result" = "yes"; then
196
AC_DEFINE(HAVE_UT_UT_EXIT_E_TERMINATION,1,[Define if your utmp struct contains a ut_exit.e_termination field.])
198
AC_MSG_RESULT($result)
200
AC_MSG_CHECKING(for ut_user field in the utmp structure)
201
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
202
#include <sys/time.h>
205
#ifdef HAVE_SYS_TIME_H
206
#include <sys/time.h>
216
#endif],[UTMP ut; char *p; p=ut.ut_user;],result=yes,result=no)
217
if test "$result" = "yes"; then
218
AC_DEFINE(HAVE_UT_UT_USER,1,[Define if your utmp struct contains a ut_user field.])
220
AC_MSG_RESULT($result)
222
AC_MSG_CHECKING(for ut_time field in the utmp structure)
223
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
224
#include <sys/time.h>
227
#ifdef HAVE_SYS_TIME_H
228
#include <sys/time.h>
238
#endif],[UTMP ut; ut.ut_time=0;],result=yes,result=no)
239
if test "$result" = "yes"; then
240
AC_DEFINE(HAVE_UT_UT_TIME,1,[Define if your utmp struct contains a ut_time field.])
242
AC_MSG_RESULT($result)
244
AC_MSG_CHECKING(for ut_tv field in the utmp structure)
245
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
246
#include <sys/time.h>
249
#ifdef HAVE_SYS_TIME_H
250
#include <sys/time.h>
260
#endif],[UTMP ut; ut.ut_tv.tv_sec=0; ut.ut_tv.tv_usec=0; ],result=yes,result=no)
261
if test "$result" = "yes"; then
262
AC_DEFINE(HAVE_UT_UT_TV,1,[Define if your utmp struct contains a ut_tv field.])
264
AC_MSG_RESULT($result)
266
AC_MSG_CHECKING(for ut_syslen field in the utmp structure)
267
AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME
268
#include <sys/time.h>
271
#ifdef HAVE_SYS_TIME_H
272
#include <sys/time.h>
282
#endif],[UTMP ut; ut.ut_syslen=0;],result=yes,result=no)
283
if test "$result" = "yes"; then
284
AC_DEFINE(HAVE_UT_UT_SYSLEN,1,[Define if your utmp struct contains a ut_syslen field.])
286
AC_MSG_RESULT($result)
290
dnl EXTRA_COMPILE_WARNINGS
291
dnl Turn on many useful compiler warnings
292
dnl For now, only works on GCC
293
AC_DEFUN([EXTRA_COMPILE_WARNINGS],[
294
dnl ******************************
295
dnl More compiler warnings
296
dnl ******************************
298
AC_ARG_ENABLE(compile-warnings,
299
AC_HELP_STRING([--enable-compile-warnings=@<:@no/minimum/yes/maximum/error@:>@],
300
[Turn on compiler warnings]),,
301
[enable_compile_warnings="m4_default([$1],[yes])"])
304
if test "x$GCC" != xyes; then
305
enable_compile_warnings=no
309
realsave_CFLAGS="$CFLAGS"
311
case "$enable_compile_warnings" in
316
warning_flags="-Wall"
319
warning_flags="-Wall -Wmissing-prototypes"
322
warning_flags="-Wall -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
323
CFLAGS="$warning_flags $CFLAGS"
324
for option in -Wno-sign-compare; do
325
SAVE_CFLAGS="$CFLAGS"
326
CFLAGS="$CFLAGS $option"
327
AC_MSG_CHECKING([whether gcc understands $option])
328
AC_TRY_COMPILE([], [],
331
CFLAGS="$SAVE_CFLAGS"
332
AC_MSG_RESULT($has_option)
333
if test $has_option = yes; then
334
warning_flags="$warning_flags $option"
340
if test "$enable_compile_warnings" = "error" ; then
341
warning_flags="$warning_flags -Werror"
345
AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings)
348
CFLAGS="$realsave_CFLAGS"
349
AC_MSG_CHECKING(what warning flags to pass to the C compiler)
350
AC_MSG_RESULT($warning_flags)
353
AC_HELP_STRING([--enable-iso-c],
354
[Try to warn if code is not ISO C ]),,
357
AC_MSG_CHECKING(what language compliance flags to pass to the C compiler)
359
if test "x$enable_iso_c" != "xno"; then
360
if test "x$GCC" = "xyes"; then
362
*[\ \ ]-ansi[\ \ ]*) ;;
363
*) complCFLAGS="$complCFLAGS -ansi" ;;
366
*[\ \ ]-pedantic[\ \ ]*) ;;
367
*) complCFLAGS="$complCFLAGS -pedantic" ;;
371
AC_MSG_RESULT($complCFLAGS)
373
WARN_CFLAGS="$warning_flags $complCFLAGS"
374
AC_SUBST(WARN_CFLAGS)