dnl
-dnl "$Id: cups-compiler.m4 6687 2007-07-18 19:49:45Z mike $"
+dnl "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $"
dnl
dnl Compiler stuff for the Common UNIX Printing System (CUPS).
dnl
-dnl Copyright 2007 by Apple Inc.
+dnl Copyright 2007-2008 by Apple Inc.
dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
dnl
dnl These coded instructions, statements, and computer programs are the
ARCH64FLAGS=""
AC_SUBST(ARCH64FLAGS)
-dnl Position-Independent Executable support on Linux...
-AC_ARG_ENABLE(pie, [ --enable-pie use GCC -fPIE option, default=no])
-
dnl Read-only data/program support on Linux...
AC_ARG_ENABLE(relro, [ --enable-relro use GCC relro option, default=no])
dnl Update compiler options...
-CXXLIBS=""
+CXXLIBS="${CXXLIBS:=}"
AC_SUBST(CXXLIBS)
PIEFLAGS=""
RELROFLAGS=""
AC_SUBST(RELROFLAGS)
+LIBCUPSORDER="libcups.order"
AC_ARG_WITH(libcupsorder, [ --with-libcupsorder libcups secorder file, default=libcups.order],
- LIBCUPSORDER="$withval",
- LIBCUPSORDER="libcups.order")
+ if test -f "$withval"; then
+ LIBCUPSORDER="$withval"
+ fi)
AC_SUBST(LIBCUPSORDER)
-AC_ARG_WITH(libcupsimageorder, [ --with-libcupimagesorder libcupsimage secorder file, default=libcups.order],
- LIBCUPSIMAGEORDER="$withval",
- LIBCUPSIMAGEORDER="libcupsimage.order")
+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
fi
fi
+ # Generate position-independent code as needed...
if test $PICFLAG = 1 -a $uname != AIX; then
OPTIM="-fPIC $OPTIM"
fi
- case $uname in
- Linux*)
- if test x$enable_pie = xyes; then
- PIEFLAGS="-pie -fPIE"
- fi
-
- if test x$enable_relro = xyes; then
- RELROFLAGS="-Wl,-z,relro"
- fi
- ;;
-
- *)
- if test x$enable_pie = xyes; then
- echo "Sorry, --enable-pie is not supported on this OS!"
- fi
- ;;
- esac
+ # The -fstack-protector option is available with some versions of
+ # GCC and adds "stack canaries" which detect when the return address
+ # has been overwritten, preventing many types of exploit attacks.
+ 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"
+
+ # The -pie option is available with some versions of GCC and adds
+ # randomization of addresses, which avoids another class of exploits
+ # that depend on a fixed address for common functions.
+ 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))
+ CFLAGS="$OLDCFLAGS"
if test "x$with_optim" = x; then
# Add useful warning options for tracking down problems...
OPTIM="-Wall -Wno-format-y2k $OPTIM"
- # Additional warning options for alpha testing...
- OPTIM="-Wshadow -Wunused $OPTIM"
+ # Additional warning options for development testing...
+ if test -d .svn; then
+ OPTIM="-Wshadow -Wunused $OPTIM"
+ fi
fi
case "$uname" in
+ Darwin*)
+ # -D_FORTIFY_SOURCE=2 adds additional object size
+ # checking, basically wrapping all string functions
+ # with buffer-limited ones. Not strictly needed for
+ # CUPS since we already use buffer-limited calls, but
+ # this will catch any additions that are broken.
+ CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
+ ;;
+
HP-UX*)
if test "x$enable_32bit" = xyes; then
# Build 32-bit libraries, 64-bit base...
;;
Linux*)
+ # The -z relro option is provided by the Linux linker command to
+ # make relocatable data read-only.
+ if test x$enable_relro = xyes; then
+ RELROFLAGS="-Wl,-z,relro"
+ fi
+
if test "x$enable_32bit" = xyes; then
# Build 32-bit libraries, 64-bit base...
if test -z "$with_arch32flags"; then
fi
CFLAGS="-Ae $CFLAGS"
- # Warning 336 is "empty translation unit"
- # Warning 829 is passing constant string as char *
- CXXFLAGS="+W336,829 $CXXFLAGS"
if test $PICFLAG = 1; then
OPTIM="+z $OPTIM"
fi
+
+ if test "x$enable_32bit" = xyes; then
+ # Build 32-bit libraries, 64-bit base...
+ 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
+ # Build 64-bit libraries, 32-bit base...
+ 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
# cups-support@cups.org...
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 and CXXFLAGS"
- echo "environment variable before running configure."
+ echo "for your platform, or set the CFLAGS and LDFLAGS environment"
+ echo "variables before running configure."
;;
esac
fi
esac
dnl
-dnl End of "$Id: cups-compiler.m4 6687 2007-07-18 19:49:45Z mike $".
+dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".
dnl