]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Give configure ability to set CFLAGS/LDFLAGS later
authorDamien Miller <djm@mindrot.org>
Fri, 8 Sep 2017 02:38:31 +0000 (12:38 +1000)
committerDamien Miller <djm@mindrot.org>
Fri, 8 Sep 2017 02:38:31 +0000 (12:38 +1000)
Some CFLAGS/LDFLAGS may disrupt the configure script's operation,
in particular santization and fuzzer options that break assumptions
about memory and file descriptor dispositions.

This adds two flags to configure --with-cflags-after and
--with-ldflags-after that allow specifying additional compiler and
linker options that are added to the resultant Makefiles but not
used in the configure run itself.

E.g.

env CC=clang-3.9 ./configure \
  --with-cflags-after=-fsantize=address \
  --with-ldflags-after="-g -fsanitize=address"

configure.ac

index 9094cf04431d4b7e330038ca53e752d420419f31..522f54b0583584b8df1e170d49508f0433cf4ff4 100644 (file)
@@ -289,6 +289,16 @@ AC_ARG_WITH([cflags],
                fi
        ]
 )
+
+AC_ARG_WITH([cflags-after],
+       [  --with-cflags-after     Specify additional flags to pass to compiler after configure],
+       [
+               if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
+                   test "x${withval}" != "xyes"; then
+                       CFLAGS_AFTER="$withval"
+               fi
+       ]
+)
 AC_ARG_WITH([cppflags],
        [  --with-cppflags         Specify additional flags to pass to preprocessor] ,
        [
@@ -307,6 +317,15 @@ AC_ARG_WITH([ldflags],
                fi
        ]
 )
+AC_ARG_WITH([ldflags-after],
+       [  --with-ldflags-after    Specify additional flags to pass to linker after configure],
+       [
+               if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
+                   test "x${withval}" != "xyes"; then
+                       LDFLAGS_AFTER="$withval"
+               fi
+       ]
+)
 AC_ARG_WITH([libs],
        [  --with-libs             Specify additional libraries to link with],
        [
@@ -5022,6 +5041,9 @@ AC_SUBST([TEST_SSH_UTF8], [$TEST_SSH_UTF8])
 AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
 AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
 
+CFLAGS="${CFLAGS} ${CFLAGS_AFTER}"
+LDFLAGS="${LDFLAGS} ${LDFLAGS_AFTER}"
+
 AC_EXEEXT
 AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
        openbsd-compat/Makefile openbsd-compat/regress/Makefile \