1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
dnl Process this file with autoconf to produce a configure script.
AC_INIT(cccp.c)
dnl Specify the autoconf file.
AC_CONFIG_HEADER(autoconfig.h)
dnl Check if we are forced to use the cxref-cpp
WITH_CXREF_CPP=test
AC_ARG_WITH(cxref-cpp,
[ --with-cxref-cpp use the supplied cpp instead of trying to use gcc],
[if test "$withval" = "yes"; then WITH_CXREF_CPP=yes; fi
if test "$withval" = "no"; then WITH_CXREF_CPP=no; fi])
dnl Checks for programs.
AC_PROG_CC
AC_PROG_YACC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_EGREP
dnl Checks for libraries.
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(fcntl.h locale.h stdlib.h string.h strings.h time.h unistd.h)
AC_CHECK_HEADERS(sys/param.h sys/stat.h sys/time.h sys/wait.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_STRUCT_TM
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
dnl Checks for library functions.
AC_CHECK_FUNCS(bcmp bcopy bzero index rindex strerror strsignal)
dnl Check the gcc version
if test ! "x$GCC" = "x" ; then
AC_MSG_CHECKING([if installed gcc is new enough to use instead of cxref-cpp])
AC_TRY_RUN([
int main()
{
#if defined(__GNUC__) && ( ( __GNUC__==2 && __GNUC_MINOR__>=8 ) || __GNUC__>=3 )
exit(0);
#else
exit(1);
#endif
}
],
[newGCC=yes])
if test "$WITH_CXREF_CPP" = "no" ; then
if test "x$newGCC" = "x" ; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([the '--without-cxref-cpp' option was used but gcc is not suitable])
else
AC_MSG_RESULT([yes, ignoring further checks due to '--without-cxref-cpp' option])
fi
elif test "x$newGCC" = "x" || test "$WITH_CXREF_CPP" = "yes" ; then
if test "x$newGCC" = "x" ; then
AC_MSG_RESULT([no, using cxref-cpp])
else
AC_MSG_RESULT([yes, but '--with-cxref-cpp' option overrides this])
fi
CXREF_CPP=cxref-cpp
else
AC_MSG_RESULT(yes)
AC_MSG_CHECKING([if installed gcc preserves comments after define statements])
echo "#define foo bar /* FIND-ME */" | $CC -E -C - > ./conftest.gcc
if $EGREP -e FIND-ME ./conftest.gcc > /dev/null 2>&1 ; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT([no, using cxref-cpp])
CXREF_CPP=cxref-cpp
fi
rm ./conftest.gcc
AC_MSG_CHECKING([if installed gcc preserves comments after include statements])
touch conftest.h
echo "#include \"conftest.h\" /* FIND-ME */" | $CC -E -C - > ./conftest.gcc
if $EGREP -e FIND-ME ./conftest.gcc > /dev/null 2>&1 ; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT([no, using cxref-cpp])
CXREF_CPP=cxref-cpp
fi
rm ./conftest.h ./conftest.gcc
fi
else
AC_MSG_WARN(-----------------------------------------------------)
AC_MSG_WARN(The C compiler is not gcc, you may have problems! )
AC_MSG_WARN(read the file cpp/README and cpp/cxref-cpp-configure.)
AC_MSG_WARN(-----------------------------------------------------)
CXREF_CPP=cxref-cpp
fi
AC_SUBST(CXREF_CPP)
AC_SUBST(GCC)
dnl Create the output files.
AC_OUTPUT(Makefile)
AC_OUTPUT(cxref-cpp-configure)
chmod 755 cxref-cpp-configure
|