From e80f6230aea18d8a7d79bfe7f87d87adb160ff61 Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Tue, 12 Mar 2002 13:13:51 +0000 Subject: Adaptions to SuSE's autoconf. --- conf/m4/kde/K_PATH_X.m4 | 125 +++++++++++- conf/m4/plptools/AC_REMOVE_FORBIDDEN.m4 | 23 +++ conf/m4/plptools/AC_VALIDIFY_CXXFLAGS.m4 | 7 + conf/m4/plptools/PLP_CHECK_COMPILERS.m4 | 299 +++++++++++++--------------- conf/m4/plptools/PLP_CHECK_COMPILER_FLAG.m4 | 27 +++ 5 files changed, 316 insertions(+), 165 deletions(-) create mode 100644 conf/m4/plptools/AC_REMOVE_FORBIDDEN.m4 create mode 100644 conf/m4/plptools/AC_VALIDIFY_CXXFLAGS.m4 create mode 100644 conf/m4/plptools/PLP_CHECK_COMPILER_FLAG.m4 (limited to 'conf') diff --git a/conf/m4/kde/K_PATH_X.m4 b/conf/m4/kde/K_PATH_X.m4 index 4e54abf..db168ee 100644 --- a/conf/m4/kde/K_PATH_X.m4 +++ b/conf/m4/kde/K_PATH_X.m4 @@ -1,3 +1,125 @@ +# KDE_PATH_X_DIRECT +dnl Internal subroutine of AC_PATH_X. +dnl Set ac_x_includes and/or ac_x_libraries. +AC_DEFUN(KDE_PATH_X_DIRECT, +[if test "$ac_x_includes" = NO; then + # Guess where to find include files, by looking for this one X11 .h file. + test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h + + # First, try using that file with no special directory specified. +AC_TRY_CPP([#include <$x_direct_test_include>], +[# We can compile using X headers with no special include directory. +ac_x_includes=], +[# Look for the header file in a standard set of common directories. +# Check X11 before X11Rn because it is often a symlink to the current release. + for ac_dir in \ + /usr/X11/include \ + /usr/X11R6/include \ + /usr/X11R5/include \ + /usr/X11R4/include \ + \ + /usr/include/X11 \ + /usr/include/X11R6 \ + /usr/include/X11R5 \ + /usr/include/X11R4 \ + \ + /usr/local/X11/include \ + /usr/local/X11R6/include \ + /usr/local/X11R5/include \ + /usr/local/X11R4/include \ + \ + /usr/local/include/X11 \ + /usr/local/include/X11R6 \ + /usr/local/include/X11R5 \ + /usr/local/include/X11R4 \ + \ + /usr/X386/include \ + /usr/x386/include \ + /usr/XFree86/include/X11 \ + \ + /usr/include \ + /usr/local/include \ + /usr/unsupported/include \ + /usr/athena/include \ + /usr/local/x11r5/include \ + /usr/lpp/Xamples/include \ + \ + /usr/openwin/include \ + /usr/openwin/share/include \ + ; \ + do + if test -r "$ac_dir/$x_direct_test_include"; then + ac_x_includes=$ac_dir + break + fi + done]) +fi # $ac_x_includes = NO + +if test "$ac_x_libraries" = NO; then + # Check for the libraries. + + test -z "$x_direct_test_library" && x_direct_test_library=Xt + test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc + + # See if we find them without any special options. + # Don't add to $LIBS permanently. + ac_save_LIBS="$LIBS" + LIBS="-l$x_direct_test_library $LIBS" +AC_TRY_LINK(, [${x_direct_test_function}()], +[LIBS="$ac_save_LIBS" +# We can link X programs with no special library path. +ac_x_libraries=], +[LIBS="$ac_save_LIBS" +# First see if replacing the include by lib works. +# Check X11 before X11Rn because it is often a symlink to the current release. +for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ + /usr/X11/lib \ + /usr/X11R6/lib \ + /usr/X11R5/lib \ + /usr/X11R4/lib \ + \ + /usr/lib/X11 \ + /usr/lib/X11R6 \ + /usr/lib/X11R5 \ + /usr/lib/X11R4 \ + \ + /usr/local/X11/lib \ + /usr/local/X11R6/lib \ + /usr/local/X11R5/lib \ + /usr/local/X11R4/lib \ + \ + /usr/local/lib/X11 \ + /usr/local/lib/X11R6 \ + /usr/local/lib/X11R5 \ + /usr/local/lib/X11R4 \ + \ + /usr/X386/lib \ + /usr/x386/lib \ + /usr/XFree86/lib/X11 \ + \ + /usr/lib \ + /usr/local/lib \ + /usr/unsupported/lib \ + /usr/athena/lib \ + /usr/local/x11r5/lib \ + /usr/lpp/Xamples/lib \ + /lib/usr/lib/X11 \ + \ + /usr/openwin/lib \ + /usr/openwin/share/lib \ + ; \ +do +dnl Don't even attempt the hair of trying to link an X program! + for ac_extension in a so sl; do + if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then + ac_x_libraries=$ac_dir + break 2 + fi + done +done]) +fi # $ac_x_libraries = NO +]) + dnl ------------------------------------------------------------------------ dnl Find the header files and libraries for X-Windows. Extended the dnl macro AC_PATH_X @@ -26,8 +148,7 @@ AC_DEFUN(K_PATH_X,[ ac_x_libraries=$kde_x_libraries ac_x_includes=$kde_x_includes - AC_PATH_X_DIRECT - AC_PATH_X_XMKMF + KDE_PATH_X_DIRECT if test -z "$ac_x_includes"; then ac_x_includes="." fi diff --git a/conf/m4/plptools/AC_REMOVE_FORBIDDEN.m4 b/conf/m4/plptools/AC_REMOVE_FORBIDDEN.m4 new file mode 100644 index 0000000..77f0dca --- /dev/null +++ b/conf/m4/plptools/AC_REMOVE_FORBIDDEN.m4 @@ -0,0 +1,23 @@ +dnl AC_REMOVE_FORBIDDEN removes forbidden arguments from variables +dnl use: AC_REMOVE_FORBIDDEN(CC, [-forbid -bad-option whatever]) +dnl it's all white-space separated +AC_DEFUN(AC_REMOVE_FORBIDDEN, +[ __val=$$1 + __forbid=" $2 " + if test -n "$__val"; then + __new="" + ac_save_IFS=$IFS + IFS=" " + for i in $__val; do + case "$__forbid" in + *" $i "*) AC_MSG_WARN([found forbidden $i in $1, removing it]) ;; + *) # Careful to not add spaces, where there were none, because otherwise + # libtool gets confused, if we change e.g. CXX + if test -z "$__new" ; then __new=$i ; else __new="$__new $i" ; fi ;; + esac + done + IFS=$ac_save_IFS + $1=$__new + fi +]) + diff --git a/conf/m4/plptools/AC_VALIDIFY_CXXFLAGS.m4 b/conf/m4/plptools/AC_VALIDIFY_CXXFLAGS.m4 new file mode 100644 index 0000000..b2b089a --- /dev/null +++ b/conf/m4/plptools/AC_VALIDIFY_CXXFLAGS.m4 @@ -0,0 +1,7 @@ +dnl AC_VALIDIFY_CXXFLAGS checks for forbidden flags the user may have given +AC_DEFUN(AC_VALIDIFY_CXXFLAGS, +[dnl + AC_REMOVE_FORBIDDEN(CXX, [-fno-rtti -rpath]) + AC_REMOVE_FORBIDDEN(CXXFLAGS, [-fno-rtti -rpath]) +]) + diff --git a/conf/m4/plptools/PLP_CHECK_COMPILERS.m4 b/conf/m4/plptools/PLP_CHECK_COMPILERS.m4 index 40eb216..b665a32 100644 --- a/conf/m4/plptools/PLP_CHECK_COMPILERS.m4 +++ b/conf/m4/plptools/PLP_CHECK_COMPILERS.m4 @@ -1,192 +1,165 @@ -dnl -dnl Check for various compiler options -dnl AC_DEFUN(PLP_CHECK_COMPILERS, [ - dnl this is somehow a fat lie, but prevents other macros from double checking - AC_PROVIDE([AC_PROG_CC]) - AC_PROVIDE([AC_PROG_CPP]) - AC_REQUIRE([PLP_HELP_MSG]) - PLP_HELP_MSG([Generic build options:]) - AC_ARG_ENABLE(debug,[ --enable-debug creates debugging code [default=no]], - [ - if test $enableval = "no"; dnl - then ac_use_debug_code="no" - else ac_use_debug_code="yes" + AC_ARG_ENABLE(debug,[ --enable-debug enables debug symbols [default=no]], + [ + if test $enableval = "no"; dnl + then + plp_use_debug_code="no" + plp_use_debug_define=yes + else + plp_use_debug_code="yes" + plp_use_debug_define=no fi - ], [ac_use_debug_code="no"]) + ], + [plp_use_debug_code="no" + plp_use_debug_define=no + ]) + + dnl Just for configure --help + AC_ARG_ENABLE(dummyoption,[ --disable-debug disables debug output and debug symbols [default=no]],[],[]) AC_ARG_ENABLE(strict,[ --enable-strict compiles with strict compiler options (may not work!)], - [ - if test $enableval = "no"; then - ac_use_strict_options="no" - else - ac_use_strict_options="yes" + [ + if test $enableval = "no"; then + plp_use_strict_options="no" + else + plp_use_strict_options="yes" fi - ], [ac_use_strict_options="no"]) - -dnl this was AC_PROG_CC. I had to include it manualy, since I had to patch it - AC_MSG_CHECKING(for a C-Compiler) - dnl if there is one, print out. if not, don't matter - AC_MSG_RESULT($CC) - - if test -z "$CC"; then AC_CHECK_PROG(CC, gcc, gcc) fi - if test -z "$CC"; then AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) fi - if test -z "$CC"; then AC_CHECK_PROG(CC, xlc, xlc) fi - test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH]) - - AC_PROG_CC_WORKS - AC_PROG_CC_GNU - - if test $ac_cv_prog_gcc = yes; then - GCC=yes - else - GCC= - fi - - if test -z "$CFLAGS"; then - if test "$ac_use_debug_code" = "yes"; then - AC_PROG_CC_G - if test $ac_cv_prog_cc_g = yes; then - CFLAGS="-g" - fi + ], [plp_use_strict_options="no"]) + + AC_ARG_ENABLE(profile,[ --enable-profile creates profiling infos [default=no]], + [plp_use_profiling=$enableval], + [plp_use_profiling="no"] + ) + + dnl this prevents stupid AC_PROG_CC to add "-g" to the default CFLAGS + CFLAGS=" $CFLAGS" + + AC_PROG_CC + + if test "$GCC" = "yes"; then + if test "$plp_use_debug_code" = "yes"; then + CFLAGS="-g -O2 $CFLAGS" + case $host in + *-*-linux-gnu) + CFLAGS="-Wpointer-arith $CFLAGS" + ;; + esac else - if test "$GCC" = "yes"; then - CFLAGS="-O2" - else - CFLAGS="" - fi + CFLAGS="-O2 $CFLAGS" fi - - if test "$GCC" = "yes"; then - CFLAGS="$CFLAGS -Wall" - - if test "$ac_use_strict_options" = "yes"; then - CFLAGS="$CFLAGS -W -ansi -pedantic" - fi + if test "$plp_use_strict_options" = "yes"; then + CFLAGS="-ansi -Wall -W -pedantic -Wshadow -Wmissing-prototypes -Wwrite-strings -D_XOPEN_SOURCE=500 -D_BSD_SOURCE $CFLAGS" fi - else - AC_MSG_RESULT(Using predefined CFLAGS $CFLAGS) fi - case "$host" in - *-*-sysv4.2uw*) CFLAGS="$CFLAGS -D_UNIXWARE";; - esac - - # - # If debugging is off, strip all programs - # - if test "$ac_use_debug_code" = "no"; then - if test -z "$LDFLAGS" && test "$GCC" = "yes"; then - LDFLAGS="-s" - LIBDEBUG="" - fi - else - AC_DEFINE_UNQUOTED(DEBUG) - LIBDEBUG="--debug" + if test "$plp_use_debug_define" = "yes"; then + CFLAGS="-DNDEBUG $CFLAGS" fi - AC_SUBST(LIB_DEBUG) -dnl this is AC_PROG_CPP. I had to include it here, since autoconf checks -dnl dependecies between AC_PROG_CPP and AC_PROG_CC (or is it automake?) + case "$host" in + *-*-sysv4.2uw*) CFLAGS="-D_UNIXWARE $CFLAGS";; + *-*-sysv5uw7*) CFLAGS="-D_UNIXWARE7 $CFLAGS";; + esac - AC_MSG_CHECKING(how to run the C preprocessor) - # On Suns, sometimes $CPP names a directory. - if test -n "$CPP" && test -d "$CPP"; then - CPP= - fi - if test -z "$CPP"; then - AC_CACHE_VAL(ac_cv_prog_CPP, - [ # This must be in double quotes, not single quotes, because CPP may get - # substituted into the Makefile and "${CC-cc}" will confuse make. - CPP="${CC-cc} -E" - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. - dnl Use a header file that comes with gcc, so configuring glibc - dnl with a fresh cross-compiler works. - AC_TRY_CPP([#include - Syntax Error], , - CPP="${CC-cc} -E -traditional-cpp" - AC_TRY_CPP([#include - Syntax Error], , CPP=/lib/cpp)) - ac_cv_prog_CPP="$CPP"])dnl - CPP="$ac_cv_prog_CPP" + if test "$plp_use_debug_code" = "no"; then + if test -z "$LDFLAGS" && test "$GCC" = "yes"; then + LDFLAGS="-s" + fi + AC_DEFINE_UNQUOTED(NDEBUG,1,[Define this to disable assert macro]) + LIBDEBUG="" else - ac_cv_prog_CPP="$CPP" + AC_DEFINE_UNQUOTED(DEBUG,1,[Define this to enable debugging code]) + LIBDEBUG="--debug" fi - AC_MSG_RESULT($CPP) - AC_SUBST(CPP)dnl + AC_SUBST(LIBDEBUG) + CXXFLAGS=" $CXXFLAGS" - AC_MSG_CHECKING(for a C++-Compiler) - dnl if there is one, print out. if not, don't matter - AC_MSG_RESULT($CXX) - - if test -z "$CXX"; then AC_CHECK_PROG(CXX, g++, g++) fi - if test -z "$CXX"; then AC_CHECK_PROG(CXX, CC, CC) fi - if test -z "$CXX"; then AC_CHECK_PROG(CXX, xlC, xlC) fi - if test -z "$CXX"; then AC_CHECK_PROG(CXX, DCC, DCC) fi - test -z "$CXX" && AC_MSG_ERROR([no acceptable C++-compiler found in \$PATH]) + AC_PROG_CXX - AC_PROG_CXX_WORKS - AC_PROG_CXX_GNU + if test "$GXX" = "yes"; then + if test "$plp_use_debug_code" = "yes"; then + CXXFLAGS="-g -O2 -Wpointer-arith -Wmissing-prototypes $CXXFLAGS" - if test $ac_cv_prog_gxx = yes; then - GXX=yes - else - AC_MSG_CHECKING(whether we are using SPARC CC) - GXX= - cat > conftest.C << EOF -#ifdef __SUNPRO_CC - yes; -#endif -EOF - - ac_try="$CXX -E conftest.C" - if { (eval echo configure:__online__: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } | egrep yes >/dev/null 2>&1; then - ac_cv_prog_CC=yes - else - ac_cv_prog_CC=no - fi - AC_MSG_RESULT($ac_cv_prog_CC) - fi + PLP_CHECK_COMPILER_FLAG(Wno-long-long,[CXXFLAGS="-Wno-long-long $CXXFLAGS"]) + PLP_CHECK_COMPILER_FLAG(Wnon-virtual-dtor,[CXXFLAGS="-Wnon-virtual-dtor $CXXFLAGS"]) + PLP_CHECK_COMPILER_FLAG(fno-builtin,[CXXFLAGS="-fno-builtin $CXXFLAGS"]) - if test -z "$CXXFLAGS"; then - if test "$ac_use_debug_code" = "yes"; then - AC_PROG_CXX_G - if test $ac_cv_prog_cxx_g = yes; then - CXXFLAGS="-g" - fi - if test "$ac_cv_prog_CC" = "yes"; then - CXXFLAGS="$CXXFLAGS -pto" + case $host in dnl + *-*-linux-gnu) + CXXFLAGS="-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wbad-function-cast -Wcast-align -Wundef $CXXFLAGS" + ;; + esac + + if test "$plp_use_strict_options" = "yes"; then + CXXFLAGS="-ansi -pedantic -W -Wconversion -Wcast-qual -Wwrite-strings -Wbad-function-cast -Wshadow -Wcast-align $CXXFLAGS" fi else - if test "$GXX" = "yes"; then - CXXFLAGS="-O2" - else - if test "$ac_cv_prog_CC" = "yes"; then - CXXFLAGS="-pto -O2" - else - CXXFLAGS="" - fi - fi + CXXFLAGS="-O2 $CXXFLAGS" fi + fi - if test "$GXX" = "yes"; then - CXXFLAGS="$CXXFLAGS -Wall" - - if test "$ac_use_strict_options" = "yes"; then - CXXFLAGS="$CXXFLAGS -W -ansi -Wtraditional -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Woverloaded-virtual -Wbad-function-cast -Wsynth" - fi - - if test "$ac_very_strict" = "yes"; then - CXXFLAGS="$CXXFLAGS -Wold-style-cast -Wshadow -Wredundant-decls -Wconversion" - fi - fi + if test "$plp_use_debug_define" = "yes"; then + CXXFLAGS="-DNDEBUG $CXXFLAGS" fi - case "$host" in - *-*-sysv4.2uw*) CXXFLAGS="$CXXFLAGS -D_UNIXWARE";; - esac + if test "$plp_use_profiling" = "yes"; then + PLP_CHECK_COMPILER_FLAG(pg, + [ + CFLAGS="-pg $CFLAGS" + CXXFLAGS="-pg $CXXFLAGS" + ]) + fi + + PLP_CHECK_COMPILER_FLAG(fno-exceptions,[CXXFLAGS="$CXXFLAGS -fno-exceptions"]) + PLP_CHECK_COMPILER_FLAG(fno-check-new, [CXXFLAGS="$CXXFLAGS -fno-check-new"]) + PLP_CHECK_COMPILER_FLAG(fexceptions, [USE_EXCEPTIONS="-fexceptions"], USE_EXCEPTIONS= ) + AC_SUBST(USE_EXCEPTIONS) + dnl obsolete macro - provided to keep things going + USE_RTTI= + AC_SUBST(USE_RTTI) + + case "$host" in + *-*-irix*) test "$GXX" = yes && CXXFLAGS="-D_LANGUAGE_C_PLUS_PLUS -D__LANGUAGE_C_PLUS_PLUS $CXXFLAGS" ;; + *-*-sysv4.2uw*) CXXFLAGS="-D_UNIXWARE $CXXFLAGS";; + *-*-sysv5uw7*) CXXFLAGS="-D_UNIXWARE7 $CXXFLAGS";; + *-*-solaris*) + if test "$GXX" = yes; then + libstdcpp=`$CXX -print-file-name=libstdc++.so` + if test ! -f $libstdcpp; then + AC_MSG_ERROR([You've compiled gcc without --enable-shared. This doesn't work with plptools. Please recompile gcc with --enable-shared to receive a libstdc++.so]) + fi + fi + ;; + esac + AC_VALIDIFY_CXXFLAGS + + AC_PROG_CXXCPP + + # the following is to allow programs, that are known to + # have problems when compiled with -O2 + if test -n "$CXXFLAGS"; then + plp_safe_IFS=$IFS + IFS=" " + NOOPT_CXXFLAGS="" + for i in $CXXFLAGS; do + case $i in + -O*) + ;; + *) + NOOPT_CXXFLAGS="$NOOPT_CXXFLAGS $i" + ;; + esac + done + IFS=$plp_safe_IFS + fi + + AC_SUBST(NOOPT_CXXFLAGS) + THREADED_CFLAGS="-D_REENTRANT $CFLAGS" + THREADED_CXXFLAGS="-D_REENTRANT $CFLAGS" + AC_SUBST(THREADED_CFLAGS) + AC_SUBST(THREADED_CXXFLAGS) ]) + diff --git a/conf/m4/plptools/PLP_CHECK_COMPILER_FLAG.m4 b/conf/m4/plptools/PLP_CHECK_COMPILER_FLAG.m4 new file mode 100644 index 0000000..120499e --- /dev/null +++ b/conf/m4/plptools/PLP_CHECK_COMPILER_FLAG.m4 @@ -0,0 +1,27 @@ +AC_DEFUN(PLP_CHECK_COMPILER_FLAG, +[ +dnl AC_REQUIRE([AC_CHECK_COMPILERS]) <- breaks with autoconf 2.50 +AC_MSG_CHECKING(whether $CXX supports -$1) +plp_cache=`echo $1 | sed 'y%.=/+-%___p_%'` +AC_CACHE_VAL(plp_cv_prog_cxx_$plp_cache, +[ +echo 'int main() { return 0; }' >conftest.cc +eval "plp_cv_prog_cxx_$plp_cache=no" +if test -z "`$CXX -$1 -c conftest.cc 2>&1`"; then + if test -z "`$CXX -$1 -o conftest conftest.o 2>&1`"; then + eval "plp_cv_prog_cxx_$plp_cache=yes" + fi +fi +rm -f conftest* +]) +if eval "test \"`echo '$plp_cv_prog_cxx_'$plp_cache`\" = yes"; then + AC_MSG_RESULT(yes) + : + $2 +else + AC_MSG_RESULT(no) + : + $3 +fi +]) + -- cgit v1.2.3