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