#!/bin/bash
export OPENSSL11_DIR=/opt/homebrew/opt/openssl@1.1
export GETTEXT_DIR=/opt/homebrew/opt/gettext
export CPPFLAGS="-I${OPENSSL11_DIR}/include -I${GETTEXT_DIR}/include -I/opt/homebrew/opt/libiconv/include"
export LDFLAGS="-L${OPENSSL11_DIR}/lib -L${GETTEXT_DIR}/lib -L/opt/homebrew/opt/libiconv/lib"
export PKG_CONFIG_PATH="${OPENSSL11_DIR}/lib/pkgconfig:${GETTEXT_DIR}/lib/pkgconfig:/opt/homebrew/opt/pkgconf/lib/pkgconfig:/opt/homebrew/opt/openssl@1.1/lib/pkgconfig:/opt/homebrew/opt/libssh2/lib/pkgconfig:/opt/homebrew/opt/lz4/lib/pkgconfig:/opt/homebrew/opt/xz/lib/pkgconfig:/opt/homebrew/opt/zstd/lib/pkgconfig:/opt/homebrew/opt/curl/lib/pkgconfig:/opt/homebrew/opt/unixodbc/lib/pkgconfig:/opt/homebrew/opt/libpng/lib/pkgconfig:/opt/homebrew/opt/freetype/lib/pkgconfig:/opt/homebrew/opt/fontconfig/lib/pkgconfig:/opt/homebrew/opt/jpeg-turbo/lib/pkgconfig:/opt/homebrew/opt/highway/lib/pkgconfig:/opt/homebrew/opt/imath/lib/pkgconfig:/opt/homebrew/opt/libtiff/lib/pkgconfig:/opt/homebrew/opt/little-cms2/lib/pkgconfig:/opt/homebrew/opt/libdeflate/lib/pkgconfig:/opt/homebrew/opt/openjph/lib/pkgconfig:/opt/homebrew/opt/openexr/lib/pkgconfig:/opt/homebrew/opt/jpeg-xl/lib/pkgconfig:/opt/homebrew/opt/libvmaf/lib/pkgconfig:/opt/homebrew/opt/aom/lib/pkgconfig:/opt/homebrew/opt/dav1d/lib/pkgconfig:/opt/homebrew/opt/libavif/lib/pkgconfig:/opt/homebrew/opt/webp/lib/pkgconfig:/opt/homebrew/opt/gd/lib/pkgconfig:/opt/homebrew/opt/gmp/lib/pkgconfig:/opt/homebrew/opt/icu4c@78/lib/pkgconfig:/opt/homebrew/opt/krb5/lib/pkgconfig:/opt/homebrew/opt/libpq/lib/pkgconfig:/opt/homebrew/opt/libsodium/lib/pkgconfig:/opt/homebrew/opt/libzip/lib/pkgconfig:/opt/homebrew/opt/net-snmp/lib/pkgconfig:/opt/homebrew/opt/oniguruma/lib/pkgconfig:/opt/homebrew/opt/openldap/lib/pkgconfig:/opt/homebrew/opt/pcre2/lib/pkgconfig:/opt/homebrew/opt/readline/lib/pkgconfig:/opt/homebrew/opt/sqlite/lib/pkgconfig:/opt/homebrew/opt/tidy-html5/lib/pkgconfig"
export PATH="/opt/homebrew/opt/bison/bin:/opt/homebrew/opt/re2c/bin:$PATH"
# curl -O https://www.php.net/distributions/php-7.4.33.tar.gz
rm -rf php-7.4.33
tar zxf php-7.4.33.tar.gz
cd php-7.4.33
./configure --prefix=/opt/dev/php/7.4 \
--with-curl --with-freetype --with-gmp=/opt/homebrew/opt/gmp --with-jpeg --with-openssl --with-openssl-dir=/opt/homebrew/opt/openssl@1.1 --with-pear \
--with-readline=/opt/homebrew/opt/readline --with-gettext=/opt/homebrew/opt/gettext --with-sodium --with-xsl --with-zip --with-zlib \
--with-iconv=/opt/homebrew/opt/libiconv \
--with-mysqli --with-pdo-mysql \
--enable-apcu --enable-bcmath --enable-calendar --enable-mbstring --enable-mysqlnd --enable-exif --enable-ftp --enable-fpm --enable-pcntl \
--enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm \
--disable-phar --without-pcre-jit \
LIBS="-lresolv" CC=clang CXX=clang++
make -j4
make install