diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 43e40974..1404280f 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -37,9 +37,9 @@ RUN mkdir -p $PHP_INI_DIR/conf.d # Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default) # Adds GNU HASH segments to generated executables (this is used if present, and is much faster than sysv hash; in this configuration, sysv hash is also generated) # https://github.com/docker-library/php/issues/272 -ENV CFLAGS="-fstack-protector-strong -fpic -fpie -O2" -ENV CPPFLAGS="$CFLAGS" -ENV LDFLAGS="-Wl,-O1 -Wl,--hash-style=both" +ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2" +ENV PHP_CPPFLAGS="$PHP_CFLAGS" +ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie" ENV GPG_KEYS %%GPG_KEYS%% @@ -89,6 +89,9 @@ RUN set -xe \ openssl-dev \ sqlite-dev \ \ + && export CFLAGS="$PHP_CFLAGS" \ + CPPFLAGS="$PHP_CPPFLAGS" \ + LDFLAGS="$PHP_LDFLAGS" \ && docker-php-source extract \ && cd /usr/src/php \ && ./configure \ diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 2f4de9cd..896f1b17 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -32,9 +32,9 @@ RUN mkdir -p $PHP_INI_DIR/conf.d # Enable linker optimization (this sorts the hash buckets to improve cache locality, and is non-default) # Adds GNU HASH segments to generated executables (this is used if present, and is much faster than sysv hash; in this configuration, sysv hash is also generated) # https://github.com/docker-library/php/issues/272 -ENV CFLAGS="-fstack-protector-strong -fpic -fpie -O2" -ENV CPPFLAGS="$CFLAGS" -ENV LDFLAGS="-Wl,-O1 -Wl,--hash-style=both" +ENV PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2" +ENV PHP_CPPFLAGS="$PHP_CFLAGS" +ENV PHP_LDFLAGS="-Wl,-O1 -Wl,--hash-style=both -pie" ENV GPG_KEYS %%GPG_KEYS%% @@ -88,6 +88,9 @@ RUN set -xe \ " \ && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \ \ + && export CFLAGS="$PHP_CFLAGS" \ + CPPFLAGS="$PHP_CPPFLAGS" \ + LDFLAGS="$PHP_LDFLAGS" \ && docker-php-source extract \ && cd /usr/src/php \ && ./configure \ diff --git a/docker-php-ext-configure b/docker-php-ext-configure index 2a6f8394..93d31601 100755 --- a/docker-php-ext-configure +++ b/docker-php-ext-configure @@ -1,6 +1,12 @@ #!/bin/sh set -e +# prefer user supplied CFLAGS, but default to our PHP_CFLAGS +: ${CFLAGS:=$PHP_CFLAGS} +: ${CPPFLAGS:=$PHP_CPPFLAGS} +: ${LDFLAGS:=$PHP_LDFLAGS} +export CFLAGS CPPFLAGS LDFLAGS + srcExists= if [ -d /usr/src/php ]; then srcExists=1 diff --git a/docker-php-ext-install b/docker-php-ext-install index 79df34e1..c0660230 100755 --- a/docker-php-ext-install +++ b/docker-php-ext-install @@ -1,6 +1,12 @@ #!/bin/sh set -e +# prefer user supplied CFLAGS, but default to our PHP_CFLAGS +: ${CFLAGS:=$PHP_CFLAGS} +: ${CPPFLAGS:=$PHP_CPPFLAGS} +: ${LDFLAGS:=$PHP_LDFLAGS} +export CFLAGS CPPFLAGS LDFLAGS + srcExists= if [ -d /usr/src/php ]; then srcExists=1