]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/byacc/aclocal.m4
Update llvm to release_39 branch r279689.
[FreeBSD/FreeBSD.git] / contrib / byacc / aclocal.m4
1 dnl $Id: aclocal.m4,v 1.39 2016/03/25 00:06:44 tom Exp $
2 dnl Macros for byacc configure script (Thomas E. Dickey)
3 dnl ---------------------------------------------------------------------------
4 dnl Copyright 2004-2015,2016 Thomas E. Dickey
5 dnl 
6 dnl Permission is hereby granted, free of charge, to any person obtaining a
7 dnl copy of this software and associated documentation files (the
8 dnl "Software"), to deal in the Software without restriction, including
9 dnl without limitation the rights to use, copy, modify, merge, publish,
10 dnl distribute, distribute with modifications, sublicense, and/or sell
11 dnl copies of the Software, and to permit persons to whom the Software is
12 dnl furnished to do so, subject to the following conditions:
13 dnl 
14 dnl The above copyright notice and this permission notice shall be included
15 dnl in all copies or portions of the Software.
16 dnl 
17 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 dnl 
25 dnl Except as contained in this notice, the name(s) of the above copyright
26 dnl holders shall not be used in advertising or otherwise to promote the
27 dnl sale, use or other dealings in this Software without prior written
28 dnl authorization.
29 dnl ---------------------------------------------------------------------------
30 dnl ---------------------------------------------------------------------------
31 dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
32 dnl ------------------
33 dnl Conditionally generate script according to whether we're using a given autoconf.
34 dnl
35 dnl $1 = version to compare against
36 dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
37 dnl $3 = code to use if AC_ACVERSION is older than $1.
38 define([CF_ACVERSION_CHECK],
39 [
40 ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
41 ifdef([m4_version_compare],
42 [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
43 [CF_ACVERSION_COMPARE(
44 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
45 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
46 dnl ---------------------------------------------------------------------------
47 dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
48 dnl --------------------
49 dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
50 dnl                      MAJOR2, MINOR2, TERNARY2,
51 dnl                      PRINTABLE2, not FOUND, FOUND)
52 define([CF_ACVERSION_COMPARE],
53 [ifelse(builtin([eval], [$2 < $5]), 1,
54 [ifelse([$8], , ,[$8])],
55 [ifelse([$9], , ,[$9])])])dnl
56 dnl ---------------------------------------------------------------------------
57 dnl CF_ADD_CFLAGS version: 12 updated: 2015/04/12 15:39:00
58 dnl -------------
59 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
60 dnl The second parameter if given makes this macro verbose.
61 dnl
62 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
63 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
64 dnl confused by the quotes (which require backslashes to keep them usable).
65 AC_DEFUN([CF_ADD_CFLAGS],
66 [
67 cf_fix_cppflags=no
68 cf_new_cflags=
69 cf_new_cppflags=
70 cf_new_extra_cppflags=
71
72 for cf_add_cflags in $1
73 do
74 case $cf_fix_cppflags in
75 (no)
76         case $cf_add_cflags in
77         (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
78                 case $cf_add_cflags in
79                 (-D*)
80                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
81
82                         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
83                                 && test -z "${cf_tst_cflags}" \
84                                 && cf_fix_cppflags=yes
85
86                         if test $cf_fix_cppflags = yes ; then
87                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
88                                 continue
89                         elif test "${cf_tst_cflags}" = "\"'" ; then
90                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
91                                 continue
92                         fi
93                         ;;
94                 esac
95                 case "$CPPFLAGS" in
96                 (*$cf_add_cflags)
97                         ;;
98                 (*)
99                         case $cf_add_cflags in
100                         (-D*)
101                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
102                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
103                                 ;;
104                         esac
105                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
106                         ;;
107                 esac
108                 ;;
109         (*)
110                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
111                 ;;
112         esac
113         ;;
114 (yes)
115         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
116
117         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
118
119         test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
120                 && test -z "${cf_tst_cflags}" \
121                 && cf_fix_cppflags=no
122         ;;
123 esac
124 done
125
126 if test -n "$cf_new_cflags" ; then
127         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
128         CFLAGS="$CFLAGS $cf_new_cflags"
129 fi
130
131 if test -n "$cf_new_cppflags" ; then
132         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
133         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
134 fi
135
136 if test -n "$cf_new_extra_cppflags" ; then
137         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
138         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
139 fi
140
141 AC_SUBST(EXTRA_CPPFLAGS)
142
143 ])dnl
144 dnl ---------------------------------------------------------------------------
145 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
146 dnl --------------
147 dnl Allow user to disable a normally-on option.
148 AC_DEFUN([CF_ARG_DISABLE],
149 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
150 dnl ---------------------------------------------------------------------------
151 dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
152 dnl -------------
153 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
154 dnl values.
155 dnl
156 dnl Parameters:
157 dnl $1 = option name
158 dnl $2 = help-string
159 dnl $3 = action to perform if option is not default
160 dnl $4 = action if perform if option is default
161 dnl $5 = default option value (either 'yes' or 'no')
162 AC_DEFUN([CF_ARG_OPTION],
163 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
164         if test "$enableval" != "$5" ; then
165 ifelse([$3],,[    :]dnl
166 ,[    $3]) ifelse([$4],,,[
167         else
168                 $4])
169         fi],[enableval=$5 ifelse([$4],,,[
170         $4
171 ])dnl
172 ])])dnl
173 dnl ---------------------------------------------------------------------------
174 dnl CF_CC_ENV_FLAGS version: 2 updated: 2015/04/12 15:39:00
175 dnl ---------------
176 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
177 dnl into CC.  This will not help with broken scripts that wrap the compiler with
178 dnl options, but eliminates a more common category of user confusion.
179 AC_DEFUN([CF_CC_ENV_FLAGS],
180 [
181 # This should have been defined by AC_PROG_CC
182 : ${CC:=cc}
183
184 AC_MSG_CHECKING(\$CC variable)
185 case "$CC" in
186 (*[[\ \ ]]-[[IUD]]*)
187         AC_MSG_RESULT(broken)
188         AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
189         # humor him...
190         cf_flags=`echo "$CC" | sed -e 's/^[[^   ]]*[[   ]]//'`
191         CC=`echo "$CC" | sed -e 's/[[   ]].*//'`
192         CF_ADD_CFLAGS($cf_flags)
193         ;;
194 (*)
195         AC_MSG_RESULT(ok)
196         ;;
197 esac
198 ])dnl
199 dnl ---------------------------------------------------------------------------
200 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
201 dnl --------------
202 dnl Check if we're accidentally using a cache from a different machine.
203 dnl Derive the system name, as a check for reusing the autoconf cache.
204 dnl
205 dnl If we've packaged config.guess and config.sub, run that (since it does a
206 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
207 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
208 dnl which is useful in cross-compiles.
209 dnl
210 dnl Note: we would use $ac_config_sub, but that is one of the places where
211 dnl autoconf 2.5x broke compatibility with autoconf 2.13
212 AC_DEFUN([CF_CHECK_CACHE],
213 [
214 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
215         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
216         system_name="$host_os"
217 else
218         system_name="`(uname -s -r) 2>/dev/null`"
219         if test -z "$system_name" ; then
220                 system_name="`(hostname) 2>/dev/null`"
221         fi
222 fi
223 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
224 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
225
226 test -z "$system_name" && system_name="$cf_cv_system_name"
227 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
228
229 if test ".$system_name" != ".$cf_cv_system_name" ; then
230         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
231         AC_MSG_ERROR("Please remove config.cache and try again.")
232 fi
233 ])dnl
234 dnl ---------------------------------------------------------------------------
235 dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
236 dnl -----------------
237 dnl Check if the given compiler is really clang.  clang's C driver defines
238 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
239 dnl not ignore some gcc options.
240 dnl
241 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
242 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
243 dnl the wrappers for gcc and g++ warnings.
244 dnl
245 dnl $1 = GCC (default) or GXX
246 dnl $2 = CLANG_COMPILER (default)
247 dnl $3 = CFLAGS (default) or CXXFLAGS
248 AC_DEFUN([CF_CLANG_COMPILER],[
249 ifelse([$2],,CLANG_COMPILER,[$2])=no
250
251 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
252         AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
253         cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
254         ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
255         AC_TRY_COMPILE([],[
256 #ifdef __clang__
257 #else
258 make an error
259 #endif
260 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
261 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
262 ],[])
263         ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
264         AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
265 fi
266 ])
267 dnl ---------------------------------------------------------------------------
268 dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
269 dnl ---------------
270 dnl You can always use "make -n" to see the actual options, but it's hard to
271 dnl pick out/analyze warning messages when the compile-line is long.
272 dnl
273 dnl Sets:
274 dnl     ECHO_LT - symbol to control if libtool is verbose
275 dnl     ECHO_LD - symbol to prefix "cc -o" lines
276 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
277 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
278 dnl     ECHO_CC - symbol to put before any "cc" line
279 dnl
280 AC_DEFUN([CF_DISABLE_ECHO],[
281 AC_MSG_CHECKING(if you want to see long compiling messages)
282 CF_ARG_DISABLE(echo,
283         [  --disable-echo          do not display "compiling" commands],
284         [
285         ECHO_LT='--silent'
286         ECHO_LD='@echo linking [$]@;'
287         RULE_CC='@echo compiling [$]<'
288         SHOW_CC='@echo compiling [$]@'
289         ECHO_CC='@'
290 ],[
291         ECHO_LT=''
292         ECHO_LD=''
293         RULE_CC=''
294         SHOW_CC=''
295         ECHO_CC=''
296 ])
297 AC_MSG_RESULT($enableval)
298 AC_SUBST(ECHO_LT)
299 AC_SUBST(ECHO_LD)
300 AC_SUBST(RULE_CC)
301 AC_SUBST(SHOW_CC)
302 AC_SUBST(ECHO_CC)
303 ])dnl
304 dnl ---------------------------------------------------------------------------
305 dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
306 dnl ----------------
307 dnl Combine no-leak checks with the libraries or tools that are used for the
308 dnl checks.
309 AC_DEFUN([CF_DISABLE_LEAKS],[
310
311 AC_REQUIRE([CF_WITH_DMALLOC])
312 AC_REQUIRE([CF_WITH_DBMALLOC])
313 AC_REQUIRE([CF_WITH_VALGRIND])
314
315 AC_MSG_CHECKING(if you want to perform memory-leak testing)
316 AC_ARG_ENABLE(leaks,
317         [  --disable-leaks         test: free permanent memory, analyze leaks],
318         [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
319         : ${with_no_leaks:=no})
320 AC_MSG_RESULT($with_no_leaks)
321
322 if test "$with_no_leaks" = yes ; then
323         AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
324         AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
325 fi
326 ])dnl
327 dnl ---------------------------------------------------------------------------
328 dnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
329 dnl -----------------
330 dnl Test for availability of useful gcc __attribute__ directives to quiet
331 dnl compiler warnings.  Though useful, not all are supported -- and contrary
332 dnl to documentation, unrecognized directives cause older compilers to barf.
333 AC_DEFUN([CF_GCC_ATTRIBUTES],
334 [
335 if test "$GCC" = yes
336 then
337 cat > conftest.i <<EOF
338 #ifndef GCC_PRINTF
339 #define GCC_PRINTF 0
340 #endif
341 #ifndef GCC_SCANF
342 #define GCC_SCANF 0
343 #endif
344 #ifndef GCC_NORETURN
345 #define GCC_NORETURN /* nothing */
346 #endif
347 #ifndef GCC_UNUSED
348 #define GCC_UNUSED /* nothing */
349 #endif
350 EOF
351 if test "$GCC" = yes
352 then
353         AC_CHECKING([for $CC __attribute__ directives])
354 cat > conftest.$ac_ext <<EOF
355 #line __oline__ "${as_me:-configure}"
356 #include "confdefs.h"
357 #include "conftest.h"
358 #include "conftest.i"
359 #if     GCC_PRINTF
360 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
361 #else
362 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
363 #endif
364 #if     GCC_SCANF
365 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
366 #else
367 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
368 #endif
369 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
370 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
371 extern void foo(void) GCC_NORETURN;
372 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
373 EOF
374         cf_printf_attribute=no
375         cf_scanf_attribute=no
376         for cf_attribute in scanf printf unused noreturn
377         do
378                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
379                 cf_directive="__attribute__(($cf_attribute))"
380                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
381
382                 case $cf_attribute in
383                 (printf)
384                         cf_printf_attribute=yes
385                         cat >conftest.h <<EOF
386 #define GCC_$cf_ATTRIBUTE 1
387 EOF
388                         ;;
389                 (scanf)
390                         cf_scanf_attribute=yes
391                         cat >conftest.h <<EOF
392 #define GCC_$cf_ATTRIBUTE 1
393 EOF
394                         ;;
395                 (*)
396                         cat >conftest.h <<EOF
397 #define GCC_$cf_ATTRIBUTE $cf_directive
398 EOF
399                         ;;
400                 esac
401
402                 if AC_TRY_EVAL(ac_compile); then
403                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
404                         cat conftest.h >>confdefs.h
405                         case $cf_attribute in
406                         (noreturn)
407                                 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
408                                 ;;
409                         (printf)
410                                 cf_value='/* nothing */'
411                                 if test "$cf_printf_attribute" != no ; then
412                                         cf_value='__attribute__((format(printf,fmt,var)))'
413                                         AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
414                                 fi
415                                 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
416                                 ;;
417                         (scanf)
418                                 cf_value='/* nothing */'
419                                 if test "$cf_scanf_attribute" != no ; then
420                                         cf_value='__attribute__((format(scanf,fmt,var)))'
421                                         AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
422                                 fi
423                                 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
424                                 ;;
425                         (unused)
426                                 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
427                                 ;;
428                         esac
429                 fi
430         done
431 else
432         fgrep define conftest.i >>confdefs.h
433 fi
434 rm -rf conftest*
435 fi
436 ])dnl
437 dnl ---------------------------------------------------------------------------
438 dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
439 dnl --------------
440 dnl Find version of gcc
441 AC_DEFUN([CF_GCC_VERSION],[
442 AC_REQUIRE([AC_PROG_CC])
443 GCC_VERSION=none
444 if test "$GCC" = yes ; then
445         AC_MSG_CHECKING(version of $CC)
446         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
447         test -z "$GCC_VERSION" && GCC_VERSION=unknown
448         AC_MSG_RESULT($GCC_VERSION)
449 fi
450 ])dnl
451 dnl ---------------------------------------------------------------------------
452 dnl CF_GCC_WARNINGS version: 32 updated: 2015/04/12 15:39:00
453 dnl ---------------
454 dnl Check if the compiler supports useful warning options.  There's a few that
455 dnl we don't use, simply because they're too noisy:
456 dnl
457 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
458 dnl     -Wredundant-decls (system headers make this too noisy)
459 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
460 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
461 dnl             is enabled for ncurses using "--enable-const".
462 dnl     -pedantic
463 dnl
464 dnl Parameter:
465 dnl     $1 is an optional list of gcc warning flags that a particular
466 dnl             application might want to use, e.g., "no-unused" for
467 dnl             -Wno-unused
468 dnl Special:
469 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
470 dnl
471 AC_DEFUN([CF_GCC_WARNINGS],
472 [
473 AC_REQUIRE([CF_GCC_VERSION])
474 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
475 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
476
477 cat > conftest.$ac_ext <<EOF
478 #line __oline__ "${as_me:-configure}"
479 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
480 EOF
481
482 if test "$INTEL_COMPILER" = yes
483 then
484 # The "-wdXXX" options suppress warnings:
485 # remark #1419: external declaration in primary source file
486 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
487 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
488 # remark #193: zero used for undefined preprocessing identifier
489 # remark #593: variable "curs_sb_left_arrow" was set but never used
490 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
491 # remark #869: parameter "tw" was never referenced
492 # remark #981: operands are evaluated in unspecified order
493 # warning #279: controlling expression is constant
494
495         AC_CHECKING([for $CC warning options])
496         cf_save_CFLAGS="$CFLAGS"
497         EXTRA_CFLAGS="-Wall"
498         for cf_opt in \
499                 wd1419 \
500                 wd1683 \
501                 wd1684 \
502                 wd193 \
503                 wd593 \
504                 wd279 \
505                 wd810 \
506                 wd869 \
507                 wd981
508         do
509                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
510                 if AC_TRY_EVAL(ac_compile); then
511                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
512                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
513                 fi
514         done
515         CFLAGS="$cf_save_CFLAGS"
516
517 elif test "$GCC" = yes
518 then
519         AC_CHECKING([for $CC warning options])
520         cf_save_CFLAGS="$CFLAGS"
521         EXTRA_CFLAGS=
522         cf_warn_CONST=""
523         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
524         cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
525         test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
526         for cf_opt in W Wall \
527                 Wbad-function-cast \
528                 Wcast-align \
529                 Wcast-qual \
530                 Wdeclaration-after-statement \
531                 Wextra \
532                 Winline \
533                 Wmissing-declarations \
534                 Wmissing-prototypes \
535                 Wnested-externs \
536                 Wpointer-arith \
537                 Wshadow \
538                 Wstrict-prototypes \
539                 Wundef $cf_gcc_warnings $cf_warn_CONST $1
540         do
541                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
542                 if AC_TRY_EVAL(ac_compile); then
543                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
544                         case $cf_opt in
545                         (Wcast-qual)
546                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
547                                 ;;
548                         (Winline)
549                                 case $GCC_VERSION in
550                                 ([[34]].*)
551                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
552                                         continue;;
553                                 esac
554                                 ;;
555                         (Wpointer-arith)
556                                 case $GCC_VERSION in
557                                 ([[12]].*)
558                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
559                                         continue;;
560                                 esac
561                                 ;;
562                         esac
563                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
564                 fi
565         done
566         CFLAGS="$cf_save_CFLAGS"
567 fi
568 rm -rf conftest*
569
570 AC_SUBST(EXTRA_CFLAGS)
571 ])dnl
572 dnl ---------------------------------------------------------------------------
573 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
574 dnl -------------
575 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
576 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
577 dnl (or misfeature) of glibc2, which breaks portability of many applications,
578 dnl since it is interwoven with GNU extensions.
579 dnl
580 dnl Well, yes we could work around it...
581 AC_DEFUN([CF_GNU_SOURCE],
582 [
583 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
584 AC_TRY_COMPILE([#include <sys/types.h>],[
585 #ifndef _XOPEN_SOURCE
586 make an error
587 #endif],
588         [cf_cv_gnu_source=no],
589         [cf_save="$CPPFLAGS"
590          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
591          AC_TRY_COMPILE([#include <sys/types.h>],[
592 #ifdef _XOPEN_SOURCE
593 make an error
594 #endif],
595         [cf_cv_gnu_source=no],
596         [cf_cv_gnu_source=yes])
597         CPPFLAGS="$cf_save"
598         ])
599 ])
600 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
601 ])dnl
602 dnl ---------------------------------------------------------------------------
603 dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
604 dnl -----------------
605 dnl Check if the given compiler is really the Intel compiler for Linux.  It
606 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
607 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
608 dnl
609 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
610 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
611 dnl the wrappers for gcc and g++ warnings.
612 dnl
613 dnl $1 = GCC (default) or GXX
614 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
615 dnl $3 = CFLAGS (default) or CXXFLAGS
616 AC_DEFUN([CF_INTEL_COMPILER],[
617 AC_REQUIRE([AC_CANONICAL_HOST])
618 ifelse([$2],,INTEL_COMPILER,[$2])=no
619
620 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
621         case $host_os in
622         (linux*|gnu*)
623                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
624                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
625                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
626                 AC_TRY_COMPILE([],[
627 #ifdef __INTEL_COMPILER
628 #else
629 make an error
630 #endif
631 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
632 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
633 ],[])
634                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
635                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
636                 ;;
637         esac
638 fi
639 ])dnl
640 dnl ---------------------------------------------------------------------------
641 dnl CF_MAKE_DOCS version: 4 updated: 2015/07/04 21:43:03
642 dnl ------------
643 dnl $1 = name(s) to generate rules for
644 dnl $2 = suffix of corresponding manpages used as input.
645 dnl
646 dnl This works best if called at the end of configure.in, following CF_WITH_MAN2HTML
647 define([CF_MAKE_DOCS],[
648 test -z "$cf_make_docs" && cf_make_docs=0
649
650 cf_output=makefile
651 test -f "$cf_output" || cf_output=Makefile
652
653 if test "$cf_make_docs" = 0
654 then
655 cat >>$cf_output <<CF_EOF
656 ################################################################################
657 ## generated by $0
658 .SUFFIXES : .html .$2 .man .ps .pdf .txt
659
660 ${NROFF_NOTE}.$2.txt :
661 ${NROFF_NOTE}   [\$](SHELL) -c "tbl [\$]*.$2 | nroff -man | col -bx" >[\$]@
662
663 ${GROFF_NOTE}.ps.pdf :
664 ${GROFF_NOTE}   ps2pdf [\$]*.ps
665 ${GROFF_NOTE}
666 ${GROFF_NOTE}.$2.ps :
667 ${GROFF_NOTE}   [\$](SHELL) -c "tbl [\$]*.$2 | groff -man" >[\$]@
668 ${GROFF_NOTE}
669 ${GROFF_NOTE}.$2.txt :
670 ${GROFF_NOTE}   GROFF_NO_SGR=stupid [\$](SHELL) -c "tbl [\$]*.$2 | nroff -Tascii -man | col -bx" >[\$]@
671
672 ${MAN2HTML_NOTE}.$2.html :
673 ${MAN2HTML_NOTE}        ./${MAN2HTML_TEMP} [\$]* $2 man >[\$]@
674
675 CF_EOF
676         cf_make_docs=1
677 fi
678
679 for cf_name in $1
680 do
681 cat >>$cf_output <<CF_EOF
682 ################################################################################
683 ${NROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
684 ${MAN2HTML_NOTE}docs docs-$cf_name :: $cf_name.html
685 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.pdf
686 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.ps
687 ${GROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
688
689 clean \\
690 docs-clean ::
691 ${NROFF_NOTE}   rm -f $cf_name.txt
692 ${MAN2HTML_NOTE}        rm -f $cf_name.html
693 ${GROFF_NOTE}   rm -f $cf_name.pdf
694 ${GROFF_NOTE}   rm -f $cf_name.ps
695 ${GROFF_NOTE}   rm -f $cf_name.txt
696
697 ${NROFF_NOTE}$cf_name.txt  : $cf_name.$2
698 ${MAN2HTML_NOTE}$cf_name.html : $cf_name.$2
699 ${GROFF_NOTE}$cf_name.pdf  : $cf_name.ps
700 ${GROFF_NOTE}$cf_name.ps   : $cf_name.$2
701 ${GROFF_NOTE}$cf_name.txt  : $cf_name.$2
702 CF_EOF
703 done
704 ])dnl
705 dnl ---------------------------------------------------------------------------
706 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
707 dnl ------------
708 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
709 dnl a monocase filesystem.
710 AC_DEFUN([CF_MAKE_TAGS],[
711 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
712
713 AC_CHECK_PROGS(CTAGS, exctags ctags)
714 AC_CHECK_PROGS(ETAGS, exetags etags)
715
716 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
717
718 if test "$cf_cv_mixedcase" = yes ; then
719         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
720 else
721         MAKE_UPPER_TAGS=no
722 fi
723
724 if test "$MAKE_UPPER_TAGS" = yes ; then
725         MAKE_UPPER_TAGS=
726 else
727         MAKE_UPPER_TAGS="#"
728 fi
729
730 if test "$MAKE_LOWER_TAGS" = yes ; then
731         MAKE_LOWER_TAGS=
732 else
733         MAKE_LOWER_TAGS="#"
734 fi
735
736 AC_SUBST(CTAGS)
737 AC_SUBST(ETAGS)
738
739 AC_SUBST(MAKE_UPPER_TAGS)
740 AC_SUBST(MAKE_LOWER_TAGS)
741 ])dnl
742 dnl ---------------------------------------------------------------------------
743 dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
744 dnl ----------------------
745 dnl Check if the file-system supports mixed-case filenames.  If we're able to
746 dnl create a lowercase name and see it as uppercase, it doesn't support that.
747 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
748 [
749 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
750 if test "$cross_compiling" = yes ; then
751         case $target_alias in
752         (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
753                 cf_cv_mixedcase=no
754                 ;;
755         (*)
756                 cf_cv_mixedcase=yes
757                 ;;
758         esac
759 else
760         rm -f conftest CONFTEST
761         echo test >conftest
762         if test -f CONFTEST ; then
763                 cf_cv_mixedcase=no
764         else
765                 cf_cv_mixedcase=yes
766         fi
767         rm -f conftest CONFTEST
768 fi
769 ])
770 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
771 ])dnl
772 dnl ---------------------------------------------------------------------------
773 dnl CF_MKSTEMP version: 9 updated: 2012/10/03 04:34:49
774 dnl ----------
775 dnl Check for a working mkstemp.  This creates two files, checks that they are
776 dnl successfully created and distinct (AmigaOS apparently fails on the last).
777 AC_DEFUN([CF_MKSTEMP],[
778 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
779 rm -rf conftest*
780 AC_TRY_RUN([
781 #include <sys/types.h>
782 #include <stdlib.h>
783 #include <stdio.h>
784 #include <string.h>
785 #include <sys/stat.h>
786 int main()
787 {
788         char *tmpl = "conftestXXXXXX";
789         char name[2][80];
790         int n;
791         int result = 0;
792         int fd;
793         struct stat sb;
794
795         umask(077);
796         for (n = 0; n < 2; ++n) {
797                 strcpy(name[n], tmpl);
798                 if ((fd = mkstemp(name[n])) >= 0) {
799                         if (!strcmp(name[n], tmpl)
800                          || stat(name[n], &sb) != 0
801                          || (sb.st_mode & S_IFMT) != S_IFREG
802                          || (sb.st_mode & 077) != 0) {
803                                 result = 1;
804                         }
805                         close(fd);
806                 }
807         }
808         if (result == 0
809          && !strcmp(name[0], name[1]))
810                 result = 1;
811         ${cf_cv_main_return:-return}(result);
812 }
813 ],[cf_cv_func_mkstemp=yes
814 ],[cf_cv_func_mkstemp=no
815 ],[cf_cv_func_mkstemp=maybe])
816 ])
817 if test "x$cf_cv_func_mkstemp" = xmaybe ; then
818         AC_CHECK_FUNC(mkstemp)
819 fi
820 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
821         AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
822 fi
823 ])dnl
824 dnl ---------------------------------------------------------------------------
825 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
826 dnl ----------
827 dnl Write a debug message to config.log, along with the line number in the
828 dnl configure script.
829 AC_DEFUN([CF_MSG_LOG],[
830 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
831 ])dnl
832 dnl ---------------------------------------------------------------------------
833 dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
834 dnl ------------------
835 dnl see CF_WITH_NO_LEAKS
836 AC_DEFUN([CF_NO_LEAKS_OPTION],[
837 AC_MSG_CHECKING(if you want to use $1 for testing)
838 AC_ARG_WITH($1,
839         [$2],
840         [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
841          $4
842 ])
843         : ${with_cflags:=-g}
844         : ${with_no_leaks:=yes}
845          with_$1=yes],
846         [with_$1=])
847 AC_MSG_RESULT(${with_$1:-no})
848
849 case .$with_cflags in
850 (.*-g*)
851         case .$CFLAGS in
852         (.*-g*)
853                 ;;
854         (*)
855                 CF_ADD_CFLAGS([-g])
856                 ;;
857         esac
858         ;;
859 esac
860 ])dnl
861 dnl ---------------------------------------------------------------------------
862 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
863 dnl --------------
864 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
865 dnl begins with one of the prefix/exec_prefix variables, and then again if the
866 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
867 dnl delayed evaluation of those symbols.
868 AC_DEFUN([CF_PATH_SYNTAX],[
869 if test "x$prefix" != xNONE; then
870         cf_path_syntax="$prefix"
871 else
872         cf_path_syntax="$ac_default_prefix"
873 fi
874
875 case ".[$]$1" in
876 (.\[$]\(*\)*|.\'*\'*)
877         ;;
878 (..|./*|.\\*)
879         ;;
880 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
881         ;;
882 (.\[$]{*prefix}*|.\[$]{*dir}*)
883         eval $1="[$]$1"
884         case ".[$]$1" in
885         (.NONE/*)
886                 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
887                 ;;
888         esac
889         ;;
890 (.no|.NONE/*)
891         $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
892         ;;
893 (*)
894         ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
895         ;;
896 esac
897 ])dnl
898 dnl ---------------------------------------------------------------------------
899 dnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
900 dnl -----------------
901 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
902 dnl
903 dnl     POSIX.1-1990                            _POSIX_SOURCE
904 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
905 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
906 dnl             Bindings Option
907 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
908 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
909 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
910 dnl
911 dnl Parameters:
912 dnl     $1 is the nominal value for _POSIX_C_SOURCE
913 AC_DEFUN([CF_POSIX_C_SOURCE],
914 [
915 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
916
917 cf_save_CFLAGS="$CFLAGS"
918 cf_save_CPPFLAGS="$CPPFLAGS"
919
920 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
921 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
922
923 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
924         CF_MSG_LOG(if the symbol is already defined go no further)
925         AC_TRY_COMPILE([#include <sys/types.h>],[
926 #ifndef _POSIX_C_SOURCE
927 make an error
928 #endif],
929         [cf_cv_posix_c_source=no],
930         [cf_want_posix_source=no
931          case .$cf_POSIX_C_SOURCE in
932          (.[[12]]??*)
933                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
934                 ;;
935          (.2)
936                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
937                 cf_want_posix_source=yes
938                 ;;
939          (.*)
940                 cf_want_posix_source=yes
941                 ;;
942          esac
943          if test "$cf_want_posix_source" = yes ; then
944                 AC_TRY_COMPILE([#include <sys/types.h>],[
945 #ifdef _POSIX_SOURCE
946 make an error
947 #endif],[],
948                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
949          fi
950          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
951          CFLAGS="$cf_trim_CFLAGS"
952          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
953          CF_MSG_LOG(if the second compile does not leave our definition intact error)
954          AC_TRY_COMPILE([#include <sys/types.h>],[
955 #ifndef _POSIX_C_SOURCE
956 make an error
957 #endif],,
958          [cf_cv_posix_c_source=no])
959          CFLAGS="$cf_save_CFLAGS"
960          CPPFLAGS="$cf_save_CPPFLAGS"
961         ])
962 ])
963
964 if test "$cf_cv_posix_c_source" != no ; then
965         CFLAGS="$cf_trim_CFLAGS"
966         CPPFLAGS="$cf_trim_CPPFLAGS"
967         CF_ADD_CFLAGS($cf_cv_posix_c_source)
968 fi
969
970 ])dnl
971 dnl ---------------------------------------------------------------------------
972 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
973 dnl -----------
974 dnl Check for awk, ensure that the check found something.
975 AC_DEFUN([CF_PROG_AWK],
976 [
977 AC_PROG_AWK
978 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
979 ])dnl
980 dnl ---------------------------------------------------------------------------
981 dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
982 dnl ----------
983 dnl standard check for CC, plus followup sanity checks
984 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
985 AC_DEFUN([CF_PROG_CC],[
986 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
987 CF_GCC_VERSION
988 CF_ACVERSION_CHECK(2.52,
989         [AC_PROG_CC_STDC],
990         [CF_ANSI_CC_REQD])
991 CF_CC_ENV_FLAGS
992 ])dnl
993 dnl ---------------------------------------------------------------------------
994 dnl CF_PROG_GROFF version: 2 updated: 2015/07/04 11:16:27
995 dnl -------------
996 dnl Check if groff is available, for cases (such as html output) where nroff
997 dnl is not enough.
998 AC_DEFUN([CF_PROG_GROFF],[
999 AC_PATH_PROG(GROFF_PATH,groff,no)
1000 AC_PATH_PROG(NROFF_PATH,nroff,no)
1001 if test "x$GROFF_PATH" = xno
1002 then
1003         NROFF_NOTE=
1004         GROFF_NOTE="#"
1005 else
1006         NROFF_NOTE="#"
1007         GROFF_NOTE=
1008 fi
1009 AC_SUBST(GROFF_NOTE)
1010 AC_SUBST(NROFF_NOTE)
1011 ])dnl
1012 dnl ---------------------------------------------------------------------------
1013 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
1014 dnl ------------
1015 AC_DEFUN([CF_PROG_LINT],
1016 [
1017 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
1018 AC_SUBST(LINT_OPTS)
1019 ])dnl
1020 dnl ---------------------------------------------------------------------------
1021 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1022 dnl ----------------
1023 dnl Remove all -U and -D options that refer to the given symbol from a list
1024 dnl of C compiler options.  This works around the problem that not all
1025 dnl compilers process -U and -D options from left-to-right, so a -U option
1026 dnl cannot be used to cancel the effect of a preceding -D option.
1027 dnl
1028 dnl $1 = target (which could be the same as the source variable)
1029 dnl $2 = source (including '$')
1030 dnl $3 = symbol to remove
1031 define([CF_REMOVE_DEFINE],
1032 [
1033 $1=`echo "$2" | \
1034         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
1035                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
1036 ])dnl
1037 dnl ---------------------------------------------------------------------------
1038 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
1039 dnl -------------------
1040 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1041 dnl can define it successfully.
1042 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1043 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1044         AC_TRY_COMPILE([
1045 #include <stdlib.h>
1046 #include <string.h>
1047 #include <sys/types.h>
1048 ],[
1049 #ifndef _XOPEN_SOURCE
1050 make an error
1051 #endif],
1052         [cf_cv_xopen_source=no],
1053         [cf_save="$CPPFLAGS"
1054          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1055          AC_TRY_COMPILE([
1056 #include <stdlib.h>
1057 #include <string.h>
1058 #include <sys/types.h>
1059 ],[
1060 #ifdef _XOPEN_SOURCE
1061 make an error
1062 #endif],
1063         [cf_cv_xopen_source=no],
1064         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1065         CPPFLAGS="$cf_save"
1066         ])
1067 ])
1068
1069 if test "$cf_cv_xopen_source" != no ; then
1070         CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1071         CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1072         cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1073         CF_ADD_CFLAGS($cf_temp_xopen_source)
1074 fi
1075 ])
1076 dnl ---------------------------------------------------------------------------
1077 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1078 dnl --------
1079 dnl Make an uppercase version of a variable
1080 dnl $1=uppercase($2)
1081 AC_DEFUN([CF_UPPER],
1082 [
1083 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1084 ])dnl
1085 dnl ---------------------------------------------------------------------------
1086 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1087 dnl ----------
1088 dnl Use AC_VERBOSE w/o the warnings
1089 AC_DEFUN([CF_VERBOSE],
1090 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
1091 CF_MSG_LOG([$1])
1092 ])dnl
1093 dnl ---------------------------------------------------------------------------
1094 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1095 dnl ----------------
1096 dnl Configure-option for dbmalloc.  The optional parameter is used to override
1097 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1098 AC_DEFUN([CF_WITH_DBMALLOC],[
1099 CF_NO_LEAKS_OPTION(dbmalloc,
1100         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
1101         [USE_DBMALLOC])
1102
1103 if test "$with_dbmalloc" = yes ; then
1104         AC_CHECK_HEADER(dbmalloc.h,
1105                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1106 fi
1107 ])dnl
1108 dnl ---------------------------------------------------------------------------
1109 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1110 dnl ---------------
1111 dnl Configure-option for dmalloc.  The optional parameter is used to override
1112 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1113 AC_DEFUN([CF_WITH_DMALLOC],[
1114 CF_NO_LEAKS_OPTION(dmalloc,
1115         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
1116         [USE_DMALLOC])
1117
1118 if test "$with_dmalloc" = yes ; then
1119         AC_CHECK_HEADER(dmalloc.h,
1120                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1121 fi
1122 ])dnl
1123 dnl ---------------------------------------------------------------------------
1124 dnl CF_WITH_MAN2HTML version: 5 updated: 2015/08/20 04:51:36
1125 dnl ----------------
1126 dnl Check for man2html and groff.  Optionally prefer man2html over groff.
1127 dnl Generate a shell script which hides the differences between the two.
1128 dnl
1129 dnl We name that "man2html.tmp".
1130 dnl
1131 dnl The shell script can be removed later, e.g., using "make distclean".
1132 AC_DEFUN([CF_WITH_MAN2HTML],[
1133 AC_REQUIRE([CF_PROG_GROFF])
1134
1135 AC_MSG_CHECKING(for program to convert manpage to html)
1136 AC_ARG_WITH(man2html,
1137         [  --with-man2html=XXX     use XXX rather than groff],
1138         [cf_man2html=$withval],
1139         [cf_man2html=$GROFF_PATH])
1140
1141 cf_with_groff=no
1142
1143 case $cf_man2html in
1144 (yes)
1145         AC_MSG_RESULT(man2html)
1146         AC_PATH_PROG(cf_man2html,man2html,no)
1147         ;;
1148 (no|groff|*/groff*)
1149         cf_with_groff=yes
1150         cf_man2html=$GROFF_PATH
1151         AC_MSG_RESULT($cf_man2html)
1152         ;;
1153 (*)
1154         AC_MSG_RESULT($cf_man2html)
1155         ;;
1156 esac
1157
1158 MAN2HTML_TEMP="man2html.tmp"
1159         cat >$MAN2HTML_TEMP <<CF_EOF
1160 #!$SHELL
1161 # Temporary script generated by CF_WITH_MAN2HTML
1162 # Convert inputs to html, sending result to standard output.
1163 #
1164 # Parameters:
1165 # \${1} = rootname of file to convert
1166 # \${2} = suffix of file to convert, e.g., "1"
1167 # \${3} = macros to use, e.g., "man"
1168 #
1169 ROOT=\[$]1
1170 TYPE=\[$]2
1171 MACS=\[$]3
1172
1173 unset LANG
1174 unset LC_ALL
1175 unset LC_CTYPE
1176 unset LANGUAGE
1177 GROFF_NO_SGR=stupid
1178 export GROFF_NO_SGR
1179
1180 CF_EOF
1181
1182 if test "x$cf_with_groff" = xyes
1183 then
1184         MAN2HTML_NOTE="$GROFF_NOTE"
1185         MAN2HTML_PATH="$GROFF_PATH"
1186         cat >>$MAN2HTML_TEMP <<CF_EOF
1187 $SHELL -c "tbl \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
1188 CF_EOF
1189 else
1190         MAN2HTML_NOTE=""
1191         CF_PATH_SYNTAX(cf_man2html)
1192         MAN2HTML_PATH="$cf_man2html"
1193         AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
1194
1195         # for this example, expect 3 lines of content, the remainder is head/foot
1196         cat >conftest.in <<CF_EOF
1197 .TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
1198 .SH SECTION
1199 MARKER
1200 CF_EOF
1201
1202         LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out
1203
1204         cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1205         cf_man2html_top=`expr $cf_man2html_1st - 2`
1206         cf_man2html_bot=`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`
1207         cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
1208         cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
1209
1210         AC_MSG_RESULT($cf_man2html_top_bot)
1211
1212         AC_MSG_CHECKING(for pagesize to use)
1213         for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1214         do
1215         cat >>conftest.in <<CF_EOF
1216 .nf
1217 0
1218 1
1219 2
1220 3
1221 4
1222 5
1223 6
1224 7
1225 8
1226 9
1227 CF_EOF
1228         done
1229
1230         LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C nroff -man conftest.in >conftest.out
1231         cf_man2html_page=`fgrep -n HEAD1 conftest.out |tail -n 1 |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1232         test -z "$cf_man2html_page" && cf_man2html_page=99999
1233         test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
1234
1235         rm -rf conftest*
1236         AC_MSG_RESULT($cf_man2html_page)
1237
1238         cat >>$MAN2HTML_TEMP <<CF_EOF
1239 : \${MAN2HTML_PATH=$MAN2HTML_PATH}
1240 MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page"
1241 case \${TYPE} in
1242 (ms)
1243         tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
1244         ;;
1245 (*)
1246         tbl \${ROOT}.\${TYPE} | nroff -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
1247         ;;
1248 esac
1249 CF_EOF
1250 fi
1251
1252 chmod 700 $MAN2HTML_TEMP
1253
1254 AC_SUBST(MAN2HTML_NOTE)
1255 AC_SUBST(MAN2HTML_PATH)
1256 AC_SUBST(MAN2HTML_TEMP)
1257 ])dnl
1258 dnl ---------------------------------------------------------------------------
1259 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
1260 dnl ----------------
1261 AC_DEFUN([CF_WITH_VALGRIND],[
1262 CF_NO_LEAKS_OPTION(valgrind,
1263         [  --with-valgrind         test: use valgrind],
1264         [USE_VALGRIND])
1265 ])dnl
1266 dnl ---------------------------------------------------------------------------
1267 dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
1268 dnl ----------------
1269 dnl Combine the checks for gcc features into a configure-script option
1270 dnl
1271 dnl Parameters:
1272 dnl     $1 - see CF_GCC_WARNINGS
1273 AC_DEFUN([CF_WITH_WARNINGS],
1274 [
1275 if ( test "$GCC" = yes || test "$GXX" = yes )
1276 then
1277 AC_MSG_CHECKING(if you want to check for gcc warnings)
1278 AC_ARG_WITH(warnings,
1279         [  --with-warnings         test: turn on gcc warnings],
1280         [cf_opt_with_warnings=$withval],
1281         [cf_opt_with_warnings=no])
1282 AC_MSG_RESULT($cf_opt_with_warnings)
1283 if test "$cf_opt_with_warnings" != no ; then
1284         CF_GCC_ATTRIBUTES
1285         CF_GCC_WARNINGS([$1])
1286 fi
1287 fi
1288 ])dnl
1289 dnl ---------------------------------------------------------------------------
1290 dnl CF_XOPEN_SOURCE version: 50 updated: 2015/10/17 19:03:33
1291 dnl ---------------
1292 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1293 dnl or adapt to the vendor's definitions to get equivalent functionality,
1294 dnl without losing the common non-POSIX features.
1295 dnl
1296 dnl Parameters:
1297 dnl     $1 is the nominal value for _XOPEN_SOURCE
1298 dnl     $2 is the nominal value for _POSIX_C_SOURCE
1299 AC_DEFUN([CF_XOPEN_SOURCE],[
1300 AC_REQUIRE([AC_CANONICAL_HOST])
1301
1302 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1303 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1304 cf_xopen_source=
1305
1306 case $host_os in
1307 (aix[[4-7]]*)
1308         cf_xopen_source="-D_ALL_SOURCE"
1309         ;;
1310 (cygwin|msys)
1311         cf_XOPEN_SOURCE=600
1312         ;;
1313 (darwin[[0-8]].*)
1314         cf_xopen_source="-D_APPLE_C_SOURCE"
1315         ;;
1316 (darwin*)
1317         cf_xopen_source="-D_DARWIN_C_SOURCE"
1318         cf_XOPEN_SOURCE=
1319         ;;
1320 (freebsd*|dragonfly*)
1321         # 5.x headers associate
1322         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1323         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1324         cf_POSIX_C_SOURCE=200112L
1325         cf_XOPEN_SOURCE=600
1326         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1327         ;;
1328 (hpux11*)
1329         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1330         ;;
1331 (hpux*)
1332         cf_xopen_source="-D_HPUX_SOURCE"
1333         ;;
1334 (irix[[56]].*)
1335         cf_xopen_source="-D_SGI_SOURCE"
1336         cf_XOPEN_SOURCE=
1337         ;;
1338 (linux*|gnu*|mint*|k*bsd*-gnu)
1339         CF_GNU_SOURCE
1340         ;;
1341 (minix*)
1342         cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
1343         ;;
1344 (mirbsd*)
1345         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1346         cf_XOPEN_SOURCE=
1347         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1348         ;;
1349 (netbsd*)
1350         cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1351         ;;
1352 (openbsd[[4-9]]*)
1353         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1354         cf_xopen_source="-D_BSD_SOURCE"
1355         cf_XOPEN_SOURCE=600
1356         ;;
1357 (openbsd*)
1358         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1359         ;;
1360 (os2*)
1361         cf_XOPEN_SOURCE=
1362         ;;
1363 (osf[[45]]*)
1364         cf_xopen_source="-D_OSF_SOURCE"
1365         ;;
1366 (nto-qnx*)
1367         cf_xopen_source="-D_QNX_SOURCE"
1368         ;;
1369 (sco*)
1370         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1371         ;;
1372 (solaris2.*)
1373         cf_xopen_source="-D__EXTENSIONS__"
1374         cf_cv_xopen_source=broken
1375         ;;
1376 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
1377         cf_XOPEN_SOURCE=
1378         cf_POSIX_C_SOURCE=
1379         ;;
1380 (*)
1381         CF_TRY_XOPEN_SOURCE
1382         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1383         ;;
1384 esac
1385
1386 if test -n "$cf_xopen_source" ; then
1387         CF_ADD_CFLAGS($cf_xopen_source,true)
1388 fi
1389
1390 dnl In anything but the default case, we may have system-specific setting
1391 dnl which is still not guaranteed to provide all of the entrypoints that
1392 dnl _XOPEN_SOURCE would yield.
1393 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
1394         AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
1395         AC_TRY_COMPILE([#include <stdlib.h>],[
1396 #ifndef _XOPEN_SOURCE
1397 make an error
1398 #endif],
1399         [cf_XOPEN_SOURCE_set=yes],
1400         [cf_XOPEN_SOURCE_set=no])
1401         AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
1402         if test $cf_XOPEN_SOURCE_set = yes
1403         then
1404                 AC_TRY_COMPILE([#include <stdlib.h>],[
1405 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1406 make an error
1407 #endif],
1408                 [cf_XOPEN_SOURCE_set_ok=yes],
1409                 [cf_XOPEN_SOURCE_set_ok=no])
1410                 if test $cf_XOPEN_SOURCE_set_ok = no
1411                 then
1412                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
1413                 fi
1414         else
1415                 CF_TRY_XOPEN_SOURCE
1416         fi
1417 fi
1418 ])