]> git.cameronkatri.com Git - apple_cmds.git/blob - patch_cmds/diffstat/aclocal.m4
Improve create_tarballs.sh
[apple_cmds.git] / patch_cmds / diffstat / aclocal.m4
1 dnl $Id: aclocal.m4,v 1.21 2012/01/03 09:37:14 tom Exp $
2 dnl autoconf macros for 'diffstat'
3 dnl
4 dnl Copyright 2003-2010,2012 Thomas E. Dickey
5 dnl
6 dnl See also
7 dnl http://invisible-island.net/autoconf/
8 dnl
9 dnl ---------------------------------------------------------------------------
10 dnl ---------------------------------------------------------------------------
11 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
12 dnl -------------
13 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
14 dnl The second parameter if given makes this macro verbose.
15 dnl
16 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
17 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
18 dnl confused by the quotes (which require backslashes to keep them usable).
19 AC_DEFUN([CF_ADD_CFLAGS],
20 [
21 cf_fix_cppflags=no
22 cf_new_cflags=
23 cf_new_cppflags=
24 cf_new_extra_cppflags=
25
26 for cf_add_cflags in $1
27 do
28 case $cf_fix_cppflags in
29 no)
30 case $cf_add_cflags in #(vi
31 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
32 case $cf_add_cflags in
33 -D*)
34 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
35
36 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
37 && test -z "${cf_tst_cflags}" \
38 && cf_fix_cppflags=yes
39
40 if test $cf_fix_cppflags = yes ; then
41 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
42 continue
43 elif test "${cf_tst_cflags}" = "\"'" ; then
44 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
45 continue
46 fi
47 ;;
48 esac
49 case "$CPPFLAGS" in
50 *$cf_add_cflags) #(vi
51 ;;
52 *) #(vi
53 case $cf_add_cflags in #(vi
54 -D*)
55 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
56 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
57 ;;
58 esac
59 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
60 ;;
61 esac
62 ;;
63 *)
64 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
65 ;;
66 esac
67 ;;
68 yes)
69 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
70
71 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
72
73 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
74 && test -z "${cf_tst_cflags}" \
75 && cf_fix_cppflags=no
76 ;;
77 esac
78 done
79
80 if test -n "$cf_new_cflags" ; then
81 ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
82 CFLAGS="$CFLAGS $cf_new_cflags"
83 fi
84
85 if test -n "$cf_new_cppflags" ; then
86 ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
87 CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
88 fi
89
90 if test -n "$cf_new_extra_cppflags" ; then
91 ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
92 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
93 fi
94
95 AC_SUBST(EXTRA_CPPFLAGS)
96
97 ])dnl
98 dnl ---------------------------------------------------------------------------
99 dnl CF_ANSI_CC_CHECK version: 11 updated: 2011/07/01 19:47:45
100 dnl ----------------
101 dnl This was originally adapted from the macros 'fp_PROG_CC_STDC' and
102 dnl 'fp_C_PROTOTYPES' in the sharutils 4.2 distribution.
103 AC_DEFUN([CF_ANSI_CC_CHECK],
104 [
105 # This should have been defined by AC_PROG_CC
106 : ${CC:=cc}
107
108 # Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
109 # into CC. This will not help with broken scripts that wrap the compiler with
110 # options, but eliminates a more common category of user confusion.
111 AC_MSG_CHECKING(\$CC variable)
112 case "$CC" in #(vi
113 *[[\ \ ]]-[[IUD]]*)
114 AC_MSG_RESULT(broken)
115 AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
116 # humor him...
117 cf_flags=`echo "$CC" | sed -e 's/^[[^ ]]*[[ ]]//'`
118 CC=`echo "$CC" | sed -e 's/[[ ]].*//'`
119 CF_ADD_CFLAGS($cf_flags)
120 ;;
121 *)
122 AC_MSG_RESULT(ok)
123 ;;
124 esac
125
126 AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
127 cf_cv_ansi_cc=no
128 cf_save_CFLAGS="$CFLAGS"
129 cf_save_CPPFLAGS="$CPPFLAGS"
130 # Don't try gcc -ansi; that turns off useful extensions and
131 # breaks some systems' header files.
132 # AIX -qlanglvl=ansi
133 # Ultrix and OSF/1 -std1
134 # HP-UX -Aa -D_HPUX_SOURCE
135 # SVR4 -Xc
136 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
137 for cf_arg in "-DCC_HAS_PROTOS" \
138 "" \
139 -qlanglvl=ansi \
140 -std1 \
141 -Ae \
142 "-Aa -D_HPUX_SOURCE" \
143 -Xc
144 do
145 CF_ADD_CFLAGS($cf_arg)
146 AC_TRY_COMPILE(
147 [
148 #ifndef CC_HAS_PROTOS
149 #if !defined(__STDC__) || (__STDC__ != 1)
150 choke me
151 #endif
152 #endif
153 ],[
154 int test (int i, double x);
155 struct s1 {int (*f) (int a);};
156 struct s2 {int (*f) (double a);};],
157 [cf_cv_ansi_cc="$cf_arg"; break])
158 done
159 CFLAGS="$cf_save_CFLAGS"
160 CPPFLAGS="$cf_save_CPPFLAGS"
161 ])
162
163 if test "$cf_cv_ansi_cc" != "no"; then
164 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
165 CF_ADD_CFLAGS($cf_cv_ansi_cc)
166 else
167 AC_DEFINE(CC_HAS_PROTOS)
168 fi
169 fi
170 ])dnl
171 dnl ---------------------------------------------------------------------------
172 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
173 dnl ---------------
174 dnl For programs that must use an ANSI compiler, obtain compiler options that
175 dnl will make it recognize prototypes. We'll do preprocessor checks in other
176 dnl macros, since tools such as unproto can fake prototypes, but only part of
177 dnl the preprocessor.
178 AC_DEFUN([CF_ANSI_CC_REQD],
179 [AC_REQUIRE([CF_ANSI_CC_CHECK])
180 if test "$cf_cv_ansi_cc" = "no"; then
181 AC_MSG_ERROR(
182 [Your compiler does not appear to recognize prototypes.
183 You have the following choices:
184 a. adjust your compiler options
185 b. get an up-to-date compiler
186 c. use a wrapper such as unproto])
187 fi
188 ])dnl
189 dnl ---------------------------------------------------------------------------
190 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
191 dnl --------------
192 dnl Allow user to disable a normally-on option.
193 AC_DEFUN([CF_ARG_DISABLE],
194 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
195 dnl ---------------------------------------------------------------------------
196 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
197 dnl -------------
198 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
199 dnl values.
200 dnl
201 dnl Parameters:
202 dnl $1 = option name
203 dnl $2 = help-string
204 dnl $3 = action to perform if option is not default
205 dnl $4 = action if perform if option is default
206 dnl $5 = default option value (either 'yes' or 'no')
207 AC_DEFUN([CF_ARG_OPTION],
208 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
209 if test "$enableval" != "$5" ; then
210 ifelse([$3],,[ :]dnl
211 ,[ $3]) ifelse([$4],,,[
212 else
213 $4])
214 fi],[enableval=$5 ifelse([$4],,,[
215 $4
216 ])dnl
217 ])])dnl
218 dnl ---------------------------------------------------------------------------
219 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
220 dnl --------------
221 dnl Check if we're accidentally using a cache from a different machine.
222 dnl Derive the system name, as a check for reusing the autoconf cache.
223 dnl
224 dnl If we've packaged config.guess and config.sub, run that (since it does a
225 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
226 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
227 dnl which is useful in cross-compiles.
228 dnl
229 dnl Note: we would use $ac_config_sub, but that is one of the places where
230 dnl autoconf 2.5x broke compatibility with autoconf 2.13
231 AC_DEFUN([CF_CHECK_CACHE],
232 [
233 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
234 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
235 system_name="$host_os"
236 else
237 system_name="`(uname -s -r) 2>/dev/null`"
238 if test -z "$system_name" ; then
239 system_name="`(hostname) 2>/dev/null`"
240 fi
241 fi
242 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
243 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
244
245 test -z "$system_name" && system_name="$cf_cv_system_name"
246 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
247
248 if test ".$system_name" != ".$cf_cv_system_name" ; then
249 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
250 AC_MSG_ERROR("Please remove config.cache and try again.")
251 fi
252 ])dnl
253 dnl ---------------------------------------------------------------------------
254 dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
255 dnl ---------------
256 dnl You can always use "make -n" to see the actual options, but it's hard to
257 dnl pick out/analyze warning messages when the compile-line is long.
258 dnl
259 dnl Sets:
260 dnl ECHO_LT - symbol to control if libtool is verbose
261 dnl ECHO_LD - symbol to prefix "cc -o" lines
262 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
263 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
264 dnl ECHO_CC - symbol to put before any "cc" line
265 dnl
266 AC_DEFUN([CF_DISABLE_ECHO],[
267 AC_MSG_CHECKING(if you want to see long compiling messages)
268 CF_ARG_DISABLE(echo,
269 [ --disable-echo display "compiling" commands],
270 [
271 ECHO_LT='--silent'
272 ECHO_LD='@echo linking [$]@;'
273 RULE_CC='@echo compiling [$]<'
274 SHOW_CC='@echo compiling [$]@'
275 ECHO_CC='@'
276 ],[
277 ECHO_LT=''
278 ECHO_LD=''
279 RULE_CC=''
280 SHOW_CC=''
281 ECHO_CC=''
282 ])
283 AC_MSG_RESULT($enableval)
284 AC_SUBST(ECHO_LT)
285 AC_SUBST(ECHO_LD)
286 AC_SUBST(RULE_CC)
287 AC_SUBST(SHOW_CC)
288 AC_SUBST(ECHO_CC)
289 ])dnl
290 dnl ---------------------------------------------------------------------------
291 dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
292 dnl ----------------
293 dnl Combine no-leak checks with the libraries or tools that are used for the
294 dnl checks.
295 AC_DEFUN([CF_DISABLE_LEAKS],[
296
297 AC_REQUIRE([CF_WITH_DMALLOC])
298 AC_REQUIRE([CF_WITH_DBMALLOC])
299 AC_REQUIRE([CF_WITH_VALGRIND])
300
301 AC_MSG_CHECKING(if you want to perform memory-leak testing)
302 AC_ARG_ENABLE(leaks,
303 [ --disable-leaks test: free permanent memory, analyze leaks],
304 [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
305 : ${with_no_leaks:=no})
306 AC_MSG_RESULT($with_no_leaks)
307
308 if test "$with_no_leaks" = yes ; then
309 AC_DEFINE(NO_LEAKS)
310 AC_DEFINE(YY_NO_LEAKS)
311 fi
312 ])dnl
313 dnl ---------------------------------------------------------------------------
314 dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
315 dnl -----------------
316 dnl Test for availability of useful gcc __attribute__ directives to quiet
317 dnl compiler warnings. Though useful, not all are supported -- and contrary
318 dnl to documentation, unrecognized directives cause older compilers to barf.
319 AC_DEFUN([CF_GCC_ATTRIBUTES],
320 [
321 if test "$GCC" = yes
322 then
323 cat > conftest.i <<EOF
324 #ifndef GCC_PRINTF
325 #define GCC_PRINTF 0
326 #endif
327 #ifndef GCC_SCANF
328 #define GCC_SCANF 0
329 #endif
330 #ifndef GCC_NORETURN
331 #define GCC_NORETURN /* nothing */
332 #endif
333 #ifndef GCC_UNUSED
334 #define GCC_UNUSED /* nothing */
335 #endif
336 EOF
337 if test "$GCC" = yes
338 then
339 AC_CHECKING([for $CC __attribute__ directives])
340 cat > conftest.$ac_ext <<EOF
341 #line __oline__ "${as_me:-configure}"
342 #include "confdefs.h"
343 #include "conftest.h"
344 #include "conftest.i"
345 #if GCC_PRINTF
346 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
347 #else
348 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
349 #endif
350 #if GCC_SCANF
351 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
352 #else
353 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
354 #endif
355 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
356 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
357 extern void foo(void) GCC_NORETURN;
358 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
359 EOF
360 cf_printf_attribute=no
361 cf_scanf_attribute=no
362 for cf_attribute in scanf printf unused noreturn
363 do
364 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
365 cf_directive="__attribute__(($cf_attribute))"
366 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
367
368 case $cf_attribute in #(vi
369 printf) #(vi
370 cf_printf_attribute=yes
371 cat >conftest.h <<EOF
372 #define GCC_$cf_ATTRIBUTE 1
373 EOF
374 ;;
375 scanf) #(vi
376 cf_scanf_attribute=yes
377 cat >conftest.h <<EOF
378 #define GCC_$cf_ATTRIBUTE 1
379 EOF
380 ;;
381 *) #(vi
382 cat >conftest.h <<EOF
383 #define GCC_$cf_ATTRIBUTE $cf_directive
384 EOF
385 ;;
386 esac
387
388 if AC_TRY_EVAL(ac_compile); then
389 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
390 cat conftest.h >>confdefs.h
391 case $cf_attribute in #(vi
392 printf) #(vi
393 if test "$cf_printf_attribute" = no ; then
394 cat >>confdefs.h <<EOF
395 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
396 EOF
397 else
398 cat >>confdefs.h <<EOF
399 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
400 EOF
401 fi
402 ;;
403 scanf) #(vi
404 if test "$cf_scanf_attribute" = no ; then
405 cat >>confdefs.h <<EOF
406 #define GCC_SCANFLIKE(fmt,var) /* nothing */
407 EOF
408 else
409 cat >>confdefs.h <<EOF
410 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
411 EOF
412 fi
413 ;;
414 esac
415 fi
416 done
417 else
418 fgrep define conftest.i >>confdefs.h
419 fi
420 rm -rf conftest*
421 fi
422 ])dnl
423 dnl ---------------------------------------------------------------------------
424 dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
425 dnl --------------
426 dnl Find version of gcc
427 AC_DEFUN([CF_GCC_VERSION],[
428 AC_REQUIRE([AC_PROG_CC])
429 GCC_VERSION=none
430 if test "$GCC" = yes ; then
431 AC_MSG_CHECKING(version of $CC)
432 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
433 test -z "$GCC_VERSION" && GCC_VERSION=unknown
434 AC_MSG_RESULT($GCC_VERSION)
435 fi
436 ])dnl
437 dnl ---------------------------------------------------------------------------
438 dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
439 dnl ---------------
440 dnl Check if the compiler supports useful warning options. There's a few that
441 dnl we don't use, simply because they're too noisy:
442 dnl
443 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
444 dnl -Wredundant-decls (system headers make this too noisy)
445 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
446 dnl -Wwrite-strings (too noisy, but should review occasionally). This
447 dnl is enabled for ncurses using "--enable-const".
448 dnl -pedantic
449 dnl
450 dnl Parameter:
451 dnl $1 is an optional list of gcc warning flags that a particular
452 dnl application might want to use, e.g., "no-unused" for
453 dnl -Wno-unused
454 dnl Special:
455 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
456 dnl
457 AC_DEFUN([CF_GCC_WARNINGS],
458 [
459 AC_REQUIRE([CF_GCC_VERSION])
460 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
461
462 cat > conftest.$ac_ext <<EOF
463 #line __oline__ "${as_me:-configure}"
464 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
465 EOF
466
467 if test "$INTEL_COMPILER" = yes
468 then
469 # The "-wdXXX" options suppress warnings:
470 # remark #1419: external declaration in primary source file
471 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
472 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
473 # remark #193: zero used for undefined preprocessing identifier
474 # remark #593: variable "curs_sb_left_arrow" was set but never used
475 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
476 # remark #869: parameter "tw" was never referenced
477 # remark #981: operands are evaluated in unspecified order
478 # warning #279: controlling expression is constant
479
480 AC_CHECKING([for $CC warning options])
481 cf_save_CFLAGS="$CFLAGS"
482 EXTRA_CFLAGS="-Wall"
483 for cf_opt in \
484 wd1419 \
485 wd1683 \
486 wd1684 \
487 wd193 \
488 wd593 \
489 wd279 \
490 wd810 \
491 wd869 \
492 wd981
493 do
494 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
495 if AC_TRY_EVAL(ac_compile); then
496 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
497 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
498 fi
499 done
500 CFLAGS="$cf_save_CFLAGS"
501
502 elif test "$GCC" = yes
503 then
504 AC_CHECKING([for $CC warning options])
505 cf_save_CFLAGS="$CFLAGS"
506 EXTRA_CFLAGS=
507 cf_warn_CONST=""
508 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
509 for cf_opt in W Wall \
510 Wbad-function-cast \
511 Wcast-align \
512 Wcast-qual \
513 Winline \
514 Wmissing-declarations \
515 Wmissing-prototypes \
516 Wnested-externs \
517 Wpointer-arith \
518 Wshadow \
519 Wstrict-prototypes \
520 Wundef $cf_warn_CONST $1
521 do
522 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
523 if AC_TRY_EVAL(ac_compile); then
524 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
525 case $cf_opt in #(vi
526 Wcast-qual) #(vi
527 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
528 ;;
529 Winline) #(vi
530 case $GCC_VERSION in
531 [[34]].*)
532 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
533 continue;;
534 esac
535 ;;
536 esac
537 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
538 fi
539 done
540 CFLAGS="$cf_save_CFLAGS"
541 fi
542 rm -rf conftest*
543
544 AC_SUBST(EXTRA_CFLAGS)
545 ])dnl
546 dnl ---------------------------------------------------------------------------
547 dnl CF_GETOPT_HEADER version: 4 updated: 2009/08/31 20:07:52
548 dnl ----------------
549 dnl Check for getopt's variables which are commonly defined in stdlib.h,
550 dnl unistd.h or (nonstandard) in getopt.h
551 AC_DEFUN([CF_GETOPT_HEADER],
552 [
553 AC_HAVE_HEADERS(unistd.h getopt.h)
554 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
555 cf_cv_getopt_header=none
556 for cf_header in stdio.h stdlib.h unistd.h getopt.h
557 do
558 AC_TRY_COMPILE([
559 #include <$cf_header>],
560 [int x = optind; char *y = optarg],
561 [cf_cv_getopt_header=$cf_header
562 break])
563 done
564 ])
565 if test $cf_cv_getopt_header != none ; then
566 AC_DEFINE(HAVE_GETOPT_HEADER)
567 fi
568 ])dnl
569 dnl ---------------------------------------------------------------------------
570 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
571 dnl -------------
572 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
573 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
574 dnl (or misfeature) of glibc2, which breaks portability of many applications,
575 dnl since it is interwoven with GNU extensions.
576 dnl
577 dnl Well, yes we could work around it...
578 AC_DEFUN([CF_GNU_SOURCE],
579 [
580 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
581 AC_TRY_COMPILE([#include <sys/types.h>],[
582 #ifndef _XOPEN_SOURCE
583 make an error
584 #endif],
585 [cf_cv_gnu_source=no],
586 [cf_save="$CPPFLAGS"
587 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
588 AC_TRY_COMPILE([#include <sys/types.h>],[
589 #ifdef _XOPEN_SOURCE
590 make an error
591 #endif],
592 [cf_cv_gnu_source=no],
593 [cf_cv_gnu_source=yes])
594 CPPFLAGS="$cf_save"
595 ])
596 ])
597 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
598 ])dnl
599 dnl ---------------------------------------------------------------------------
600 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
601 dnl -------------
602 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
603 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
604 dnl (or misfeature) of glibc2, which breaks portability of many applications,
605 dnl since it is interwoven with GNU extensions.
606 dnl
607 dnl Well, yes we could work around it...
608 AC_DEFUN([CF_GNU_SOURCE],
609 [
610 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
611 AC_TRY_COMPILE([#include <sys/types.h>],[
612 #ifndef _XOPEN_SOURCE
613 make an error
614 #endif],
615 [cf_cv_gnu_source=no],
616 [cf_save="$CPPFLAGS"
617 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
618 AC_TRY_COMPILE([#include <sys/types.h>],[
619 #ifdef _XOPEN_SOURCE
620 make an error
621 #endif],
622 [cf_cv_gnu_source=no],
623 [cf_cv_gnu_source=yes])
624 CPPFLAGS="$cf_save"
625 ])
626 ])
627 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
628 ])dnl
629 dnl ---------------------------------------------------------------------------
630 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
631 dnl -----------------
632 dnl Check if the given compiler is really the Intel compiler for Linux. It
633 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
634 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
635 dnl
636 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
637 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
638 dnl the wrappers for gcc and g++ warnings.
639 dnl
640 dnl $1 = GCC (default) or GXX
641 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
642 dnl $3 = CFLAGS (default) or CXXFLAGS
643 AC_DEFUN([CF_INTEL_COMPILER],[
644 ifelse([$2],,INTEL_COMPILER,[$2])=no
645
646 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
647 case $host_os in
648 linux*|gnu*)
649 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
650 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
651 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
652 AC_TRY_COMPILE([],[
653 #ifdef __INTEL_COMPILER
654 #else
655 make an error
656 #endif
657 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
658 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
659 ],[])
660 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
661 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
662 ;;
663 esac
664 fi
665 ])dnl
666 dnl ---------------------------------------------------------------------------
667 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
668 dnl ------------
669 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
670 dnl a monocase filesystem.
671 AC_DEFUN([CF_MAKE_TAGS],[
672 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
673
674 AC_CHECK_PROGS(CTAGS, exctags ctags)
675 AC_CHECK_PROGS(ETAGS, exetags etags)
676
677 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
678
679 if test "$cf_cv_mixedcase" = yes ; then
680 AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
681 else
682 MAKE_UPPER_TAGS=no
683 fi
684
685 if test "$MAKE_UPPER_TAGS" = yes ; then
686 MAKE_UPPER_TAGS=
687 else
688 MAKE_UPPER_TAGS="#"
689 fi
690
691 if test "$MAKE_LOWER_TAGS" = yes ; then
692 MAKE_LOWER_TAGS=
693 else
694 MAKE_LOWER_TAGS="#"
695 fi
696
697 AC_SUBST(CTAGS)
698 AC_SUBST(ETAGS)
699
700 AC_SUBST(MAKE_UPPER_TAGS)
701 AC_SUBST(MAKE_LOWER_TAGS)
702 ])dnl
703 dnl ---------------------------------------------------------------------------
704 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
705 dnl ----------------------
706 dnl Check if the file-system supports mixed-case filenames. If we're able to
707 dnl create a lowercase name and see it as uppercase, it doesn't support that.
708 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
709 [
710 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
711 if test "$cross_compiling" = yes ; then
712 case $target_alias in #(vi
713 *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
714 cf_cv_mixedcase=no
715 ;;
716 *)
717 cf_cv_mixedcase=yes
718 ;;
719 esac
720 else
721 rm -f conftest CONFTEST
722 echo test >conftest
723 if test -f CONFTEST ; then
724 cf_cv_mixedcase=no
725 else
726 cf_cv_mixedcase=yes
727 fi
728 rm -f conftest CONFTEST
729 fi
730 ])
731 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
732 ])dnl
733 dnl ---------------------------------------------------------------------------
734 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
735 dnl ----------
736 dnl Write a debug message to config.log, along with the line number in the
737 dnl configure script.
738 AC_DEFUN([CF_MSG_LOG],[
739 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
740 ])dnl
741 dnl ---------------------------------------------------------------------------
742 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
743 dnl ------------------
744 dnl see CF_WITH_NO_LEAKS
745 AC_DEFUN([CF_NO_LEAKS_OPTION],[
746 AC_MSG_CHECKING(if you want to use $1 for testing)
747 AC_ARG_WITH($1,
748 [$2],
749 [AC_DEFINE($3)ifelse([$4],,[
750 $4
751 ])
752 : ${with_cflags:=-g}
753 : ${with_no_leaks:=yes}
754 with_$1=yes],
755 [with_$1=])
756 AC_MSG_RESULT(${with_$1:-no})
757
758 case .$with_cflags in #(vi
759 .*-g*)
760 case .$CFLAGS in #(vi
761 .*-g*) #(vi
762 ;;
763 *)
764 CF_ADD_CFLAGS([-g])
765 ;;
766 esac
767 ;;
768 esac
769 ])dnl
770 dnl ---------------------------------------------------------------------------
771 dnl CF_PATHSEP version: 5 updated: 2010/05/26 05:38:42
772 dnl ----------
773 dnl Provide a value for the $PATH and similar separator
774 AC_DEFUN([CF_PATHSEP],
775 [
776 case $cf_cv_system_name in
777 os2*) PATH_SEPARATOR=';' ;;
778 *) PATH_SEPARATOR=':' ;;
779 esac
780 ifelse([$1],,,[$1=$PATH_SEPARATOR])
781 AC_SUBST(PATH_SEPARATOR)
782 ])dnl
783 dnl ---------------------------------------------------------------------------
784 dnl CF_PATH_PROG version: 8 updated: 2010/10/23 16:12:25
785 dnl ------------
786 dnl Check for a given program, defining corresponding symbol.
787 dnl $1 = environment variable, which is suffixed by "_PATH" in the #define.
788 dnl $2 = program name to find.
789 dnl $3 = optional list of additional program names to test.
790 dnl
791 dnl If there is more than one token in the result, #define the remaining tokens
792 dnl to $1_ARGS. We need this for 'install' in particular.
793 dnl
794 dnl FIXME: we should allow this to be overridden by environment variables
795 dnl
796 AC_DEFUN([CF_PATH_PROG],[
797 AC_REQUIRE([CF_PATHSEP])
798 test -z "[$]$1" && $1=$2
799 AC_PATH_PROGS($1,[$]$1 $2 $3,[$]$1)
800
801 cf_path_prog=""
802 cf_path_args=""
803 IFS="${IFS:- }"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
804 for cf_temp in $ac_cv_path_$1
805 do
806 if test -z "$cf_path_prog" ; then
807 if test "$with_full_paths" = yes ; then
808 CF_PATH_SYNTAX(cf_temp,break)
809 cf_path_prog="$cf_temp"
810 else
811 cf_path_prog="`basename $cf_temp`"
812 fi
813 elif test -z "$cf_path_args" ; then
814 cf_path_args="$cf_temp"
815 else
816 cf_path_args="$cf_path_args $cf_temp"
817 fi
818 done
819 IFS="$cf_save_ifs"
820
821 if test -n "$cf_path_prog" ; then
822 CF_MSG_LOG(defining path for ${cf_path_prog})
823 AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog")
824 test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args")
825 fi
826 ])dnl
827 dnl ---------------------------------------------------------------------------
828 dnl CF_PATH_SYNTAX version: 13 updated: 2010/05/26 05:38:42
829 dnl --------------
830 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
831 dnl begins with one of the prefix/exec_prefix variables, and then again if the
832 dnl result begins with 'NONE'. This is necessary to work around autoconf's
833 dnl delayed evaluation of those symbols.
834 AC_DEFUN([CF_PATH_SYNTAX],[
835 if test "x$prefix" != xNONE; then
836 cf_path_syntax="$prefix"
837 else
838 cf_path_syntax="$ac_default_prefix"
839 fi
840
841 case ".[$]$1" in #(vi
842 .\[$]\(*\)*|.\'*\'*) #(vi
843 ;;
844 ..|./*|.\\*) #(vi
845 ;;
846 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
847 ;;
848 .\[$]{*prefix}*) #(vi
849 eval $1="[$]$1"
850 case ".[$]$1" in #(vi
851 .NONE/*)
852 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
853 ;;
854 esac
855 ;; #(vi
856 .no|.NONE/*)
857 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
858 ;;
859 *)
860 ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
861 ;;
862 esac
863 ])dnl
864 dnl ---------------------------------------------------------------------------
865 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
866 dnl -----------------
867 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
868 dnl
869 dnl POSIX.1-1990 _POSIX_SOURCE
870 dnl POSIX.1-1990 and _POSIX_SOURCE and
871 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
872 dnl Bindings Option
873 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
874 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
875 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
876 dnl
877 dnl Parameters:
878 dnl $1 is the nominal value for _POSIX_C_SOURCE
879 AC_DEFUN([CF_POSIX_C_SOURCE],
880 [
881 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
882
883 cf_save_CFLAGS="$CFLAGS"
884 cf_save_CPPFLAGS="$CPPFLAGS"
885
886 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
887 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
888
889 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
890 CF_MSG_LOG(if the symbol is already defined go no further)
891 AC_TRY_COMPILE([#include <sys/types.h>],[
892 #ifndef _POSIX_C_SOURCE
893 make an error
894 #endif],
895 [cf_cv_posix_c_source=no],
896 [cf_want_posix_source=no
897 case .$cf_POSIX_C_SOURCE in #(vi
898 .[[12]]??*) #(vi
899 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
900 ;;
901 .2) #(vi
902 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
903 cf_want_posix_source=yes
904 ;;
905 .*)
906 cf_want_posix_source=yes
907 ;;
908 esac
909 if test "$cf_want_posix_source" = yes ; then
910 AC_TRY_COMPILE([#include <sys/types.h>],[
911 #ifdef _POSIX_SOURCE
912 make an error
913 #endif],[],
914 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
915 fi
916 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
917 CFLAGS="$cf_trim_CFLAGS"
918 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
919 CF_MSG_LOG(if the second compile does not leave our definition intact error)
920 AC_TRY_COMPILE([#include <sys/types.h>],[
921 #ifndef _POSIX_C_SOURCE
922 make an error
923 #endif],,
924 [cf_cv_posix_c_source=no])
925 CFLAGS="$cf_save_CFLAGS"
926 CPPFLAGS="$cf_save_CPPFLAGS"
927 ])
928 ])
929
930 if test "$cf_cv_posix_c_source" != no ; then
931 CFLAGS="$cf_trim_CFLAGS"
932 CPPFLAGS="$cf_trim_CPPFLAGS"
933 CF_ADD_CFLAGS($cf_cv_posix_c_source)
934 fi
935
936 ])dnl
937 dnl ---------------------------------------------------------------------------
938 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
939 dnl --------------
940 dnl Check if C (preprocessor) -U and -D options are processed in the order
941 dnl given rather than by type of option. Some compilers insist on apply all
942 dnl of the -U options after all of the -D options. Others allow mixing them,
943 dnl and may predefine symbols that conflict with those we define.
944 AC_DEFUN([CF_PROG_CC_U_D],
945 [
946 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
947 cf_save_CPPFLAGS="$CPPFLAGS"
948 CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
949 AC_TRY_COMPILE([],[
950 #ifndef U_D_OPTIONS
951 make an undefined-error
952 #endif
953 #ifdef D_U_OPTIONS
954 make a defined-error
955 #endif
956 ],[
957 cf_cv_cc_u_d_options=yes],[
958 cf_cv_cc_u_d_options=no])
959 CPPFLAGS="$cf_save_CPPFLAGS"
960 ])
961 ])dnl
962 dnl ---------------------------------------------------------------------------
963 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
964 dnl -----------
965 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
966 AC_DEFUN([CF_PROG_EXT],
967 [
968 AC_REQUIRE([CF_CHECK_CACHE])
969 case $cf_cv_system_name in
970 os2*)
971 CFLAGS="$CFLAGS -Zmt"
972 CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
973 CXXFLAGS="$CXXFLAGS -Zmt"
974 # autoconf's macro sets -Zexe and suffix both, which conflict:w
975 LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
976 ac_cv_exeext=.exe
977 ;;
978 esac
979
980 AC_EXEEXT
981 AC_OBJEXT
982
983 PROG_EXT="$EXEEXT"
984 AC_SUBST(PROG_EXT)
985 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
986 ])dnl
987 dnl ---------------------------------------------------------------------------
988 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
989 dnl ------------
990 AC_DEFUN([CF_PROG_LINT],
991 [
992 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
993 AC_SUBST(LINT_OPTS)
994 ])dnl
995 dnl ---------------------------------------------------------------------------
996 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
997 dnl ----------------
998 dnl Remove all -U and -D options that refer to the given symbol from a list
999 dnl of C compiler options. This works around the problem that not all
1000 dnl compilers process -U and -D options from left-to-right, so a -U option
1001 dnl cannot be used to cancel the effect of a preceding -D option.
1002 dnl
1003 dnl $1 = target (which could be the same as the source variable)
1004 dnl $2 = source (including '$')
1005 dnl $3 = symbol to remove
1006 define([CF_REMOVE_DEFINE],
1007 [
1008 $1=`echo "$2" | \
1009 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
1010 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
1011 ])dnl
1012 dnl ---------------------------------------------------------------------------
1013 dnl CF_STDIO_UNLOCKED version: 3 updated: 2009/10/06 19:54:39
1014 dnl -----------------
1015 dnl The four functions getc_unlocked(), getchar_unlocked(), putc_unlocked(),
1016 dnl putchar_unlocked() are in POSIX.1-2001.
1017 dnl
1018 dnl Test for one or more of the "unlocked" stdio getc/putc functions, and (if
1019 dnl the system requires it to declare the prototype) define _REENTRANT
1020 dnl
1021 dnl $1 = one or more stdio functions to check for existence and prototype.
1022 AC_DEFUN([CF_STDIO_UNLOCKED],
1023 [
1024 cf_stdio_unlocked=no
1025 AC_CHECK_FUNCS(ifelse([$1],,[getc_unlocked putc_unlocked],[$1]),
1026 [cf_stdio_unlocked=$ac_func])
1027 if test "$cf_stdio_unlocked" != no ; then
1028 case "$CPPFLAGS" in #(vi
1029 *-D_REENTRANT*) #(vi
1030 ;;
1031 *)
1032 AC_CACHE_CHECK(if we should define _REENTRANT,cf_cv_stdio_unlocked,[
1033 AC_TRY_COMPILE([#include <stdio.h>],[
1034 extern void *$cf_stdio_unlocked(void *);
1035 void *dummy = $cf_stdio_unlocked(0)],
1036 [cf_cv_stdio_unlocked=yes],
1037 [cf_cv_stdio_unlocked=no])])
1038 if test "$cf_cv_stdio_unlocked" = yes ; then
1039 AC_DEFINE(_REENTRANT)
1040 fi
1041 ;;
1042 esac
1043 fi
1044 ])
1045 dnl ---------------------------------------------------------------------------
1046 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
1047 dnl -------------------
1048 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1049 dnl can define it successfully.
1050 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1051 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1052 AC_TRY_COMPILE([
1053 #include <stdlib.h>
1054 #include <string.h>
1055 #include <sys/types.h>
1056 ],[
1057 #ifndef _XOPEN_SOURCE
1058 make an error
1059 #endif],
1060 [cf_cv_xopen_source=no],
1061 [cf_save="$CPPFLAGS"
1062 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1063 AC_TRY_COMPILE([
1064 #include <stdlib.h>
1065 #include <string.h>
1066 #include <sys/types.h>
1067 ],[
1068 #ifdef _XOPEN_SOURCE
1069 make an error
1070 #endif],
1071 [cf_cv_xopen_source=no],
1072 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1073 CPPFLAGS="$cf_save"
1074 ])
1075 ])
1076
1077 if test "$cf_cv_xopen_source" != no ; then
1078 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1079 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1080 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1081 CF_ADD_CFLAGS($cf_temp_xopen_source)
1082 fi
1083 ])
1084 dnl ---------------------------------------------------------------------------
1085 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1086 dnl --------
1087 dnl Make an uppercase version of a variable
1088 dnl $1=uppercase($2)
1089 AC_DEFUN([CF_UPPER],
1090 [
1091 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1092 ])dnl
1093 dnl ---------------------------------------------------------------------------
1094 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1095 dnl ----------
1096 dnl Use AC_VERBOSE w/o the warnings
1097 AC_DEFUN([CF_VERBOSE],
1098 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
1099 CF_MSG_LOG([$1])
1100 ])dnl
1101 dnl ---------------------------------------------------------------------------
1102 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1103 dnl ----------------
1104 dnl Configure-option for dbmalloc. The optional parameter is used to override
1105 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1106 AC_DEFUN([CF_WITH_DBMALLOC],[
1107 CF_NO_LEAKS_OPTION(dbmalloc,
1108 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
1109 [USE_DBMALLOC])
1110
1111 if test "$with_dbmalloc" = yes ; then
1112 AC_CHECK_HEADER(dbmalloc.h,
1113 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1114 fi
1115 ])dnl
1116 dnl ---------------------------------------------------------------------------
1117 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1118 dnl ---------------
1119 dnl Configure-option for dmalloc. The optional parameter is used to override
1120 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1121 AC_DEFUN([CF_WITH_DMALLOC],[
1122 CF_NO_LEAKS_OPTION(dmalloc,
1123 [ --with-dmalloc test: use Gray Watson's dmalloc library],
1124 [USE_DMALLOC])
1125
1126 if test "$with_dmalloc" = yes ; then
1127 AC_CHECK_HEADER(dmalloc.h,
1128 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1129 fi
1130 ])dnl
1131 dnl ---------------------------------------------------------------------------
1132 dnl CF_WITH_INSTALL_PREFIX version: 4 updated: 2010/10/23 15:52:32
1133 dnl ----------------------
1134 dnl Configure-script option to give a default value for the poorly-chosen name
1135 dnl $(DESTDIR).
1136 AC_DEFUN([CF_WITH_INSTALL_PREFIX],
1137 [
1138 AC_MSG_CHECKING(for install-prefix)
1139 AC_ARG_WITH(install-prefix,
1140 [ --with-install-prefix=XXX sets DESTDIR, useful for packaging],
1141 [cf_opt_with_install_prefix=$withval],
1142 [cf_opt_with_install_prefix=${DESTDIR:-no}])
1143 AC_MSG_RESULT($cf_opt_with_install_prefix)
1144 if test "$cf_opt_with_install_prefix" != no ; then
1145 CF_PATH_SYNTAX(cf_opt_with_install_prefix)
1146 DESTDIR=$cf_opt_with_install_prefix
1147 fi
1148 AC_SUBST(DESTDIR)
1149 ])dnl
1150 dnl ---------------------------------------------------------------------------
1151 dnl CF_WITH_PURIFY version: 2 updated: 2006/12/14 18:43:43
1152 dnl --------------
1153 AC_DEFUN([CF_WITH_PURIFY],[
1154 CF_NO_LEAKS_OPTION(purify,
1155 [ --with-purify test: use Purify],
1156 [USE_PURIFY],
1157 [LINK_PREFIX="$LINK_PREFIX purify"])
1158 AC_SUBST(LINK_PREFIX)
1159 ])dnl
1160 dnl ---------------------------------------------------------------------------
1161 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
1162 dnl ----------------
1163 AC_DEFUN([CF_WITH_VALGRIND],[
1164 CF_NO_LEAKS_OPTION(valgrind,
1165 [ --with-valgrind test: use valgrind],
1166 [USE_VALGRIND])
1167 ])dnl
1168 dnl ---------------------------------------------------------------------------
1169 dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
1170 dnl ----------------
1171 dnl Combine the checks for gcc features into a configure-script option
1172 dnl
1173 dnl Parameters:
1174 dnl $1 - see CF_GCC_WARNINGS
1175 AC_DEFUN([CF_WITH_WARNINGS],
1176 [
1177 if ( test "$GCC" = yes || test "$GXX" = yes )
1178 then
1179 AC_MSG_CHECKING(if you want to check for gcc warnings)
1180 AC_ARG_WITH(warnings,
1181 [ --with-warnings test: turn on gcc warnings],
1182 [cf_opt_with_warnings=$withval],
1183 [cf_opt_with_warnings=no])
1184 AC_MSG_RESULT($cf_opt_with_warnings)
1185 if test "$cf_opt_with_warnings" != no ; then
1186 CF_GCC_ATTRIBUTES
1187 CF_GCC_WARNINGS([$1])
1188 fi
1189 fi
1190 ])dnl
1191 dnl ---------------------------------------------------------------------------
1192 dnl CF_XOPEN_SOURCE version: 41 updated: 2011/12/10 18:58:47
1193 dnl ---------------
1194 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1195 dnl or adapt to the vendor's definitions to get equivalent functionality,
1196 dnl without losing the common non-POSIX features.
1197 dnl
1198 dnl Parameters:
1199 dnl $1 is the nominal value for _XOPEN_SOURCE
1200 dnl $2 is the nominal value for _POSIX_C_SOURCE
1201 AC_DEFUN([CF_XOPEN_SOURCE],[
1202
1203 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1204 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1205 cf_xopen_source=
1206
1207 case $host_os in #(vi
1208 aix[[4-7]]*) #(vi
1209 cf_xopen_source="-D_ALL_SOURCE"
1210 ;;
1211 cygwin) #(vi
1212 cf_XOPEN_SOURCE=600
1213 ;;
1214 darwin[[0-8]].*) #(vi
1215 cf_xopen_source="-D_APPLE_C_SOURCE"
1216 ;;
1217 darwin*) #(vi
1218 cf_xopen_source="-D_DARWIN_C_SOURCE"
1219 ;;
1220 freebsd*|dragonfly*) #(vi
1221 # 5.x headers associate
1222 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1223 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1224 cf_POSIX_C_SOURCE=200112L
1225 cf_XOPEN_SOURCE=600
1226 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1227 ;;
1228 hpux11*) #(vi
1229 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1230 ;;
1231 hpux*) #(vi
1232 cf_xopen_source="-D_HPUX_SOURCE"
1233 ;;
1234 irix[[56]].*) #(vi
1235 cf_xopen_source="-D_SGI_SOURCE"
1236 cf_XOPEN_SOURCE=
1237 ;;
1238 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
1239 CF_GNU_SOURCE
1240 ;;
1241 mirbsd*) #(vi
1242 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1243 cf_XOPEN_SOURCE=
1244 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1245 ;;
1246 netbsd*) #(vi
1247 cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1248 ;;
1249 openbsd[[4-9]]*) #(vi
1250 # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1251 cf_XOPEN_SOURCE=600
1252 ;;
1253 openbsd*) #(vi
1254 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1255 ;;
1256 osf[[45]]*) #(vi
1257 cf_xopen_source="-D_OSF_SOURCE"
1258 ;;
1259 nto-qnx*) #(vi
1260 cf_xopen_source="-D_QNX_SOURCE"
1261 ;;
1262 sco*) #(vi
1263 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1264 ;;
1265 solaris2.*) #(vi
1266 cf_xopen_source="-D__EXTENSIONS__"
1267 ;;
1268 *)
1269 CF_TRY_XOPEN_SOURCE
1270 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1271 ;;
1272 esac
1273
1274 if test -n "$cf_xopen_source" ; then
1275 CF_ADD_CFLAGS($cf_xopen_source)
1276 fi
1277
1278 dnl In anything but the default case, we may have system-specific setting
1279 dnl which is still not guaranteed to provide all of the entrypoints that
1280 dnl _XOPEN_SOURCE would yield.
1281 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
1282 AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
1283 AC_TRY_COMPILE([#include <stdlib.h>],[
1284 #ifndef _XOPEN_SOURCE
1285 make an error
1286 #endif],
1287 [cf_XOPEN_SOURCE_set=yes],
1288 [cf_XOPEN_SOURCE_set=no])
1289 AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
1290 if test $cf_XOPEN_SOURCE_set = yes
1291 then
1292 AC_TRY_COMPILE([#include <stdlib.h>],[
1293 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1294 make an error
1295 #endif],
1296 [cf_XOPEN_SOURCE_set_ok=yes],
1297 [cf_XOPEN_SOURCE_set_ok=no])
1298 if test $cf_XOPEN_SOURCE_set_ok = no
1299 then
1300 AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
1301 fi
1302 else
1303 CF_TRY_XOPEN_SOURCE
1304 fi
1305 fi
1306 ])