SUMMARY="The Number One HTTP Server On The Internet"
DESCRIPTION="The Apache HTTP Server Project is a collaborative software \
development effort aimed at creating a robust, commercial-grade, featureful, \
and freely-available source code implementation of an HTTP (Web) server"
HOMEPAGE="https://httpd.apache.org/"
COPYRIGHT="1995-2021 The Apache Software Foundation."
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="https://archive.apache.org/dist/httpd/httpd-$portVersion.tar.bz2"
CHECKSUM_SHA256="6a2817c070c606682eb53ed963511407d3c3d7a379cdf855971467b00fb3890f"
SOURCE_DIR="httpd-$portVersion"
PATCHES="apache-$portVersion.patchset"

ARCHITECTURES="?all"
SECONDARY_ARCHITECTURES="?x86"

commandBinDir=$binDir
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]
then
	commandBinDir=$prefix/bin
	commandSuffix=
fi

GLOBAL_WRITABLE_FILES="
	settings/apache/extra/httpd-autoindex.conf keep-old
	settings/apache/extra/httpd-dav.conf keep-old
	settings/apache/extra/httpd-default.conf keep-old
	settings/apache/extra/httpd-info.conf keep-old
	settings/apache/extra/httpd-languages.conf keep-old
	settings/apache/extra/httpd-manual.conf keep-old
	settings/apache/extra/httpd-mpm.conf keep-old
	settings/apache/extra/httpd-multilang-errordoc.conf keep-old
	settings/apache/extra/httpd-ssl.conf keep-old
	settings/apache/extra/httpd-userdir.conf keep-old
	settings/apache/extra/httpd-vhosts.conf keep-old
	settings/apache/extra/proxy-html.conf keep-old
	settings/apache/httpd.conf keep-old
	settings/apache/magic keep-old
	settings/apache/mime.types keep-old
	settings/apache/original/extra/httpd-autoindex.conf keep-old
	settings/apache/original/extra/httpd-dav.conf keep-old
	settings/apache/original/extra/httpd-default.conf keep-old
	settings/apache/original/extra/httpd-info.conf keep-old
	settings/apache/original/extra/httpd-languages.conf keep-old
	settings/apache/original/extra/httpd-manual.conf keep-old
	settings/apache/original/extra/httpd-mpm.conf keep-old
	settings/apache/original/extra/httpd-multilang-errordoc.conf keep-old
	settings/apache/original/extra/httpd-ssl.conf keep-old
	settings/apache/original/extra/httpd-userdir.conf keep-old
	settings/apache/original/extra/httpd-vhosts.conf keep-old
	settings/apache/original/extra/proxy-html.conf keep-old
	settings/apache/original/httpd.conf keep-old
	"

PROVIDES="
	apache$secondaryArchSuffix = $portVersion
	cmd:ab$commandSuffix
	cmd:apachectl$commandSuffix
	cmd:apxs$commandSuffix
	cmd:checkgid$commandSuffix
	cmd:dbmmanage$commandSuffix
	cmd:envvars$commandSuffix
	cmd:envvars_std$commandSuffix
	cmd:fcgistarter$commandSuffix
	cmd:htcacheclean$commandSuffix
	cmd:htdbm$commandSuffix
	cmd:htdigest$commandSuffix
	cmd:htpasswd$commandSuffix
	cmd:httpd$commandSuffix
	cmd:httxt2dbm$commandSuffix
	cmd:logresolve$commandSuffix
	cmd:rotatelogs$commandSuffix
	lib:mod_access_compat$secondaryArchSuffix
	lib:mod_actions$secondaryArchSuffix
	lib:mod_alias$secondaryArchSuffix
	lib:mod_allowmethods$secondaryArchSuffix
	lib:mod_auth_basic$secondaryArchSuffix
	lib:mod_auth_digest$secondaryArchSuffix
	lib:mod_auth_form$secondaryArchSuffix
	lib:mod_authn_anon$secondaryArchSuffix
	lib:mod_authn_core$secondaryArchSuffix
	lib:mod_authn_dbd$secondaryArchSuffix
	lib:mod_authn_dbm$secondaryArchSuffix
	lib:mod_authn_file$secondaryArchSuffix
	lib:mod_authn_socache$secondaryArchSuffix
	lib:mod_authz_core$secondaryArchSuffix
	lib:mod_authz_dbd$secondaryArchSuffix
	lib:mod_authz_dbm$secondaryArchSuffix
	lib:mod_authz_groupfile$secondaryArchSuffix
	lib:mod_authz_host$secondaryArchSuffix
	lib:mod_authz_owner$secondaryArchSuffix
	lib:mod_authz_user$secondaryArchSuffix
	lib:mod_autoindex$secondaryArchSuffix
	lib:mod_brotli$secondaryArchSuffix
	lib:mod_buffer$secondaryArchSuffix
	lib:mod_cache$secondaryArchSuffix
	lib:mod_cache_disk$secondaryArchSuffix
	lib:mod_cache_socache$secondaryArchSuffix
	lib:mod_cgid$secondaryArchSuffix
	lib:mod_dav$secondaryArchSuffix
	lib:mod_dav_fs$secondaryArchSuffix
	lib:mod_dbd$secondaryArchSuffix
	lib:mod_dir$secondaryArchSuffix
	lib:mod_dumpio$secondaryArchSuffix
	lib:mod_env$secondaryArchSuffix
	lib:mod_expires$secondaryArchSuffix
	lib:mod_ext_filter$secondaryArchSuffix
	lib:mod_file_cache$secondaryArchSuffix
	lib:mod_filter$secondaryArchSuffix
	lib:mod_headers$secondaryArchSuffix
	lib:mod_http2$secondaryArchSuffix
	lib:mod_include$secondaryArchSuffix
	lib:mod_info$secondaryArchSuffix
	lib:mod_lbmethod_bybusyness$secondaryArchSuffix
	lib:mod_lbmethod_byrequests$secondaryArchSuffix
	lib:mod_lbmethod_bytraffic$secondaryArchSuffix
	lib:mod_lbmethod_heartbeat$secondaryArchSuffix
	lib:mod_log_config$secondaryArchSuffix
	lib:mod_log_debug$secondaryArchSuffix
	lib:mod_logio$secondaryArchSuffix
	lib:mod_macro$secondaryArchSuffix
	lib:mod_md$secondaryArchSuffix
	lib:mod_mime$secondaryArchSuffix
	lib:mod_negotiation$secondaryArchSuffix
	lib:mod_proxy$secondaryArchSuffix
	lib:mod_proxy_ajp$secondaryArchSuffix
	lib:mod_proxy_balancer$secondaryArchSuffix
	lib:mod_proxy_connect$secondaryArchSuffix
	lib:mod_proxy_express$secondaryArchSuffix
	lib:mod_proxy_fcgi$secondaryArchSuffix
	lib:mod_proxy_fdpass$secondaryArchSuffix
	lib:mod_proxy_ftp$secondaryArchSuffix
	lib:mod_proxy_hcheck$secondaryArchSuffix
	lib:mod_proxy_http$secondaryArchSuffix
	lib:mod_proxy_scgi$secondaryArchSuffix
	lib:mod_proxy_uwsgi$secondaryArchSuffix
	lib:mod_proxy_wstunnel$secondaryArchSuffix
	lib:mod_ratelimit$secondaryArchSuffix
	lib:mod_remoteip$secondaryArchSuffix
	lib:mod_reqtimeout$secondaryArchSuffix
	lib:mod_request$secondaryArchSuffix
	lib:mod_rewrite$secondaryArchSuffix
	lib:mod_sed$secondaryArchSuffix
	lib:mod_session$secondaryArchSuffix
	lib:mod_session_cookie$secondaryArchSuffix
	lib:mod_session_dbd$secondaryArchSuffix
	lib:mod_setenvif$secondaryArchSuffix
	lib:mod_slotmem_shm$secondaryArchSuffix
	lib:mod_socache_dbm$secondaryArchSuffix
	lib:mod_socache_memcache$secondaryArchSuffix
	lib:mod_socache_shmcb$secondaryArchSuffix
	lib:mod_speling$secondaryArchSuffix
	lib:mod_ssl$secondaryArchSuffix
	lib:mod_status$secondaryArchSuffix
	lib:mod_substitute$secondaryArchSuffix
	lib:mod_unique_id$secondaryArchSuffix
	lib:mod_unixd$secondaryArchSuffix
	lib:mod_userdir$secondaryArchSuffix
	lib:mod_version$secondaryArchSuffix
	lib:mod_vhost_alias$secondaryArchSuffix
	lib:mod_watchdog$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libapr_1$secondaryArchSuffix
	lib:libaprutil_1$secondaryArchSuffix
	lib:libbrotlienc$secondaryArchSuffix
	lib:libcrypto$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libexpat$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libjansson$secondaryArchSuffix
#	lib:libldap$secondaryArchSuffix
	lib:libnghttp2$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	lib:libssl$secondaryArchSuffix
	"
if [ -n "$secondaryArchSuffix" -a -z "$commandSuffix" ]; then
CONFLICTS="
	apache
	"
fi

BUILD_REQUIRES="
	devel:libapr_1$secondaryArchSuffix
	devel:libaprutil_1$secondaryArchSuffix
	devel:libbrotlienc$secondaryArchSuffix
	devel:libcrypto$secondaryArchSuffix
	devel:libcurl$secondaryArchSuffix
	devel:libexpat$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libjansson$secondaryArchSuffix
#	devel:libldap$secondaryArchSuffix
	devel:libnghttp2$secondaryArchSuffix
	devel:libssl$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:autoconf
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:pcre_config$secondaryArchSuffix
	"

defineDebugInfoPackage apache$secondaryArchSuffix \
	"$commandBinDir"/ab \
	"$commandBinDir"/checkgid \
	"$commandBinDir"/fcgistarter \
	"$commandBinDir"/htcacheclean \
	"$commandBinDir"/htdbm \
	"$commandBinDir"/htdigest \
	"$commandBinDir"/htpasswd \
	"$commandBinDir"/httpd \
	"$commandBinDir"/httxt2dbm \
	"$commandBinDir"/logresolve \
	"$commandBinDir"/rotatelogs \
	"$libDir"/apache/mod_access_compat.so \
	"$libDir"/apache/mod_actions.so \
	"$libDir"/apache/mod_alias.so \
	"$libDir"/apache/mod_allowmethods.so \
	"$libDir"/apache/mod_auth_basic.so \
	"$libDir"/apache/mod_auth_digest.so \
	"$libDir"/apache/mod_auth_form.so \
	"$libDir"/apache/mod_authn_anon.so \
	"$libDir"/apache/mod_authn_core.so \
	"$libDir"/apache/mod_authn_dbd.so \
	"$libDir"/apache/mod_authn_dbm.so \
	"$libDir"/apache/mod_authn_file.so \
	"$libDir"/apache/mod_authn_socache.so \
	"$libDir"/apache/mod_authz_core.so \
	"$libDir"/apache/mod_authz_dbd.so \
	"$libDir"/apache/mod_authz_dbm.so \
	"$libDir"/apache/mod_authz_groupfile.so \
	"$libDir"/apache/mod_authz_host.so \
	"$libDir"/apache/mod_authz_owner.so \
	"$libDir"/apache/mod_authz_user.so \
	"$libDir"/apache/mod_autoindex.so \
	"$libDir"/apache/mod_buffer.so \
	"$libDir"/apache/mod_cache.so \
	"$libDir"/apache/mod_cache_disk.so \
	"$libDir"/apache/mod_cache_socache.so \
	"$libDir"/apache/mod_cgid.so \
	"$libDir"/apache/mod_dav.so \
	"$libDir"/apache/mod_dav_fs.so \
	"$libDir"/apache/mod_dbd.so \
	"$libDir"/apache/mod_dir.so \
	"$libDir"/apache/mod_dumpio.so \
	"$libDir"/apache/mod_env.so \
	"$libDir"/apache/mod_expires.so \
	"$libDir"/apache/mod_ext_filter.so \
	"$libDir"/apache/mod_file_cache.so \
	"$libDir"/apache/mod_filter.so \
	"$libDir"/apache/mod_headers.so \
	"$libDir"/apache/mod_include.so \
	"$libDir"/apache/mod_info.so \
	"$libDir"/apache/mod_lbmethod_bybusyness.so \
	"$libDir"/apache/mod_lbmethod_byrequests.so \
	"$libDir"/apache/mod_lbmethod_bytraffic.so \
	"$libDir"/apache/mod_lbmethod_heartbeat.so \
	"$libDir"/apache/mod_log_config.so \
	"$libDir"/apache/mod_log_debug.so \
	"$libDir"/apache/mod_logio.so \
	"$libDir"/apache/mod_macro.so \
	"$libDir"/apache/mod_mime.so \
	"$libDir"/apache/mod_negotiation.so \
	"$libDir"/apache/mod_proxy.so \
	"$libDir"/apache/mod_proxy_ajp.so \
	"$libDir"/apache/mod_proxy_balancer.so \
	"$libDir"/apache/mod_proxy_connect.so \
	"$libDir"/apache/mod_proxy_express.so \
	"$libDir"/apache/mod_proxy_fcgi.so \
	"$libDir"/apache/mod_proxy_fdpass.so \
	"$libDir"/apache/mod_proxy_ftp.so \
	"$libDir"/apache/mod_proxy_hcheck.so \
	"$libDir"/apache/mod_proxy_http.so \
	"$libDir"/apache/mod_proxy_scgi.so \
	"$libDir"/apache/mod_proxy_uwsgi.so \
	"$libDir"/apache/mod_proxy_wstunnel.so \
	"$libDir"/apache/mod_ratelimit.so \
	"$libDir"/apache/mod_remoteip.so \
	"$libDir"/apache/mod_reqtimeout.so \
	"$libDir"/apache/mod_request.so \
	"$libDir"/apache/mod_rewrite.so \
	"$libDir"/apache/mod_sed.so \
	"$libDir"/apache/mod_session.so \
	"$libDir"/apache/mod_session_cookie.so \
	"$libDir"/apache/mod_session_dbd.so \
	"$libDir"/apache/mod_setenvif.so \
	"$libDir"/apache/mod_slotmem_shm.so \
	"$libDir"/apache/mod_socache_dbm.so \
	"$libDir"/apache/mod_socache_memcache.so \
	"$libDir"/apache/mod_socache_shmcb.so \
	"$libDir"/apache/mod_speling.so \
	"$libDir"/apache/mod_ssl.so \
	"$libDir"/apache/mod_status.so \
	"$libDir"/apache/mod_substitute.so \
	"$libDir"/apache/mod_unique_id.so \
	"$libDir"/apache/mod_unixd.so \
	"$libDir"/apache/mod_userdir.so \
	"$libDir"/apache/mod_version.so \
	"$libDir"/apache/mod_vhost_alias.so \
	"$libDir"/apache/mod_watchdog.so \


BUILD()
{
	libtoolize --force --copy --install
	aclocal
	autoconf

	runConfigure --omit-dirs "binDir sbinDir libExecDir dataDir" ./configure \
		--bindir="$commandBinDir" \
		--sbindir="$commandBinDir" \
		--datadir="$dataDir"/apache \
		--libexecdir="$libDir"/apache \
		--sysconfdir="$sysconfDir"/apache \
		--with-apr=/$relativeBinDir \
		--with-apr-util=/$relativeBinDir
	make $jobArgs
}

INSTALL()
{
	make install

	# Replace "/packages/apache-*/.settings" by "/boot/system/settings"
	# Replace "/packages/apache-*/.self" by "/boot/system"
	# Comment out directives that would otherwise need a daemon user and group.
	sed -i \
		-e "s|$sysconfDir|`finddir B_SYSTEM_SETTINGS_DIRECTORY`|" \
		-e "s|$prefix|`finddir B_SYSTEM_DIRECTORY`|" \
		-e "s/^User daemon/#&/" \
		-e "s/^Group daemon/#&/" \
		"$settingsDir"/apache/httpd.conf
}
