Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,19 @@ dnl
m4_define(incstart,sinc)
m4_define(incend,lude)

dnl
dnl Save environment CFLAGS before autoconf starts messing with it.
dnl It is restored later.
dnl
ENV_CFLAGS="$CFLAGS"

dnl ######################################################################
dnl Checks for programs.
dnl ######################################################################

AC_PROG_GREP
AC_PROG_EGREP

dnl
dnl Prevent AC_PROG_CC from defaulting to "-g -O2".
dnl CFLAGS is left for the user; project flags go into CF3_CFLAGS via cf3_gcc_flags.m4.
dnl
: ${CFLAGS=""}
: ${CPPFLAGS=""}
AC_PROG_CC
AC_PROG_MKDIR_P
AC_EXEEXT
Expand Down Expand Up @@ -149,6 +150,7 @@ ACX_PTHREAD([],

CC="$PTHREAD_CC"
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
dnl TODO: PTHREAD_CFLAGS should be handled via AM_CFLAGS in Makefile.am
LIBS="$PTHREAD_LIBS $LIBS"

dnl ######################################################################
Expand Down Expand Up @@ -225,7 +227,7 @@ AS_CASE([${target_os}],
[mingw*],
# Disable printf format warnings, because our wrapper supports more
# flags than vanilla Windows version, so they are false positives.
[CFLAGS="$CFLAGS -Wno-format"])
[CF3_CFLAGS="$CF3_CFLAGS -Wno-format"])

dnl ######################################################################
dnl Enable debugging
Expand All @@ -237,20 +239,16 @@ AC_ARG_ENABLE(debug,
[debug=no])
AM_CONDITIONAL([NDEBUG], [test x"$debug" = x"no"])

dnl Even though CFLAGS should contain the command-line CFLAGS
dnl as last, some macro seem to messes the order up and insert
dnl its own optimisation flags as well. So we append ENV_CFLAGS
dnl at the end manually, causing a bit of flag duplication.

AC_MSG_CHECKING([for debug option])
if test x"$debug" = x"yes"
then
AC_MSG_RESULT(yes)
CFLAGS="$CFLAGS -g3 -O0 $ENV_CFLAGS"
DEBUG_CFLAGS="-g3 -O0"
else
AC_MSG_RESULT(no)
CFLAGS="$CFLAGS -O2 -DNDEBUG $ENV_CFLAGS"
DEBUG_CFLAGS="-O2 -DNDEBUG"
fi
AC_SUBST([DEBUG_CFLAGS])

dnl ######################################################################
dnl Checks for libraries.
Expand Down Expand Up @@ -1264,13 +1262,14 @@ if test "x$use_coverage" = "xyes"; then
AC_MSG_ERROR([Could not find genhtml from the LTP package])
fi

dnl Remove all optimization flags from CFLAGS
dnl Remove all optimization flags from CF3_CFLAGS
changequote({,})
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
CF3_CFLAGS=`echo "$CF3_CFLAGS" | $SED -e 's/-O[0-9]*//g'`
DEBUG_CFLAGS=""
changequote([,])

dnl Add the special gcc flags
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
CF3_CFLAGS="$CF3_CFLAGS -fprofile-arcs -ftest-coverage"
LDFLAGS="$LDFLAGS -lgcov"
# Need to set ENABLE_COVERAGE so that tests/unit/Makefile.am can adapt for one
# test which needs gcov stubs if core not built with coverage.
Expand All @@ -1283,8 +1282,8 @@ dnl ######################################################################
dnl Collect all the options
dnl ######################################################################

CORE_CPPFLAGS="$PCRE2_CPPFLAGS $OPENSSL_CPPFLAGS $LIBYAML_CPPFLAGS $CPPFLAGS"
CORE_CFLAGS="$PCRE2_CFLAGS $OPENSSL_CFLAGS $LIBYAML_CFLAGS $CFLAGS"
CORE_CPPFLAGS="$PCRE2_CPPFLAGS $OPENSSL_CPPFLAGS $LIBYAML_CPPFLAGS"
CORE_CFLAGS="$PCRE2_CFLAGS $OPENSSL_CFLAGS $LIBYAML_CFLAGS $CF3_CFLAGS $DEBUG_CFLAGS"
CORE_LDFLAGS="$PCRE2_LDFLAGS $OPENSSL_LDFLAGS $LIBYAML_LDFLAGS $LDFLAGS"
CORE_LIBS="$PCRE2_LIBS $OPENSSL_LIBS $LIBYAML_LIBS $LIBS"

Expand Down
2 changes: 2 additions & 0 deletions libcompat/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ noinst_LTLIBRARIES = libcompat.la

AM_CPPFLAGS = -I$(top_srcdir)/libutils # platform.h

AM_CFLAGS = $(CORE_CFLAGS)

libcompat_la_LIBADD = $(LTLIBOBJS)

libcompat_la_SOURCES = \
Expand Down
46 changes: 24 additions & 22 deletions m4/cf3_gcc_flags.m4
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
# included file COSL.txt.
#
dnl ####################################################################
dnl Set GCC CFLAGS only if using GCC.
dnl Set GCC flags only if using GCC.
dnl Flags are collected into CF3_CFLAGS for use in AM_CFLAGS.
dnl CFLAGS is left untouched for the user.
dnl ####################################################################

AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
Expand All @@ -30,8 +32,7 @@ AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
#endif
]])], [
HP_UX_AC="no"], [
CFLAGS="$CFLAGS -Agcc"
CPPFLAGS="$CPPFLAGS -Agcc"
CF3_CFLAGS="$CF3_CFLAGS -Agcc"
HP_UX_AC="yes"])

AC_MSG_CHECKING(for HP-UX aC)
Expand All @@ -43,33 +44,32 @@ fi

AC_MSG_CHECKING(for GCC specific compile flags)
if test x"$GCC" = "xyes" && test x"$HP_UX_AC" != x"yes"; then
CFLAGS="$CFLAGS -g -Wall"
CPPFLAGS="$CPPFLAGS -std=gnu99"
CF3_CFLAGS="$CF3_CFLAGS -std=gnu99 -g -Wall"
AC_MSG_RESULT(yes)

save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wno-pointer-sign"
AC_MSG_CHECKING(for -Wno-pointer-sign)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() {}])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
CFLAGS="$save_CFLAGS"])
[AC_MSG_RESULT(yes)
CF3_CFLAGS="$CF3_CFLAGS -Wno-pointer-sign"],
[AC_MSG_RESULT(no)])

save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror=implicit-function-declaration"
AC_MSG_CHECKING(for -Werror=implicit-function-declaration)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() {}])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
CFLAGS="$save_CFLAGS"])
[AC_MSG_RESULT(yes)
CF3_CFLAGS="$CF3_CFLAGS -Werror=implicit-function-declaration"],
[AC_MSG_RESULT(no)])

save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wunused-parameter"
AC_MSG_CHECKING(for -Wunused-parameter)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() {}])],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
CFLAGS="$save_CFLAGS"])
[AC_MSG_RESULT(yes)
CF3_CFLAGS="$CF3_CFLAGS -Wunused-parameter"],
[AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for -Wno-incompatible-pointer-types)
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() {}])],
[AC_MSG_RESULT(yes)
CF3_CFLAGS="$CF3_CFLAGS -Wno-incompatible-pointer-types"],
[AC_MSG_RESULT(no)])

dnl Clang does not like 'const const' construct arising from
dnl expansion of TYPED_SET_DECLARE macro
Expand All @@ -83,8 +83,10 @@ if test x"$GCC" = "xyes" && test x"$HP_UX_AC" != x"yes"; then
#endif
int main() {}])],
[AC_MSG_RESULT(yes)
CFLAGS="$save_CFLAGS -Wno-duplicate-decl-specifier"],
CF3_CFLAGS="$CF3_CFLAGS -Wno-duplicate-decl-specifier"],
[AC_MSG_RESULT(no)])
else
else
AC_MSG_RESULT(no)
fi

AC_SUBST([CF3_CFLAGS])
2 changes: 2 additions & 0 deletions tests/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ AM_CPPFLAGS = $(CORE_CPPFLAGS) \
-I$(srcdir)/../../libutils \
-DTESTDATADIR='"$(srcdir)/data"'

AM_CFLAGS = $(CORE_CFLAGS)

LDADD = libtest.la

# automake does not support "maude_LIBS" variables. We can only alter
Expand Down
Loading