INSTALL_STRIP=""
OPTIM=""
AC_SUBST(INSTALL_STRIP)
AC_SUBST(OPTIM)
AC_ARG_WITH(optim, [ --with-optim set optimization flags ])
AC_ARG_ENABLE(debug, [ --enable-debug build with debugging symbols])
AC_ARG_ENABLE(debug_guards, [ --enable-debug-guards build with memory allocation guards])
AC_ARG_ENABLE(debug_printfs, [ --enable-debug-printfs build with CUPS_DEBUG_LOG support])
AC_ARG_ENABLE(unit_tests, [ --enable-unit-tests build and run unit tests])
if test x$enable_debug = xyes; then
OPTIM="-g"
else
INSTALL_STRIP="-s"
fi
if test x$enable_debug_printfs = xyes; then
CFLAGS="$CFLAGS -DDEBUG"
CXXFLAGS="$CXXFLAGS -DDEBUG"
fi
if test x$enable_debug_guards = xyes; then
CFLAGS="$CFLAGS -DDEBUG_GUARDS"
CXXFLAGS="$CXXFLAGS -DDEBUG_GUARDS"
fi
if test x$enable_unit_tests = xyes; then
UNITTESTS="unittests"
else
UNITTESTS=""
fi
AC_SUBST(UNITTESTS)
AC_ARG_WITH(archflags, [ --with-archflags set default architecture flags ])
AC_ARG_WITH(ldarchflags, [ --with-ldarchflags set program architecture flags ])
if test -z "$with_archflags"; then
ARCHFLAGS=""
else
ARCHFLAGS="$with_archflags"
fi
if test -z "$with_ldarchflags"; then
if test "$uname" = Darwin; then
LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch ppc64//'`"
else
LDARCHFLAGS="$ARCHFLAGS"
fi
else
LDARCHFLAGS="$with_ldarchflags"
fi
AC_SUBST(ARCHFLAGS)
AC_SUBST(LDARCHFLAGS)
AC_ARG_ENABLE(relro, [ --enable-relro build with the GCC relro option])
CXXLIBS="${CXXLIBS:=}"
AC_SUBST(CXXLIBS)
PIEFLAGS=""
AC_SUBST(PIEFLAGS)
RELROFLAGS=""
AC_SUBST(RELROFLAGS)
if test -n "$GCC"; then
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="-Os -g"
else
OPTIM="$with_optim $OPTIM"
fi
fi
if test $PICFLAG = 1; then
OPTIM="-fPIC $OPTIM"
fi
AC_MSG_CHECKING(whether compiler supports -fstack-protector)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fstack-protector"
AC_TRY_LINK(,,
if test "x$LSB_BUILD" = xy; then
OPTIM="$OPTIM -fno-stack-protector"
else
OPTIM="$OPTIM -fstack-protector"
fi
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS="$OLDCFLAGS"
if test "x$LSB_BUILD" != xy; then
AC_MSG_CHECKING(whether compiler supports -fPIE)
OLDCFLAGS="$CFLAGS"
case "$uname" in
Darwin*)
CFLAGS="$CFLAGS -fPIE -Wl,-pie"
AC_TRY_COMPILE(,,[
PIEFLAGS="-fPIE -Wl,-pie"
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
;;
*)
CFLAGS="$CFLAGS -fPIE -pie"
AC_TRY_COMPILE(,,[
PIEFLAGS="-fPIE -pie"
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
;;
esac
CFLAGS="$OLDCFLAGS"
fi
if test "x$with_optim" = x; then
OPTIM="-Wall -Wno-format-y2k -Wunused $OPTIM"
AC_MSG_CHECKING(whether compiler supports -Wno-unused-result)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror -Wno-unused-result"
AC_TRY_COMPILE(,,
[OPTIM="$OPTIM -Wno-unused-result"
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
CFLAGS="$OLDCFLAGS"
AC_MSG_CHECKING(whether compiler supports -Wsign-conversion)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror -Wsign-conversion"
AC_TRY_COMPILE(,,
[OPTIM="$OPTIM -Wsign-conversion"
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
CFLAGS="$OLDCFLAGS"
AC_MSG_CHECKING(whether compiler supports -Wno-tautological-compare)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror -Wno-tautological-compare"
AC_TRY_COMPILE(,,
[OPTIM="$OPTIM -Wno-tautological-compare"
AC_MSG_RESULT(yes)],
AC_MSG_RESULT(no))
CFLAGS="$OLDCFLAGS"
if test -d .svn; then
OPTIM="-Werror $OPTIM"
fi
fi
case "$uname" in
Darwin*)
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
;;
Linux*)
if test x$enable_relro = xyes; then
RELROFLAGS="-Wl,-z,relro,-z,now"
fi
;;
esac
else
case $uname in
SunOS*)
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="-xO2"
else
OPTIM="$with_optim $OPTIM"
fi
fi
if test $PICFLAG = 1; then
OPTIM="-KPIC $OPTIM"
fi
;;
*)
echo "Building CUPS with default compiler optimizations; contact"
echo "cups-devel@cups.org with uname and compiler options needed"
echo "for your platform, or set the CFLAGS and LDFLAGS environment"
echo "variables before running configure."
;;
esac
fi
case $uname in
Linux*)
OPTIM="$OPTIM -D_GNU_SOURCE"
;;
esac