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 |
---|
4 | |
---|
5 | dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) |
---|
6 | dnl example |
---|
7 | dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) |
---|
8 | dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local |
---|
9 | |
---|
10 | AC_DEFUN([AS_AC_EXPAND], |
---|
11 | [ |
---|
12 | EXP_VAR=[$1] |
---|
13 | FROM_VAR=[$2] |
---|
14 | |
---|
15 | dnl first expand prefix and exec_prefix if necessary |
---|
16 | prefix_save=$prefix |
---|
17 | exec_prefix_save=$exec_prefix |
---|
18 | |
---|
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" |
---|
22 | fi |
---|
23 | dnl if no exec_prefix given, then use prefix |
---|
24 | if test "x$exec_prefix" = "xNONE"; then |
---|
25 | exec_prefix=$prefix |
---|
26 | fi |
---|
27 | |
---|
28 | full_var="$FROM_VAR" |
---|
29 | dnl loop until it doesn't change anymore |
---|
30 | while true; do |
---|
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 |
---|
34 | done |
---|
35 | |
---|
36 | dnl clean up |
---|
37 | full_var=$new_full_var |
---|
38 | AC_SUBST([$1], "$full_var") |
---|
39 | |
---|
40 | dnl restore prefix and exec_prefix |
---|
41 | prefix=$prefix_save |
---|
42 | exec_prefix=$exec_prefix_save |
---|
43 | ]) |
---|
44 | |
---|
45 | dnl Checks for availability of various utmp fields |
---|
46 | dnl |
---|
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 |
---|
50 | dnl |
---|
51 | |
---|
52 | dnl GDM_CHECK_UTMP() |
---|
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 |
---|
55 | |
---|
56 | AC_DEFUN([GDM_CHECK_UTMP],[ |
---|
57 | |
---|
58 | AC_CHECK_HEADERS(sys/time.h utmp.h utmpx.h) |
---|
59 | AC_HEADER_TIME |
---|
60 | |
---|
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.]) |
---|
63 | else |
---|
64 | AC_DEFINE(UTMP,[struct utmp],[Define to the name of a structure which holds utmp data.]) |
---|
65 | fi |
---|
66 | |
---|
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 |
---|
70 | #include <sys/time.h> |
---|
71 | #include <time.h> |
---|
72 | #else |
---|
73 | #ifdef HAVE_SYS_TIME_H |
---|
74 | #include <sys/time.h> |
---|
75 | #else |
---|
76 | #include <time.h> |
---|
77 | #endif |
---|
78 | #endif |
---|
79 | #ifdef HAVE_UTMP_H |
---|
80 | #include <utmp.h> |
---|
81 | #endif |
---|
82 | #ifdef HAVE_UTMPX_H |
---|
83 | #include <utmpx.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.]) |
---|
87 | fi |
---|
88 | AC_MSG_RESULT($result) |
---|
89 | |
---|
90 | AC_MSG_CHECKING(for ut_pid field in the utmp structure) |
---|
91 | AC_TRY_COMPILE([#ifdef TIME_WITH_SYS_TIME |
---|
92 | #include <sys/time.h> |
---|
93 | #include <time.h> |
---|
94 | #else |
---|
95 | #ifdef HAVE_SYS_TIME_H |
---|
96 | #include <sys/time.h> |
---|
97 | #else |
---|
98 | #include <time.h> |
---|
99 | #endif |
---|
100 | #endif |
---|
101 | #ifdef HAVE_UTMP_H |
---|
102 | #include <utmp.h> |
---|
103 | #endif |
---|
104 | #ifdef HAVE_UTMPX_H |
---|
105 | #include <utmpx.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.]) |
---|
109 | fi |
---|
110 | AC_MSG_RESULT($result) |
---|
111 | |
---|
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> |
---|
115 | #include <time.h> |
---|
116 | #else |
---|
117 | #ifdef HAVE_SYS_TIME_H |
---|
118 | #include <sys/time.h> |
---|
119 | #else |
---|
120 | #include <time.h> |
---|
121 | #endif |
---|
122 | #endif |
---|
123 | #ifdef HAVE_UTMP_H |
---|
124 | #include <utmp.h> |
---|
125 | #endif |
---|
126 | #ifdef HAVE_UTMPX_H |
---|
127 | #include <utmpx.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.]) |
---|
131 | fi |
---|
132 | AC_MSG_RESULT($result) |
---|
133 | |
---|
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> |
---|
137 | #include <time.h> |
---|
138 | #else |
---|
139 | #ifdef HAVE_SYS_TIME_H |
---|
140 | #include <sys/time.h> |
---|
141 | #else |
---|
142 | #include <time.h> |
---|
143 | #endif |
---|
144 | #endif |
---|
145 | #ifdef HAVE_UTMP_H |
---|
146 | #include <utmp.h> |
---|
147 | #endif |
---|
148 | #ifdef HAVE_UTMPX_H |
---|
149 | #include <utmpx.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.]) |
---|
153 | fi |
---|
154 | AC_MSG_RESULT($result) |
---|
155 | |
---|
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> |
---|
159 | #include <time.h> |
---|
160 | #else |
---|
161 | #ifdef HAVE_SYS_TIME_H |
---|
162 | #include <sys/time.h> |
---|
163 | #else |
---|
164 | #include <time.h> |
---|
165 | #endif |
---|
166 | #endif |
---|
167 | #ifdef HAVE_UTMP_H |
---|
168 | #include <utmp.h> |
---|
169 | #endif |
---|
170 | #ifdef HAVE_UTMPX_H |
---|
171 | #include <utmpx.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.]) |
---|
175 | fi |
---|
176 | AC_MSG_RESULT($result) |
---|
177 | |
---|
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> |
---|
181 | #include <time.h> |
---|
182 | #else |
---|
183 | #ifdef HAVE_SYS_TIME_H |
---|
184 | #include <sys/time.h> |
---|
185 | #else |
---|
186 | #include <time.h> |
---|
187 | #endif |
---|
188 | #endif |
---|
189 | #ifdef HAVE_UTMP_H |
---|
190 | #include <utmp.h> |
---|
191 | #endif |
---|
192 | #ifdef HAVE_UTMPX_H |
---|
193 | #include <utmpx.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.]) |
---|
197 | fi |
---|
198 | AC_MSG_RESULT($result) |
---|
199 | |
---|
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> |
---|
203 | #include <time.h> |
---|
204 | #else |
---|
205 | #ifdef HAVE_SYS_TIME_H |
---|
206 | #include <sys/time.h> |
---|
207 | #else |
---|
208 | #include <time.h> |
---|
209 | #endif |
---|
210 | #endif |
---|
211 | #ifdef HAVE_UTMP_H |
---|
212 | #include <utmp.h> |
---|
213 | #endif |
---|
214 | #ifdef HAVE_UTMPX_H |
---|
215 | #include <utmpx.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.]) |
---|
219 | fi |
---|
220 | AC_MSG_RESULT($result) |
---|
221 | |
---|
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> |
---|
225 | #include <time.h> |
---|
226 | #else |
---|
227 | #ifdef HAVE_SYS_TIME_H |
---|
228 | #include <sys/time.h> |
---|
229 | #else |
---|
230 | #include <time.h> |
---|
231 | #endif |
---|
232 | #endif |
---|
233 | #ifdef HAVE_UTMP_H |
---|
234 | #include <utmp.h> |
---|
235 | #endif |
---|
236 | #ifdef HAVE_UTMPX_H |
---|
237 | #include <utmpx.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.]) |
---|
241 | fi |
---|
242 | AC_MSG_RESULT($result) |
---|
243 | |
---|
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> |
---|
247 | #include <time.h> |
---|
248 | #else |
---|
249 | #ifdef HAVE_SYS_TIME_H |
---|
250 | #include <sys/time.h> |
---|
251 | #else |
---|
252 | #include <time.h> |
---|
253 | #endif |
---|
254 | #endif |
---|
255 | #ifdef HAVE_UTMP_H |
---|
256 | #include <utmp.h> |
---|
257 | #endif |
---|
258 | #ifdef HAVE_UTMPX_H |
---|
259 | #include <utmpx.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.]) |
---|
263 | fi |
---|
264 | AC_MSG_RESULT($result) |
---|
265 | |
---|
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> |
---|
269 | #include <time.h> |
---|
270 | #else |
---|
271 | #ifdef HAVE_SYS_TIME_H |
---|
272 | #include <sys/time.h> |
---|
273 | #else |
---|
274 | #include <time.h> |
---|
275 | #endif |
---|
276 | #endif |
---|
277 | #ifdef HAVE_UTMP_H |
---|
278 | #include <utmp.h> |
---|
279 | #endif |
---|
280 | #ifdef HAVE_UTMPX_H |
---|
281 | #include <utmpx.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.]) |
---|
285 | fi |
---|
286 | AC_MSG_RESULT($result) |
---|
287 | |
---|
288 | ]) |
---|
289 | |
---|
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 ****************************** |
---|
297 | |
---|
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])"]) |
---|
302 | |
---|
303 | warnCFLAGS= |
---|
304 | if test "x$GCC" != xyes; then |
---|
305 | enable_compile_warnings=no |
---|
306 | fi |
---|
307 | |
---|
308 | warning_flags= |
---|
309 | realsave_CFLAGS="$CFLAGS" |
---|
310 | |
---|
311 | case "$enable_compile_warnings" in |
---|
312 | no) |
---|
313 | warning_flags= |
---|
314 | ;; |
---|
315 | minimum) |
---|
316 | warning_flags="-Wall" |
---|
317 | ;; |
---|
318 | yes) |
---|
319 | warning_flags="-Wall -Wmissing-prototypes" |
---|
320 | ;; |
---|
321 | maximum|error) |
---|
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([], [], |
---|
329 | has_option=yes, |
---|
330 | has_option=no,) |
---|
331 | CFLAGS="$SAVE_CFLAGS" |
---|
332 | AC_MSG_RESULT($has_option) |
---|
333 | if test $has_option = yes; then |
---|
334 | warning_flags="$warning_flags $option" |
---|
335 | fi |
---|
336 | unset has_option |
---|
337 | unset SAVE_CFLAGS |
---|
338 | done |
---|
339 | unset option |
---|
340 | if test "$enable_compile_warnings" = "error" ; then |
---|
341 | warning_flags="$warning_flags -Werror" |
---|
342 | fi |
---|
343 | ;; |
---|
344 | *) |
---|
345 | AC_MSG_ERROR(Unknown argument '$enable_compile_warnings' to --enable-compile-warnings) |
---|
346 | ;; |
---|
347 | esac |
---|
348 | CFLAGS="$realsave_CFLAGS" |
---|
349 | AC_MSG_CHECKING(what warning flags to pass to the C compiler) |
---|
350 | AC_MSG_RESULT($warning_flags) |
---|
351 | |
---|
352 | AC_ARG_ENABLE(iso-c, |
---|
353 | AC_HELP_STRING([--enable-iso-c], |
---|
354 | [Try to warn if code is not ISO C ]),, |
---|
355 | [enable_iso_c=no]) |
---|
356 | |
---|
357 | AC_MSG_CHECKING(what language compliance flags to pass to the C compiler) |
---|
358 | complCFLAGS= |
---|
359 | if test "x$enable_iso_c" != "xno"; then |
---|
360 | if test "x$GCC" = "xyes"; then |
---|
361 | case " $CFLAGS " in |
---|
362 | *[\ \ ]-ansi[\ \ ]*) ;; |
---|
363 | *) complCFLAGS="$complCFLAGS -ansi" ;; |
---|
364 | esac |
---|
365 | case " $CFLAGS " in |
---|
366 | *[\ \ ]-pedantic[\ \ ]*) ;; |
---|
367 | *) complCFLAGS="$complCFLAGS -pedantic" ;; |
---|
368 | esac |
---|
369 | fi |
---|
370 | fi |
---|
371 | AC_MSG_RESULT($complCFLAGS) |
---|
372 | |
---|
373 | WARN_CFLAGS="$warning_flags $complCFLAGS" |
---|
374 | AC_SUBST(WARN_CFLAGS) |
---|
375 | ]) |
---|