dnl Process this file with autoconf to produce a configure script.
-dnl $PostgreSQL: pgsql/configure.in,v 1.560 2008/05/03 00:24:05 adunstan Exp $
+dnl $PostgreSQL: pgsql/configure.in,v 1.567 2008/09/05 18:54:58 petere Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
[ --enable-profiling build with profiling enabled ])
AC_SUBST(enable_profiling)
+#
+# --enable-coverage enables generation of code coverage metrics with gcov
+#
+PGAC_ARG_BOOL(enable, coverage, no,
+ [ --enable-coverage build with coverage testing instrumentation],
+[AC_CHECK_PROGS(GCOV, gcov)
+if test -z "$GCOV"; then
+ AC_MSG_ERROR([gcov not found])
+fi
+AC_CHECK_PROGS(LCOV, lcov)
+if test -z "$LCOV"; then
+ AC_MSG_ERROR([lcov not found])
+fi
+AC_CHECK_PROGS(GENHTML, genhtml)
+if test -z "$GENHTML"; then
+ AC_MSG_ERROR([genhtml not found])
+fi])
+AC_SUBST(enable_coverage)
+
#
# DTrace
#
# CFLAGS are selected so:
# If the user specifies something in the environment, that is used.
# else: If the template file set something, that is used.
+# else: If coverage was enabled, don't set anything.
# else: If the compiler is GCC, then we use -O2.
-# else: If the compiler is something else, then we use -0.
+# else: If the compiler is something else, then we use -O.
if test "$ac_env_CFLAGS_set" = set; then
CFLAGS=$ac_env_CFLAGS_value
elif test "${CFLAGS+set}" = set; then
: # (keep what template set)
+elif test "$enable_coverage" = yes; then
+ : # no optimization by default
elif test "$GCC" = yes; then
CFLAGS="-O2"
else
# ICC pretends to be GCC but it's lying; it doesn't support these options.
if test "$GCC" = yes -a "$ICC" = no; then
- CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith -Winline"
+ CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith"
# These work in some but not all gcc versions
PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
CFLAGS="$CFLAGS -g"
fi
+# enable code coverage if --enable-coverage
+if test "$enable_coverage" = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
+ else
+ AC_MSG_ERROR([--enable-coverage is supported only when using GCC])
+ fi
+fi
+
# enable profiling if --enable-profiling
if test "$enable_profiling" = yes && test "$ac_cv_prog_cc_g" = yes; then
if test "$GCC" = yes; then
fi
fi
-AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
-
# We already have this in Makefile.win32, but configure needs it too
if test "$PORTNAME" = "win32"; then
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
CPPFLAGS="$CPPFLAGS $INCLUDES"
LDFLAGS="$LDFLAGS $LIBDIRS"
-AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
-AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
-
AC_ARG_VAR(LDFLAGS_SL)
PGAC_PROG_LD
AC_PROG_LN_S
AC_PROG_AWK
-PGAC_PATH_YACC
+PGAC_PATH_BISON
PGAC_PATH_FLEX
PGAC_PATH_PERL
fi
fi
+# If compiler will take -Wl,--as-needed then add that to LDFLAGS.
+# This is much easier than trying to filter LIBS to the minimum for each
+# executable. (Note that shared library links won't use this switch, though.)
+# On (at least) some Red-Hat-derived systems, this switch breaks linking to
+# libreadline; therefore we postpone testing it until we know what library
+# dependencies readline has. The test code will try to link with $LIBS.
+if test "$with_readline" = yes; then
+ link_test_func=readline
+else
+ link_test_func=exit
+fi
+if test "$PORTNAME" != "darwin"; then
+ PGAC_PROG_CC_LDFLAGS_OPT([-Wl,--as-needed], $link_test_func)
+else
+ # On Darwin it's spelled -Wl,-dead_strip_dylibs, but don't try that elsewhere
+ PGAC_PROG_CC_LDFLAGS_OPT([-Wl,-dead_strip_dylibs], $link_test_func)
+fi
+
+
+# Begin output steps
+
+AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
+AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
+AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
+
# prepare build tree if outside source tree
# Note 1: test -ef might not exist, but it's more reliable than `pwd`.
# Note 2: /bin/pwd might be better than shell's built-in at getting