dnl
-dnl Compiler stuff for CUPS.
+dnl Compiler tests for CUPS.
dnl
-dnl Copyright 2007-2018 by Apple Inc.
-dnl Copyright 1997-2007 by Easy Software Products, all rights reserved.
+dnl Copyright © 2021 by OpenPrinting.
+dnl Copyright © 2007-2018 by Apple Inc.
+dnl Copyright © 1997-2007 by Easy Software Products, all rights reserved.
dnl
-dnl Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+dnl Licensed under Apache License v2.0. See the file "LICENSE" for more
+dnl information.
dnl
dnl Clear the debugging and non-shared library options unless the user asks
INSTALL_STRIP=""
AC_SUBST(INSTALL_STRIP)
-AC_ARG_WITH(optim, [ --with-optim set optimization flags ],
- OPTIM="$withval",
- OPTIM="")
-AC_SUBST(OPTIM)
+AC_ARG_WITH([optim], AS_HELP_STRING([--with-optim], [set optimization flags]), [
+ OPTIM="$withval"
+], [
+ OPTIM=""
+])
+AC_SUBST([OPTIM])
-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])
+AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug], [build with debugging symbols]))
+AC_ARG_ENABLE([debug_guards], AS_HELP_STRING([--enable-debug-guards], [build with memory allocation guards]))
+AC_ARG_ENABLE([debug_printfs], AS_HELP_STRING([--enable-debug-printfs], [build with CUPS_DEBUG_LOG support]))
+AC_ARG_ENABLE([maintainer], AS_HELP_STRING([--enable-maintainer], [turn on maintainer mode (warnings as errors)]))
+AC_ARG_ENABLE([unit_tests], AS_HELP_STRING([--enable-unit-tests], [build and run unit tests]))
dnl For debugging, keep symbols, otherwise strip them...
-if test x$enable_debug = xyes -a "x$OPTIM" = x; then
- OPTIM="-g"
-else
- INSTALL_STRIP="-s"
-fi
+AS_IF([test x$enable_debug = xyes -a "x$OPTIM" = x], [
+ OPTIM="-g"
+], [
+ INSTALL_STRIP="-s"
+])
dnl Debug printfs can slow things down, so provide a separate option for that
-if test x$enable_debug_printfs = xyes; then
- CFLAGS="$CFLAGS -DDEBUG"
- CXXFLAGS="$CXXFLAGS -DDEBUG"
-fi
+AS_IF([test x$enable_debug_printfs = xyes], [
+ CFLAGS="$CFLAGS -DDEBUG"
+ CXXFLAGS="$CXXFLAGS -DDEBUG"
+])
dnl Debug guards use an extra 4 bytes for some structures like strings in the
dnl string pool, so provide a separate option for that
-if test x$enable_debug_guards = xyes; then
- CFLAGS="$CFLAGS -DDEBUG_GUARDS"
- CXXFLAGS="$CXXFLAGS -DDEBUG_GUARDS"
-fi
+AS_IF([test x$enable_debug_guards = xyes], [
+ CFLAGS="$CFLAGS -DDEBUG_GUARDS"
+ CXXFLAGS="$CXXFLAGS -DDEBUG_GUARDS"
+])
dnl Unit tests take up time during a compile...
-if test x$enable_unit_tests = xyes; then
- if test "$build" != "$host"; then
- AC_MSG_ERROR([Sorry, cannot build unit tests when cross-compiling.])
- fi
+AS_IF([test x$enable_unit_tests = xyes], [
+ AS_IF([test "$build" != "$host"], [
+ AC_MSG_ERROR([Sorry, cannot build unit tests when cross-compiling.])
+ ])
- UNITTESTS="unittests"
-else
- UNITTESTS=""
-fi
-AC_SUBST(UNITTESTS)
+ UNITTESTS="unittests"
+], [
+ UNITTESTS=""
+])
+AC_SUBST([UNITTESTS])
dnl Setup general architecture flags...
-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 "$host_os_name" = darwin; then
- # Only create Intel programs by default
- 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_WITH([archflags], AS_HELP_STRING([--with-archflags], [set default architecture flags]))
+AC_ARG_WITH([ldarchflags], AS_HELP_STRING([--with-ldarchflags], [set program architecture flags]))
+
+AS_IF([test -z "$with_archflags"], [
+ ARCHFLAGS=""
+], [
+ ARCHFLAGS="$with_archflags"
+])
+
+AS_IF([test -z "$with_ldarchflags"], [
+ LDARCHFLAGS="$ARCHFLAGS"
+], [
+ LDARCHFLAGS="$with_ldarchflags"
+])
+
+AC_SUBST([ARCHFLAGS])
+AC_SUBST([LDARCHFLAGS])
dnl Read-only data/program support on Linux...
-AC_ARG_ENABLE(relro, [ --enable-relro build with the GCC relro option])
+AC_ARG_ENABLE([relro], AS_HELP_STRING([--enable-relro], [build with the relro option]))
dnl Clang/GCC address sanitizer...
-AC_ARG_ENABLE(sanitizer, [ --enable-sanitizer build with AddressSanitizer])
+AC_ARG_ENABLE([sanitizer], AS_HELP_STRING([--enable-sanitizer], [build with AddressSanitizer]))
dnl Update compiler options...
CXXLIBS="${CXXLIBS:=}"
-AC_SUBST(CXXLIBS)
+AC_SUBST([CXXLIBS])
PIEFLAGS=""
-AC_SUBST(PIEFLAGS)
+AC_SUBST([PIEFLAGS])
RELROFLAGS=""
-AC_SUBST(RELROFLAGS)
+AC_SUBST([RELROFLAGS])
WARNING_OPTIONS=""
-AC_SUBST(WARNING_OPTIONS)
-
-if test -n "$GCC"; then
- # Add GCC-specific compiler options...
-
- # Address sanitizer is a useful tool to use when developing/debugging
- # code but adds about 2x overhead...
- if test x$enable_sanitizer = xyes; then
- # Use -fsanitize=address with debugging...
- OPTIM="$OPTIM -g -fsanitize=address"
- else
- # Otherwise use the Fortify enhancements to catch any unbounded
- # string operations...
- CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
- CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
- fi
-
- # Default optimization options...
- if test -z "$OPTIM"; then
- # Default to optimize-for-size and debug
- OPTIM="-Os -g"
- fi
-
- # Generate position-independent code as needed...
- if test $PICFLAG = 1; then
- OPTIM="-fPIC $OPTIM"
- fi
-
- # 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(whether compiler supports -fstack-protector)
+AC_SUBST([WARNING_OPTIONS])
+
+AS_IF([test -n "$GCC"], [
+ # Add GCC/Clang compiler options...
+
+ # Address sanitizer is a useful tool to use when developing/debugging
+ # code but adds about 2x overhead...
+ AS_IF([test x$enable_sanitizer = xyes], [
+ # Use -fsanitize=address with debugging...
+ OPTIM="$OPTIM -g -fsanitize=address"
+ ], [
+ # Otherwise use the Fortify enhancements to catch any unbounded
+ # string operations...
+ CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
+ CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
+ ])
+
+ # Default optimization options...
+ AS_IF([test -z "$OPTIM"], [
+ # Default to optimize-for-size and debug
+ OPTIM="-Os -g"
+ ])
+
+ # Generate position-independent code as needed...
+ AS_IF([test $PICFLAG = 1], [
+ OPTIM="-fPIC $OPTIM"
+ ])
+
+ # 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([whether compiler supports -fstack-protector])
+ OLDCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fstack-protector"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM()], [
+ AS_IF([test "x$LSB_BUILD" = xy], [
+ # Can't use stack-protector with LSB binaries...
+ OPTIM="$OPTIM -fno-stack-protector"
+ ], [
+ OPTIM="$OPTIM -fstack-protector"
+ ])
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+ CFLAGS="$OLDCFLAGS"
+
+ AS_IF([test "x$LSB_BUILD" != xy], [
+ # The -fPIE 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.
+ #
+ # Not available to LSB binaries...
+ AC_MSG_CHECKING([whether compiler supports -fPIE])
OLDCFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -fstack-protector"
- AC_TRY_LINK(,,
- if test "x$LSB_BUILD" = xy; then
- # Can't use stack-protector with LSB binaries...
- OPTIM="$OPTIM -fno-stack-protector"
- else
- OPTIM="$OPTIM -fstack-protector"
- fi
- AC_MSG_RESULT(yes),
- AC_MSG_RESULT(no))
+ AS_CASE(["$host_os_name"], [darwin*], [
+ CFLAGS="$CFLAGS -fPIE -Wl,-pie"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ PIEFLAGS="-fPIE -Wl,-pie"
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+ ], [*], [
+ CFLAGS="$CFLAGS -fPIE -pie"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ PIEFLAGS="-fPIE -pie"
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_RESULT([no])
+ ])
+ ])
CFLAGS="$OLDCFLAGS"
+ ])
+
+ dnl Show all standard warnings + unused variables when compiling...
+ WARNINGS="-Wall -Wunused"
+
+ dnl Drop some not-useful/unreliable warnings...
+ for warning in char-subscripts format-truncation format-y2k switch unused-result; do
+ AC_MSG_CHECKING([whether compiler supports -Wno-$warning])
- if test "x$LSB_BUILD" != xy; then
- # The -fPIE 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.
- #
- # Not available to LSB binaries...
- AC_MSG_CHECKING(whether compiler supports -fPIE)
- OLDCFLAGS="$CFLAGS"
- case "$host_os_name" 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
-
- # Add useful warning options for tracking down problems...
- WARNING_OPTIONS="-Wall -Wno-format-y2k -Wunused -Wno-unused-result -Wsign-conversion -Wno-deprecated-declarations"
-
- # Test GCC version for certain warning flags since -Werror
- # doesn't trigger...
- gccversion=`$CC --version | head -1 | awk '{print $NF}'`
- case "$gccversion" in
- 7.* | 8.* | 9.* | 10.* | 11.* | 12.*)
- WARNING_OPTIONS="$WARNING_OPTIONS -Wno-format-truncation -Wno-tautological-compare"
- ;;
- esac
-
- # Additional warning options for development testing...
-# if test -d .git; then
-# WARNING_OPTIONS="-Werror -Wno-error=deprecated-declarations $WARNING_OPTIONS"
-# fi
-else
- # Add vendor-specific compiler options...
- case $host_os_name in
- sunos*)
- # Solaris
- if test -z "$OPTIM"; then
- OPTIM="-xO2"
- fi
-
- if test $PICFLAG = 1; then
- OPTIM="-KPIC $OPTIM"
- fi
- ;;
- *)
- # Running some other operating system; inform the user
- # they should contribute the necessary options via
- # Github...
- echo "Building CUPS with default compiler optimizations; contact the CUPS developers on Github"
- echo "(https://github.com/apple/cups/issues) with the uname and compiler options needed for"
- echo "your platform, or set the CFLAGS and LDFLAGS environment variables before running"
- echo "configure."
- ;;
- esac
-fi
+ OLDCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wno-$warning -Werror"
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [
+ AC_MSG_RESULT(yes)
+ WARNINGS="$WARNINGS -Wno-$warning"
+ ], [
+ AC_MSG_RESULT(no)
+ ])
+
+ CFLAGS="$OLDCFLAGS"
+ done
+
+ dnl Maintainer mode enables -Werror...
+ AS_IF([test x$enable_maintainer = xyes], [
+ WARNINGS="$WARNINGS -Werror"
+ ])
+], [
+ # Add vendor-specific compiler options...
+ AS_CASE([$host_os_name], [sunos*], [
+ # Solaris
+ AS_IF([test -z "$OPTIM"], [
+ OPTIM="-xO2"
+ ])
+
+ AS_IF([test $PICFLAG = 1], [
+ OPTIM="-KPIC $OPTIM"
+ ])
+ ], [*], [
+ # Running some other operating system; inform the user
+ # they should contribute the necessary options via
+ # Github...
+ echo "Building CUPS with default compiler optimizations."
+ echo "Contact the OpenPrinting CUPS developers on Github with the uname and compiler"
+ echo "options needed for your platform, or set the CFLAGS and LDFLAGS environment"
+ echo "variables before running configure."
+ echo ""
+ echo "https://github.com/openprinting/cups"
+ ;;
+ ])
+])
# Add general compiler options per platform...
-case $host_os_name in
- linux*)
- # glibc 2.8 and higher breaks peer credentials unless you
- # define _GNU_SOURCE...
- OPTIM="$OPTIM -D_GNU_SOURCE"
-
- # 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,-z,now"
- fi
- ;;
-esac
+AS_CASE([$host_os_name], [linux*], [
+ # glibc 2.8 and higher breaks peer credentials unless you
+ # define _GNU_SOURCE...
+ OPTIM="$OPTIM -D_GNU_SOURCE"
+
+ # The -z relro option is provided by the Linux linker command to
+ # make relocatable data read-only.
+ AS_IF([test x$enable_relro = xyes], [
+ RELROFLAGS="-Wl,-z,relro,-z,now"
+ ])
+])
enable_debug
enable_debug_guards
enable_debug_printfs
+enable_maintainer
enable_unit_tests
with_archflags
with_ldarchflags
--enable-debug build with debugging symbols
--enable-debug-guards build with memory allocation guards
--enable-debug-printfs build with CUPS_DEBUG_LOG support
+ --enable-maintainer turn on maintainer mode (warnings as errors)
--enable-unit-tests build and run unit tests
- --enable-relro build with the GCC relro option
+ --enable-relro build with the relro option
--enable-sanitizer build with AddressSanitizer
--disable-gssapi disable GSSAPI support
--disable-threads disable multi-threading support
# Check whether --with-optim was given.
if test ${with_optim+y}
then :
- withval=$with_optim; OPTIM="$withval"
+ withval=$with_optim;
+ OPTIM="$withval"
+
else $as_nop
- OPTIM=""
+
+ OPTIM=""
+
fi
enableval=$enable_debug_printfs;
fi
+# Check whether --enable-maintainer was given.
+if test ${enable_maintainer+y}
+then :
+ enableval=$enable_maintainer;
+fi
+
# Check whether --enable-unit_tests was given.
if test ${enable_unit_tests+y}
then :
fi
-if test x$enable_debug = xyes -a "x$OPTIM" = x; then
- OPTIM="-g"
-else
- INSTALL_STRIP="-s"
+if test x$enable_debug = xyes -a "x$OPTIM" = x
+then :
+
+ OPTIM="-g"
+
+else $as_nop
+
+ INSTALL_STRIP="-s"
+
fi
-if test x$enable_debug_printfs = xyes; then
- CFLAGS="$CFLAGS -DDEBUG"
- CXXFLAGS="$CXXFLAGS -DDEBUG"
+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"
+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
- if test "$build" != "$host"; then
- as_fn_error $? "Sorry, cannot build unit tests when cross-compiling." "$LINENO" 5
- fi
+if test x$enable_unit_tests = xyes
+then :
+
+ if test "$build" != "$host"
+then :
+
+ as_fn_error $? "Sorry, cannot build unit tests when cross-compiling." "$LINENO" 5
+
+fi
+
+ UNITTESTS="unittests"
+
+else $as_nop
+
+ UNITTESTS=""
- UNITTESTS="unittests"
-else
- UNITTESTS=""
fi
fi
-if test -z "$with_archflags"; then
- ARCHFLAGS=""
-else
- ARCHFLAGS="$with_archflags"
+if test -z "$with_archflags"
+then :
+
+ ARCHFLAGS=""
+
+else $as_nop
+
+ ARCHFLAGS="$with_archflags"
+
fi
-if test -z "$with_ldarchflags"; then
- if test "$host_os_name" = darwin; then
- # Only create Intel programs by default
- LDARCHFLAGS="`echo $ARCHFLAGS | sed -e '1,$s/-arch ppc64//'`"
- else
- LDARCHFLAGS="$ARCHFLAGS"
- fi
-else
- LDARCHFLAGS="$with_ldarchflags"
+if test -z "$with_ldarchflags"
+then :
+
+ LDARCHFLAGS="$ARCHFLAGS"
+
+else $as_nop
+
+ LDARCHFLAGS="$with_ldarchflags"
+
fi
WARNING_OPTIONS=""
-if test -n "$GCC"; then
- # Add GCC-specific compiler options...
+if test -n "$GCC"
+then :
- # Address sanitizer is a useful tool to use when developing/debugging
- # code but adds about 2x overhead...
- if test x$enable_sanitizer = xyes; then
- # Use -fsanitize=address with debugging...
- OPTIM="$OPTIM -g -fsanitize=address"
- else
- # Otherwise use the Fortify enhancements to catch any unbounded
- # string operations...
- CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
- CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
- fi
+ # Add GCC/Clang compiler options...
- # Default optimization options...
- if test -z "$OPTIM"; then
- # Default to optimize-for-size and debug
- OPTIM="-Os -g"
- fi
+ # Address sanitizer is a useful tool to use when developing/debugging
+ # code but adds about 2x overhead...
+ if test x$enable_sanitizer = xyes
+then :
- # Generate position-independent code as needed...
- if test $PICFLAG = 1; then
- OPTIM="-fPIC $OPTIM"
- fi
+ # Use -fsanitize=address with debugging...
+ OPTIM="$OPTIM -g -fsanitize=address"
+
+else $as_nop
+
+ # Otherwise use the Fortify enhancements to catch any unbounded
+ # string operations...
+ CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
+ CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
+
+fi
+
+ # Default optimization options...
+ if test -z "$OPTIM"
+then :
+
+ # Default to optimize-for-size and debug
+ OPTIM="-Os -g"
+
+fi
- # 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.
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -fstack-protector" >&5
+ # Generate position-independent code as needed...
+ if test $PICFLAG = 1
+then :
+
+ OPTIM="-fPIC $OPTIM"
+
+fi
+
+ # 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.
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -fstack-protector" >&5
printf %s "checking whether compiler supports -fstack-protector... " >&6; }
- OLDCFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -fstack-protector"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ OLDCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fstack-protector"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
- if test "x$LSB_BUILD" = xy; then
- # Can't use stack-protector with LSB binaries...
- OPTIM="$OPTIM -fno-stack-protector"
- else
- OPTIM="$OPTIM -fstack-protector"
- fi
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+
+ if test "x$LSB_BUILD" = xy
+then :
+
+ # Can't use stack-protector with LSB binaries...
+ OPTIM="$OPTIM -fno-stack-protector"
+
+else $as_nop
+
+ OPTIM="$OPTIM -fstack-protector"
+
+fi
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
+
else $as_nop
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
+
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$OLDCFLAGS"
+ CFLAGS="$OLDCFLAGS"
- if test "x$LSB_BUILD" != xy; then
- # The -fPIE 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.
- #
- # Not available to LSB binaries...
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -fPIE" >&5
+ if test "x$LSB_BUILD" != xy
+then :
+
+ # The -fPIE 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.
+ #
+ # Not available to LSB binaries...
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -fPIE" >&5
printf %s "checking whether compiler supports -fPIE... " >&6; }
- OLDCFLAGS="$CFLAGS"
- case "$host_os_name" in
- darwin*)
- CFLAGS="$CFLAGS -fPIE -Wl,-pie"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ OLDCFLAGS="$CFLAGS"
+ case "$host_os_name" in #(
+ darwin*) :
+
+ CFLAGS="$CFLAGS -fPIE -Wl,-pie"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
if ac_fn_c_try_compile "$LINENO"
then :
- PIEFLAGS="-fPIE -Wl,-pie"
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ PIEFLAGS="-fPIE -Wl,-pie"
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
+
else $as_nop
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
+
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
- ;;
+ ;; #(
+ *) :
- *)
- CFLAGS="$CFLAGS -fPIE -pie"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ CFLAGS="$CFLAGS -fPIE -pie"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
if ac_fn_c_try_compile "$LINENO"
then :
- PIEFLAGS="-fPIE -pie"
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ PIEFLAGS="-fPIE -pie"
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
+
else $as_nop
- { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
+
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
- ;;
- esac
- CFLAGS="$OLDCFLAGS"
- fi
+ ;; #(
+ *) :
+ ;;
+esac
+ CFLAGS="$OLDCFLAGS"
- # Add useful warning options for tracking down problems...
- WARNING_OPTIONS="-Wall -Wno-format-y2k -Wunused -Wno-unused-result -Wsign-conversion -Wno-deprecated-declarations"
+fi
- # Test GCC version for certain warning flags since -Werror
- # doesn't trigger...
- gccversion=`$CC --version | head -1 | awk '{print $NF}'`
- case "$gccversion" in
- 7.* | 8.* | 9.* | 10.* | 11.* | 12.*)
- WARNING_OPTIONS="$WARNING_OPTIONS -Wno-format-truncation -Wno-tautological-compare"
- ;;
- esac
+ WARNINGS="-Wall -Wunused"
- # Additional warning options for development testing...
-# if test -d .git; then
-# WARNING_OPTIONS="-Werror -Wno-error=deprecated-declarations $WARNING_OPTIONS"
-# fi
-else
- # Add vendor-specific compiler options...
- case $host_os_name in
- sunos*)
- # Solaris
- if test -z "$OPTIM"; then
- OPTIM="-xO2"
- fi
+ for warning in char-subscripts format-truncation format-y2k switch unused-result; do
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether compiler supports -Wno-$warning" >&5
+printf %s "checking whether compiler supports -Wno-$warning... " >&6; }
+
+ OLDCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wno-$warning -Werror"
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main (void)
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+ WARNINGS="$WARNINGS -Wno-$warning"
+
+else $as_nop
+
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
+ CFLAGS="$OLDCFLAGS"
+ done
+
+ if test x$enable_maintainer = xyes
+then :
+
+ WARNINGS="$WARNINGS -Werror"
+
+fi
+
+else $as_nop
+
+ # Add vendor-specific compiler options...
+ case $host_os_name in #(
+ sunos*) :
+
+ # Solaris
+ if test -z "$OPTIM"
+then :
+
+ OPTIM="-xO2"
+
+fi
+
+ if test $PICFLAG = 1
+then :
+
+ OPTIM="-KPIC $OPTIM"
+
+fi
+ ;; #(
+ *) :
+
+ # Running some other operating system; inform the user
+ # they should contribute the necessary options via
+ # Github...
+ echo "Building CUPS with default compiler optimizations."
+ echo "Contact the OpenPrinting CUPS developers on Github with the uname and compiler"
+ echo "options needed for your platform, or set the CFLAGS and LDFLAGS environment"
+ echo "variables before running configure."
+ echo ""
+ echo "https://github.com/openprinting/cups"
+ ;;
+ ;; #(
+ *) :
+ ;;
+esac
- if test $PICFLAG = 1; then
- OPTIM="-KPIC $OPTIM"
- fi
- ;;
- *)
- # Running some other operating system; inform the user
- # they should contribute the necessary options via
- # Github...
- echo "Building CUPS with default compiler optimizations; contact the CUPS developers on Github"
- echo "(https://github.com/apple/cups/issues) with the uname and compiler options needed for"
- echo "your platform, or set the CFLAGS and LDFLAGS environment variables before running"
- echo "configure."
- ;;
- esac
fi
# Add general compiler options per platform...
-case $host_os_name in
- linux*)
- # glibc 2.8 and higher breaks peer credentials unless you
- # define _GNU_SOURCE...
- OPTIM="$OPTIM -D_GNU_SOURCE"
-
- # 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,-z,now"
- fi
- ;;
+case $host_os_name in #(
+ linux*) :
+
+ # glibc 2.8 and higher breaks peer credentials unless you
+ # define _GNU_SOURCE...
+ OPTIM="$OPTIM -D_GNU_SOURCE"
+
+ # 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,-z,now"
+
+fi
+ ;; #(
+ *) :
+ ;;
esac