1dnl This is the input file which autoconf uses to construct a
2dnl "configure" script for the tecla library. It is a bourne shell
3dnl script which autoconf pre-processes with the m4 preprocessor to
4dnl expand autoconf-defined m4 macros such as AC_INIT().  The
5dnl following line just initializes autoconf. Autoconf interprets the
6dnl single argument as the name of an arbitrary file, which it uses to
7dnl ensure that it is being run correctly from the directory which
8dnl contains the libtecla source code.
9
10AC_INIT(getline.c)
11
12dnl Here we set the major version number of the tecla library.
13dnl Incrementing this number implies that a change has been made to
14dnl the library's public interface, which makes it binary incompatible
15dnl with programs that were linked with previous shared versions of
16dnl the tecla library.  Incompatible changes of this type should be
17dnl avoided at all costs, so it is hoped that the major version number
18dnl won't ever have to change. The major version number must be a
19dnl small integer number, preferably a single numeric digit.
20
21AC_SUBST(MAJOR_VER)
22MAJOR_VER="1"
23
24dnl Set the minor version number of the tecla library. This number
25dnl should be incremented by one whenever additional functionality,
26dnl such as new functions or modules, are added to the library. The
27dnl idea is that a program that was linked with a shared library of
28dnl the same major version number, but a lower minor version number,
29dnl will continue to function when the run-time loader links it
30dnl against the updated version.  The minor version number must be a
31dnl small integer number, which should be reset to 0 whenever the
32dnl major version number is incremented.
33
34AC_SUBST(MINOR_VER)
35MINOR_VER="6"
36
37dnl Set the micro version number of the tecla library. This is
38dnl incremented whenever modifications to the library are made which
39dnl make no changes to the public interface, but which fix bugs and/or
40dnl improve the behind-the-scenes implementation.  The micro version
41dnl number should be reset to 0 whenever the minor version number is
42dnl incremented.  The micro version number must be a small integer
43dnl number.
44
45AC_SUBST(MICRO_VER)
46MICRO_VER="3"
47
48dnl The AC_PROG_CC line looks for a C compiler, and if gcc is chosen,
49dnl sets the $GCC shell variable to "yes". Make sure that CFLAGS is
50dnl set to something first, to prevent AC_PROG_CC from substituting -g
51dnl for the optimization level.
52
53CFLAGS="$CFLAGS"
54AC_PROG_CC
55
56dnl Apparently not all implementations of the 'make' command define
57dnl the MAKE variable. The following directive creates a variable
58dnl called SET_MAKE which when expanded in a makefile is either empty
59dnl if the local 'make' command was found to define the MAKE variable,
60dnl or contains an assignment which will give the MAKE variable the
61dnl value 'make'.
62
63AC_PROG_MAKE_SET
64
65dnl The following directive causes autoconf to see if symbolic links
66dnl are supported on the current filesystem. If so, it sets the
67dnl variable LN_S to "ln -s". Otherwise it sets LN_S to just "ln".
68dnl This allows us to create symbolic links where possible, but falls
69dnl back to creating hard links where symbolic links aren't available.
70
71AC_PROG_LN_S
72
73dnl The following macro searches for the best implementation of awk
74dnl on the host system, and records it in the AWK shell variable.
75
76AC_PROG_AWK
77
78dnl If ranlib is needed on the target system, the RANLIB make variable
79dnl is set to ranlib. Otherwise it is set to :, which is the do-nothing
80dnl command of the bourne shell.
81dnl Note that we do not use AC_PROG_RANLIB because (at least in
82dnl autoconf 2.53) this does not check for cross-compilation.
83
84AC_CHECK_TOOL(RANLIB, ranlib)
85
86dnl Set LD as appropriate, especially when cross-compiling
87
88AC_CHECK_TOOL(LD, ld)
89
90dnl The following directive tells autoconf to figure out the target
91dnl system type and assign a canonical name for this to the $target
92dnl shell variable. This is used below in the target-specific case
93dnl statement.
94
95AC_CANONICAL_SYSTEM
96
97dnl In early versions of Solaris, some libraries are in /usr/ccs/lib,
98dnl where gcc doesn't look. The tests below for the curses library
99dnl would thus fail without this directory being added to the search
100dnl path. We thus add it here before the tests. Note that in the
101dnl following, since [ and ] are m4 quotes, and m4 will remove the
102dnl outermost quotes when it processes this file, we have to double
103dnl them up here to get [0-6] to appear in the output configure
104dnl script.
105
106case $target_os in
107solaris2.[[0-6]]|solaris2.[[0-6]].*)
108  LIBS="$LIBS -L/usr/ccs/lib"
109  ;;
110esac
111
112dnl Recent versions of gcc place /usr/local/include at the head of the
113dnl system include-file search path. This causes problems when include
114dnl files that have the same name as standard system include files are
115dnl placed in this directory by third-party packages. To avoid this,
116dnl move /usr/local/include to the end of the search path.
117
118if test "$GCC"_ = "yes"_; then
119  touch foo.c
120  fix=`$CC -E -Wp,-v foo.c 2>&1 | $AWK '
121    /^#include <...> search starts here:/ {in_list=1;ndir=0}
122    / *\// && in_list {path[[ndir++]] = $1}
123    /^End of search list/ {in_list=0}
124    END {
125      if(path[[0]] ~ /\/usr\/local\/include/) {
126        for(dir=1; dir<ndir; dir++) {
127          printf(" -isystem %s", path[[dir]])
128        }
129        printf("\n");
130      }
131    }'`
132  rm -f foo.c
133  CFLAGS="$CFLAGS$fix"
134fi
135
136dnl The following lines look for terminfo functions in the normal
137dnl curses library. If not found, they are searched for in the GNU
138dnl ncurses library. If the terminfo functions still aren't found,
139dnl then termcap functions are searched for in the curses library.  If
140dnl either set of functions is found, the corresponding variable
141dnl USE_TERMINFO or USE_TERMCAP is arranged to be defined in CFLAGS,
142dnl via the exported DEFINES shell variable, and the library in which
143dnl they were found is appended to the LIBS shell variable.
144
145AC_CHECK_LIB(curses, tigetstr, [
146  AC_DEFINE(USE_TERMINFO)
147  LIBS="$LIBS -lcurses"
148], [AC_CHECK_LIB(ncurses, tigetstr, [
149  AC_DEFINE(USE_TERMINFO)
150  LIBS="$LIBS -lncurses"
151], [AC_CHECK_LIB(curses, tgetstr, [
152  AC_DEFINE(USE_TERMCAP)
153  LIBS="$LIBS -lcurses"
154  AC_CHECK_HEADER(termcap.h, AC_DEFINE(HAVE_TERMCAP_H))
155])])])
156
157dnl Search for the curses.h and term.h header files, first in the
158dnl standard system-include directories, and then if not found there,
159dnl in any ncurses subdirectories of these directories. If found, have
160dnl CFLAGS define C macros such as HAVE_TERM_H or HAVE_NCURSES_TERM_H.
161dnl Note that on some systems trying to compile term.h without first
162dnl including curses.h causes complaints, so when checking for term.h
163dnl we tell AC_CHECK_HEADERS() to include curses.h in the test file
164dnl that it attempts to compile.
165
166AC_CHECK_HEADERS(curses.h, [AC_CHECK_HEADERS(term.h,[],[],[#include <curses.h>])], [AC_CHECK_HEADERS(ncurses/curses.h, [AC_CHECK_HEADERS(ncurses/term.h,[],[],[#include <ncurses/curses.h>])])])
167
168dnl The following variable lists the targets that will be created if
169dnl the user runs make without any arguments. Initially we assume
170dnl that we can create both the normal and the reentrant versions
171dnl of the library.
172
173AC_SUBST(TARGETS)
174TARGETS="normal reentrant"
175
176dnl Check for reentrant functions by attempting to compile and link a
177dnl temporary program which calls them, being sure to include the
178dnl appropriate headers and define _POSIX_C_SOURCE, just in case any
179dnl of the functions are defined as macros. In the following,
180dnl AC_CACHE_CHECK outputs the message "checking for reentrant
181dnl functions". If this check has been done before, it assigns the
182dnl cached yes/no value to tecla_cv_reentrant.  Otherwise it uses
183dnl AC_TRY_LINK() to attempt to compile and link the specified dummy
184dnl program, and sets tecla_cv_reentrant to yes or no, depending on
185dnl whether this succeeds. Finally it caches the value of
186dnl tecla_cv_reentrant in the file config.cache, and writes "yes" or
187dnl "no" to the terminal.
188
189AC_CACHE_CHECK(for reentrant functions, tecla_cv_reentrant, [
190  KEPT_CFLAGS="$CFLAGS"
191  CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199506L"
192  AC_TRY_LINK([
193#include <unistd.h>
194#include <sys/types.h>
195#include <sys/stat.h>
196#include <dirent.h>
197#include <pwd.h>
198  ], [
199    (void) readdir_r(NULL, NULL, NULL);
200    (void) getpwuid_r(geteuid(), NULL, NULL, 0, NULL);
201    (void) getpwnam_r(NULL, NULL, NULL, 0, NULL);
202  ], tecla_cv_reentrant=yes, tecla_cv_reentrant=no)
203  CFLAGS="$KEPT_CFLAGS"
204])
205
206dnl If the necessary reentrant functions weren't found to be
207dnl available, default to only compiling the non-reentrant version of
208dnl the library.
209
210if test $tecla_cv_reentrant = no; then
211  TARGETS="normal"
212fi
213
214dnl If sys/select.h exists, arrange for the HAVE_SYS_SELECT_H C-macro to
215dnl be defined when compiling the library.
216
217AC_CHECK_HEADER(sys/select.h, AC_DEFINE(HAVE_SYS_SELECT_H))
218
219dnl Check for the select system call with the normal arguments,
220dnl by attempting to compile and link a temporary program which
221dnl calls it, being sure to include the appropriate headers.
222dnl In the following, AC_CACHE_CHECK outputs the message
223dnl "checking for select system call". If this check has been done
224dnl before, it assigns the cached yes/no value to tecla_cv_select.
225dnl Otherwise it uses AC_TRY_LINK() to attempt to compile and link
226dnl the specified dummy program, and sets tecla_cv_select to yes
227dnl or no, depending on whether this succeeds. Finally it caches
228dnl the value of tecla_cv_select in the file config.cache, and
229dnl writes "yes" or "no" to the terminal.
230
231AC_CACHE_CHECK(for select system call, tecla_cv_select, [
232  AC_TRY_LINK([
233#include <sys/time.h>
234#include <sys/types.h>
235#include <unistd.h>
236#ifdef HAVE_SYS_SELECT_H
237#include <sys/select.h>
238#endif
239  ], [
240    fd_set fds;
241    int nready;
242    FD_ZERO(&fds);
243    FD_SET(1, &fds);
244    nready = select(2, &fds, &fds, &fds, NULL);
245  ], tecla_cv_select=yes, tecla_cv_select=no)
246])
247
248dnl If the select function was available, arrange for HAVE_SELECT to
249dnl be defined by CFLAGS.
250
251if test $tecla_cv_select = yes; then
252  AC_DEFINE(HAVE_SELECT)
253fi
254
255dnl Check if this system supports the system V pseudo terminal interface.
256
257AC_CACHE_CHECK(for SysV pseudo-terminals, tecla_cv_sysv_pty, [
258  AC_TRY_LINK([
259#include <stdlib.h>
260#include <unistd.h>
261  ], [
262    char *name = ptsname(0);
263    int i1 = grantpt(0);
264    int i2 = unlockpt(0);
265    return 0;
266  ], tecla_cv_sysv_pty=yes, tecla_cv_sysv_pty=no)
267])
268
269dnl If the system-V pseudo-terminal interface is available, arrange
270dnl for HAVE_SYSV_PTY to be defined by CFLAGS.
271
272if test $tecla_cv_sysv_pty = yes; then
273  AC_DEFINE(HAVE_SYSV_PTY)
274fi
275
276dnl Check if this system uses the system-V streams pseudo terminal interface.
277
278AC_CACHE_CHECK(for SysV streams pseudo-terminals, tecla_cv_sysv_ptem, [
279  AC_TRY_LINK([
280#include <stdlib.h>
281#include <unistd.h>
282#include <stropts.h>
283  ], [
284    char *name = ptsname(0);
285    int i1 = grantpt(0);
286    int i2 = unlockpt(0);
287    int i3 = ioctl(0, I_PUSH, "ptem");
288    int i4 = ioctl(fd, I_PUSH, "ldterm");
289    return 0;
290  ], tecla_cv_sysv_ptem=yes, tecla_cv_sysv_ptem=no)
291])
292
293dnl If the system-V pseudo-terminal interface is available, arrange
294dnl for HAVE_SYSV_PTEM to be defined by CFLAGS.
295
296if test $tecla_cv_sysv_ptem = yes; then
297  AC_DEFINE(HAVE_SYSV_PTEM)
298fi
299
300dnl The following variable contains the extension to append to
301dnl "libtecla" and "libtecla_r" when creating shared libraries on the
302dnl target platform.  This is system dependent and is ignored if
303dnl LINK_SHARED remains an empty string. On most platforms that
304dnl support shared libaries, this will be .so.$MAJOR_VER, where
305dnl MAJOR_VER is the major version number described above, which on
306dnl some systems, tells the run-time loader if the program being
307dnl loaded is binary compatible with a given version of the library
308dnl (see the discussion of MAJOR_VER near the top of this file).
309dnl The following empty default can be overriden on a system by system
310dnl basis later in this file.
311
312AC_SUBST(SHARED_EXT)
313SHARED_EXT=""
314
315dnl When a shared library is installed with the extension $SHARED_EXT,
316dnl you can optionally produce other copies of this library with
317dnl different extensions. This is done using symbolic or hard links,
318dnl depending on what is available on the current filesystem, and the
319dnl extensions to use for these links are listed in the following
320dnl variable, separated by spaces. The following empty default can be
321dnl overriden on a system by system basis later in this file.
322
323AC_SUBST(SHARED_ALT)
324SHARED_ALT=""
325
326dnl The following variable lists extra compilation flags needed to
327dnl create object files that can be included in shared libraries.
328dnl Normally one would include a flag to tell the C compiler to
329dnl compile position-independent code. This option commonly includes
330dnl the acronym 'pic'.
331
332AC_SUBST(SHARED_CFLAGS)
333SHARED_CFLAGS=""
334
335dnl On systems that support shared libraries, the following variable
336dnl provides the command needed to make a shared library. In this
337dnl variable, $$@ will be replaced with the name of the shared
338dnl library, $$(LIB_OBJECTS) will be replaced with a space separated
339dnl list of the object files that are to be included in the library,
340dnl and libtecla$$(SUFFIX) will be the name of the library being
341dnl built, minus the system-specific extension (eg. libtecla or
342dnl libtecla_r).  If LINK_SHARED is left as an empty string, shared
343dnl library creation will not attempted. If your system supports
344dnl shared library creation, you should override the default value of
345dnl this variable in the target-specific case statement later in this
346dnl file.
347
348AC_SUBST(LINK_SHARED)
349LINK_SHARED=""
350
351dnl When compiling the reentrant version of the library, the following
352dnl compiler flags are presented to the compiler, in addition to those
353dnl that are used when compiling the non-reentrant version of the
354dnl library. The PREFER_REENTRANT macro is an internal libtecla macro
355dnl whose presence reports when the reentrant version of the library
356dnl is being compiled. This allows the code to determine when to
357dnl disable features that can't portably be implemented reentrantly,
358dnl such as username completion. The existence of the _POSIX_C_SOURCE
359dnl macro can't be reliably used for this purpose, since some systems
360dnl define it by default for all code.
361
362AC_SUBST(DEFS_R)
363DEFS_R="-D_POSIX_C_SOURCE=199506L -DPREFER_REENTRANT"
364
365dnl For man pages relating to library features, the following two
366dnl variables determine in which sub-directory of the top-level man
367dnl directory the man pages should go, and what file-name extensions
368dnl these files should have. On systems where the following defaults
369dnl are not valid, the default values should be overriden in the
370dnl target-specific case statement later in this file.
371
372AC_SUBST(LIBR_MANDIR)
373AC_SUBST(LIBR_MANEXT)
374LIBR_MANDIR="man3"
375LIBR_MANEXT="3"
376
377dnl For man pages relating to library functions, the following two
378dnl variables serve the same purpose as the previously described
379dnl LIBR_MANDIR and LIBR_MANEXT variables.
380
381AC_SUBST(FUNC_MANDIR)
382AC_SUBST(FUNC_MANEXT)
383FUNC_MANDIR="man3"
384FUNC_MANEXT="3"
385
386dnl For man pages relating to programs, the following two variables
387dnl serve the same purpose as the previously described LIBR_MANDIR
388dnl and LIBR_MANEXT variables.
389
390AC_SUBST(PROG_MANDIR)
391AC_SUBST(PROG_MANEXT)
392PROG_MANDIR="man1"
393PROG_MANEXT="1"
394
395dnl For man pages on miscellaneous topics, the following two variables
396dnl serve the same purpose as the previously described LIBR_MANDIR
397dnl and LIBR_MANEXT variables.
398
399AC_SUBST(MISC_MANDIR)
400AC_SUBST(MISC_MANEXT)
401MISC_MANDIR="man7"
402MISC_MANEXT="7"
403
404dnl For man pages relating to configuration files, the following two
405dnl variables serve the same purpose as the previously described
406dnl LIBR_MANDIR and LIBR_MANEXT variables.
407
408AC_SUBST(FILE_MANDIR)
409AC_SUBST(FILE_MANEXT)
410FILE_MANDIR="man5"
411FILE_MANEXT="5"
412
413dnl If the application doesn't want the user to have access to the
414dnl filesystem, it can remove all action functions that list, read or
415dnl write files, by including the configuration argument
416dnl --without-file-actions.
417
418AC_ARG_WITH(file-actions, AC_HELP_STRING([--with-file-actions], [Should users of gl_get_line() have access to the filesystem (default=yes)]),
419 AC_DEFINE(HIDE_FILE_SYSTEM), )
420
421dnl If the target system either has no file-system, or file-system access
422dnl isn't needed, libtecla can be made smaller by excluding all file and
423dnl directory access code. This is done by adding the configuration
424dnl argument --without-file-system.
425
426AC_ARG_WITH(file-system, AC_HELP_STRING([--with-file-system], [Does the target have a filesystem (default=yes)]),
427 AC_DEFINE(WITHOUT_FILE_SYSTEM), )
428
429dnl The following bourne shell case statement is where system
430dnl dependencies can be added.  In particular, if your system supports
431dnl shared library creation, the following switch is the place to
432dnl configure it. To do so you will first need to find out what target
433dnl type was just assigned by the AC_CANONICAL_SYSTEM macro executed
434dnl previously.  The target type of your current system can be
435dnl determined by cd'ing to the top level directory of the tecla
436dnl distribution, and typing the command "sh config.guess". This will
437dnl report what autoconf thinks the system type is. Note that this
438dnl will be very specific, so if you know that the configuration
439dnl parameters that you are about to provide apply to different
440dnl versions of the current system type, you can express this in the
441dnl case statement by using a wild-card in place of the version
442dnl number, or by using an | alternation to list one or more version
443dnl names. Beware that autoconf uses [] as quote characters, so if you
444dnl want to use a regexp character range like [a-z], you should write
445dnl this as [[a-z]].
446
447case $target in
448*solaris*)
449  AC_DEFINE(__EXTENSIONS__)
450  SHARED_EXT=".so.${MAJOR_VER}"
451  SHARED_ALT=".so"
452  LINK_SHARED="$LD"' -G -M $$(srcdir)/libtecla.map -o $$@ -h $$(@F) -z defs -i $$(LIB_OBJECTS) $$(LIBS) -lc'
453  SHARED_CFLAGS="-Kpic"
454  case $CC in
455  */cc|cc) SHARED_CFLAGS="$SHARED_CFLAGS -xstrconst" ;;
456  esac
457  case $target_cpu in
458  sparc) SHARED_CFLAGS="$SHARED_CFLAGS -xregs=no%appl"
459  esac
460  case $target_os in
461  solaris2.[[89]]*|solaris2.1[[0-9]]*)
462    LIBR_MANEXT=3lib
463    FUNC_MANEXT=3tecla
464    LIBR_MANDIR=man$LIBR_MANEXT
465    FUNC_MANDIR=man$FUNC_MANEXT
466  esac
467  MISC_MANDIR="man5"
468  MISC_MANEXT="5"
469  FILE_MANDIR="man4"
470  FILE_MANEXT="4"
471  ;;
472*linux*)
473  SHARED_EXT=".so.${MAJOR_VER}.${MINOR_VER}.${MICRO_VER}"
474  SHARED_ALT=".so .so.${MAJOR_VER}"
475
476dnl See if the installed version of Gnu ld accepts version scripts.
477
478  AC_CACHE_CHECK([for --version-script in GNU ld], tecla_cv_gnu_ld_script, [
479    if (echo 'void dummy(void) {return;}' > dummy.c; $CC -c -fpic dummy.c; \
480         $LD -o dummy.so dummy.o -shared --version-script=$srcdir/libtecla.map) 1>&2 2>/dev/null; then
481      tecla_cv_gnu_ld_script=yes
482    else
483      tecla_cv_gnu_ld_script=no
484    fi
485    rm -f dummy.c dummy.o dummy.so
486  ])
487  if test $tecla_cv_gnu_ld_script = yes; then
488    VERSION_OPT='--version-script=$$(srcdir)/libtecla.map'
489  else
490    VERSION_OPT=''
491  fi
492
493  LINK_SHARED="$LD"' -o $$@ -soname libtecla$$(SUFFIX).so.'${MAJOR_VER}' -shared '$VERSION_OPT' $$(LIB_OBJECTS) $$(LIBS) -lc'
494  SHARED_CFLAGS="-fpic"
495
496dnl Reenable the inclusion of symbols which get undefined when POSIX_C_SOURCE
497dnl is specified.
498
499  CFLAGS="-D_SVID_SOURCE -D_BSD_SOURCE $CFLAGS"
500  ;;
501*hpux*)
502  SHARED_EXT=".${MAJOR_VER}"
503  SHARED_ALT=".sl"
504  LINK_SHARED="$LD"' -b +h $$(@F) +k +vshlibunsats -o $$@ -c libtecla.map.opt $$(LIB_OBJECTS) $$(LIBS) -lc'
505  SHARED_CFLAGS="+z"
506  MISC_MANEXT=5
507  FILE_MANEXT=4
508  MISC_MANDIR=man$MISC_MANEXT
509  FILE_MANDIR=man$FILE_MANEXT
510  ;;
511*darwin*)
512  SHARED_EXT=".${MAJOR_VER}.${MINOR_VER}.${MICRO_VER}.dylib"
513  SHARED_ALT=".dylib .${MAJOR_VER}.dylib"
514  LINK_SHARED='$(CC) -o $$@ -dynamiclib -flat_namespace -undefined suppress -compatibility_version '${MAJOR_VER}.${MINOR_VER}' -current_version '${MAJOR_VER}.${MINOR_VER}.${MICRO_VER}' -install_name '${libdir}'/$$@ $$(LIB_OBJECTS)'
515  SHARED_CFLAGS=""
516  ;;
517*dec-osf*)
518  AC_DEFINE(_OSF_SOURCE)
519  ;;
520*freebsd*)
521  SHARED_EXT=".so.${MAJOR_VER}"
522  SHARED_ALT=".so"
523  VERSION_OPT='--version-script=$$(srcdir)/libtecla.map'
524  LINK_SHARED='ld -o $$@ -soname libtecla$$(SUFFIX).so.'${MAJOR_VER}' -shared '$VERSION_OPT' $$(LIB_OBJECTS) $$(LIBS) -lc'
525  SHARED_CFLAGS="-fpic"
526  ;;
527mips-sgi-irix*)
528  DEFS_R="$DEFS_R -D_XOPEN_SOURCE=500"
529  if test "$RANLIB"_ = "_"; then
530    RANLIB=":"
531  fi
532  ;;
533esac
534
535dnl The following statement checks to see if the GNU C compiler has
536dnl been chosen instead of the normal compiler of the host operating
537dnl system. If it has, and shared library creation has been
538dnl configured, it replaces the shared-library-specific C compilation
539dnl flags with those supported by gcc. Also append the gcc run-time
540dnl library to the shared library link line.
541
542if test "$GCC"_ = "yes"_ && test "$LINK_SHARED"_ != "_" ; then
543  SHARED_CFLAGS="-fpic"
544  case $target in
545  sparc-*-solaris*)
546    SHARED_CFLAGS="$SHARED_CFLAGS -mno-app-regs"
547    ;;
548  *darwin*)
549    SHARED_CFLAGS=""
550    ;;
551  esac
552
553dnl Try to find libgcc.a. Beware that the clang compiler pretends to
554dnl be gcc and even understands -print-libgcc-file-name, but just
555dnl replies to it with "libgcc.a" without a path. This makes
556dnl compilations fail, so we have to check here whether the returned
557dnl filename actually exists, and only use it if it does.
558
559  LIBGCC="`$CC -print-libgcc-file-name 2>/dev/null`"
560  if test "$LIBGCC"_ != "_" && test -r "$LIBGCC"; then
561    LINK_SHARED="$LINK_SHARED $LIBGCC"
562  fi
563fi
564
565dnl The following variable will list which types of libraries,
566dnl "static", and possibly "shared", are to be created and installed.
567
568AC_SUBST(TARGET_LIBS)
569
570dnl If shared library creation has been configured, add shared
571dnl libraries to the list of libraries to be built.
572
573if test "$LINK_SHARED"_ != "_"; then
574  TARGET_LIBS="static shared"
575else
576  TARGET_LIBS="static"
577  LINK_SHARED="@:"
578fi
579
580dnl Set the shell variable and Makefile variable, MAKE_MAN_PAGES, to
581dnl "yes" if man pages are desired. By default they are, but if the
582dnl user specifies --with-man-pages=no or --without-man-pages, then
583dnl they won't be preprocessed by the configure script or installed
584dnl by the Makefile.
585
586AC_SUBST(MAKE_MAN_PAGES)
587AC_ARG_WITH(man-pages, AC_HELP_STRING([--with-man-pages], [Are man pages desired (default=yes)]),
588 MAKE_MAN_PAGES="$withval", MAKE_MAN_PAGES="yes")
589
590dnl Create the list of files to be generated by the configure script.
591
592OUTPUT_FILES="Makefile"
593rm -rf man/man*
594if test "$MAKE_MAN_PAGES"_ = "yes"_; then
595  for area in libr func misc prog file; do
596    for page in man/$area/*.in; do
597      OUTPUT_FILES="$OUTPUT_FILES `echo $page | sed 's/\.in$//'`"
598    done
599  done
600fi
601
602dnl The following directive must always be the last line of any
603dnl autoconf script. It causes autoconf to create the configure
604dnl script, which for each argument of AC_OUTPUT, will look for a
605dnl filename formed by appending ".in" to the argument, preprocess
606dnl that file, replacing @VAR@ directives with the corresponding value
607dnl of the specified shell variable VAR, as set above in this file,
608dnl and write the resulting output to the filename given in the
609dnl argument. Note that only shell variables that were exported above
610dnl with the AC_SUBST() directive will be substituted in @VAR@
611dnl directives (some macros like AC_PROG_CC also call AC_SUBST for you
612dnl for the variables that they output).
613
614AC_OUTPUT($OUTPUT_FILES)
615