ncurses 5.0
[ncurses.git] / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 1998,1999 Free Software Foundation, Inc.                   *
3 dnl                                                                          *
4 dnl Permission is hereby granted, free of charge, to any person obtaining a  *
5 dnl copy of this software and associated documentation files (the            *
6 dnl "Software"), to deal in the Software without restriction, including      *
7 dnl without limitation the rights to use, copy, modify, merge, publish,      *
8 dnl distribute, distribute with modifications, sublicense, and/or sell       *
9 dnl copies of the Software, and to permit persons to whom the Software is    *
10 dnl furnished to do so, subject to the following conditions:                 *
11 dnl                                                                          *
12 dnl The above copyright notice and this permission notice shall be included  *
13 dnl in all copies or substantial portions of the Software.                   *
14 dnl                                                                          *
15 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 dnl                                                                          *
23 dnl Except as contained in this notice, the name(s) of the above copyright   *
24 dnl holders shall not be used in advertising or otherwise to promote the     *
25 dnl sale, use or other dealings in this Software without prior written       *
26 dnl authorization.                                                           *
27 dnl***************************************************************************
28 dnl
29 dnl Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,1998
30 dnl
31 dnl $Id: aclocal.m4,v 1.179 1999/10/23 21:49:25 tom Exp $
32 dnl Macros used in NCURSES auto-configuration script.
33 dnl
34 dnl ---------------------------------------------------------------------------
35 dnl ---------------------------------------------------------------------------
36 dnl Construct the list of include-options for the C programs in the Ada95
37 dnl binding.
38 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
39 [
40 ACPPFLAGS="$ACPPFLAGS -I. -I../../include"
41 if test "$srcdir" != "."; then
42         ACPPFLAGS="$ACPPFLAGS -I\$(srcdir)/../../include"
43 fi
44 if test -z "$GCC"; then
45         ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
46 elif test "$includedir" != "/usr/include"; then
47         if test "$includedir" = '${prefix}/include' ; then
48                 if test $prefix != /usr ; then
49                         ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
50                 fi
51         else
52                 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
53         fi
54 fi
55 AC_SUBST(ACPPFLAGS)
56 ])dnl
57 dnl ---------------------------------------------------------------------------
58 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
59 dnl in the sharutils 4.2 distribution.
60 AC_DEFUN([CF_ANSI_CC_CHECK],
61 [
62 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
63 AC_CACHE_VAL(cf_cv_ansi_cc,[
64 cf_cv_ansi_cc=no
65 cf_save_CFLAGS="$CFLAGS"
66 # Don't try gcc -ansi; that turns off useful extensions and
67 # breaks some systems' header files.
68 # AIX                   -qlanglvl=ansi
69 # Ultrix and OSF/1      -std1
70 # HP-UX                 -Aa -D_HPUX_SOURCE
71 # SVR4                  -Xc
72 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
73 for cf_arg in "-DCC_HAS_PROTOS" \
74         "" \
75         -qlanglvl=ansi \
76         -std1 \
77         "-Aa -D_HPUX_SOURCE +e" \
78         "-Aa -D_HPUX_SOURCE" \
79         -Xc
80 do
81         CFLAGS="$cf_save_CFLAGS $cf_arg"
82         AC_TRY_COMPILE(
83 [
84 #ifndef CC_HAS_PROTOS
85 #if !defined(__STDC__) || (__STDC__ != 1)
86 choke me
87 #endif
88 #endif
89 ],[
90         int test (int i, double x);
91         struct s1 {int (*f) (int a);};
92         struct s2 {int (*f) (double a);};],
93         [cf_cv_ansi_cc="$cf_arg"; break])
94 done
95 CFLAGS="$cf_save_CFLAGS"
96 ])
97 AC_MSG_RESULT($cf_cv_ansi_cc)
98
99 if test "$cf_cv_ansi_cc" != "no"; then
100 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
101         CFLAGS="$CFLAGS $cf_cv_ansi_cc"
102 else
103         AC_DEFINE(CC_HAS_PROTOS)
104 fi
105 fi
106 ])dnl
107 dnl ---------------------------------------------------------------------------
108 dnl For programs that must use an ANSI compiler, obtain compiler options that
109 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
110 dnl macros, since tools such as unproto can fake prototypes, but only part of
111 dnl the preprocessor.
112 AC_DEFUN([CF_ANSI_CC_REQD],
113 [AC_REQUIRE([CF_ANSI_CC_CHECK])
114 if test "$cf_cv_ansi_cc" = "no"; then
115         AC_ERROR(
116 [Your compiler does not appear to recognize prototypes.
117 You have the following choices:
118         a. adjust your compiler options
119         b. get an up-to-date compiler
120         c. use a wrapper such as unproto])
121 fi
122 ])dnl
123 dnl ---------------------------------------------------------------------------
124 dnl Test if 'bool' is a builtin type in the configured C++ compiler.  Some
125 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
126 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
127 dnl
128 dnl Treat the configuration-variable specially here, since we're directly
129 dnl substituting its value (i.e., 1/0).
130 AC_DEFUN([CF_BOOL_DECL],
131 [
132 AC_MSG_CHECKING([for builtin ifelse(AC_LANG,[C],$CC,$CXX) bool type])
133 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
134         AC_TRY_COMPILE([
135 #include <stdio.h>
136 #include <sys/types.h>
137 ],[bool x = false],
138                 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
139                 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
140         ])
141 if test $ifelse($1,,cf_cv_builtin_bool,[$1]) = 1
142 then    AC_MSG_RESULT(yes)
143 else    AC_MSG_RESULT(no)
144 fi
145 ])dnl
146 dnl ---------------------------------------------------------------------------
147 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
148 dnl Don't bother looking for bool.h, since it's been deprecated.
149 AC_DEFUN([CF_BOOL_SIZE],
150 [
151 AC_MSG_CHECKING([for size of ifelse(AC_LANG,[C],$CC,$CXX) bool])
152 AC_CACHE_VAL(cf_cv_type_of_bool,[
153         rm -f cf_test.out
154         AC_TRY_RUN([
155 #include <stdlib.h>
156 #include <stdio.h>
157 #if HAVE_GXX_BUILTIN_H
158 #include <g++/builtin.h>
159 #elif HAVE_GPP_BUILTIN_H
160 #include <gpp/builtin.h>
161 #elif HAVE_BUILTIN_H
162 #include <builtin.h>
163 #endif
164 main()
165 {
166         FILE *fp = fopen("cf_test.out", "w");
167         if (fp != 0) {
168                 bool x = true;
169                 if ((bool)(-x) >= 0)
170                         fputs("unsigned ", fp);
171                 if (sizeof(x) == sizeof(int))       fputs("int",  fp);
172                 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
173                 else if (sizeof(x) == sizeof(short))fputs("short",fp);
174                 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
175                 fclose(fp);
176         }
177         exit(0);
178 }
179                 ],
180                 [cf_cv_type_of_bool=`cat cf_test.out`],
181                 [cf_cv_type_of_bool=unknown],
182                 [cf_cv_type_of_bool=unknown])
183         ])
184         rm -f cf_test.out
185 AC_MSG_RESULT($cf_cv_type_of_bool)
186 if test "$cf_cv_type_of_bool" = unknown ; then
187         AC_MSG_WARN(Assuming unsigned for type of bool)
188         cf_cv_type_of_bool=unsigned
189 fi
190 ])dnl
191 dnl ---------------------------------------------------------------------------
192 dnl Determine the default configuration into which we'll install ncurses.  This
193 dnl can be overridden by the user's command-line options.  There's two items to
194 dnl look for:
195 dnl     1. the prefix (e.g., /usr)
196 dnl     2. the header files (e.g., /usr/include/ncurses)
197 dnl We'll look for a previous installation of ncurses and use the same defaults.
198 dnl
199 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
200 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
201 dnl programs from a vendor's.
202 AC_DEFUN([CF_CFG_DEFAULTS],
203 [
204 AC_MSG_CHECKING(for prefix)
205 if test "x$prefix" = "xNONE" ; then
206         case "$cf_cv_system_name" in
207                 # non-vendor systems don't have a conflict
208         openbsd*|netbsd*|freebsd*|linux*)
209                 prefix=/usr
210                 ;;
211         *)      prefix=$ac_default_prefix
212                 ;;
213         esac
214 fi
215 AC_MSG_RESULT($prefix)
216
217 if test "x$prefix" = "xNONE" ; then
218 AC_MSG_CHECKING(for default include-directory)
219 test -n "$verbose" && echo 1>&AC_FD_MSG
220 for cf_symbol in \
221         $includedir \
222         $includedir/ncurses \
223         $prefix/include \
224         $prefix/include/ncurses \
225         /usr/local/include \
226         /usr/local/include/ncurses \
227         /usr/include \
228         /usr/include/ncurses
229 do
230         cf_dir=`eval echo $cf_symbol`
231         if test -f $cf_dir/curses.h ; then
232         if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
233                 includedir="$cf_symbol"
234                 test -n "$verbose"  && echo $ac_n "     found " 1>&AC_FD_MSG
235                 break
236         fi
237         fi
238         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AC_FD_MSG
239 done
240 AC_MSG_RESULT($includedir)
241 fi
242 ])dnl
243 dnl ---------------------------------------------------------------------------
244 dnl Check if the terminal-capability database functions are available.  If not,
245 dnl ncurses has a much-reduced version.
246 AC_DEFUN([CF_CGETENT],[
247 AC_MSG_CHECKING(for terminal-capability database functions)
248 AC_CACHE_VAL(cf_cv_cgetent,[
249 AC_TRY_LINK([
250 #include <stdlib.h>],[
251         char temp[128];
252         char *buf = temp;
253         char *db_array = temp;
254         cgetent(&buf, /* int *, */ &db_array, "vt100");
255         cgetcap(buf, "tc", '=');
256         cgetmatch(buf, "tc");
257         ],
258         [cf_cv_cgetent=yes],
259         [cf_cv_cgetent=no])
260 ])
261 AC_MSG_RESULT($cf_cv_cgetent)
262 test $cf_cv_cgetent = yes && AC_DEFINE(HAVE_BSD_CGETENT)
263 ])dnl
264 dnl ---------------------------------------------------------------------------
265 dnl Check if we're accidentally using a cache from a different machine.
266 dnl Derive the system name, as a check for reusing the autoconf cache.
267 dnl
268 dnl If we've packaged config.guess and config.sub, run that (since it does a
269 dnl better job than uname).
270 AC_DEFUN([CF_CHECK_CACHE],
271 [
272 if test -f $srcdir/config.guess ; then
273         AC_CANONICAL_HOST
274         system_name="$host_os"
275 else
276         system_name="`(uname -s -r) 2>/dev/null`"
277         if test -z "$system_name" ; then
278                 system_name="`(hostname) 2>/dev/null`"
279         fi
280 fi
281 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
282 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
283
284 test -z "$system_name" && system_name="$cf_cv_system_name"
285 test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name")
286
287 if test ".$system_name" != ".$cf_cv_system_name" ; then
288         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
289         AC_ERROR("Please remove config.cache and try again.")
290 fi
291 ])dnl
292 dnl ---------------------------------------------------------------------------
293 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
294 dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
295 dnl ourselves.
296 dnl
297 dnl (I would use AC_CACHE_CHECK here, but it will not work when called in a
298 dnl loop from CF_SYS_ERRLIST).
299 dnl
300 dnl $1 = the name to check
301 AC_DEFUN([CF_CHECK_ERRNO],
302 [
303 AC_MSG_CHECKING(if external $1 is declared)
304 AC_CACHE_VAL(cf_cv_dcl_$1,[
305     AC_TRY_COMPILE([
306 #if HAVE_STDLIB_H
307 #include <stdlib.h>
308 #endif
309 #include <stdio.h>
310 #include <sys/types.h>
311 #include <errno.h> ],
312     [long x = (long) $1],
313     [eval 'cf_cv_dcl_'$1'=yes'],
314     [eval 'cf_cv_dcl_'$1'=no]')
315 ])
316
317 eval 'cf_result=$cf_cv_dcl_'$1
318 AC_MSG_RESULT($cf_result)
319
320 if test "$cf_result" = no ; then
321     eval 'cf_result=DECL_'$1
322     CF_UPPER(cf_result,$cf_result)
323     AC_DEFINE_UNQUOTED($cf_result)
324 fi
325
326 # It's possible (for near-UNIX clones) that the data doesn't exist
327 CF_CHECK_EXTERN_DATA($1,int)
328 ])dnl
329 dnl ---------------------------------------------------------------------------
330 dnl Check for existence of external data in the current set of libraries.  If
331 dnl we can modify it, it's real enough.
332 dnl $1 = the name to check
333 dnl $2 = its type
334 AC_DEFUN([CF_CHECK_EXTERN_DATA],
335 [
336 AC_MSG_CHECKING(if external $1 exists)
337 AC_CACHE_VAL(cf_cv_have_$1,[
338     AC_TRY_LINK([
339 #undef $1
340 extern $2 $1;
341 ],
342     [$1 = 2],
343     [eval 'cf_cv_have_'$1'=yes'],
344     [eval 'cf_cv_have_'$1'=no'])])
345
346 eval 'cf_result=$cf_cv_have_'$1
347 AC_MSG_RESULT($cf_result)
348
349 if test "$cf_result" = yes ; then
350     eval 'cf_result=HAVE_'$1
351     CF_UPPER(cf_result,$cf_result)
352     AC_DEFINE_UNQUOTED($cf_result)
353 fi
354
355 ])dnl
356 dnl ---------------------------------------------------------------------------
357 dnl Check if the C++ compiler accepts duplicate parameter initialization.  This
358 dnl is a late feature for the standard and is not in some recent compilers
359 dnl (1999/9/11).
360 AC_DEFUN([CF_CPP_PARAM_INIT],
361 [
362 if test -n "$CXX" ; then
363 AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
364         AC_LANG_CPLUSPLUS
365         AC_TRY_RUN([
366 class TEST {
367 private:
368         int value;
369 public:
370         TEST(int x = 1);
371         ~TEST();
372 };
373
374 TEST::TEST(int x = 1)   // some compilers do not like second initializer
375 {
376         value = x;
377 }
378 void main() { }
379 ],
380         [cf_cv_cpp_param_init=yes],
381         [cf_cv_cpp_param_init=no],
382         [cf_cv_cpp_param_init=unknown])
383 ])
384 fi
385 test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT)
386 ])dnl
387 dnl ---------------------------------------------------------------------------
388 AC_DEFUN([CF_DIRS_TO_MAKE],
389 [
390 DIRS_TO_MAKE="lib"
391 for cf_item in $cf_list_models
392 do
393         CF_OBJ_SUBDIR($cf_item,cf_subdir)
394         DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
395 done
396 for cf_dir in $DIRS_TO_MAKE
397 do
398         test ! -d $cf_dir && mkdir $cf_dir
399 done
400 AC_SUBST(DIRS_TO_MAKE)
401 ])dnl
402 dnl ---------------------------------------------------------------------------
403 dnl Check if 'errno' is declared in <errno.h>
404 AC_DEFUN([CF_ERRNO],
405 [
406 CF_CHECK_ERRNO(errno)
407 ])dnl
408 dnl ---------------------------------------------------------------------------
409 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
410 dnl math.h and builtin.h, only for ncurses
411 AC_DEFUN([CF_ETIP_DEFINES],
412 [
413 AC_MSG_CHECKING(for special defines needed for etip.h)
414 cf_save_CXXFLAGS="$CXXFLAGS"
415 cf_result="none"
416 for cf_math in "" MATH_H
417 do
418 for cf_excp in "" MATH_EXCEPTION
419 do
420         CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu"
421         test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
422         test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
423 AC_TRY_COMPILE([
424 #include <etip.h.in>
425 ],[],[
426         test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
427         test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
428         cf_result="$cf_math $cf_excp"
429         break
430 ],[])
431 done
432 done
433 AC_MSG_RESULT($cf_result)
434 CXXFLAGS="$cf_save_CXXFLAGS"
435 ])
436 dnl ---------------------------------------------------------------------------
437 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
438 dnl is found, add our own version of memmove to the list of objects.
439 AC_DEFUN([CF_FUNC_MEMMOVE],
440 [
441 AC_CHECK_FUNC(memmove,,[
442 AC_CHECK_FUNC(bcopy,[
443         AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
444                 AC_TRY_RUN([
445 int main() {
446         static char data[] = "abcdefghijklmnopqrstuwwxyz";
447         char temp[40];
448         bcopy(data, temp, sizeof(data));
449         bcopy(temp+10, temp, 15);
450         bcopy(temp+5, temp+15, 10);
451         exit (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
452 }
453                 ],
454                 [cf_cv_good_bcopy=yes],
455                 [cf_cv_good_bcopy=no],
456                 [cf_cv_good_bcopy=unknown])
457                 ])
458         ],[cf_cv_good_bcopy=no])
459         if test $cf_cv_good_bcopy = yes ; then
460                 AC_DEFINE(USE_OK_BCOPY)
461         else
462                 AC_DEFINE(USE_MY_MEMMOVE)
463         fi
464 ])])dnl
465 dnl ---------------------------------------------------------------------------
466 dnl Test for availability of useful gcc __attribute__ directives to quiet
467 dnl compiler warnings.  Though useful, not all are supported -- and contrary
468 dnl to documentation, unrecognized directives cause older compilers to barf.
469 AC_DEFUN([CF_GCC_ATTRIBUTES],
470 [
471 if test -n "$GCC"
472 then
473 cat > conftest.i <<EOF
474 #ifndef GCC_PRINTF
475 #define GCC_PRINTF 0
476 #endif
477 #ifndef GCC_SCANF
478 #define GCC_SCANF 0
479 #endif
480 #ifndef GCC_NORETURN
481 #define GCC_NORETURN /* nothing */
482 #endif
483 #ifndef GCC_UNUSED
484 #define GCC_UNUSED /* nothing */
485 #endif
486 EOF
487 if test -n "$GCC"
488 then
489         AC_CHECKING([for $CC __attribute__ directives])
490         changequote(,)dnl
491 cat > conftest.$ac_ext <<EOF
492 #line __oline__ "configure"
493 #include "confdefs.h"
494 #include "conftest.h"
495 #include "conftest.i"
496 #if     GCC_PRINTF
497 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
498 #else
499 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
500 #endif
501 #if     GCC_SCANF
502 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
503 #else
504 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
505 #endif
506 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
507 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
508 extern void foo(void) GCC_NORETURN;
509 int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
510 EOF
511         changequote([,])dnl
512         for cf_attribute in scanf printf unused noreturn
513         do
514                 CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
515                 cf_directive="__attribute__(($cf_attribute))"
516                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
517                 case $cf_attribute in
518                 scanf|printf)
519                 cat >conftest.h <<EOF
520 #define GCC_$CF_ATTRIBUTE 1
521 EOF
522                         ;;
523                 *)
524                 cat >conftest.h <<EOF
525 #define GCC_$CF_ATTRIBUTE $cf_directive
526 EOF
527                         ;;
528                 esac
529                 if AC_TRY_EVAL(ac_compile); then
530                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
531                         cat conftest.h >>confdefs.h
532 #               else
533 #                       sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
534                 fi
535         done
536 else
537         fgrep define conftest.i >>confdefs.h
538 fi
539 rm -rf conftest*
540 fi
541 ])dnl
542 dnl ---------------------------------------------------------------------------
543 dnl Check if the compiler supports useful warning options.  There's a few that
544 dnl we don't use, simply because they're too noisy:
545 dnl
546 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
547 dnl     -Wredundant-decls (system headers make this too noisy)
548 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
549 dnl     -Wwrite-strings (too noisy, but should review occasionally)
550 dnl     -pedantic
551 dnl
552 AC_DEFUN([CF_GCC_WARNINGS],
553 [
554 if test -n "$GCC"
555 then
556         changequote(,)dnl
557         cat > conftest.$ac_ext <<EOF
558 #line __oline__ "configure"
559 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
560 EOF
561         changequote([,])dnl
562         AC_CHECKING([for $CC warning options])
563         cf_save_CFLAGS="$CFLAGS"
564         EXTRA_CFLAGS="-W -Wall"
565         cf_warn_CONST=""
566         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
567         for cf_opt in \
568                 Wbad-function-cast \
569                 Wcast-align \
570                 Wcast-qual \
571                 Winline \
572                 Wmissing-declarations \
573                 Wmissing-prototypes \
574                 Wnested-externs \
575                 Wpointer-arith \
576                 Wshadow \
577                 Wstrict-prototypes $cf_warn_CONST
578         do
579                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
580                 if AC_TRY_EVAL(ac_compile); then
581                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
582                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
583                         test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
584                 fi
585         done
586         rm -f conftest*
587         CFLAGS="$cf_save_CFLAGS"
588 fi
589 AC_SUBST(EXTRA_CFLAGS)
590 ])dnl
591 dnl ---------------------------------------------------------------------------
592 dnl Verify that a test program compiles and runs with GNAT
593 dnl $cf_ada_make is set to the program that compiles/links
594 AC_DEFUN([CF_GNAT_TRY_RUN],
595 [
596 rm -f conftest*
597 cat >>conftest.ads <<CF_EOF
598 $1
599 CF_EOF
600 cat >>conftest.adb <<CF_EOF
601 $2
602 CF_EOF
603 if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then
604    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
605 ifelse($3,,      :,[      $3])
606 ifelse($4,,,[   else
607       $4])
608    fi
609 ifelse($4,,,[else
610    $4])
611 fi
612 rm -f conftest*
613 ])dnl
614 dnl ---------------------------------------------------------------------------
615 dnl Verify Version of GNAT.
616 AC_DEFUN([CF_GNAT_VERSION],
617 [
618 changequote(<<, >>)dnl
619 cf_cv_gnat_version=`$cf_ada_make -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\
620   sed -e 's/[^0-9 \.]//g' | $AWK '{print $<<1>>;}'`
621 case $cf_cv_gnat_version in
622   3.[1-9]*|[4-9].*)
623     cf_cv_prog_gnat_correct=yes
624     ;;
625   *) echo Unsupported GNAT version $cf_cv_gnat_version. Required is 3.10 or better. Disabling Ada95 binding.
626      cf_cv_prog_gnat_correct=no
627      ;;
628 esac
629 case $cf_cv_gnat_version in
630   3.1*|[4-9].*)
631       cf_compile_generics=generics
632       cf_generic_objects="\$(GENOBJS)"
633       ;;
634   *)  cf_compile_generics=
635       cf_generic_objects=
636       ;;
637 esac
638 changequote([, ])dnl
639 ])
640 dnl ---------------------------------------------------------------------------
641 dnl If we're trying to use g++, test if libg++ is installed (a rather common
642 dnl problem :-).  If we have the compiler but no library, we'll be able to
643 dnl configure, but won't be able to build the c++ demo program.
644 AC_DEFUN([CF_GPP_LIBRARY],
645 [
646 cf_cxx_library=unknown
647 case $cf_cv_system_name in #(vi
648 os2*) #(vi
649         cf_gpp_libname=gpp
650         ;;
651 *)
652         cf_gpp_libname=g++
653         ;;
654 esac
655 if test $ac_cv_prog_gxx = yes; then
656         AC_MSG_CHECKING([for lib$cf_gpp_libname])
657         cf_save="$LIBS"
658         LIBS="$LIBS -l$cf_gpp_libname -lm"
659         AC_TRY_LINK([
660 #include <$cf_gpp_libname/builtin.h>
661         ],
662         [//float foo=abs(1.0);
663          two_arg_error_handler_t foo2 = lib_error_handler],
664         [cf_cxx_library=yes
665          CXXLIBS="$CXXLIBS -l$cf_gpp_libname -lm"
666          if test "$cf_gpp_libname" = cpp ; then
667             AC_DEFINE(HAVE_GPP_BUILTIN_H)
668          else
669             AC_DEFINE(HAVE_GXX_BUILTIN_H)
670          fi],
671         [AC_TRY_LINK([
672 #include <builtin.h>
673         ],
674         [//float foo=abs(1.0);
675          two_arg_error_handler_t foo2 = lib_error_handler],
676         [cf_cxx_library=yes
677          CXXLIBS="$CXXLIBS -l$cf_gpp_libname -lm"
678          AC_DEFINE(HAVE_BUILTIN_H)],
679         [cf_cxx_library=no])])
680         LIBS="$cf_save"
681         AC_MSG_RESULT($cf_cxx_library)
682 fi
683 ])dnl
684 dnl ---------------------------------------------------------------------------
685 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
686 AC_DEFUN([CF_HELP_MESSAGE],
687 [AC_DIVERT_HELP([$1])dnl
688 ])dnl
689 dnl ---------------------------------------------------------------------------
690 dnl Construct the list of include-options according to whether we're building
691 dnl in the source directory or using '--srcdir=DIR' option.  If we're building
692 dnl with gcc, don't append the includedir if it happens to be /usr/include,
693 dnl since that usually breaks gcc's shadow-includes.
694 AC_DEFUN([CF_INCLUDE_DIRS],
695 [
696 CPPFLAGS="$CPPFLAGS -I. -I../include"
697 if test "$srcdir" != "."; then
698         CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include"
699 fi
700 if test -z "$GCC"; then
701         CPPFLAGS="$CPPFLAGS -I\$(includedir)"
702 elif test "$includedir" != "/usr/include"; then
703         if test "$includedir" = '${prefix}/include' ; then
704                 if test $prefix != /usr ; then
705                         CPPFLAGS="$CPPFLAGS -I\$(includedir)"
706                 fi
707         else
708                 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
709         fi
710 fi
711 AC_SUBST(CPPFLAGS)
712 ])dnl
713 dnl ---------------------------------------------------------------------------
714 dnl Check if we have either a function or macro for 'isascii()'.
715 AC_DEFUN([CF_ISASCII],
716 [
717 AC_MSG_CHECKING(for isascii)
718 AC_CACHE_VAL(cf_cv_have_isascii,[
719         AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
720         [cf_cv_have_isascii=yes],
721         [cf_cv_have_isascii=no])
722 ])dnl
723 AC_MSG_RESULT($cf_cv_have_isascii)
724 test $cf_cv_have_isascii = yes && AC_DEFINE(HAVE_ISASCII)
725 ])dnl
726 dnl ---------------------------------------------------------------------------
727 dnl Compute the library-prefix for the given host system
728 dnl $1 = variable to set
729 AC_DEFUN([CF_LIB_PREFIX],
730 [
731         case $cf_cv_system_name in
732         os2)    $1=''     ;;
733         *)      $1='lib'  ;;
734         esac
735         LIB_PREFIX=[$]$1
736         AC_SUBST(LIB_PREFIX)
737 ])dnl
738 dnl ---------------------------------------------------------------------------
739 dnl Append definitions and rules for the given models to the subdirectory
740 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
741 dnl subdirectory is a library-source directory, modify the LIBRARIES list in
742 dnl the corresponding makefile to list the models that we'll generate.
743 dnl
744 dnl For shared libraries, make a list of symbolic links to construct when
745 dnl generating each library.  The convention used for Linux is the simplest
746 dnl one:
747 dnl     lib<name>.so    ->
748 dnl     lib<name>.so.<major>    ->
749 dnl     lib<name>.so.<maj>.<minor>
750 AC_DEFUN([CF_LIB_RULES],
751 [
752 CF_LIB_PREFIX(cf_prefix)
753 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
754 for cf_dir in $SRC_SUBDIRS
755 do
756         if test -f $srcdir/$cf_dir/modules; then
757
758                 cf_libs_to_make=
759                 for cf_item in $CF_LIST_MODELS
760                 do
761                         CF_LIB_SUFFIX($cf_item,cf_suffix)
762                         cf_libs_to_make="$cf_libs_to_make ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
763                 done
764
765                 if test $cf_dir = ncurses ; then
766                         case "$LIB_SUBSETS" in
767                         termlib+*) #(vi
768                                 ;;
769                         *) #(vi
770                                 cf_item=`echo $cf_libs_to_make |sed -e s/$LIB_NAME/$TINFO_NAME/g`
771                                 cf_libs_to_make="$cf_item $cf_libs_to_make"
772                                 ;;
773                         esac
774                 fi
775
776                 sed -e "s@\@LIBS_TO_MAKE\@@$cf_libs_to_make@" \
777                         $cf_dir/Makefile >$cf_dir/Makefile.out
778                 mv $cf_dir/Makefile.out $cf_dir/Makefile
779
780                 $AWK -f $srcdir/mk-0th.awk \
781                         name=$cf_dir \
782                         $srcdir/$cf_dir/modules >>$cf_dir/Makefile
783
784                 for cf_item in $CF_LIST_MODELS
785                 do
786                         echo 'Appending rules for '$cf_item' model ('$cf_dir')'
787                         CF_UPPER(CF_ITEM,$cf_item)
788                         CF_LIB_SUFFIX($cf_item,cf_suffix)
789                         CF_OBJ_SUBDIR($cf_item,cf_subdir)
790
791                         # These dependencies really are for development, not
792                         # builds, but they are useful in porting, too.
793                         cf_depend="../include/ncurses_cfg.h"
794                         if test "$srcdir" = "."; then
795                                 cf_reldir="."
796                         else
797                                 cf_reldir="\$(srcdir)"
798                         fi
799
800                         if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
801                                 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
802                         elif test -f $srcdir/$cf_dir/curses.priv.h; then
803                                 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
804                         fi
805
806                         for cf_subset in $LIB_SUBSETS
807                         do
808                         $AWK -f $srcdir/mk-1st.awk \
809                                 name=$cf_dir \
810                                 MODEL=$CF_ITEM \
811                                 model=$cf_subdir \
812                                 prefix=$cf_prefix \
813                                 suffix=$cf_suffix \
814                                 subset=$cf_subset \
815                                 DoLinks=$cf_cv_do_symlinks \
816                                 rmSoLocs=$cf_cv_rm_so_locs \
817                                 ldconfig="$LDCONFIG" \
818                                 overwrite=$WITH_OVERWRITE \
819                                 depend="$cf_depend" \
820                                 target="$target" \
821                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
822                         test $cf_dir = ncurses && WITH_OVERWRITE=no
823                         $AWK -f $srcdir/mk-2nd.awk \
824                                 name=$cf_dir \
825                                 MODEL=$CF_ITEM \
826                                 model=$cf_subdir \
827                                 subset=$cf_subset \
828                                 srcdir=$srcdir \
829                                 echo=$WITH_ECHO \
830                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
831                         done
832                 done
833         fi
834
835         echo '  cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >>Makefile
836 done
837
838 for cf_dir in $SRC_SUBDIRS
839 do
840         if test -f $cf_dir/Makefile ; then
841                 case "$cf_dir" in
842                 Ada95) #(vi
843                         echo 'install.libs \' >> Makefile
844                         echo 'uninstall.libs ::' >> Makefile
845                         echo '  cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >> Makefile
846                         ;;
847                 esac
848         fi
849
850         if test -f $srcdir/$cf_dir/modules; then
851                 echo >> Makefile
852                 if test -f $srcdir/$cf_dir/headers; then
853 cat >> Makefile <<CF_EOF
854 install.includes \\
855 uninstall.includes \\
856 CF_EOF
857                 fi
858 if test "$cf_dir" != "c++" ; then
859 echo 'lint \' >> Makefile
860 fi
861 cat >> Makefile <<CF_EOF
862 lintlib \\
863 install.libs \\
864 uninstall.libs \\
865 install.$cf_dir \\
866 uninstall.$cf_dir ::
867         cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
868 CF_EOF
869         elif test -f $srcdir/$cf_dir/headers; then
870 cat >> Makefile <<CF_EOF
871
872 install.libs \\
873 uninstall.libs \\
874 install.includes \\
875 uninstall.includes ::
876         cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
877 CF_EOF
878 fi
879 done
880
881 cat >> Makefile <<CF_EOF
882
883 install.data \
884 uninstall.data ::
885         cd misc && \$(MAKE) \$(CF_MFLAGS) \[$]@
886
887 install.man \
888 uninstall.man ::
889         cd man && \$(MAKE) \$(CF_MFLAGS) \[$]@
890
891 distclean ::
892         rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
893         rm -f headers.sh headers.sed
894         rm -rf \$(DIRS_TO_MAKE)
895 CF_EOF
896
897 dnl If we're installing into a subdirectory of /usr/include, etc., we should
898 dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
899 dnl anything, and will make it more standardized.  It's awkward to decide this
900 dnl at configuration because of quoting, so we'll simply make all headers
901 dnl installed via a script that can do the right thing.
902
903 rm -f headers.sed headers.sh
904
905 dnl ( generating this script makes the makefiles a little tidier :-)
906 echo creating headers.sh
907 cat >headers.sh <<CF_EOF
908 #! /bin/sh
909 # This shell script is generated by the 'configure' script.  It is invoked in a
910 # subdirectory of the build tree.  It generates a sed-script in the parent
911 # directory that is used to adjust includes for header files that reside in a
912 # subdirectory of /usr/include, etc.
913 PRG=""
914 while test \[$]# != 3
915 do
916 PRG="\$PRG \[$]1"; shift
917 done
918 DST=\[$]1
919 REF=\[$]2
920 SRC=\[$]3
921 echo installing \$SRC in \$DST
922 case \$DST in
923 /*/include/*)
924         TMP=\${TMPDIR-/tmp}/\`basename \$SRC\`
925         if test ! -f ../headers.sed ; then
926                 END=\`basename \$DST\`
927                 for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
928                 do
929                         NAME=\`basename \$i\`
930                         echo "s/<\$NAME>/<\$END\/\$NAME>/" >> ../headers.sed
931                 done
932         fi
933         rm -f \$TMP
934         sed -f ../headers.sed \$SRC > \$TMP
935         eval \$PRG \$TMP \$DST
936         rm -f \$TMP
937         ;;
938 *)
939         eval \$PRG \$SRC \$DST
940         ;;
941 esac
942 CF_EOF
943
944 chmod 0755 headers.sh
945
946 for cf_dir in $SRC_SUBDIRS
947 do
948         if test -f $srcdir/$cf_dir/headers; then
949         cat >>$cf_dir/Makefile <<CF_EOF
950 \$(INSTALL_PREFIX)\$(includedir) :
951         \$(srcdir)/../mkinstalldirs \[$]@
952
953 install \\
954 install.libs \\
955 install.includes :: \$(INSTALL_PREFIX)\$(includedir) \\
956 CF_EOF
957                 j=""
958                 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
959                 do
960                         test -n "$j" && echo "          $j \\" >>$cf_dir/Makefile
961                         j=$i
962                 done
963                 echo "          $j" >>$cf_dir/Makefile
964                 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
965                 do
966                         echo "  @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(INSTALL_PREFIX)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile
967                         test $i = curses.h && echo "    @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile
968                 done
969
970         cat >>$cf_dir/Makefile <<CF_EOF
971
972 uninstall \\
973 uninstall.libs \\
974 uninstall.includes ::
975 CF_EOF
976                 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
977                 do
978                         i=`basename $i`
979                         echo "  -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f $i)" >>$cf_dir/Makefile
980                         test $i = curses.h && echo "    -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h)" >>$cf_dir/Makefile
981                 done
982         fi
983 done
984
985 ])dnl
986 dnl ---------------------------------------------------------------------------
987 dnl Compute the library-suffix from the given model name
988 dnl $1 = model name
989 dnl $2 = variable to set
990 AC_DEFUN([CF_LIB_SUFFIX],
991 [
992         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
993         case $1 in
994         normal)  $2='.a'   ;;
995         debug)   $2='_g.a' ;;
996         profile) $2='_p.a' ;;
997         shared)
998                 case $cf_cv_system_name in
999                 openbsd*|freebsd*)
1000                         $2='.so.$(REL_VERSION)' ;;
1001                 netbsd*)
1002                         if test -f /usr/libexec/ld.elf_so; then
1003                                 $2='.so'
1004                         else
1005                                 $2='.so.$(REL_VERSION)'
1006                         fi
1007                         ;;
1008                 hpux*)  $2='.sl'  ;;
1009                 *)      $2='.so'  ;;
1010                 esac
1011         esac
1012 ])dnl
1013 dnl ---------------------------------------------------------------------------
1014 dnl Compute the string to append to -library from the given model name
1015 AC_DEFUN([CF_LIB_TYPE],
1016 [
1017         case $1 in
1018         normal)  $2=''   ;;
1019         debug)   $2='_g' ;;
1020         profile) $2='_p' ;;
1021         shared)  $2=''   ;;
1022         esac
1023 ])dnl
1024 dnl ---------------------------------------------------------------------------
1025 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
1026 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
1027 dnl have to provide wrappers for global tables to ensure they're linked
1028 dnl properly.
1029 AC_DEFUN([CF_LINK_DATAONLY],
1030 [
1031 AC_MSG_CHECKING([if data-only library module links])
1032 AC_CACHE_VAL(cf_cv_link_dataonly,[
1033         rm -f conftest.a
1034         changequote(,)dnl
1035         cat >conftest.$ac_ext <<EOF
1036 #line __oline__ "configure"
1037 int     testdata[3] = { 123, 456, 789 };
1038 EOF
1039         changequote([,])dnl
1040         if AC_TRY_EVAL(ac_compile) ; then
1041                 mv conftest.o data.o && \
1042                 ( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
1043         fi
1044         rm -f conftest.$ac_ext data.o
1045         changequote(,)dnl
1046         cat >conftest.$ac_ext <<EOF
1047 #line __oline__ "configure"
1048 int     testfunc()
1049 {
1050 #if defined(NeXT)
1051         exit(1);        /* I'm told this linker is broken */
1052 #else
1053         extern int testdata[3];
1054         return testdata[0] == 123
1055            &&  testdata[1] == 456
1056            &&  testdata[2] == 789;
1057 #endif
1058 }
1059 EOF
1060         changequote([,])dnl
1061         if AC_TRY_EVAL(ac_compile); then
1062                 mv conftest.o func.o && \
1063                 ( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
1064         fi
1065         rm -f conftest.$ac_ext func.o
1066         ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null
1067         cf_saveLIBS="$LIBS"
1068         LIBS="conftest.a $LIBS"
1069         AC_TRY_RUN([
1070         int main()
1071         {
1072                 extern int testfunc();
1073                 exit (!testfunc());
1074         }
1075         ],
1076         [cf_cv_link_dataonly=yes],
1077         [cf_cv_link_dataonly=no],
1078         [cf_cv_link_dataonly=unknown])
1079         LIBS="$cf_saveLIBS"
1080         ])
1081 AC_MSG_RESULT($cf_cv_link_dataonly)
1082 test $cf_cv_link_dataonly = no && AC_DEFINE(BROKEN_LINKER)
1083 ])dnl
1084 dnl ---------------------------------------------------------------------------
1085 dnl Most Unix systems have both link and symlink, a few don't have symlink.
1086 dnl A few non-Unix systems implement symlink, but not link.
1087 dnl A few non-systems implement neither (or have nonfunctional versions).
1088 AC_DEFUN([CF_LINK_FUNCS],
1089 [
1090 AC_CHECK_FUNCS( \
1091         remove \
1092         unlink )
1093
1094 if test "$ac_cv_prog_cc_cross" = yes ; then
1095         AC_CHECK_FUNCS( \
1096                 link \
1097                 symlink )
1098 else
1099         AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1100                 cf_cv_link_funcs=
1101                 for cf_func in link symlink ; do
1102                         AC_TRY_RUN([
1103 #include <sys/types.h>
1104 #include <sys/stat.h>
1105 #ifdef HAVE_UNISTD_H
1106 #include <unistd.h>
1107 #endif
1108 int main()
1109 {
1110         int fail = 0;
1111         char *src = "config.log";
1112         char *dst = "conftest.chk";
1113         struct stat src_sb;
1114         struct stat dst_sb;
1115
1116         stat(src, &src_sb);
1117         fail = ($cf_func("config.log", "conftest.chk") < 0)
1118             || (stat(dst, &dst_sb) < 0)
1119             || (dst_sb.st_mtime != src_sb.st_mtime);
1120 #ifdef HAVE_UNLINK
1121         unlink(dst);
1122 #else
1123         remove(dst);
1124 #endif
1125         exit (fail);
1126 }
1127                         ],[
1128                         cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
1129                         eval 'ac_cv_func_'$cf_func'=yes'
1130                         CF_UPPER(cf_FUNC,$cf_func)
1131                         AC_DEFINE_UNQUOTED(HAVE_$cf_FUNC)],[
1132                         eval 'ac_cv_func_'$cf_func'=no'],[
1133                         eval 'ac_cv_func_'$cf_func'=error'])
1134                 done
1135                 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1136         ])
1137 fi
1138 ])dnl
1139 dnl ---------------------------------------------------------------------------
1140 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
1141 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
1142 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1143 dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-)
1144 AC_DEFUN([CF_MAKEFLAGS],
1145 [
1146 AC_MSG_CHECKING([for makeflags variable])
1147 AC_CACHE_VAL(cf_cv_makeflags,[
1148         cf_cv_makeflags=''
1149         for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)'
1150         do
1151                 cat >cf_makeflags.tmp <<CF_EOF
1152 all :
1153         @ echo '.$cf_option'
1154 CF_EOF
1155                 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null`
1156                 case "$cf_result" in
1157                 .*k)
1158                         cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1159                         case "$cf_result" in
1160                         .*CC=*) cf_cv_makeflags=
1161                                 ;;
1162                         *)      cf_cv_makeflags=$cf_option
1163                                 ;;
1164                         esac
1165                         break
1166                         ;;
1167                 *)      echo no match "$cf_result"
1168                         ;;
1169                 esac
1170         done
1171         rm -f cf_makeflags.tmp])
1172 AC_MSG_RESULT($cf_cv_makeflags)
1173 AC_SUBST(cf_cv_makeflags)
1174 ])dnl
1175 dnl ---------------------------------------------------------------------------
1176 dnl Option to allow user to override automatic configuration of manpage format.
1177 dnl There are several special cases.
1178 AC_DEFUN([CF_MANPAGE_FORMAT],
1179 [ AC_MSG_CHECKING(format of man-pages)
1180
1181 AC_ARG_WITH(manpage-format,
1182         [  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
1183                           optionally formatted, e.g., gzip,formatted],
1184         [cf_manpage_form=$withval],
1185         [cf_manpage_form=unknown])
1186
1187 case ".$cf_manpage_form" in
1188 .gzip|.compress|.BSDI|.normal|.formatted) # (vi
1189   ;;
1190 .unknown|.) # (vi
1191   if test -z "$MANPATH" ; then
1192     MANPATH="/usr/man:/usr/share/man"
1193   fi
1194   # look for the 'date' man-page (it's most likely to be installed!)
1195   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1196   cf_manpage_form=unknown
1197   for cf_dir in $MANPATH; do
1198     test -z "$cf_dir" && cf_dir=/usr/man
1199 changequote({{,}})dnl
1200     for cf_name in $cf_dir/*/date.[01]* $cf_dir/*/date
1201 changequote([,])dnl
1202     do
1203        cf_test=`echo $cf_name | sed -e 's/*//'`
1204        if test "x$cf_test" = "x$cf_name" ; then
1205           case "$cf_name" in
1206           *.gz) cf_manpage_form=gzip;;
1207           *.Z)  cf_manpage_form=compress;;
1208           *.0)  cf_manpage_form=BSDI,formatted;;
1209           *)    cf_manpage_form=normal;;
1210           esac
1211           break
1212        fi
1213     done
1214     if test "$cf_manpage_form" != "unknown" ; then
1215        break
1216     fi
1217   done
1218   IFS="$ac_save_ifs"
1219   ;;
1220 .*) # (vi
1221   AC_MSG_WARN(Unexpected manpage-format)
1222   ;;
1223 esac
1224
1225 AC_MSG_RESULT($cf_manpage_form)
1226 ])dnl
1227 dnl ---------------------------------------------------------------------------
1228 dnl The Debian people have their own naming convention for manpages.  This
1229 dnl option lets us override the name of the file containing renaming, or
1230 dnl disable it altogether.
1231 AC_DEFUN([CF_MANPAGE_RENAMES],
1232 [
1233 AC_MSG_CHECKING(for manpage renaming)
1234
1235 AC_ARG_WITH(manpage-renames,
1236         [  --with-manpage-renames  specify manpage-renaming],
1237         [cf_manpage_renames=$withval],
1238         [cf_manpage_renames=yes])
1239
1240 case ".$cf_manpage_renames" in #(vi
1241 .no) #(vi
1242   ;;
1243 .|.yes)
1244   # Debian 'man' program?
1245   if test -f /etc/debian_version ; then
1246     cf_manpage_renames=`cd $srcdir && pwd`/man/man_db.renames
1247   else
1248     cf_manpage_renames=no
1249   fi
1250   ;;
1251 esac
1252
1253 if test "$cf_manpage_renames" != no ; then
1254   if test ! -f $cf_manpage_renames ; then
1255     AC_MSG_ERROR(not a filename: $cf_manpage_renames)
1256   fi
1257
1258   test ! -d man && mkdir man
1259
1260   # Construct a sed-script to perform renaming within man-pages
1261   if test -n "$cf_manpage_renames" ; then
1262     test ! -d man && mkdir man
1263     $srcdir/man/make_sed.sh $cf_manpage_renames >man/edit_man.sed
1264   fi
1265 fi
1266
1267 AC_MSG_RESULT($cf_manpage_renames)
1268 ])dnl
1269 dnl ---------------------------------------------------------------------------
1270 dnl Try to determine if the man-pages on the system are compressed, and if
1271 dnl so, what format is used.  Use this information to construct a script that
1272 dnl will install man-pages.
1273 AC_DEFUN([CF_MAN_PAGES],
1274 [
1275 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
1276 CF_MANPAGE_FORMAT
1277 CF_MANPAGE_RENAMES
1278
1279   if test "$prefix" = "NONE" ; then
1280      cf_prefix="$ac_default_prefix"
1281   else
1282      cf_prefix="$prefix"
1283   fi
1284
1285   case "$cf_manpage_form" in # (vi
1286   *formatted*) # (vi
1287     cf_subdir='$mandir/cat'
1288     cf_format=yes
1289     ;;
1290   *)
1291     cf_subdir='$mandir/man'
1292     cf_format=no
1293     ;;
1294   esac
1295
1296 test ! -d man && mkdir man
1297 cat >man/edit_man.sh <<CF_EOF
1298 changequote({{,}})dnl
1299 #! /bin/sh
1300 # this script is generated by the configure-script
1301 prefix="$cf_prefix"
1302 datadir="$datadir"
1303 MKDIRS="`cd $srcdir && pwd`/mkinstalldirs"
1304 INSTALL="$INSTALL"
1305 INSTALL_DATA="$INSTALL_DATA"
1306 TMP=\${TMPDIR-/tmp}/man\$\$
1307 trap "rm -f \$TMP" 0 1 2 5 15
1308
1309 verb=\{{$}}1
1310 shift
1311
1312 mandir=\{{$}}1
1313 shift
1314
1315 for i in \{{$}}* ; do
1316 case \$i in #(vi
1317 *.orig|*.rej) ;; #(vi
1318 *.[0-9]*)
1319         section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
1320         if test \$verb = installing ; then
1321         if test ! -d $cf_subdir\${section} ; then
1322                 \$MKDIRS $cf_subdir\$section
1323         fi
1324         fi
1325         source=\`basename \$i\`
1326 CF_EOF
1327 if test "$cf_manpage_renames" = no ; then
1328 cat >>man/edit_man.sh <<CF_EOF
1329         target=$cf_subdir\${section}/\$source
1330         sed -e "s,@DATADIR@,\$datadir," < \$i >\$TMP
1331 CF_EOF
1332 else
1333 cat >>man/edit_man.sh <<CF_EOF
1334         target=\`grep "^\$source" $cf_manpage_renames | $AWK '{print \{{$}}2}'\`
1335         if test -z "\$target" ; then
1336                 echo '? missing rename for '\$source
1337                 target="\$source"
1338         fi
1339         target="$cf_subdir\$section/\$target"
1340         test \$verb = installing && sed -e "s,@DATADIR@,\$datadir," < \$i | sed -f edit_man.sed >\$TMP
1341 CF_EOF
1342 fi
1343 if test $cf_format = yes ; then
1344 cat >>man/edit_man.sh <<CF_EOF
1345         nroff -man \$TMP >\$TMP.out
1346         mv \$TMP.out \$TMP
1347 CF_EOF
1348 fi
1349 case "$cf_manpage_form" in #(vi
1350 *compress*) #(vi
1351 cat >>man/edit_man.sh <<CF_EOF
1352         if test \$verb = installing ; then
1353         if ( compress -f \$TMP )
1354         then
1355                 mv \$TMP.Z \$TMP
1356         fi
1357         fi
1358         target="\$target.Z"
1359 CF_EOF
1360   ;;
1361 *gzip*) #(vi
1362 cat >>man/edit_man.sh <<CF_EOF
1363         if test \$verb = installing ; then
1364         if ( gzip -f \$TMP )
1365         then
1366                 mv \$TMP.gz \$TMP
1367         fi
1368         fi
1369         target="\$target.gz"
1370 CF_EOF
1371   ;;
1372 *BSDI*)
1373 cat >>man/edit_man.sh <<CF_EOF
1374         # BSDI installs only .0 suffixes in the cat directories
1375         target="\`echo \$target|sed -e 's/\.[1-9]\+.\?/.0/'\`"
1376 CF_EOF
1377   ;;
1378 esac
1379 cat >>man/edit_man.sh <<CF_EOF
1380         echo \$verb \$target
1381         if test \$verb = installing ; then
1382                 \$INSTALL_DATA \$TMP \$target
1383         else
1384                 rm -f \$target
1385         fi
1386         ;;
1387 esac
1388 done
1389 CF_EOF
1390 changequote([,])dnl
1391 chmod 755 man/edit_man.sh
1392
1393 ])dnl
1394 dnl ---------------------------------------------------------------------------
1395 dnl Compute the object-directory name from the given model name
1396 AC_DEFUN([CF_OBJ_SUBDIR],
1397 [
1398         case $1 in
1399         normal)  $2='objects' ;;
1400         debug)   $2='obj_g' ;;
1401         profile) $2='obj_p' ;;
1402         shared)  $2='obj_s' ;;
1403         esac
1404 ])dnl
1405 dnl ---------------------------------------------------------------------------
1406 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1407 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1408 dnl result begins with 'NONE'.  This is necessary to workaround autoconf's
1409 dnl delayed evaluation of those symbols.
1410 AC_DEFUN([CF_PATH_SYNTAX],[
1411 case ".[$]$1" in #(vi
1412 ./*) #(vi
1413   ;;
1414 .\[$]{*prefix}*) #(vi
1415   eval $1="[$]$1"
1416   case ".[$]$1" in #(vi
1417   .NONE/*)
1418     $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1419     ;;
1420   esac
1421   ;; #(vi
1422 .NONE/*)
1423   $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1424   ;;
1425 *)
1426   AC_ERROR(expected a pathname)
1427   ;;
1428 esac
1429 ])dnl
1430 dnl ---------------------------------------------------------------------------
1431 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
1432 AC_DEFUN([CF_PROG_EXT],
1433 [
1434 AC_REQUIRE([CF_CHECK_CACHE])
1435 PROG_EXT=
1436 case $cf_cv_system_name in
1437 os2*)
1438     # We make sure -Zexe is not used -- it would interfere with @PROG_EXT@
1439     CFLAGS="$CFLAGS -Zmt -D__ST_MT_ERRNO__"
1440     CXXFLAGS="$CXXFLAGS -Zmt -D__ST_MT_ERRNO__"
1441     LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed "s/-Zexe//g"`
1442     PROG_EXT=".exe"
1443     ;;
1444 cygwin*)
1445     PROG_EXT=".exe"
1446     ;;
1447 esac
1448 AC_SUBST(PROG_EXT)
1449 ])dnl
1450 dnl ---------------------------------------------------------------------------
1451 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
1452 dnl misc/tabset install won't work properly.  Usually this happens only when
1453 dnl using the fallback mkinstalldirs script
1454 AC_DEFUN([CF_PROG_INSTALL],
1455 [AC_PROG_INSTALL
1456 case $INSTALL in
1457 /*)
1458   ;;
1459 *)
1460 changequote({{,}})dnl
1461   cf_dir=`echo $INSTALL|sed -e 's%/[^/]*$%%'`
1462   test -z "$cf_dir" && cf_dir=.
1463 changequote([,])dnl
1464   INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's:^.*/::'`
1465   ;;
1466 esac
1467 ])dnl
1468 dnl ---------------------------------------------------------------------------
1469 dnl Attempt to determine if we've got one of the flavors of regular-expression
1470 dnl code that we can support.
1471 AC_DEFUN([CF_REGEX],
1472 [
1473 AC_MSG_CHECKING([for regular-expression headers])
1474 AC_CACHE_VAL(cf_cv_regex,[
1475 AC_TRY_LINK([#include <sys/types.h>
1476 #include <regex.h>],[
1477         regex_t *p;
1478         int x = regcomp(p, "", 0);
1479         int y = regexec(p, "", 0, 0, 0);
1480         regfree(p);
1481         ],[cf_cv_regex="regex.h"],[
1482         AC_TRY_LINK([#include <regexp.h>],[
1483                 char *p = compile("", "", "", 0);
1484                 int x = step("", "");
1485         ],[cf_cv_regex="regexp.h"],[
1486                 cf_save_LIBS="$LIBS"
1487                 LIBS="-lgen $LIBS"
1488                 AC_TRY_LINK([#include <regexpr.h>],[
1489                         char *p = compile("", "", "");
1490                         int x = step("", "");
1491                 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
1492 ])
1493 AC_MSG_RESULT($cf_cv_regex)
1494 case $cf_cv_regex in
1495         regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
1496         regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
1497         regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
1498 esac
1499 ])dnl
1500 dnl ---------------------------------------------------------------------------
1501 dnl Attempt to determine the appropriate CC/LD options for creating a shared
1502 dnl library.
1503 dnl
1504 dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the
1505 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
1506 dnl We avoid compiling-in a ../lib path for the shared library since that can
1507 dnl lead to unexpected results at runtime.
1508 dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries
1509 dnl are compiled in ../../lib
1510 dnl
1511 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
1512 dnl to install symbolic links to the rel/abi versions of shared libraries.
1513 dnl
1514 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
1515 dnl version when making symbolic links.
1516 dnl
1517 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
1518 AC_DEFUN([CF_SHARED_OPTS],
1519 [
1520         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1521         LOCAL_LDFLAGS=
1522         LOCAL_LDFLAGS2=
1523         LD_SHARED_OPTS=
1524         INSTALL_LIB="-m 644"
1525
1526         cf_cv_do_symlinks=no
1527
1528         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
1529         AC_ARG_WITH(shlib-version,
1530         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
1531         [test -z "$withval" && withval=auto
1532         case $withval in #(vi
1533         yes) #(vi
1534                 cf_cv_shlib_version=auto
1535                 ;;
1536         rel|abi|auto|no) #(vi
1537                 cf_cv_shlib_version=$withval
1538                 ;;
1539         *)
1540                 AC_ERROR([option value must be one of: rel, abi, auto or no])
1541                 ;;
1542         esac
1543         ],[cf_cv_shlib_version=auto])
1544         AC_MSG_RESULT($cf_cv_shlib_version)
1545
1546         cf_cv_rm_so_locs=no
1547
1548         case $cf_cv_system_name in
1549         hpux10.*)
1550                 # (tested with gcc 2.7.2 -- I don't have c89)
1551                 if test -n "$GCC"; then
1552                         CC_SHARED_OPTS='-fPIC'
1553                         LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1554                 else
1555                         CC_SHARED_OPTS='+Z'
1556                         LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1557                 fi
1558                 MK_SHARED_LIB='$(LD) +b $(libdir) -b +h `basename $[@]` -o $[@]'
1559                 # HP-UX shared libraries must be executable, and should be
1560                 # readonly to exploit a quirk in the memory manager.
1561                 INSTALL_LIB="-m 555"
1562                 cf_cv_do_symlinks=reverse
1563                 ;;
1564         hpux*)
1565                 # (tested with gcc 2.7.2 -- I don't have c89)
1566                 if test -n "$GCC"; then
1567                         CC_SHARED_OPTS='-fPIC'
1568                         LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1569                 else
1570                         CC_SHARED_OPTS='+Z'
1571                         LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1572                 fi
1573                 MK_SHARED_LIB='$(LD) +b $(libdir) -b -o $[@]'
1574                 # HP-UX shared libraries must be executable, and should be
1575                 # readonly to exploit a quirk in the memory manager.
1576                 INSTALL_LIB="-m 555"
1577                 ;;
1578         irix*)
1579                 # tested with IRIX 5.2 and 'cc'.
1580                 if test -n "$GCC"; then
1581                         CC_SHARED_OPTS='-fPIC'
1582                 else
1583                         CC_SHARED_OPTS='-KPIC'
1584                 fi
1585                 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
1586                 cf_cv_rm_so_locs=yes
1587                 ;;
1588         linux*|gnu*)
1589                 # tested with Linux 2.0.29 and gcc 2.7.2 (ELF)
1590                 CC_SHARED_OPTS='-fpic'
1591                 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-Wl,-rpath,"
1592                 if test $DFT_LWR_MODEL = "shared" ; then
1593                         LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1594                         LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1595                 fi
1596                 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1597                 if test $cf_cv_shlib_version = no ; then
1598                         MK_SHARED_LIB='$(CC) -shared -Wl,-stats,-lc -o $[@]'
1599                 else
1600                         MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@].$(ABI_VERSION)`,-stats,-lc -o $[@]'
1601                 fi
1602                 ;;
1603         openbsd2*)
1604                 CC_SHARED_OPTS='-fpic -DPIC'
1605                 MK_SHARED_LIB='$(LD) -Bshareable -soname,`basename $[@].$(ABI_VERSION)` -o $[@]'
1606                 ;;
1607         openbsd*|freebsd*)
1608                 CC_SHARED_OPTS='-fpic -DPIC'
1609                 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1610                 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1611                 ;;
1612         netbsd*)
1613                 CC_SHARED_OPTS='-fpic -DPIC'
1614                 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-Wl,-rpath,"
1615                 if test $DFT_LWR_MODEL = "shared" && test $cf_cv_ld_rpath = yes ; then
1616                         LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1617                         LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1618                         EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
1619                         MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@].$(ABI_VERSION)` -o $[@]'
1620                         test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1621                 else
1622                         MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1623                 fi
1624                 ;;
1625         osf*|mls+*)
1626                 # tested with OSF/1 V3.2 and 'cc'
1627                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
1628                 # link with shared libs).
1629                 CC_SHARED_OPTS=''
1630                 MK_SHARED_LIB='$(LD) -set_version $(REL_VERSION):$(ABI_VERSION) -expect_unresolved "*" -shared -soname `basename $[@]`'
1631                 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-rpath"
1632                 case $host_os in
1633                 osf4*)
1634                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
1635                         ;;
1636                 esac
1637                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
1638                 if test $DFT_LWR_MODEL = "shared" ; then
1639                         LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1640                         LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1641                 fi
1642                 cf_cv_rm_so_locs=yes
1643                 ;;
1644         sco3.2v5*)  # (also uw2* and UW7) hops 13-Apr-98
1645                 # tested with osr5.0.5
1646                 if test $ac_cv_prog_gcc = yes; then
1647                         CC_SHARED_OPTS='-fpic'
1648                 else
1649                         CC_SHARED_OPTS='-belf -KPIC'
1650                 fi
1651                 MK_SHARED_LIB='$(LD) -dy -G -h `basename [$]@.$(ABI_VERSION)` -o [$]@'
1652                 if test $cf_cv_ld_rpath = yes ; then
1653                         # only way is to set LD_RUN_PATH but no switch for it
1654                         RUN_PATH=$libdir
1655                 fi
1656                 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1657                 LINK_PROGS='LD_RUN_PATH=$(libdir)'
1658                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
1659                 ;;
1660         sunos4*)
1661                 # tested with SunOS 4.1.1 and gcc 2.7.0
1662                 if test $ac_cv_prog_gcc = yes; then
1663                         CC_SHARED_OPTS='-fpic'
1664                 else
1665                         CC_SHARED_OPTS='-KPIC'
1666                 fi
1667                 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@]'
1668                 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1669                 ;;
1670         solaris2*)
1671                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
1672                 if test $ac_cv_prog_gcc = yes; then
1673                         CC_SHARED_OPTS='-fpic'
1674                 else
1675                         CC_SHARED_OPTS='-KPIC'
1676                 fi
1677                 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@].$(ABI_VERSION)` -o $[@]'
1678                 if test $cf_cv_ld_rpath = yes ; then
1679                         cf_ld_rpath_opt="-R"
1680                         EXTRA_LDFLAGS="-R ../lib:\$(libdir) $EXTRA_LDFLAGS"
1681                 fi
1682                 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1683                 ;;
1684         unix_sv*)
1685                 # tested with UnixWare 1.1.2
1686                 CC_SHARED_OPTS='-KPIC'
1687                 MK_SHARED_LIB='$(LD) -d y -G -o $[@]'
1688                 ;;
1689         *)
1690                 CC_SHARED_OPTS='unknown'
1691                 MK_SHARED_LIB='echo unknown'
1692                 ;;
1693         esac
1694
1695         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
1696         case "$cf_cv_shlib_version" in #(vi
1697         rel|abi)
1698                 case "$MK_SHARED_LIB" in #(vi
1699                 *'-o $[@]')
1700                         if test "$cf_cv_do_symlinks" = reverse ; then
1701                                 AC_ERROR(cannot use --with-shlib-version with this platform)
1702                         fi
1703                         if test "$cf_cv_shlib_version" = rel ; then
1704                                 MK_SHARED_LIB="$MK_SHARED_LIB"'.$(REL_VERSION)'
1705                         else
1706                                 MK_SHARED_LIB="$MK_SHARED_LIB"'.$(ABI_VERSION)'
1707                         fi
1708                         cf_cv_do_symlinks=yes
1709                         ;;
1710                 *)
1711                         AC_MSG_WARN(ignored --with-shlib-version)
1712                         ;;
1713                 esac
1714                 ;;
1715         esac
1716
1717         if test -n "$cf_ld_rpath_opt" ; then
1718                 AC_MSG_CHECKING(if we need a space after rpath option)
1719                 cf_save_LIBS="$LIBS"
1720                 LIBS="$LIBS ${cf_ld_rpath_opt}/usr/lib"
1721                 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1722                 LIBS="$cf_save_LIBS"
1723                 AC_MSG_RESULT($cf_rpath_space)
1724                 test $cf_rpath_space = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
1725                 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
1726         fi
1727
1728         AC_SUBST(CC_SHARED_OPTS)
1729         AC_SUBST(LD_SHARED_OPTS)
1730         AC_SUBST(MK_SHARED_LIB)
1731         AC_SUBST(LINK_PROGS)
1732         AC_SUBST(LINK_TESTS)
1733         AC_SUBST(EXTRA_LDFLAGS)
1734         AC_SUBST(LOCAL_LDFLAGS)
1735         AC_SUBST(LOCAL_LDFLAGS2)
1736         AC_SUBST(INSTALL_LIB)
1737 ])dnl
1738 dnl ---------------------------------------------------------------------------
1739 dnl Check for definitions & structures needed for window size-changing
1740 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
1741 AC_DEFUN([CF_SIZECHANGE],
1742 [
1743 AC_MSG_CHECKING([declaration of size-change])
1744 AC_CACHE_VAL(cf_cv_sizechange,[
1745     cf_cv_sizechange=unknown
1746     cf_save_CFLAGS="$CFLAGS"
1747
1748 for cf_opts in "" "NEED_PTEM_H"
1749 do
1750
1751     CFLAGS="$cf_save_CFLAGS"
1752     test -n "$cf_opts" && CFLAGS="$CFLAGS -D$cf_opts"
1753     AC_TRY_COMPILE([#include <sys/types.h>
1754 #if HAVE_TERMIOS_H
1755 #include <termios.h>
1756 #else
1757 #if HAVE_TERMIO_H
1758 #include <termio.h>
1759 #endif
1760 #endif
1761 #if NEED_PTEM_H
1762 /* This is a workaround for SCO:  they neglected to define struct winsize in
1763  * termios.h -- it's only in termio.h and ptem.h
1764  */
1765 #include        <sys/stream.h>
1766 #include        <sys/ptem.h>
1767 #endif
1768 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
1769 #include <sys/ioctl.h>
1770 #endif
1771 ],[
1772 #ifdef TIOCGSIZE
1773         struct ttysize win;     /* FIXME: what system is this? */
1774         int y = win.ts_lines;
1775         int x = win.ts_cols;
1776 #else
1777 #ifdef TIOCGWINSZ
1778         struct winsize win;
1779         int y = win.ws_row;
1780         int x = win.ws_col;
1781 #else
1782         no TIOCGSIZE or TIOCGWINSZ
1783 #endif /* TIOCGWINSZ */
1784 #endif /* TIOCGSIZE */
1785         ],
1786         [cf_cv_sizechange=yes],
1787         [cf_cv_sizechange=no])
1788
1789         CFLAGS="$cf_save_CFLAGS"
1790         if test "$cf_cv_sizechange" = yes ; then
1791                 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
1792                 test -n "$cf_opts" && AC_DEFINE_UNQUOTED($cf_opts)
1793                 break
1794         fi
1795 done
1796         ])
1797 AC_MSG_RESULT($cf_cv_sizechange)
1798 test $cf_cv_sizechange != no && AC_DEFINE(HAVE_SIZECHANGE)
1799 ])dnl
1800 dnl ---------------------------------------------------------------------------
1801 dnl Check for datatype 'speed_t', which is normally declared via either
1802 dnl sys/types.h or termios.h
1803 AC_DEFUN([CF_SPEED_TYPE],
1804 [
1805 AC_MSG_CHECKING(for speed_t)
1806 OSPEED_INCLUDES=
1807 AC_TRY_COMPILE([#include <sys/types.h>],
1808         [speed_t some_variable = 0],
1809         [OSPEED_TYPE=speed_t],
1810         [OSPEED_TYPE=unsigned])
1811 AC_TRY_COMPILE([#include <termios.h>],
1812         [speed_t some_variable = 0],
1813         [OSPEED_TYPE=speed_t
1814          OSPEED_INCLUDES="#include <termios.h>"],[])
1815 AC_SUBST(OSPEED_TYPE)
1816 AC_SUBST(OSPEED_INCLUDES)
1817 if test "$OSPEED_TYPE" = "unsigned" ; then
1818         AC_MSG_RESULT(no)
1819         AC_DEFINE(speed_t,unsigned)
1820 else
1821         AC_MSG_RESULT(yes)
1822 fi
1823 ])dnl
1824 dnl ---------------------------------------------------------------------------
1825 dnl For each parameter, test if the source-directory exists, and if it contains
1826 dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
1827 dnl use in CF_LIB_RULES.
1828 dnl
1829 dnl This uses the configured value to make the lists SRC_SUBDIRS and
1830 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
1831 AC_DEFUN([CF_SRC_MODULES],
1832 [
1833 AC_MSG_CHECKING(for src modules)
1834
1835 # dependencies and linker-arguments for test-programs
1836 TEST_DEPS="${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
1837 TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
1838
1839 # dependencies and linker-arguments for utility-programs
1840 PROG_ARGS="$TEST_ARGS"
1841
1842 cf_cv_src_modules=
1843 for cf_dir in $1
1844 do
1845         if test -f $srcdir/$cf_dir/modules; then
1846
1847                 # We may/may not have tack in the distribution, though the
1848                 # makefile is.
1849                 if test $cf_dir = tack ; then
1850                         if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
1851                                 continue
1852                         fi
1853                 fi
1854
1855                 if test -z "$cf_cv_src_modules"; then
1856                         cf_cv_src_modules=$cf_dir
1857                 else
1858                         cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
1859                 fi
1860
1861                 # Make the ncurses_cfg.h file record the library interface files as
1862                 # well.  These are header files that are the same name as their
1863                 # directory.  Ncurses is the only library that does not follow
1864                 # that pattern.
1865                 if test $cf_dir = tack ; then
1866                         continue
1867                 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
1868                         CF_UPPER(cf_have_include,$cf_dir)
1869                         AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
1870                         AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
1871                         TEST_DEPS="${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
1872                         TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
1873                 fi
1874         fi
1875 done
1876 AC_MSG_RESULT($cf_cv_src_modules)
1877 TEST_ARGS="-L${LIB_DIR} -L\$(libdir) $TEST_ARGS"
1878 AC_SUBST(TEST_DEPS)
1879 AC_SUBST(TEST_ARGS)
1880
1881 PROG_ARGS="-L${LIB_DIR} -L\$(libdir) $PROG_ARGS"
1882 AC_SUBST(PROG_ARGS)
1883
1884 SRC_SUBDIRS="man include"
1885 for cf_dir in $cf_cv_src_modules
1886 do
1887         SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
1888 done
1889 SRC_SUBDIRS="$SRC_SUBDIRS misc test"
1890 test $cf_with_cxx_binding != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
1891
1892 ADA_SUBDIRS=
1893 if test "$cf_cv_prog_gnat_correct" = yes && test -d $srcdir/Ada95; then
1894    SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
1895    ADA_SUBDIRS="gen src samples"
1896 fi
1897
1898 SUB_MAKEFILES=
1899 for cf_dir in $SRC_SUBDIRS
1900 do
1901         SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
1902 done
1903
1904 if test -n "$ADA_SUBDIRS"; then
1905    for cf_dir in $ADA_SUBDIRS
1906    do
1907       SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
1908    done
1909    AC_SUBST(ADA_SUBDIRS)
1910 fi
1911 ])dnl
1912 dnl ---------------------------------------------------------------------------
1913 dnl Check for -lstdc++, which is GNU's standard C++ library.
1914 AC_DEFUN([CF_STDCPP_LIBRARY],
1915 [
1916 if test -n "$GXX" ; then
1917 case $cf_cv_system_name in #(vi
1918 os2*) #(vi
1919         cf_stdcpp_libname=stdcpp
1920         ;;
1921 *)
1922         cf_stdcpp_libname=stdc++
1923         ;;
1924 esac
1925 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
1926         cf_save="$LIBS"
1927         LIBS="$LIBS -l$cf_stdcpp_libname -lm"
1928 AC_TRY_LINK([
1929 #include <strstream.h>],[
1930 char buf[80];
1931 strstreambuf foo(buf, sizeof(buf))
1932 //destroy foo
1933 ],
1934         [cf_cv_libstdcpp=yes],
1935         [cf_cv_libstdcpp=no])
1936         LIBS="$cf_save"
1937 ])
1938 test $cf_cv_libstdcpp = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
1939 fi
1940 ])dnl
1941 dnl ---------------------------------------------------------------------------
1942 dnl     Remove "-g" option from the compiler options
1943 AC_DEFUN([CF_STRIP_G_OPT],
1944 [$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl
1945 dnl ---------------------------------------------------------------------------
1946 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
1947 dnl do this if we've found the sigaction function.
1948 dnl
1949 dnl If needed, define SVR4_ACTION.
1950 AC_DEFUN([CF_STRUCT_SIGACTION],[
1951 if test $ac_cv_func_sigaction = yes; then
1952 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
1953 AC_TRY_COMPILE([
1954 #include <sys/types.h>
1955 #include <signal.h>],
1956         [struct sigaction act],
1957         [sigact_bad=no],
1958         [
1959 AC_TRY_COMPILE([
1960 #define _POSIX_SOURCE
1961 #include <sys/types.h>
1962 #include <signal.h>],
1963         [struct sigaction act],
1964         [sigact_bad=yes
1965          AC_DEFINE(SVR4_ACTION)],
1966          [sigact_bad=unknown])])
1967 AC_MSG_RESULT($sigact_bad)
1968 fi
1969 ])dnl
1970 dnl ---------------------------------------------------------------------------
1971 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
1972 dnl If so, define SVR4_TERMIO
1973 AC_DEFUN([CF_STRUCT_TERMIOS],[
1974 if test $ac_cv_header_termios_h = yes ; then
1975         case "$CFLAGS" in
1976         *-D_POSIX_SOURCE*)
1977                 termios_bad=dunno ;;
1978         *)      termios_bad=maybe ;;
1979         esac
1980         if test $termios_bad = maybe ; then
1981         AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
1982         AC_TRY_COMPILE([#include <termios.h>],
1983                 [struct termios foo; int x = foo.c_iflag],
1984                 termios_bad=no, [
1985                 AC_TRY_COMPILE([
1986 #define _POSIX_SOURCE
1987 #include <termios.h>],
1988                         [struct termios foo; int x = foo.c_iflag],
1989                         termios_bad=unknown,
1990                         termios_bad=yes AC_DEFINE(SVR4_TERMIO))
1991                         ])
1992         AC_MSG_RESULT($termios_bad)
1993         fi
1994 fi
1995 ])dnl
1996 dnl ---------------------------------------------------------------------------
1997 dnl     Shorthand macro for substituting things that the user may override
1998 dnl     with an environment variable.
1999 dnl
2000 dnl     $1 = long/descriptive name
2001 dnl     $2 = environment variable
2002 dnl     $3 = default value
2003 AC_DEFUN([CF_SUBST],
2004 [AC_CACHE_VAL(cf_cv_subst_$2,[
2005 AC_MSG_CHECKING(for $1 (symbol $2))
2006 test -z "[$]$2" && $2=$3
2007 AC_MSG_RESULT([$]$2)
2008 AC_SUBST($2)
2009 cf_cv_subst_$2=[$]$2])
2010 $2=${cf_cv_subst_$2}
2011 ])dnl
2012 dnl ---------------------------------------------------------------------------
2013 dnl Get the version-number for use in shared-library naming, etc.
2014 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
2015 [
2016 changequote(,)dnl
2017 NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[  ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2018 NCURSES_MINOR="`egrep '^NCURSES_MINOR[  ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2019 NCURSES_PATCH="`egrep '^NCURSES_PATCH[  ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2020 changequote([,])dnl
2021 cf_cv_abi_version=${NCURSES_MAJOR}
2022 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
2023 dnl Show the computed version, for logging
2024 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version (`date`))
2025 dnl We need these values in the generated headers
2026 AC_SUBST(NCURSES_MAJOR)
2027 AC_SUBST(NCURSES_MINOR)
2028 AC_SUBST(NCURSES_PATCH)
2029 dnl We need these values in the generated makefiles
2030 AC_SUBST(cf_cv_rel_version)
2031 AC_SUBST(cf_cv_abi_version)
2032 AC_SUBST(cf_cv_cc_bool_type)
2033 AC_SUBST(cf_cv_builtin_bool)
2034 AC_SUBST(cf_cv_type_of_bool)dnl
2035 ])dnl
2036 dnl ---------------------------------------------------------------------------
2037 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2038 dnl older SCO configurations.
2039 AC_DEFUN([CF_SYS_TIME_SELECT],
2040 [
2041 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2042 AC_CACHE_VAL(cf_cv_sys_time_select,[
2043 AC_TRY_COMPILE([
2044 #include <sys/types.h>
2045 #if HAVE_SYS_TIME_H
2046 #include <sys/time.h>
2047 #endif
2048 #if HAVE_SYS_SELECT_H
2049 #include <sys/select.h>
2050 #endif
2051 ],[],[cf_cv_sys_time_select=yes],
2052      [cf_cv_sys_time_select=no])
2053      ])
2054 AC_MSG_RESULT($cf_cv_sys_time_select)
2055 test $cf_cv_sys_time_select = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
2056 ])dnl
2057 dnl ---------------------------------------------------------------------------
2058 dnl Determine the type we should use for chtype (and attr_t, which is treated
2059 dnl as the same thing).  We want around 32 bits, so on most machines want a
2060 dnl long, but on newer 64-bit machines, probably want an int.  If we're using
2061 dnl wide characters, we have to have a type compatible with that, as well.
2062 AC_DEFUN([CF_TYPEOF_CHTYPE],
2063 [
2064 AC_REQUIRE([CF_UNSIGNED_LITERALS])
2065 AC_MSG_CHECKING([for type of chtype])
2066 AC_CACHE_VAL(cf_cv_typeof_chtype,[
2067                 AC_TRY_RUN([
2068 #if USE_WIDEC_SUPPORT
2069 #include <stddef.h>     /* we want wchar_t */
2070 #define WANT_BITS 39
2071 #else
2072 #define WANT_BITS 31
2073 #endif
2074 #include <stdio.h>
2075 int main()
2076 {
2077         FILE *fp = fopen("cf_test.out", "w");
2078         if (fp != 0) {
2079                 char *result = "long";
2080 #if USE_WIDEC_SUPPORT
2081                 /*
2082                  * If wchar_t is smaller than a long, it must be an int or a
2083                  * short.  We prefer not to use a short anyway.
2084                  */
2085                 if (sizeof(unsigned long) > sizeof(wchar_t))
2086                         result = "int";
2087 #endif
2088                 if (sizeof(unsigned long) > sizeof(unsigned int)) {
2089                         int n;
2090                         unsigned int x;
2091                         for (n = 0; n < WANT_BITS; n++) {
2092                                 unsigned int y = (x >> n);
2093                                 if (y != 1 || x == 0) {
2094                                         x = 0;
2095                                         break;
2096                                 }
2097                         }
2098                         /*
2099                          * If x is nonzero, an int is big enough for the bits
2100                          * that we want.
2101                          */
2102                         result = (x != 0) ? "int" : "long";
2103                 }
2104                 fputs(result, fp);
2105                 fclose(fp);
2106         }
2107         exit(0);
2108 }
2109                 ],
2110                 [cf_cv_typeof_chtype=`cat cf_test.out`],
2111                 [cf_cv_typeof_chtype=long],
2112                 [cf_cv_typeof_chtype=long])
2113                 rm -f cf_test.out
2114         ])
2115 AC_MSG_RESULT($cf_cv_typeof_chtype)
2116
2117 AC_SUBST(cf_cv_typeof_chtype)
2118 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
2119
2120 cf_cv_1UL="1"
2121 test "$cf_cv_unsigned_literals" = yes && cf_cv_1UL="${cf_cv_1UL}U"
2122 test "$cf_cv_typeof_chtype"    = long && cf_cv_1UL="${cf_cv_1UL}L"
2123 AC_SUBST(cf_cv_1UL)
2124
2125 ])dnl
2126 dnl ---------------------------------------------------------------------------
2127 dnl
2128 AC_DEFUN([CF_TYPE_SIGACTION],
2129 [
2130 AC_MSG_CHECKING([for type sigaction_t])
2131 AC_CACHE_VAL(cf_cv_type_sigaction,[
2132         AC_TRY_COMPILE([
2133 #include <signal.h>],
2134                 [sigaction_t x],
2135                 [cf_cv_type_sigaction=yes],
2136                 [cf_cv_type_sigaction=no])])
2137 AC_MSG_RESULT($cf_cv_type_sigaction)
2138 test $cf_cv_type_sigaction = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
2139 ])dnl
2140 dnl ---------------------------------------------------------------------------
2141 dnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
2142 dnl won't, but they're still there.
2143 AC_DEFUN([CF_UNSIGNED_LITERALS],
2144 [
2145 AC_MSG_CHECKING([if unsigned literals are legal])
2146 AC_CACHE_VAL(cf_cv_unsigned_literals,[
2147         AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
2148                 [cf_cv_unsigned_literals=yes],
2149                 [cf_cv_unsigned_literals=no])
2150         ])
2151 AC_MSG_RESULT($cf_cv_unsigned_literals)
2152 ])dnl
2153 dnl ---------------------------------------------------------------------------
2154 dnl Make an uppercase version of a variable
2155 dnl $1=uppercase($2)
2156 AC_DEFUN([CF_UPPER],
2157 [
2158 changequote(,)dnl
2159 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
2160 changequote([,])dnl
2161 ])dnl
2162 dnl ---------------------------------------------------------------------------
2163 dnl Compute the shift-mask that we'll use for wide-character indices.  We use
2164 dnl all but the index portion of chtype for storing attributes.
2165 AC_DEFUN([CF_WIDEC_SHIFT],
2166 [
2167 AC_REQUIRE([CF_TYPEOF_CHTYPE])
2168 AC_MSG_CHECKING([for number of bits in chtype])
2169 AC_CACHE_VAL(cf_cv_shift_limit,[
2170         AC_TRY_RUN([
2171 #include <stdio.h>
2172 int main()
2173 {
2174         FILE *fp = fopen("cf_test.out", "w");
2175         if (fp != 0) {
2176                 int n;
2177                 unsigned TYPEOF_CHTYPE x = 1L;
2178                 for (n = 0; ; n++) {
2179                         unsigned long y = (x >> n);
2180                         if (y != 1 || x == 0)
2181                                 break;
2182                         x <<= 1;
2183                 }
2184                 fprintf(fp, "%d", n);
2185                 fclose(fp);
2186         }
2187         exit(0);
2188 }
2189                 ],
2190                 [cf_cv_shift_limit=`cat cf_test.out`],
2191                 [cf_cv_shift_limit=32],
2192                 [cf_cv_shift_limit=32])
2193                 rm -f cf_test.out
2194         ])
2195 AC_MSG_RESULT($cf_cv_shift_limit)
2196 AC_SUBST(cf_cv_shift_limit)
2197
2198 AC_MSG_CHECKING([for width of character-index])
2199 AC_CACHE_VAL(cf_cv_widec_shift,[
2200 if test ".$with_widec" = ".yes" ; then
2201         cf_attrs_width=39
2202         if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null )
2203         then
2204                 cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width`
2205         else
2206                 cf_cv_widec_shift=16
2207         fi
2208 else
2209         cf_cv_widec_shift=8
2210 fi
2211 ])
2212 AC_MSG_RESULT($cf_cv_widec_shift)
2213 AC_SUBST(cf_cv_widec_shift)
2214 ])dnl
2215 dnl ---------------------------------------------------------------------------
2216 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
2217 dnl defaulting to yes/no.
2218 dnl
2219 dnl $1 = option name
2220 dnl $2 = help-text
2221 dnl $3 = environment variable to set
2222 dnl $4 = default value, shown in the help-message, must be a constant
2223 dnl $5 = default value, if it's an expression & cannot be in the help-message
2224 dnl
2225 AC_DEFUN([CF_WITH_PATH],
2226 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2227 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2228 CF_PATH_SYNTAX(withval)
2229 eval $3="$withval"
2230 AC_SUBST($3)dnl
2231 ])dnl
2232 dnl ---------------------------------------------------------------------------
2233 dnl Process an option specifying a list of colon-separated paths.
2234 dnl
2235 dnl $1 = option name
2236 dnl $2 = help-text
2237 dnl $3 = environment variable to set
2238 dnl $4 = default value, shown in the help-message, must be a constant
2239 dnl $5 = default value, if it's an expression & cannot be in the help-message
2240 dnl
2241 AC_DEFUN([CF_WITH_PATHLIST],[
2242 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2243 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2244
2245 IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2246 cf_dst_path=
2247 for cf_src_path in $withval
2248 do
2249   CF_PATH_SYNTAX(cf_src_path)
2250   test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
2251   cf_dst_path="${cf_dst_path}${cf_src_path}"
2252 done
2253 IFS="$ac_save_ifs"
2254
2255 eval $3="$cf_dst_path"
2256 AC_SUBST($3)dnl
2257 ])dnl