Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.03 285 lines 12 kB view raw
1# pcre functionality is tested in nixos/tests/php-pcre.nix 2{ lib, stdenv, fetchurl, autoconf, bison, libtool, pkgconfig, re2c 3, libmysqlclient, libxml2, readline, zlib, curl, postgresql, gettext 4, openssl, pcre, pcre2, sqlite, config, libjpeg, libpng, freetype 5, libxslt, libmcrypt, bzip2, icu, openldap, cyrus_sasl, libmhash, unixODBC 6, uwimap, pam, gmp, apacheHttpd, libiconv, systemd, libsodium, html-tidy, libargon2 7, libzip, valgrind, oniguruma 8}: 9 10with lib; 11 12let 13 generic = 14 { version 15 , sha256 16 , extraPatches ? [] 17 , withSystemd ? config.php.systemd or stdenv.isLinux 18 , imapSupport ? config.php.imap or (!stdenv.isDarwin) 19 , ldapSupport ? config.php.ldap or true 20 , mhashSupport ? config.php.mhash or false 21 , mysqlndSupport ? config.php.mysqlnd or true 22 , mysqliSupport ? config.php.mysqli or true 23 , pdo_mysqlSupport ? config.php.pdo_mysql or true 24 , libxml2Support ? config.php.libxml2 or true 25 , apxs2Support ? config.php.apxs2 or (!stdenv.isDarwin) 26 , embedSupport ? config.php.embed or false 27 , bcmathSupport ? config.php.bcmath or true 28 , socketsSupport ? config.php.sockets or true 29 , curlSupport ? config.php.curl or true 30 , gettextSupport ? config.php.gettext or true 31 , pcntlSupport ? config.php.pcntl or true 32 , pdo_odbcSupport ? config.php.pdo_odbc or true 33 , postgresqlSupport ? config.php.postgresql or true 34 , pdo_pgsqlSupport ? config.php.pdo_pgsql or true 35 , readlineSupport ? config.php.readline or true 36 , sqliteSupport ? config.php.sqlite or true 37 , soapSupport ? (config.php.soap or true) && (libxml2Support) 38 , zlibSupport ? config.php.zlib or true 39 , opensslSupport ? config.php.openssl or true 40 , mbstringSupport ? config.php.mbstring or true 41 , gdSupport ? config.php.gd or true 42 , intlSupport ? config.php.intl or true 43 , exifSupport ? config.php.exif or true 44 , xslSupport ? config.php.xsl or false 45 , mcryptSupport ? (config.php.mcrypt or true) && (versionOlder version "7.2") 46 , bz2Support ? config.php.bz2 or false 47 , zipSupport ? config.php.zip or true 48 , ftpSupport ? config.php.ftp or true 49 , fpmSupport ? config.php.fpm or true 50 , gmpSupport ? config.php.gmp or true 51 , ztsSupport ? (config.php.zts or false) || (apxs2Support) 52 , calendarSupport ? config.php.calendar or true 53 , sodiumSupport ? (config.php.sodium or true) && (versionAtLeast version "7.2") 54 , tidySupport ? (config.php.tidy or false) 55 , argon2Support ? (config.php.argon2 or true) && (versionAtLeast version "7.2") 56 , libzipSupport ? (config.php.libzip or true) && (versionAtLeast version "7.2") 57 , phpdbgSupport ? config.php.phpdbg or true 58 , cgiSupport ? config.php.cgi or true 59 , cliSupport ? config.php.cli or true 60 , pharSupport ? config.php.phar or true 61 , xmlrpcSupport ? (config.php.xmlrpc or false) && (libxml2Support) 62 , cgotoSupport ? config.php.cgoto or false 63 , valgrindSupport ? (config.php.valgrind or true) && (versionAtLeast version "7.2") 64 }: 65 66 let 67 mysqlBuildInputs = optional (!mysqlndSupport) libmysqlclient; 68 libmcrypt' = libmcrypt.override { disablePosixThreads = true; }; 69 in stdenv.mkDerivation { 70 71 inherit version; 72 73 name = "php-${version}"; 74 75 enableParallelBuilding = true; 76 77 nativeBuildInputs = [ autoconf bison libtool pkgconfig re2c ]; 78 buildInputs = [ ] 79 ++ optional (versionOlder version "7.3") pcre 80 ++ optional (versionAtLeast version "7.3") pcre2 81 ++ optional (versionAtLeast version "7.4") oniguruma 82 ++ optional withSystemd systemd 83 ++ optionals imapSupport [ uwimap openssl pam ] 84 ++ optionals curlSupport [ curl openssl ] 85 ++ optionals ldapSupport [ openldap openssl ] 86 ++ optionals gdSupport [ libpng libjpeg freetype ] 87 ++ optionals opensslSupport [ openssl openssl.dev ] 88 ++ optional apxs2Support apacheHttpd 89 ++ optional (ldapSupport && stdenv.isLinux) cyrus_sasl 90 ++ optional mhashSupport libmhash 91 ++ optional zlibSupport zlib 92 ++ optional libxml2Support libxml2 93 ++ optional readlineSupport readline 94 ++ optional sqliteSupport sqlite 95 ++ optional postgresqlSupport postgresql 96 ++ optional pdo_odbcSupport unixODBC 97 ++ optional pdo_pgsqlSupport postgresql 98 ++ optionals pdo_mysqlSupport mysqlBuildInputs 99 ++ optionals mysqliSupport mysqlBuildInputs 100 ++ optional gmpSupport gmp 101 ++ optional gettextSupport gettext 102 ++ optional intlSupport icu 103 ++ optional xslSupport libxslt 104 ++ optional mcryptSupport libmcrypt' 105 ++ optional bz2Support bzip2 106 ++ optional sodiumSupport libsodium 107 ++ optional tidySupport html-tidy 108 ++ optional argon2Support libargon2 109 ++ optional libzipSupport libzip 110 ++ optional valgrindSupport valgrind; 111 112 CXXFLAGS = optionalString stdenv.cc.isClang "-std=c++11"; 113 114 configureFlags = [ 115 "--with-config-file-scan-dir=/etc/php.d" 116 ] 117 ++ optionals (versionOlder version "7.3") [ "--with-pcre-regex=${pcre.dev}" "PCRE_LIBDIR=${pcre}" ] 118 ++ optionals (versions.majorMinor version == "7.3") [ "--with-pcre-regex=${pcre2.dev}" "PCRE_LIBDIR=${pcre2}" ] 119 ++ optionals (versionAtLeast version "7.4") [ "--with-external-pcre=${pcre2.dev}" "PCRE_LIBDIR=${pcre2}" ] 120 ++ optional stdenv.isDarwin "--with-iconv=${libiconv}" 121 ++ optional withSystemd "--with-fpm-systemd" 122 ++ optionals imapSupport [ 123 "--with-imap=${uwimap}" 124 "--with-imap-ssl" 125 ] 126 ++ optionals ldapSupport [ 127 "--with-ldap=/invalid/path" 128 "LDAP_DIR=${openldap.dev}" 129 "LDAP_INCDIR=${openldap.dev}/include" 130 "LDAP_LIBDIR=${openldap.out}/lib" 131 ] 132 ++ optional (ldapSupport && stdenv.isLinux) "--with-ldap-sasl=${cyrus_sasl.dev}" 133 ++ optional apxs2Support "--with-apxs2=${apacheHttpd.dev}/bin/apxs" 134 ++ optional embedSupport "--enable-embed" 135 ++ optional mhashSupport "--with-mhash" 136 ++ optional curlSupport "--with-curl=${curl.dev}" 137 ++ optional zlibSupport "--with-zlib=${zlib.dev}" 138 ++ optional (libxml2Support && (versionOlder version "7.4")) "--with-libxml-dir=${libxml2.dev}" 139 ++ optional (!libxml2Support) [ 140 "--disable-dom" 141 "--disable-libxml" 142 (if (versionOlder version "7.4") then "--disable-libxml" else "--without-libxml") 143 "--disable-simplexml" 144 "--disable-xml" 145 "--disable-xmlreader" 146 "--disable-xmlwriter" 147 "--without-pear" 148 ] 149 ++ optional pcntlSupport "--enable-pcntl" 150 ++ optional readlineSupport "--with-readline=${readline.dev}" 151 ++ optional sqliteSupport "--with-pdo-sqlite=${sqlite.dev}" 152 ++ optional postgresqlSupport "--with-pgsql=${postgresql}" 153 ++ optional pdo_odbcSupport "--with-pdo-odbc=unixODBC,${unixODBC}" 154 ++ optional pdo_pgsqlSupport "--with-pdo-pgsql=${postgresql}" 155 ++ optional pdo_mysqlSupport "--with-pdo-mysql=${if mysqlndSupport then "mysqlnd" else libmysqlclient}" 156 ++ optionals mysqliSupport [ 157 "--with-mysqli=${if mysqlndSupport then "mysqlnd" else "${libmysqlclient}/bin/mysql_config"}" 158 ] 159 ++ optional ( pdo_mysqlSupport || mysqliSupport ) "--with-mysql-sock=/run/mysqld/mysqld.sock" 160 ++ optional bcmathSupport "--enable-bcmath" 161 # FIXME: Our own gd package doesn't work, see https://bugs.php.net/bug.php?id=60108. 162 ++ optionals (gdSupport && versionAtLeast version "7.4") [ 163 "--enable-gd" 164 "--with-jpeg=${libjpeg.dev}" 165 "--with-freetype=${freetype.dev}" 166 "--enable-gd-jis-conv" 167 ] ++ optionals (gdSupport && versionOlder version "7.4") [ 168 "--with-gd" 169 "--with-freetype-dir=${freetype.dev}" 170 "--with-png-dir=${libpng.dev}" 171 "--with-jpeg-dir=${libjpeg.dev}" 172 ] 173 ++ optional gmpSupport "--with-gmp=${gmp.dev}" 174 ++ optional soapSupport "--enable-soap" 175 ++ optional socketsSupport "--enable-sockets" 176 ++ optional opensslSupport "--with-openssl" 177 ++ optional mbstringSupport "--enable-mbstring" 178 ++ optional gettextSupport "--with-gettext=${gettext}" 179 ++ optional intlSupport "--enable-intl" 180 ++ optional exifSupport "--enable-exif" 181 ++ optional xslSupport "--with-xsl=${libxslt.dev}" 182 ++ optional mcryptSupport "--with-mcrypt=${libmcrypt'}" 183 ++ optional bz2Support "--with-bz2=${bzip2.dev}" 184 ++ optional (zipSupport && (versionOlder version "7.4")) "--enable-zip" 185 ++ optional (zipSupport && (versionAtLeast version "7.4")) "--with-zip" 186 ++ optional ftpSupport "--enable-ftp" 187 ++ optional fpmSupport "--enable-fpm" 188 ++ optional ztsSupport "--enable-maintainer-zts" 189 ++ optional calendarSupport "--enable-calendar" 190 ++ optional sodiumSupport "--with-sodium=${libsodium.dev}" 191 ++ optional tidySupport "--with-tidy=${html-tidy}" 192 ++ optional argon2Support "--with-password-argon2=${libargon2}" 193 ++ optional (libzipSupport && (versionOlder version "7.4")) "--with-libzip=${libzip.dev}" 194 ++ optional phpdbgSupport "--enable-phpdbg" 195 ++ optional (!phpdbgSupport) "--disable-phpdbg" 196 ++ optional (!cgiSupport) "--disable-cgi" 197 ++ optional (!cliSupport) "--disable-cli" 198 ++ optional (!pharSupport) "--disable-phar" 199 ++ optional xmlrpcSupport "--with-xmlrpc" 200 ++ optional cgotoSupport "--enable-re2c-cgoto" 201 ++ optional valgrindSupport "--with-valgrind=${valgrind.dev}"; 202 203 hardeningDisable = [ "bindnow" ]; 204 205 preConfigure = '' 206 # Don't record the configure flags since this causes unnecessary 207 # runtime dependencies 208 for i in main/build-defs.h.in scripts/php-config.in; do 209 substituteInPlace $i \ 210 --replace '@CONFIGURE_COMMAND@' '(omitted)' \ 211 --replace '@CONFIGURE_OPTIONS@' "" \ 212 --replace '@PHP_LDFLAGS@' "" 213 done 214 215 #[[ -z "$libxml2" ]] || addToSearchPath PATH $libxml2/bin 216 217 export EXTENSION_DIR=$out/lib/php/extensions 218 219 configureFlags+=(--with-config-file-path=$out/etc \ 220 --includedir=$dev/include) 221 222 ./buildconf --force 223 ''; 224 225 postInstall = '' 226 test -d $out/etc || mkdir $out/etc 227 cp php.ini-production $out/etc/php.ini 228 ''; 229 230 postFixup = '' 231 mkdir -p $dev/bin $dev/share/man/man1 232 mv $out/bin/phpize $out/bin/php-config $dev/bin/ 233 mv $out/share/man/man1/phpize.1.gz \ 234 $out/share/man/man1/php-config.1.gz \ 235 $dev/share/man/man1/ 236 ''; 237 238 src = fetchurl { 239 url = "https://www.php.net/distributions/php-${version}.tar.bz2"; 240 inherit sha256; 241 }; 242 243 meta = with stdenv.lib; { 244 description = "An HTML-embedded scripting language"; 245 homepage = https://www.php.net/; 246 license = licenses.php301; 247 maintainers = with maintainers; [ globin etu ]; 248 platforms = platforms.all; 249 outputsToInstall = [ "out" "dev" ]; 250 }; 251 252 patches = [ ./fix-paths-php7.patch ] ++ extraPatches; 253 254 postPatch = optional stdenv.isDarwin '' 255 substituteInPlace configure --replace "-lstdc++" "-lc++" 256 ''; 257 258 stripDebugList = "bin sbin lib modules"; 259 260 outputs = [ "out" "dev" ]; 261 262 }; 263 264in { 265 php72 = generic { 266 version = "7.2.29"; 267 sha256 = "08xry2fgqgg8s0ym1hh11wkbr36av3zq1bn4krbciw1b7x8gb8ga"; 268 269 # https://bugs.php.net/bug.php?id=76826 270 extraPatches = optional stdenv.isDarwin ./php72-darwin-isfinite.patch; 271 }; 272 273 php73 = generic { 274 version = "7.3.16"; 275 sha256 = "0bh499v9dfgh9k51w4rird1slb9rh9whp5h37fb84c98d992s1xq"; 276 277 # https://bugs.php.net/bug.php?id=76826 278 extraPatches = optional stdenv.isDarwin ./php73-darwin-isfinite.patch; 279 }; 280 281 php74 = generic { 282 version = "7.4.4"; 283 sha256 = "17w2m4phhpj76x5fx67vgjrlkcczqvky3f5in1kjg2pch90qz3ih"; 284 }; 285}