### this file is sourced not run
PKGVER=7.4.33
PKGBUILD=1
PKGARCH=x86_64

# post BLFS 7.5 (2014-08-04) updated to post BLFS 9.0 2019-11-24; updated to
# https://www.linuxfromscratch.org/blfs/downloads/10.0/BLFS-BOOK-10.0-nochunks.html#php
TARBALL=php-$PKGVER.tar.xz
MD5SUM=f098632163cd47f2c1ffe2bdc6ef1ff2
SRC_URL=http://www.php.net/distributions/$TARBALL
BUNDLE=

# using internal GD
SLACKREQ='libxml2 libjpeg-turbo libtiff libpng libexif freetype2 libX11
libxslt libpcre2 aspell libenchant sqlite3 openssl-compat gdbm
libmhash libreadline libargon2 libsodium libwebp libzip
liboniguruma' # postgresql curl
SLACKDESC="php7: php $PKGVER (PHP Hypertext Processor)
php7:
php7: This is a a legacy PHP version 7 package! There is a newer package.
php7: Install this package only if you need to host an old web site that
php7: cannot run the newer PHP version 8 and higher.
php7: https://www.php.net/ChangeLog-7.php
php7:
php7: PHP is the PHP Hypertext Preprocessor. Primarily used in dynamic web
php7: sites, it allows for programming code to be directly embedded into the
php7: HTML markup. It is also useful as a general purpose scripting language.
php7: https://www.php.net
"

INSTALL_ROOT=/opt/php7

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	export OPENSSL_CFLAGS="-I/opt/openssl-compat/include"
	export OPENSSL_LIBS="-L/opt/openssl-compat/$LIBDIR -lssl -lcrypto"

	cd /tmp/php* &&

	./configure $CONFFLAGS         \
		--prefix=$INSTALL_ROOT       \
		--datadir=/usr/share/php     \
		--mandir=/usr/share/man      \
		--with-config-file-path=$INSTALL_ROOT/etc \
		--with-config-file-scan-dir=$INSTALL_ROOT/etc/php/$PKGVER/conf.d \
		--with-pear=$INSTALL_ROOT/$LIBDIR/php-$PKGVER \
		--with-openssl --without-curl --enable-ftp                       \
		--enable-fpm --with-fpm-user=webuser --with-fpm-group=webgroup \
		--with-apxs2                        \
		--with-bz2 --with-zip \
		--enable-gd --with-freetype=/usr --with-jpeg=/usr --with-xpm=/usr --with-webp=/usr \
		--enable-dba=shared --with-gdbm                 \
		--enable-mysqlnd --with-pdo-mysql --with-mysqli \
		--without-pdo-pgsql --without-pgsql    \
		--with-mhash                     \
		--with-gmp --enable-bcmath       \
		--enable-mbstring --with-gettext \
		--with-enchant --enable-exif     \
		--enable-soap --enable-calendar  \
		--with-readline --with-xsl       \
		--with-password-argon2 --with-sodium \
		--enable-intl --enable-sockets &&
	make $MAKEFLAGS &&

	mkdir -p $INSTALL_ROOT/etc &&
	make install                                         &&
	install -v -m644 php.ini-production $INSTALL_ROOT/etc/php.ini     &&
	mv -v /etc/php-fpm.conf.default $INSTALL_ROOT/etc/php-fpm.conf    &&
	mv -v /etc/php-fpm.d $INSTALL_ROOT/etc    &&

	install -v -m755 -d $INSTALL_ROOT/share/doc/php-$PKGVER &&
	install -v -m644    CODING_STANDARDS* EXTENSIONS NEWS README* UPGRADING* \
						$INSTALL_ROOT/share/doc/php-$PKGVER &&
	ln -v -sfn          $INSTALL_ROOT/$LIBDIR/php/doc/Archive_Tar/docs/Archive_Tar.txt \
						$INSTALL_ROOT/share/doc/php-$PKGVER &&
	ln -v -sfn          $INSTALL_ROOT/$LIBDIR/php/doc/Structures_Graph/docs \
						$INSTALL_ROOT/share/doc/php-$PKGVER &&
	pkg_build_slackdesc &&

	# don't overwrite apache's configuration
	mv /etc/httpd/httpd.conf /etc/httpd/httpd.conf.php_${PKGVER//./_} &&
	rm /etc/httpd/httpd.conf.bak &&

	# for extensions and compatibility with common tutorials
	mkdir -p $INSTALL_ROOT/etc/php/$PKGVER/conf.d &&

	# for PEAR and others
	sed -i "s@php/includes\"@&\ninclude_path = \".:$INSTALL_ROOT/$LIBDIR/php\"@" $INSTALL_ROOT/etc/php.ini &&

	# remove unwanted PEAR files
	rm -rf $INSTALL_ROOT/$LIBDIR/php/.registry/.channel.pecl.php.net \
	$INSTALL_ROOT/$LIBDIR/php/.registry/.channel.doc.php.net \
	$INSTALL_ROOT/$LIBDIR/php/.registry/.channel.__uri &&

	# multi-lib
	mv -v $INSTALL_ROOT/bin/php-config{,-64}               &&
	ln -sfv /usr/bin/multiarch_wrapper $INSTALL_ROOT/bin/php-config
}

# vim:ft=sh:

