]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - config-scripts/cups-compiler.m4
Merge CUPS 1.4svn-r7319.
[thirdparty/cups.git] / config-scripts / cups-compiler.m4
index adbc1294ff0df830b0d621b0a6190925a5f96683..fc1c821eae97ccb2161ed9324fdf47049aab2936 100644 (file)
@@ -1,25 +1,16 @@
 dnl
-dnl "$Id: cups-compiler.m4 5643 2006-06-07 20:58:29Z 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 1997-2006 by Easy Software Products, all rights reserved.
+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
-dnl   property of Easy Software Products and are protected by Federal
-dnl   copyright law.  Distribution and use rights are outlined in the file
-dnl   "LICENSE.txt" which should have been included with this file.  If this
-dnl   file is missing or damaged please contact Easy Software Products
-dnl   at:
-dnl
-dnl       Attn: CUPS Licensing Information
-dnl       Easy Software Products
-dnl       44141 Airport View Drive, Suite 204
-dnl       Hollywood, Maryland 20636 USA
-dnl
-dnl       Voice: (301) 373-9600
-dnl       EMail: cups-info@cups.org
-dnl         WWW: http://www.cups.org
+dnl   property of Apple Inc. and are protected by Federal copyright
+dnl   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
+dnl   which should have been included with this file.  If this file is
+dnl   file is missing or damaged, see the license at "http://www.cups.org/".
 dnl
 
 dnl Clear the debugging and non-shared library options unless the user asks
@@ -39,60 +30,62 @@ AC_ARG_WITH(archflags, [  --with-archflags="flags"
 
 if test -z "$with_archflags"; then
        ARCHFLAGS=""
+       LDARCHFLAGS=""
 else
        ARCHFLAGS="$with_archflags"
+       if test "$uname" = Darwin; then
+               # Only link 32-bit programs - 64-bit is for the shared
+               # libraries...
+               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)
 
 dnl Setup support for separate 32/64-bit library generation...
-AC_ARG_ENABLE(32bit, [  --enable-32bit          generate 32-bit libraries on 32/64-bit systems, default=no])
 AC_ARG_WITH(arch32flags, [  --with-arch32flags="flags"
                           specifies 32-bit architecture flags])
-
 ARCH32FLAGS=""
-INSTALL32=""
-LIB32CUPS=""
-LIB32CUPSIMAGE=""
-LIB32DIR=""
-UNINSTALL32=""
-
 AC_SUBST(ARCH32FLAGS)
-AC_SUBST(INSTALL32)
-AC_SUBST(LIB32CUPS)
-AC_SUBST(LIB32CUPSIMAGE)
-AC_SUBST(LIB32DIR)
-AC_SUBST(UNINSTALL32)
 
-AC_ARG_ENABLE(64bit, [  --enable-64bit          generate 64-bit libraries on 32/64-bit systems, default=no])
 AC_ARG_WITH(arch64flags, [  --with-arch64flags="flags"
                           specifies 64-bit architecture flags])
-
 ARCH64FLAGS=""
-INSTALL64=""
-LIB64CUPS=""
-LIB64CUPSIMAGE=""
-LIB64DIR=""
-UNINSTALL64=""
-
 AC_SUBST(ARCH64FLAGS)
-AC_SUBST(INSTALL64)
-AC_SUBST(LIB64CUPS)
-AC_SUBST(LIB64CUPSIMAGE)
-AC_SUBST(LIB64DIR)
-AC_SUBST(UNINSTALL64)
 
-dnl Position-Independent Executable support on Linux and *BSD...
-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=""
 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
+       # Add GCC-specific compiler options...
        if test -z "$OPTIM"; then
                if test "x$with_optim" = x; then
                        # Default to optimize-for-size and debug
@@ -102,32 +95,90 @@ 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_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...
+                               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
+                               # Build 64-bit libraries, 32-bit base...
+                               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
                                # Build 32-bit libraries, 64-bit base...
@@ -136,11 +187,6 @@ if test -n "$GCC"; then
                                else
                                        ARCH32FLAGS="$with_arch32flags"
                                fi
-                               INSTALL32="install32bit"
-                               LIB32CUPS="32bit/libcups.so.2"
-                               LIB32CUPSIMAGE="32bit/libcupsimage.so.2"
-                               LIB32DIR="$prefix/lib32"
-                               UNINSTALL32="uninstall32bit"
 
                                if test -z "$with_archflags"; then
                                        if test -z "$with_arch64flags"; then
@@ -158,11 +204,6 @@ if test -n "$GCC"; then
                                else
                                        ARCH64FLAGS="$with_arch64flags"
                                fi
-                               INSTALL64="install64bit"
-                               LIB64CUPS="64bit/libcups.so.2"
-                               LIB64CUPSIMAGE="64bit/libcupsimage.so.2"
-                               LIB64DIR="$prefix/lib64"
-                               UNINSTALL64="uninstall64bit"
 
                                if test -z "$with_archflags"; then
                                        if test -z "$with_arch32flags"; then
@@ -175,6 +216,12 @@ if test -n "$GCC"; then
                        ;;
 
                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
@@ -182,14 +229,6 @@ if test -n "$GCC"; then
                                else
                                        ARCH32FLAGS="$with_arch32flags"
                                fi
-                               INSTALL32="install32bit"
-                               LIB32CUPS="32bit/libcups.so.2"
-                               LIB32CUPSIMAGE="32bit/libcupsimage.so.2"
-                               LIB32DIR="$exec_prefix/lib"
-                               if test -d /usr/lib32; then
-                                       LIB32DIR="${LIB32DIR}32"
-                               fi
-                               UNINSTALL32="uninstall32bit"
 
                                if test -z "$with_archflags"; then
                                        if test -z "$with_arch64flags"; then
@@ -207,14 +246,6 @@ if test -n "$GCC"; then
                                else
                                        ARCH64FLAGS="$with_arch64flags"
                                fi
-                               INSTALL64="install64bit"
-                               LIB64CUPS="64bit/libcups.so.2"
-                               LIB64CUPSIMAGE="64bit/libcupsimage.so.2"
-                               LIB64DIR="$exec_prefix/lib"
-                               if test -d /usr/lib64; then
-                                       LIB64DIR="${LIB64DIR}64"
-                               fi
-                               UNINSTALL64="uninstall64bit"
 
                                if test -z "$with_archflags"; then
                                        if test -z "$with_arch32flags"; then
@@ -234,11 +265,6 @@ if test -n "$GCC"; then
                                else
                                        ARCH32FLAGS="$with_arch32flags"
                                fi
-                               INSTALL32="install32bit"
-                               LIB32CUPS="32bit/libcups.so.2"
-                               LIB32CUPSIMAGE="32bit/libcupsimage.so.2"
-                               LIB32DIR="$exec_prefix/lib/32"
-                               UNINSTALL32="uninstall32bit"
 
                                if test -z "$with_archflags"; then
                                        if test -z "$with_arch64flags"; then
@@ -256,11 +282,6 @@ if test -n "$GCC"; then
                                else
                                        ARCH64FLAGS="$with_arch64flags"
                                fi
-                               INSTALL64="install64bit"
-                               LIB64CUPS="64bit/libcups.so.2"
-                               LIB64CUPSIMAGE="64bit/libcupsimage.so.2"
-                               LIB64DIR="$exec_prefix/lib/64"
-                               UNINSTALL64="uninstall64bit"
 
                                if test -z "$with_archflags"; then
                                        if test -z "$with_arch32flags"; then
@@ -273,6 +294,7 @@ if test -n "$GCC"; then
                        ;;
        esac
 else
+       # Add vendor-specific compiler options...
        case $uname in
                AIX*)
                        if test -z "$OPTIM"; then
@@ -293,18 +315,44 @@ else
                        fi
 
                        CFLAGS="-Ae $CFLAGS"
-                       # Warning 336 is "empty translation unit"
-                       # Warning 829 is passing constant string as char *
-                       CXXFLAGS="+W336,829 $CXXFLAGS"
-
-                       if test -z "$with_archflags"; then
-                               # Build portable binaries for all HP systems...
-                               ARCHFLAGS="+DAportable"
-                       fi
 
                        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
@@ -326,11 +374,6 @@ else
                                else
                                        ARCH32FLAGS="$with_arch32flags"
                                fi
-                               INSTALL32="install32bit"
-                               LIB32CUPS="32bit/libcups.so.2"
-                               LIB32CUPSIMAGE="32bit/libcupsimage.so.2"
-                               LIB32DIR="$prefix/lib32"
-                               UNINSTALL32="uninstall32bit"
 
                                if test -z "$with_archflags"; then
                                        if test -z "$with_arch64flags"; then
@@ -348,11 +391,6 @@ else
                                else
                                        ARCH64FLAGS="$with_arch64flags"
                                fi
-                               INSTALL64="install64bit"
-                               LIB64CUPS="64bit/libcups.so.2"
-                               LIB64CUPSIMAGE="64bit/libcupsimage.so.2"
-                               LIB64DIR="$prefix/lib64"
-                               UNINSTALL64="uninstall64bit"
 
                                if test -z "$with_archflags"; then
                                        if test -z "$with_arch32flags"; then
@@ -363,6 +401,16 @@ else
                                fi
                        fi
                        ;;
+               OSF*)
+                       # Tru64 UNIX aka Digital UNIX aka OSF/1
+                       if test -z "$OPTIM"; then
+                               if test "x$with_optim" = x; then
+                                       OPTIM="-O"
+                               else
+                                       OPTIM="$with_optim"
+                               fi
+                       fi
+                       ;;
                SunOS*)
                        # Solaris
                        if test -z "$OPTIM"; then
@@ -381,11 +429,6 @@ else
                                # Compiling on a Solaris system, build 64-bit
                                # binaries with separate 32-bit libraries...
                                ARCH32FLAGS="-xarch=generic"
-                               INSTALL32="install32bit"
-                               LIB32CUPS="32bit/libcups.so.2"
-                               LIB32CUPSIMAGE="32bit/libcupsimage.so.2"
-                               LIB32DIR="$exec_prefix/lib/32"
-                               UNINSTALL32="uninstall32bit"
 
                                if test "x$with_optim" = x; then
                                        # Suppress all of Sun's questionable
@@ -405,11 +448,6 @@ else
                                if test "x$enable_64bit" = xyes; then
                                        # Build 64-bit libraries...
                                        ARCH64FLAGS="-xarch=generic64"
-                                       INSTALL64="install64bit"
-                                       LIB64CUPS="64bit/libcups.so.2"
-                                       LIB64CUPSIMAGE="64bit/libcupsimage.so.2"
-                                       LIB64DIR="$exec_prefix/lib/64"
-                                       UNINSTALL64="uninstall64bit"
                                fi
 
                                if test "x$with_optim" = x; then
@@ -448,22 +486,35 @@ else
                        # 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
 
-if test $uname = HP-UX; then
-       # HP-UX 10.20 (at least) needs this definition to get the
-       # h_errno global...
-       OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
-
-       # HP-UX 11.00 (at least) needs this definition to get the
-       # u_short type used by the IP headers...
-       OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
-fi
+# Add general compiler options per platform...
+case $uname in
+       HP-UX*)
+               # HP-UX 10.20 (at least) needs this definition to get the
+               # h_errno global...
+               OPTIM="$OPTIM -D_XOPEN_SOURCE_EXTENDED"
+
+               # HP-UX 11.00 (at least) needs this definition to get the
+               # u_short type used by the IP headers...
+               OPTIM="$OPTIM -D_INCLUDE_HPUX_SOURCE"
+
+               # HP-UX 11.23 (at least) needs this definition to get the
+               # IPv6 header to work...
+               OPTIM="$OPTIM -D_HPUX_SOURCE"
+               ;;
+
+       OSF*)
+               # Tru64 UNIX aka Digital UNIX aka OSF/1 need to be told
+               # to be POSIX-compliant...
+               OPTIM="$OPTIM -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE"
+               ;;
+esac
 
 dnl
-dnl End of "$Id: cups-compiler.m4 5643 2006-06-07 20:58:29Z mike $".
+dnl End of "$Id: cups-compiler.m4 6975 2007-09-18 20:37:09Z mike $".
 dnl