From: Akim Demaille Date: Wed, 10 May 2000 11:47:35 +0000 (+0000) Subject: * acgeneral.m4 (AC_LIBOBJ_DECL, AC_LIBOBJ): New macros. X-Git-Tag: autoconf-2.50~938 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0591c3a3ba56deb4bd4235b9c1990a59a99d6ca7;p=thirdparty%2Fautoconf.git * acgeneral.m4 (AC_LIBOBJ_DECL, AC_LIBOBJ): New macros. (AC_REPLACE_FUNCS): Use AC_LIBOBJ. * acspecific.m4 (AC_FUNC_MKTIME, AC_FUNC_MEMCMP, AC_STRUCT_ST_BLOCKS): Use AC_LIBOBJ. * doc/autoconf.texi : Adjust so that the user is not encouraged to use LIBOBJS directly. (Generic Functions): Document AC_LIBOBJ_DECL and AC_LIBOBJ. --- diff --git a/ChangeLog b/ChangeLog index e8674c2cf..e554e9bd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2000-05-10 Akim Demaille + + * acgeneral.m4 (AC_LIBOBJ_DECL, AC_LIBOBJ): New macros. + (AC_REPLACE_FUNCS): Use AC_LIBOBJ. + * acspecific.m4 (AC_FUNC_MKTIME, AC_FUNC_MEMCMP, + AC_STRUCT_ST_BLOCKS): Use AC_LIBOBJ. + * doc/autoconf.texi : Adjust so that the user is not encouraged to + use LIBOBJS directly. + (Generic Functions): Document AC_LIBOBJ_DECL and AC_LIBOBJ. + 2000-05-09 Jim Meyering * acgeneral.m4 (AC_SEARCH_LIBS): Remove double quotes around `no'. diff --git a/acgeneral.m4 b/acgeneral.m4 index cce58e2b7..2262dc664 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -3159,11 +3159,30 @@ done ]) +# AC_LIBOBJ_DECL(FILENAME-NOEXT) +# ------------------------------ +# Announce we might need the file `FILENAME-NOEXT.c'. +define([AC_LIBOBJ_DECL], []) + + +# AC_LIBOBJ(FILENAME-NOEXT) +# ------------------------- +# We need `FILENAME-NOEXT.o', save this into `LIBOBJS'. +# We don't use AC_SUBST/2 because it forces an unneeded eol. +define([AC_LIBOBJ], +[AC_VAR_IF_INDIR([$1], + [AC_DIAGNOSE(syntax, + [$0: you should use literals])], + [AC_LIBOBJ_DECL([$1])])dnl +AC_SUBST([LIBOBJS])dnl +LIBOBJS="$LIBOBJS $1.${ac_objext}"]) + + # AC_REPLACE_FUNCS(FUNCTION...) # ----------------------------- -AC_DEFUN(AC_REPLACE_FUNCS, -[AC_CHECK_FUNCS([$1], , [LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"]) -AC_SUBST(LIBOBJS)dnl +AC_DEFUN([AC_REPLACE_FUNCS], +[AC_FOREACH([AC_Func], [$1], [AC_LIBOBJ_DECL(AC_Func)])dnl +AC_CHECK_FUNCS([$1], , [AC_LIBOBJ(${ac_func})]) ]) diff --git a/acspecific.m4 b/acspecific.m4 index 1abf790c5..d91916352 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -1194,7 +1194,7 @@ main () ac_cv_func_working_mktime=yes, ac_cv_func_working_mktime=no, ac_cv_func_working_mktime=no)]) if test $ac_cv_func_working_mktime = no; then - LIBOBJS="$LIBOBJS mktime.${ac_objext}" + AC_LIBOBJ([mktime]) fi AC_SUBST(LIBOBJS)dnl ])# AC_FUNC_MKTIME @@ -1359,8 +1359,7 @@ main() && memcmp(&c1, &c2, 1) < 0 ? 0 : 1); }], ac_cv_func_memcmp_clean=yes, ac_cv_func_memcmp_clean=no, ac_cv_func_memcmp_clean=no)]) -test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" -AC_SUBST(LIBOBJS)dnl +test $ac_cv_func_memcmp_clean = no && AC_LIBOBJ([memcmp]) ])# AC_FUNC_MEMCMP @@ -1795,7 +1794,7 @@ AC_CHECK_MEMBERS((struct stat.st_blksize), # # AC_OBSOLETE([$0], [; replace it with # AC_CHECK_MEMBERS((struct stat.st_blocks), -# LIBOBJS="$LIBOBJS fileblocks.${ac_objext}") +# [AC_LIBOBJ([fileblocks])]) # Please note that it will define `HAVE_STRUCT_STAT_ST_BLOCKS', # and not `HAVE_ST_BLOCKS'.])dnl # @@ -1805,8 +1804,7 @@ AC_DEFUN(AC_STRUCT_ST_BLOCKS, [Define if your `struct stat' has `st_blocks'. Deprecated, use `HAVE_STRUCT_STAT_ST_BLOCKS' instead.])], - [LIBOBJS="$LIBOBJS fileblocks.${ac_objext}" -AC_SUBST(LIBOBJS)], + [AC_LIBOBJ([fileblocks])], [#include #include ])dnl diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 2a8914dec..8fad5f773 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -2834,7 +2834,6 @@ return value for an error indicator. @defmac AC_FUNC_FNMATCH @maindex FUNC_FNMATCH -@ovindex LIBOBJS If the @code{fnmatch} function is available and works (unlike the one on SunOS 5.4), define @code{HAVE_FNMATCH}. @end defmac @@ -2856,8 +2855,8 @@ Check how to get the system load averages. If the system has the @code{getloadavg} function, this macro defines @code{HAVE_GETLOADAVG}, and adds to @code{LIBS} any libraries needed to get that function. -Otherwise, it adds @samp{getloadavg.o} to the output variable -@code{LIBOBJS}, and possibly defines several other C preprocessor +Otherwise, it requires an @code{AC_LIBOBJ} replacement of +@samp{getloadavg}, and possibly defines several other C preprocessor macros and output variables: @enumerate @@ -2908,15 +2907,15 @@ first call @code{AC_CHECK_FUNC} for @code{getpgrp}. @maindex FUNC_MEMCMP @ovindex LIBOBJS If the @code{memcmp} function is not available, or does not work on -8-bit data (like the one on SunOS 4.1.3), add @samp{memcmp.o} to output -variable @code{LIBOBJS}. +8-bit data (like the one on SunOS 4.1.3), require an @code{AC_LIBOBJ} +replacement for @samp{memcmp}. @end defmac @defmac AC_FUNC_MKTIME @maindex FUNC_MKTIME @ovindex LIBOBJS If the @code{mktime} function is not available, or does not work -correctly, add @samp{mktime.o} to output variable @code{LIBOBJS}. +correctly, require an @code{AC_LIBOBJ} replacement for @samp{mktime}. @end defmac @defmac AC_FUNC_MMAP @@ -3045,16 +3044,62 @@ execute when one of the functions is found. You can give it a value of functions is not found. @end defmac +Autoconf follows a philosophy which was hammered along the years by the +people who fought for portability: isolate the portability issues in +specific files, and program as if you were on a @sc{posix} host. Some +functions cannot be repaired or are completely missing, your package +must be ready to replace them. + +Use the two following macros to specify the function which might be +replaced, and use the third one to check and replace a function if +needed. + +@defmac AC_LIBOBJ (@var{function}) +@maindex LIBOBJ +@ovindex LIBOBJS +Specify that @samp{@var{function}.c} must be included in the executables +to replace a missing or broken implementation of @var{function}. + +Technically it adds @samp{@var{function}.$@{ac_objext@}} to the output +variable @code{LIBOBJS}, nevertheless you must not directly change +@code{LIBOBJS} since this is not traceable. +@end defmac + +@defmac AC_LIBOBJ_DECL (@var{function}) +@maindex LIBOBJ_DECL +@ovindex LIBOBJS +Specify that @samp{@var{function}.c} might be needed to compile the +project. You must use this macro when you are calling @code{AC_LIBOBJ} +with a shell variable, since shell variables cannot be traced +statically. @var{function} must be a literal. + +For instance you might need to: + +@example +AC_LIBOBJ_DECL(foo) +AC_LIBOBJ_DECL(bar) +AC_LIBOBJ($foo_or_bar) +@end example + +@noindent +nevertheless, there is always a means to avoid this, and you are +encouraged to always uses literals with @code{AC_LIBOBJ}. + +Conversely, if you need to know what are the files that might be needed +by a @file{configure.in}, you should trace @code{AC_LIBOBJ_DECL}. +@end defmac + + @defmac AC_REPLACE_FUNCS (@var{function}@dots{}) @maindex REPLACE_FUNCS @ovindex LIBOBJS -Like calling @code{AC_CHECK_FUNCS} using an @var{action-if-not-found} -that adds @samp{@var{function}.o} to the value of the output variable -@code{LIBOBJS}. You can declare a function for which your replacement -version is used by enclosing the prototype in @samp{#if -!HAVE_@var{function}}. If the system has the function, it probably -declares it in a header file you should be including, so you shouldn't -redeclare it, lest your declaration conflict. +Like calling @code{AC_CHECK_FUNCS} using +@samp{AC_LIBOBJ(@var{function})} as @var{action-if-not-found}. You can +declare a function for which your replacement version is used by +enclosing the prototype in @samp{#if !HAVE_@var{function}}. If the +system has the function, it probably declares it in a header file you +should be including, so you shouldn't redeclare it, lest your +declaration conflict. @end defmac @node Header Files, Declarations, Library Functions, Existing Tests @@ -3455,8 +3500,8 @@ AC_CHECK_MEMBERS((struct stat.st_blksize)) @cvindex HAVE_ST_BLOCKS @ovindex LIBOBJS If @code{struct stat} contains an @code{st_blocks} member, define -@code{HAVE_STRUCT STAT_ST_BLOCKS}. Otherwise, add @samp{fileblocks.o} -to the output variable @code{LIBOBJS}. The former name, +@code{HAVE_STRUCT STAT_ST_BLOCKS}. Otherwise, require an +@code{AC_LIBOBJ} replacement of @samp{fileblocks}. The former name, @code{HAVE_ST_BLOCKS} is to be avoided, as its support will cease in the future. @end defmac diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index cce58e2b7..2262dc664 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -3159,11 +3159,30 @@ done ]) +# AC_LIBOBJ_DECL(FILENAME-NOEXT) +# ------------------------------ +# Announce we might need the file `FILENAME-NOEXT.c'. +define([AC_LIBOBJ_DECL], []) + + +# AC_LIBOBJ(FILENAME-NOEXT) +# ------------------------- +# We need `FILENAME-NOEXT.o', save this into `LIBOBJS'. +# We don't use AC_SUBST/2 because it forces an unneeded eol. +define([AC_LIBOBJ], +[AC_VAR_IF_INDIR([$1], + [AC_DIAGNOSE(syntax, + [$0: you should use literals])], + [AC_LIBOBJ_DECL([$1])])dnl +AC_SUBST([LIBOBJS])dnl +LIBOBJS="$LIBOBJS $1.${ac_objext}"]) + + # AC_REPLACE_FUNCS(FUNCTION...) # ----------------------------- -AC_DEFUN(AC_REPLACE_FUNCS, -[AC_CHECK_FUNCS([$1], , [LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"]) -AC_SUBST(LIBOBJS)dnl +AC_DEFUN([AC_REPLACE_FUNCS], +[AC_FOREACH([AC_Func], [$1], [AC_LIBOBJ_DECL(AC_Func)])dnl +AC_CHECK_FUNCS([$1], , [AC_LIBOBJ(${ac_func})]) ]) diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 1abf790c5..d91916352 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -1194,7 +1194,7 @@ main () ac_cv_func_working_mktime=yes, ac_cv_func_working_mktime=no, ac_cv_func_working_mktime=no)]) if test $ac_cv_func_working_mktime = no; then - LIBOBJS="$LIBOBJS mktime.${ac_objext}" + AC_LIBOBJ([mktime]) fi AC_SUBST(LIBOBJS)dnl ])# AC_FUNC_MKTIME @@ -1359,8 +1359,7 @@ main() && memcmp(&c1, &c2, 1) < 0 ? 0 : 1); }], ac_cv_func_memcmp_clean=yes, ac_cv_func_memcmp_clean=no, ac_cv_func_memcmp_clean=no)]) -test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}" -AC_SUBST(LIBOBJS)dnl +test $ac_cv_func_memcmp_clean = no && AC_LIBOBJ([memcmp]) ])# AC_FUNC_MEMCMP @@ -1795,7 +1794,7 @@ AC_CHECK_MEMBERS((struct stat.st_blksize), # # AC_OBSOLETE([$0], [; replace it with # AC_CHECK_MEMBERS((struct stat.st_blocks), -# LIBOBJS="$LIBOBJS fileblocks.${ac_objext}") +# [AC_LIBOBJ([fileblocks])]) # Please note that it will define `HAVE_STRUCT_STAT_ST_BLOCKS', # and not `HAVE_ST_BLOCKS'.])dnl # @@ -1805,8 +1804,7 @@ AC_DEFUN(AC_STRUCT_ST_BLOCKS, [Define if your `struct stat' has `st_blocks'. Deprecated, use `HAVE_STRUCT_STAT_ST_BLOCKS' instead.])], - [LIBOBJS="$LIBOBJS fileblocks.${ac_objext}" -AC_SUBST(LIBOBJS)], + [AC_LIBOBJ([fileblocks])], [#include #include ])dnl