autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

avoiding recompiles


From: Golubev I. N.
Subject: avoiding recompiles
Date: Fri, 29 Dec 2000 17:55:43 (GMT)

Many autoconf tests for availability of some function involve trying
to link the same C code with different libraries in attempt to detect
which one contains the function.  Typically C input is the same, and
even the intermediate object file being linked with libs is the same.
However, TRY_LINK always puts `conftest.c' on compiler command line,
so we obtain the same object code several times, each time going
through extremely time- consuming compilation phases.  Why can not we
avoid this?

The following patch to 2.13 adds macros to perform recompilation
avoidance.  They might be used like this (recompilations in
AC_CHECK_LIB remain)

AC_CHECK_HEADER(dlfcn.h, [
  AC_CHECK_LIB(dl, dlopen, [ have_dl=yes libdl=dl], [
  AC_CHECK_LIB(c,  dlopen, [ have_dl=yes ], [
  AC_MSG_CHECKING([for dlopen in -lc including <dlfcn.h>])
  AC_TRY_COMPILE_NRM([#include <dlfcn.h>],dnl
    [(void) dlopen ("", 0);], [
  AC_TRY_LINK_O([ have_dl=yes ], [
  AC_MSG_CHECKING([for dlopen in -ldl including <dlfcn.h>])
  ac_save_LIBS="$LIBS"
  LIBS="-ldl $LIBS"
  AC_TRY_LINK_O([ have_dl=yes ], [LIBS="$ac_save_LIBS"])
  ac_save_LIBS=])])])])])

--- acgeneral.m4        2000/12/22 15:20:58     1.1
+++ acgeneral.m4        2000/12/22 17:34:50     1.3
@@ -1254,6 +1254,15 @@
 cross_compiling=$ac_cv_prog_f77_cross
 ])
 
+dnl AC_LANG_O()
+AC_DEFUN(AC_LANG_O,
+[define([AC_LANG], [O])dnl
+ac_ext=o
+ac_compile=:
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS 
conftest.$ac_ext $LIBS 1>&AC_FD_CC'
+cross_compiling=$ac_cv_prog_cc_cross
+])
+
 dnl Push the current language on a stack.
 dnl AC_LANG_SAVE()
 define(AC_LANG_SAVE,
@@ -1264,7 +1273,8 @@
 pushdef([AC_LANG_RESTORE],
 [ifelse(AC_LANG_STACK, [C], [AC_LANG_C],dnl
 AC_LANG_STACK, [CPLUSPLUS], [AC_LANG_CPLUSPLUS],dnl
-AC_LANG_STACK, [FORTRAN77], [AC_LANG_FORTRAN77])[]popdef([AC_LANG_STACK])])
+AC_LANG_STACK, [FORTRAN77], [AC_LANG_FORTRAN77],dnl
+AC_LANG_STACK, [O], [AC_LANG_O])[]popdef([AC_LANG_STACK])])
 
 
 dnl ### Compiler-running mechanics
@@ -1748,6 +1758,33 @@
 ])dnl
 fi
 rm -f conftest*])
+dnl AC_TRY_COMPILE_NRM(INCLUDES, FUNCTION-BODY,
+dnl             [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+AC_DEFUN(AC_TRY_COMPILE_NRM,
+[cat > conftest.$ac_ext <<EOF
+ifelse(AC_LANG, [FORTRAN77],
+[      program main
+[$2]
+      end],
+[dnl This sometimes fails to find confdefs.h, for some reason.
+dnl [#]line __oline__ "[$]0"
+[#]line __oline__ "configure"
+#include "confdefs.h"
+[$1]
+int main() {
+[$2]
+; return 0; }
+])EOF
+if AC_TRY_EVAL(ac_compile); then
+  ifelse([$3], , :, [$3])
+else
+  echo "configure: failed program was:" >&AC_FD_CC
+  cat conftest.$ac_ext >&AC_FD_CC
+ifelse([$4], , , [  rm -rf conftest*
+  $4
+])dnl
+fi
+rm -f conftest*])
 
 
 dnl ### Examining libraries
@@ -1792,6 +1829,26 @@
 ])dnl
 fi
 rm -f conftest*])
+dnl AC_TRY_LINK_O([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+AC_DEFUN(AC_TRY_LINK_O,
+[AC_LANG_SAVE()dnl
+AC_LANG_O
+if
+  AC_TRY_EVAL(ac_link)
+  ac_exit_status=$?
+  AC_LANG_RESTORE
+  test $ac_exit_status -eq 0 -a -s conftest${ac_exeext}
+then
+  ifelse([$1], , :, [rm -rf conftest${ac_exeext}
+  $1])
+else
+  echo "configure: failed program was:" >&AC_FD_CC
+  cat conftest.$ac_ext >&AC_FD_CC
+ifelse([$2], , , [  rm -rf conftest${ac_exeext}
+  $2
+])dnl
+fi
+rm -f conftest${ac_exeext}])
 
 
 dnl ### Checking for run-time features



reply via email to

[Prev in Thread] Current Thread [Next in Thread]