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