From: David MacKenzie Date: Sat, 19 Mar 1994 21:49:18 +0000 (+0000) Subject: (AC_PROG_CXX, AC_PROG_CXXCPP, AC_REQUIRE_CPP): New macros based on X-Git-Tag: fsf-origin~782 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8202df5faf642cde4e5b1fa02cd9cc4411a7a477;p=thirdparty%2Fautoconf.git (AC_PROG_CXX, AC_PROG_CXXCPP, AC_REQUIRE_CPP): New macros based on work by zoo@aggregate.com (david d zuhn). (AC_DECLARE_YYTEXT): Use AC_REQUIRE_CPP. Warn that it's broken. (AC_STDC_HEADERS): Use AC_REQUIRE_CPP. (AC_MMAP): New macro from Mike Haertel and Jim Avera. --- diff --git a/acspecific.m4 b/acspecific.m4 index 8f33f39e1..bf1955723 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -39,6 +39,21 @@ fi rm -f conftest* ])dnl dnl +define(AC_PROG_CXX, +[AC_BEFORE([$0], [AC_PROG_CXXCPP])AC_PROVIDE([$0])AC_PROGRAMS_CHECK(CXX, $CCC c++ g++ gcc CC, gcc) +# Find out if we are using GNU C++, under whatever name. +cat > conftest.C < conftest.out 2>&1 +if egrep yes conftest.out >/dev/null 2>&1; then + GXX=1 # For later tests. +fi +rm -f conftest* +])dnl +dnl define(AC_GCC_TRADITIONAL, [AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])if test -n "$GCC"; then echo checking whether -traditional is needed @@ -97,7 +112,7 @@ if test -z "$CPP"; then # substituted into the Makefile and ``${CC-cc}'' will simply confuse # make. It must be expanded now. CPP="${CC-cc} -E" -dnl On the NeXT, cc -E appears to run the code through the compiler's parser, +dnl On the NeXT, cc -E runs the code through the compiler's parser, dnl not just through cpp. AC_TEST_CPP([#include Syntax Error], , @@ -110,6 +125,25 @@ test ".${ac_verbose}" != "." && echo " setting CPP to $CPP" AC_SUBST(CPP)dnl ])dnl dnl +define(AC_PROG_CXXCPP, +[AC_PROVIDE([$0])echo checking how to run the C++ preprocessor +AC_LANG_SAVE[]dnl +AC_LANG_CPLUSPLUS[]dnl +if test -z "$CXXCPP"; then + CXXCPP="${CXX-c++} -E" + AC_TEST_CPP([#include ], , CXXCPP=/lib/cpp) +fi +CXXCPP="$CXXCPP \$CXXFLAGS" +test ".${ac_verbose}" != "." && echo " setting CXXCPP to $CXXCPP" +AC_LANG_RESTORE[]dnl +AC_SUBST(CXXCPP)dnl +])dnl +dnl +dnl Require finding the C or C++ preprocessor, whichever is the +dnl current language. +define(AC_REQUIRE_CPP, +[ifelse(AC_LANG,C,[AC_REQUIRE([AC_PROG_CPP])],[AC_REQUIRE([AC_PROG_CXXCPP])])])dnl +dnl define(AC_PROG_LEX, [AC_PROVIDE([$0])AC_PROGRAM_CHECK(LEX, flex, flex, lex) if test -z "$LEXLIB" @@ -122,7 +156,9 @@ fi AC_SUBST(LEXLIB)])dnl dnl define(AC_DECLARE_YYTEXT, -[AC_REQUIRE([AC_PROG_CPP])AC_REQUIRE([AC_PROG_LEX])dnl +[AC_REQUIRE_CPP()AC_REQUIRE([AC_PROG_LEX])dnl +errprint(warning: [$0] is currently broken due to a quoting quagmire +)dnl echo checking how to declare yytext # Figure out what yytext is by creating a minimal parser and # examining the (preprocessed, in case macros are used) output. @@ -246,7 +282,7 @@ dnl checks for header files dnl dnl define(AC_STDC_HEADERS, -[AC_REQUIRE([AC_PROG_CPP])dnl +[AC_REQUIRE_CPP()dnl echo checking for ANSI C header files AC_TEST_CPP([#include #include @@ -396,6 +432,73 @@ dnl dnl checks for functions dnl dnl +define(AC_MMAP, [ +echo checking for working mmap +AC_TEST_PROGRAM([/* Thanks to Mike Haertel and Jim Avera for this test. */ +#include +#include +#include + +#ifdef BSD +#ifndef BSD4_1 +#define HAVE_GETPAGESIZE +#endif +#endif +#ifndef HAVE_GETPAGESIZE +#include +#ifdef EXEC_PAGESIZE +#define getpagesize() EXEC_PAGESIZE +#else +#ifdef NBPG +#define getpagesize() NBPG * CLSIZE +#ifndef CLSIZE +#define CLSIZE 1 +#endif /* no CLSIZE */ +#else /* no NBPG */ +#define getpagesize() NBPC +#endif /* no NBPG */ +#endif /* no EXEC_PAGESIZE */ +#endif /* not HAVE_GETPAGESIZE */ + +#ifdef __osf__ +#define valloc malloc +#endif + +extern char *valloc(); +extern char *malloc(); + +int +main() +{ + char *buf1, *buf2, *buf3; + int i = getpagesize(), j; + int i2 = getpagesize()*2; + int fd; + + buf1 = valloc(i2); + buf2 = valloc(i); + buf3 = malloc(i2); + for (j = 0; j < i2; ++j) + *(buf1 + j) = rand(); + fd = open("conftestmmap", O_CREAT | O_RDWR, 0666); + write(fd, buf1, i2); + mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0); + for (j = 0; j < i; ++j) + if (*(buf1 + j) != *(buf2 + j)) + exit(1); + lseek(fd, (long)i, 0); + read(fd, buf2, i); /* read into mapped memory -- file should not change */ + /* (it does in i386 SVR4.0 - Jim Avera) */ + lseek(fd, (long)0, 0); + read(fd, buf3, i2); + for (j = 0; j < i2; ++j) + if (*(buf1 + j) != *(buf3 + j)) + exit(1); + exit(0); +} +], AC_DEFINE(HAVE_MMAP)) +])dnl +dnl define(AC_VPRINTF, [AC_COMPILE_CHECK([vprintf], , [vprintf();], AC_DEFINE(HAVE_VPRINTF), ac_vprintf_missing=1) diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 8f33f39e1..bf1955723 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -39,6 +39,21 @@ fi rm -f conftest* ])dnl dnl +define(AC_PROG_CXX, +[AC_BEFORE([$0], [AC_PROG_CXXCPP])AC_PROVIDE([$0])AC_PROGRAMS_CHECK(CXX, $CCC c++ g++ gcc CC, gcc) +# Find out if we are using GNU C++, under whatever name. +cat > conftest.C < conftest.out 2>&1 +if egrep yes conftest.out >/dev/null 2>&1; then + GXX=1 # For later tests. +fi +rm -f conftest* +])dnl +dnl define(AC_GCC_TRADITIONAL, [AC_REQUIRE([AC_PROG_CC])AC_REQUIRE([AC_PROG_CPP])if test -n "$GCC"; then echo checking whether -traditional is needed @@ -97,7 +112,7 @@ if test -z "$CPP"; then # substituted into the Makefile and ``${CC-cc}'' will simply confuse # make. It must be expanded now. CPP="${CC-cc} -E" -dnl On the NeXT, cc -E appears to run the code through the compiler's parser, +dnl On the NeXT, cc -E runs the code through the compiler's parser, dnl not just through cpp. AC_TEST_CPP([#include Syntax Error], , @@ -110,6 +125,25 @@ test ".${ac_verbose}" != "." && echo " setting CPP to $CPP" AC_SUBST(CPP)dnl ])dnl dnl +define(AC_PROG_CXXCPP, +[AC_PROVIDE([$0])echo checking how to run the C++ preprocessor +AC_LANG_SAVE[]dnl +AC_LANG_CPLUSPLUS[]dnl +if test -z "$CXXCPP"; then + CXXCPP="${CXX-c++} -E" + AC_TEST_CPP([#include ], , CXXCPP=/lib/cpp) +fi +CXXCPP="$CXXCPP \$CXXFLAGS" +test ".${ac_verbose}" != "." && echo " setting CXXCPP to $CXXCPP" +AC_LANG_RESTORE[]dnl +AC_SUBST(CXXCPP)dnl +])dnl +dnl +dnl Require finding the C or C++ preprocessor, whichever is the +dnl current language. +define(AC_REQUIRE_CPP, +[ifelse(AC_LANG,C,[AC_REQUIRE([AC_PROG_CPP])],[AC_REQUIRE([AC_PROG_CXXCPP])])])dnl +dnl define(AC_PROG_LEX, [AC_PROVIDE([$0])AC_PROGRAM_CHECK(LEX, flex, flex, lex) if test -z "$LEXLIB" @@ -122,7 +156,9 @@ fi AC_SUBST(LEXLIB)])dnl dnl define(AC_DECLARE_YYTEXT, -[AC_REQUIRE([AC_PROG_CPP])AC_REQUIRE([AC_PROG_LEX])dnl +[AC_REQUIRE_CPP()AC_REQUIRE([AC_PROG_LEX])dnl +errprint(warning: [$0] is currently broken due to a quoting quagmire +)dnl echo checking how to declare yytext # Figure out what yytext is by creating a minimal parser and # examining the (preprocessed, in case macros are used) output. @@ -246,7 +282,7 @@ dnl checks for header files dnl dnl define(AC_STDC_HEADERS, -[AC_REQUIRE([AC_PROG_CPP])dnl +[AC_REQUIRE_CPP()dnl echo checking for ANSI C header files AC_TEST_CPP([#include #include @@ -396,6 +432,73 @@ dnl dnl checks for functions dnl dnl +define(AC_MMAP, [ +echo checking for working mmap +AC_TEST_PROGRAM([/* Thanks to Mike Haertel and Jim Avera for this test. */ +#include +#include +#include + +#ifdef BSD +#ifndef BSD4_1 +#define HAVE_GETPAGESIZE +#endif +#endif +#ifndef HAVE_GETPAGESIZE +#include +#ifdef EXEC_PAGESIZE +#define getpagesize() EXEC_PAGESIZE +#else +#ifdef NBPG +#define getpagesize() NBPG * CLSIZE +#ifndef CLSIZE +#define CLSIZE 1 +#endif /* no CLSIZE */ +#else /* no NBPG */ +#define getpagesize() NBPC +#endif /* no NBPG */ +#endif /* no EXEC_PAGESIZE */ +#endif /* not HAVE_GETPAGESIZE */ + +#ifdef __osf__ +#define valloc malloc +#endif + +extern char *valloc(); +extern char *malloc(); + +int +main() +{ + char *buf1, *buf2, *buf3; + int i = getpagesize(), j; + int i2 = getpagesize()*2; + int fd; + + buf1 = valloc(i2); + buf2 = valloc(i); + buf3 = malloc(i2); + for (j = 0; j < i2; ++j) + *(buf1 + j) = rand(); + fd = open("conftestmmap", O_CREAT | O_RDWR, 0666); + write(fd, buf1, i2); + mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0); + for (j = 0; j < i; ++j) + if (*(buf1 + j) != *(buf2 + j)) + exit(1); + lseek(fd, (long)i, 0); + read(fd, buf2, i); /* read into mapped memory -- file should not change */ + /* (it does in i386 SVR4.0 - Jim Avera) */ + lseek(fd, (long)0, 0); + read(fd, buf3, i2); + for (j = 0; j < i2; ++j) + if (*(buf1 + j) != *(buf3 + j)) + exit(1); + exit(0); +} +], AC_DEFINE(HAVE_MMAP)) +])dnl +dnl define(AC_VPRINTF, [AC_COMPILE_CHECK([vprintf], , [vprintf();], AC_DEFINE(HAVE_VPRINTF), ac_vprintf_missing=1)