OPTIM=""
AC_SUBST(OPTIM)
AC_ARG_WITH(optim, [ --with-optim="flags" set optimization flags ])
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no],
[if test x$enable_debug = xyes; then
OPTIM="-g"
fi])
AC_ARG_WITH(archflags, [ --with-archflags="flags"
set default architecture flags ])
if test -z "$with_archflags"; then
ARCHFLAGS=""
LDARCHFLAGS=""
else
ARCHFLAGS="$with_archflags"
if test "$uname" = Darwin; then
LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch x86_64//' -e '1,$s/-arch ppc64//'`"
else
LDARCHFLAGS="$ARCHFLAGS"
fi
fi
AC_SUBST(ARCHFLAGS)
AC_SUBST(LDARCHFLAGS)
AC_ARG_WITH(arch32flags, [ --with-arch32flags="flags"
specifies 32-bit architecture flags])
ARCH32FLAGS=""
AC_SUBST(ARCH32FLAGS)
AC_ARG_WITH(arch64flags, [ --with-arch64flags="flags"
specifies 64-bit architecture flags])
ARCH64FLAGS=""
AC_SUBST(ARCH64FLAGS)
AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fPIE option, default=no])
AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
CXXLIBS=""
AC_SUBST(CXXLIBS)
PIEFLAGS=""
AC_SUBST(PIEFLAGS)
RELROFLAGS=""
AC_SUBST(RELROFLAGS)
LIBCUPSORDER="libcups.order"
AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
if test -f "$withval"; then
LIBCUPSORDER="$withval"
fi)
AC_SUBST(LIBCUPSORDER)
LIBCUPSIMAGEORDER="libcupsimage.order"
AC_ARG_WITH(libcupsimageorder, [ --with-libcupsimagesorder
libcupsimage secorder file, default=libcupsimage.order],
if test -f "$withval"; then
LIBCUPSIMAGEORDER="$withval"
fi)
AC_SUBST(LIBCUPSIMAGEORDER)
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 -a $uname != AIX; then
OPTIM="-fPIC $OPTIM"
fi
AC_MSG_CHECKING(if GCC supports -fstack-protector)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fstack-protector"
AC_TRY_COMPILE(,,
OPTIM="$OPTIM -fstack-protector"
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS="$OLDCFLAGS"
if test x$enable_pie = xyes; then
AC_MSG_CHECKING(if GCC supports -pie)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -pie -fPIE"
AC_TRY_COMPILE(,,
PIEFLAGS="-pie -fPIE"
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no, ignoring --enable-pie))
CFLAGS="$OLDCFLAGS"
fi
if test "x$with_optim" = x; then
OPTIM="-Wall -Wno-format-y2k $OPTIM"
if test -d .svn; then
OPTIM="-Wshadow -Wunused $OPTIM"
fi
fi
case "$uname" in
Darwin*)
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
if test x$enable_pie = xyes; then
LDFLAGS="$LDFLAGS -Wl,-pie"
fi
;;
HP-UX*)
if test "x$enable_32bit" = xyes; then
if test -z "$with_arch32flags"; then
ARCH32FLAGS="-milp32"
else
ARCH32FLAGS="$with_arch32flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-mlp64"
else
ARCHFLAGS="$with_arch64flags"
fi
fi
fi
if test "x$enable_64bit" = xyes; then
if test -z "$with_arch64flags"; then
ARCH64FLAGS="-mlp64"
else
ARCH64FLAGS="$with_arch64flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-milp32"
else
ARCHFLAGS="$with_arch32flags"
fi
fi
fi
;;
IRIX)
if test "x$enable_32bit" = xyes; then
if test -z "$with_arch32flags"; then
ARCH32FLAGS="-n32 -mips3"
else
ARCH32FLAGS="$with_arch32flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-64 -mips4"
else
ARCHFLAGS="$with_arch64flags"
fi
fi
fi
if test "x$enable_64bit" = xyes; then
if test -z "$with_arch64flags"; then
ARCH64FLAGS="-64 -mips4"
else
ARCH64FLAGS="$with_arch64flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-n32 -mips3"
else
ARCHFLAGS="$with_arch32flags"
fi
fi
fi
;;
Linux*)
if test x$enable_relro = xyes; then
RELROFLAGS="-Wl,-z,relro"
fi
if test "x$enable_32bit" = xyes; then
if test -z "$with_arch32flags"; then
ARCH32FLAGS="-m32"
else
ARCH32FLAGS="$with_arch32flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-m64"
else
ARCHFLAGS="$with_arch64flags"
fi
fi
fi
if test "x$enable_64bit" = xyes; then
if test -z "$with_arch64flags"; then
ARCH64FLAGS="-m64"
else
ARCH64FLAGS="$with_arch64flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-m32"
else
ARCHFLAGS="$with_arch32flags"
fi
fi
fi
;;
SunOS*)
if test "x$enable_32bit" = xyes; then
if test -z "$with_arch32flags"; then
ARCH32FLAGS="-m32"
else
ARCH32FLAGS="$with_arch32flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-m64"
else
ARCHFLAGS="$with_arch64flags"
fi
fi
fi
if test "x$enable_64bit" = xyes; then
if test -z "$with_arch64flags"; then
ARCH64FLAGS="-m64"
else
ARCH64FLAGS="$with_arch64flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-m32"
else
ARCHFLAGS="$with_arch32flags"
fi
fi
fi
;;
esac
else
case $uname in
AIX*)
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="-O2 -qmaxmem=6000"
else
OPTIM="$with_optim $OPTIM"
fi
fi
;;
HP-UX*)
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="+O2"
else
OPTIM="$with_optim $OPTIM"
fi
fi
CFLAGS="-Ae $CFLAGS"
CXXFLAGS="+W336,829 $CXXFLAGS"
if test $PICFLAG = 1; then
OPTIM="+z $OPTIM"
fi
if test "x$enable_32bit" = xyes; then
if test -z "$with_arch32flags"; then
ARCH32FLAGS="+DD32"
else
ARCH32FLAGS="$with_arch32flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="+DD64"
else
ARCHFLAGS="$with_arch64flags"
fi
fi
fi
if test "x$enable_64bit" = xyes; then
if test -z "$with_arch64flags"; then
ARCH64FLAGS="+DD64"
else
ARCH64FLAGS="$with_arch64flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="+DD32"
else
ARCHFLAGS="$with_arch32flags"
fi
fi
fi
;;
IRIX)
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="-O2"
else
OPTIM="$with_optim $OPTIM"
fi
fi
if test "x$with_optim" = x; then
OPTIM="-fullwarn -woff 1183,1209,1349,1506,3201 $OPTIM"
fi
if test "x$enable_32bit" = xyes; then
if test -z "$with_arch32flags"; then
ARCH32FLAGS="-n32 -mips3"
else
ARCH32FLAGS="$with_arch32flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-64 -mips4"
else
ARCHFLAGS="$with_arch64flags"
fi
fi
fi
if test "x$enable_64bit" = xyes; then
if test -z "$with_arch64flags"; then
ARCH64FLAGS="-64 -mips4"
else
ARCH64FLAGS="$with_arch64flags"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-n32 -mips3"
else
ARCHFLAGS="$with_arch32flags"
fi
fi
fi
;;
OSF*)
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="-O"
else
OPTIM="$with_optim"
fi
fi
;;
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
if test "x$enable_32bit" = xyes; then
ARCH32FLAGS="-xarch=generic"
if test "x$with_optim" = x; then
OPTIM="-w $OPTIM"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch64flags"; then
ARCHFLAGS="-xarch=generic64"
else
ARCHFLAGS="$with_arch64flags"
fi
fi
else
if test "x$enable_64bit" = xyes; then
ARCH64FLAGS="-xarch=generic64"
fi
if test "x$with_optim" = x; then
OPTIM="-w $OPTIM"
fi
if test -z "$with_archflags"; then
if test -z "$with_arch32flags"; then
ARCHFLAGS="-xarch=generic"
else
ARCHFLAGS="$with_arch32flags"
fi
fi
fi
;;
UNIX_SVR*)
if test -z "$OPTIM"; then
if test "x$with_optim" = x; then
OPTIM="-O"
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-bugs@cups.org with uname and compiler options needed"
echo "for your platform, or set the CFLAGS, CXXFLAGS, and LDFLAGS"
echo "environment variables before running configure."
;;
esac
fi
case $uname in
HP-UX*)
OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
OPTIM="$OPTIM -D_HPUX_SOURCE"
;;
Linux*)
OPTIM="$OPTIM -D_GNU_SOURCE"
;;
OSF*)
OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
;;
esac