Skip to content

Commit

Permalink
Merge pull request #75451 from Izorkin/php-build
Browse files Browse the repository at this point in the history
Update php build configuration
  • Loading branch information
Mic92 committed Feb 25, 2020
2 parents 538ec50 + ffe9053 commit 21baef3
Showing 1 changed file with 39 additions and 32 deletions.
71 changes: 39 additions & 32 deletions pkgs/development/interpreters/php/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# pcre functionality is tested in nixos/tests/php-pcre.nix
{ lib, stdenv, fetchurl, autoconf, bison, libtool, pkgconfig, re2c
, libmysqlclient, libxml2, readline, zlib, curl, postgresql, gettext
, openssl, pcre, pcre2, sqlite, config, libjpeg, libpng, freetype
{ config, lib, stdenv, fetchurl
, autoconf, automake, bison, file, flex, libtool, pkgconfig, re2c
, libxml2, readline, zlib, curl, postgresql, gettext
, openssl, pcre, pcre2, sqlite
, libxslt, libmcrypt, bzip2, icu, openldap, cyrus_sasl, libmhash, unixODBC
, uwimap, pam, gmp, apacheHttpd, libiconv, systemd, libsodium, html-tidy, libargon2
, gd, freetype, libXpm, libjpeg, libpng, libwebp
, libzip, valgrind, oniguruma
}:

Expand All @@ -19,8 +21,8 @@ let
, ldapSupport ? config.php.ldap or true
, mhashSupport ? config.php.mhash or false
, mysqlndSupport ? config.php.mysqlnd or true
, mysqliSupport ? config.php.mysqli or true
, pdo_mysqlSupport ? config.php.pdo_mysql or true
, mysqliSupport ? (config.php.mysqli or true) && (mysqlndSupport)
, pdo_mysqlSupport ? (config.php.pdo_mysql or true) && (mysqlndSupport)
, libxml2Support ? config.php.libxml2 or true
, apxs2Support ? config.php.apxs2 or (!stdenv.isDarwin)
, embedSupport ? config.php.embed or false
Expand Down Expand Up @@ -61,20 +63,24 @@ let
, xmlrpcSupport ? (config.php.xmlrpc or false) && (libxml2Support)
, cgotoSupport ? config.php.cgoto or false
, valgrindSupport ? (config.php.valgrind or true) && (versionAtLeast version "7.2")
, ipv6Support ? config.php.ipv6 or true
, pearSupport ? (config.php.pear or true) && (libxml2Support)
}:

let
mysqlBuildInputs = optional (!mysqlndSupport) libmysqlclient;
libmcrypt' = libmcrypt.override { disablePosixThreads = true; };
in stdenv.mkDerivation {

inherit version;

name = "php-${version}";
pname = "php";

enableParallelBuilding = true;

nativeBuildInputs = [ autoconf bison libtool pkgconfig re2c ];
nativeBuildInputs = [
autoconf automake bison file flex libtool pkgconfig re2c
];

buildInputs = [ ]
++ optional (versionOlder version "7.3") pcre
++ optional (versionAtLeast version "7.3") pcre2
Expand All @@ -83,7 +89,7 @@ let
++ optionals imapSupport [ uwimap openssl pam ]
++ optionals curlSupport [ curl openssl ]
++ optionals ldapSupport [ openldap openssl ]
++ optionals gdSupport [ libpng libjpeg freetype ]
++ optionals gdSupport [ gd freetype libXpm libjpeg libpng libwebp ]
++ optionals opensslSupport [ openssl openssl.dev ]
++ optional apxs2Support apacheHttpd
++ optional (ldapSupport && stdenv.isLinux) cyrus_sasl
Expand All @@ -95,8 +101,6 @@ let
++ optional postgresqlSupport postgresql
++ optional pdo_odbcSupport unixODBC
++ optional pdo_pgsqlSupport postgresql
++ optionals pdo_mysqlSupport mysqlBuildInputs
++ optionals mysqliSupport mysqlBuildInputs
++ optional gmpSupport gmp
++ optional gettextSupport gettext
++ optional intlSupport icu
Expand Down Expand Up @@ -138,7 +142,6 @@ let
++ optional (libxml2Support && (versionOlder version "7.4")) "--with-libxml-dir=${libxml2.dev}"
++ optional (!libxml2Support) [
"--disable-dom"
"--disable-libxml"
(if (versionOlder version "7.4") then "--disable-libxml" else "--without-libxml")
"--disable-simplexml"
"--disable-xml"
Expand All @@ -152,23 +155,26 @@ let
++ optional postgresqlSupport "--with-pgsql=${postgresql}"
++ optional pdo_odbcSupport "--with-pdo-odbc=unixODBC,${unixODBC}"
++ optional pdo_pgsqlSupport "--with-pdo-pgsql=${postgresql}"
++ optional pdo_mysqlSupport "--with-pdo-mysql=${if mysqlndSupport then "mysqlnd" else libmysqlclient}"
++ optionals mysqliSupport [
"--with-mysqli=${if mysqlndSupport then "mysqlnd" else "${libmysqlclient}/bin/mysql_config"}"
]
++ optional ( pdo_mysqlSupport || mysqliSupport ) "--with-mysql-sock=/run/mysqld/mysqld.sock"
++ optional (pdo_mysqlSupport && mysqlndSupport) "--with-pdo-mysql=mysqlnd"
++ optional (mysqliSupport && mysqlndSupport) "--with-mysqli=mysqlnd"
++ optional (pdo_mysqlSupport || mysqliSupport) "--with-mysql-sock=/run/mysqld/mysqld.sock"
++ optional bcmathSupport "--enable-bcmath"
# FIXME: Our own gd package doesn't work, see https://bugs.php.net/bug.php?id=60108.
++ optionals (gdSupport && versionAtLeast version "7.4") [
"--enable-gd"
"--with-external-gd=${gd.dev}"
"--with-webp=${libwebp}"
"--with-jpeg=${libjpeg.dev}"
"--with-xpm=${libXpm.dev}"
"--with-freetype=${freetype.dev}"
"--enable-gd-jis-conv"
] ++ optionals (gdSupport && versionOlder version "7.4") [
"--with-gd"
"--with-freetype-dir=${freetype.dev}"
"--with-png-dir=${libpng.dev}"
"--with-gd=${gd.dev}"
"--with-webp-dir=${libwebp}"
"--with-jpeg-dir=${libjpeg.dev}"
"--with-png-dir=${libpng.dev}"
"--with-freetype-dir=${freetype.dev}"
"--with-xpm-dir=${libXpm.dev}"
"--enable-gd-jis-conv"
]
++ optional gmpSupport "--with-gmp=${gmp.dev}"
++ optional soapSupport "--enable-soap"
Expand Down Expand Up @@ -198,7 +204,9 @@ let
++ optional (!pharSupport) "--disable-phar"
++ optional xmlrpcSupport "--with-xmlrpc"
++ optional cgotoSupport "--enable-re2c-cgoto"
++ optional valgrindSupport "--with-valgrind=${valgrind.dev}";
++ optional valgrindSupport "--with-valgrind=${valgrind.dev}"
++ optional (!ipv6Support) "--disable-ipv6"
++ optional (pearSupport && libxml2Support) "--with-pear=$(out)/lib/php/pear";

hardeningDisable = [ "bindnow" ];

Expand All @@ -212,14 +220,17 @@ let
--replace '@PHP_LDFLAGS@' ""
done
#[[ -z "$libxml2" ]] || addToSearchPath PATH $libxml2/bin
substituteInPlace ./build/libtool.m4 --replace /usr/bin/file ${file}/bin/file
export EXTENSION_DIR=$out/lib/php/extensions
configureFlags+=(--with-config-file-path=$out/etc \
--includedir=$dev/include)
./buildconf --copy --force
./buildconf --force
if test -f $src/genfiles; then
./genfiles
fi
'' + optionalString stdenv.isDarwin ''
substituteInPlace configure --replace "-lstdc++" "-lc++"
'';

postInstall = ''
Expand All @@ -231,8 +242,8 @@ let
mkdir -p $dev/bin $dev/share/man/man1
mv $out/bin/phpize $out/bin/php-config $dev/bin/
mv $out/share/man/man1/phpize.1.gz \
$out/share/man/man1/php-config.1.gz \
$dev/share/man/man1/
$out/share/man/man1/php-config.1.gz \
$dev/share/man/man1/
'';

src = fetchurl {
Expand All @@ -251,10 +262,6 @@ let

patches = [ ./fix-paths-php7.patch ] ++ extraPatches;

postPatch = optional stdenv.isDarwin ''
substituteInPlace configure --replace "-lstdc++" "-lc++"
'';

stripDebugList = "bin sbin lib modules";

outputs = [ "out" "dev" ];
Expand Down

0 comments on commit 21baef3

Please sign in to comment.