# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0

name		apr-util
version		1.6.3
revision	2
categories	devel
maintainers	{geeklair.net:dluke @danielluke}
description	utilities built with the apache group's portability library
license		Apache-2

long_description	apr-util is a library of useful utilities built with \
			and intended to be used with the Apache Portable Runtime.

homepage	https://apr.apache.org/
master_sites	apache:apr
use_bzip2	yes
checksums	sha1    8c6293a787b69986ce43bc49c7c247d4ff5fc828 \
		rmd160  6cecfe5640363ebb741803257fe1babc6ec05d69 \
		sha256  a41076e3710746326c3945042994ad9a4fcac0ce0277dd8fea076fec3c9772b5 \
		size    432692

depends_lib	port:apr port:expat \
		port:libiconv port:db48 \
		port:sqlite3

# https://trac.macports.org/wiki/UsingTheRightCompiler
patchfiles-append \
        patch-using_the_right_compiler.diff \
        patch-implicit-int-bdb-check.diff

# regen configure script for implicit int fix
use_autoconf yes

use_parallel_build	yes
configure.ccache	no
configure.args	--with-apr=${prefix}/bin/apr-1-config --with-expat=${prefix} \
		--with-iconv=${prefix} --with-berkeley-db=${prefix}/include:${prefix}/lib/db48 \
		--without-mysql --without-pgsql --without-sqlite2 --with-sqlite3=${prefix} \
		--without-odbc

test.run	yes
test.target	check
test.env	DYLD_LIBRARY_PATH=${worksrcpath}/.libs
pre-test	{
	use_parallel_build	no
}


variant no_bdb	description {Build without BerkeleyDB support} {
			depends_lib-delete port:db48
			configure.args-delete --with-berkeley-db=${prefix}/include:${prefix}/lib/db48
			configure.args-append --without-berkeley-db
		}

variant no_sqlite	description {Build without sqlite support} {
				depends_lib-delete port:sqlite3
				configure.args-delete --with-sqlite3=${prefix}
				configure.args-append --without-sqlite2 \
					--without-sqlite3
			}

variant openldap	description {Build with OpenLDAP support} {
				depends_lib-append path:lib/libldap.dylib:openldap
				configure.args-append --with-ldap \
					--with-ldap-include=${prefix}/include \
					--with-ldap-lib=${prefix}/lib
			}

set extralibs	"-L${prefix}/lib/db48"

pre-configure	{
			reinplace "s|^Libs: |Libs: ${extralibs} |" $worksrcpath/apr-util.pc.in
		}

pre-build {
	if {[variant_exists universal] && [variant_isset universal]} {
		build.args	EXTRA_CFLAGS='${configure.universal_cflags}' \
				EXTRA_LDFLAGS='${configure.universal_ldflags}'
	} else {
        build.args  EXTRA_CFLAGS='${configure.cc_archflags}' \
                EXTRA_LDFLAGS='${configure.ld_archflags}'
    }
}

variant postgresql16	description {Build with postgres support (using postgresql v16)} conflicts {
				depends_lib-append port:postgresql16
				configure.args-delete --without-pgsql
				configure.args-append --with-pgsql=yes
			}

variant mysql51 conflicts mysql55 mysql56 mariadb percona description {Enable MySQL 5.1 support} {
    depends_lib-append port:mysql51
    configure.args-replace --without-mysql --with-mysql
    configure.env-append MYSQL_CONFIG=${prefix}/lib/mysql51/bin/mysql_config
}

variant mysql55 conflicts mysql51 mysql56 mariadb percona description {Enable MySQL 5.5 support} {
    depends_lib-append port:mysql55
    configure.args-replace --without-mysql --with-mysql
    configure.env-append MYSQL_CONFIG=${prefix}/lib/mysql55/bin/mysql_config
}

variant mysql56 conflicts mysql51 mysql55 mariadb percona description {Enable MySQL 5.6 support} {
    depends_lib-append port:mysql56
    configure.args-replace --without-mysql --with-mysql
    configure.env-append MYSQL_CONFIG=${prefix}/lib/mysql56/bin/mysql_config
}

variant mariadb conflicts mysql51 mysql55 mysql56 percona description {Enable MariaDB (MySQL) support} {
    depends_lib-append port:mariadb
    configure.args-replace --without-mysql --with-mysql
    configure.env-append MYSQL_CONFIG=${prefix}/lib/mariadb/bin/mysql_config
}

variant percona conflicts mysql51 mysql55 mysql56 mariadb description {Enable Percona (MySQL) support} {
    depends_lib-append port:percona
    configure.args-replace --without-mysql --with-mysql
    configure.env-append MYSQL_CONFIG=${prefix}/lib/percona/bin/mysql_config
}

livecheck.type  regex
livecheck.url   https://apr.apache.org/
livecheck.regex {APR-util (\d+(?:\.\d+)*), released}
