makedepends=(pcre apr-util sqlite expat)

description="A high performance Unix-based HTTP server"
url="http://www.apache.org/dist/httpd"

packager="Great-OS Team"
maintainer="Great-OS Team"

name=apache
version=2.4.66
release=1
greatos_version=1.0-RC1

source=(https://repo.great-os.org/files/great-os-${greatos_version}.tar.xz
  https://archive.apache.org/dist/httpd/httpd-${version}.tar.bz2
  https://www.linuxfromscratch.org/patches/blfs/svn/httpd-blfs_layout-1.patch)

prepare() {
  cd httpd-$version
  unset MAKEFLAGS
  patch -Np1 -i ../httpd-blfs_layout-1.patch
  sed '/dir.*CFG_PREFIX/s@^@#@' -i support/apxs.in
}

build() {

  cd httpd-${version}

	./configure --enable-authnz-fcgi                        \
    --enable-layout=BLFS                            \
    --enable-mods-shared="all cgi"                  \
    --enable-mpms-shared=all                        \
    --enable-suexec=shared                          \
    --with-apr=/usr/bin/apr-1-config                \
    --with-apr-util=/usr/bin/apu-1-config           \
    --with-suexec-bin=/usr/lib/httpd/suexec         \
    --with-suexec-caller=apache                     \
    --with-suexec-docroot=/srv/www                  \
    --with-suexec-logfile=/var/log/httpd/suexec.log \
    --with-suexec-uidmin=100                        \
    --with-suexec-userdir=public_html
	make
}

package() {

	cd httpd-${version}

	make DESTDIR=$PKG install

	mv -v $PKG/usr/sbin/suexec $PKG/usr/lib/httpd/suexec
	chgrp apache $PKG/usr/lib/httpd/suexec
	chmod 4754 $PKG/usr/lib/httpd/suexec

	chown -v -R apache:apache $PKG/srv/www

	# Service
	cd ../great-os-"${greatos_version}"
	make DESTDIR=$PKG install-httpd
}
