# vim: ft=make ts=4 sw=4 noet
.DEFAULT_GOAL := all

NAME    = subversion
VERSION = 1.14.5
GARTYPE = v2

DESCRIPTION = Apache Subversion version control system
define BLURB
  Subversion (svn) is an open-source version control system designed as a
  successor to CVS. It manages files and directories over time with full
  branching and merging support.
endef

MASTER_SITES = https://dlcdn.apache.org/subversion/
DISTFILES   += $(DISTNAME).tar.gz

LICENSE = LICENSE

BUILD_DEP_PKGS                    += OZSWapr OZSWaprutil OZSWsqlite OZSWopenssl
RUNTIME_DEP_PKGS_OZSWsubversion   += OZSWapr OZSWaprutil OZSWsqlite OZSWopenssl

PACKAGES                     += OZSWsubversion
SPKG_DESC_OZSWsubversion      = Apache Subversion version control system
CATALOGNAME_OZSWsubversion   = subversion

EXTENSIONS = 1

EXTRA_CONFIGURE_ARGS += --with-apr=$(prefix)
EXTRA_CONFIGURE_ARGS += --with-apr-util=$(prefix)
EXTRA_CONFIGURE_ARGS += --with-sqlite=$(prefix)
EXTRA_CONFIGURE_ARGS += --with-lz4=internal
EXTRA_CONFIGURE_ARGS += --with-utf8proc=internal
EXTRA_CONFIGURE_ARGS += --disable-nls
EXTRA_LD_FLAGS += -lintl -lm

# subversion's configure sets CMODEFLAGS=-std=c90, which conflicts with
# _XPG6+__XOPEN_OR_POSIX requiring C99 (_STDC_C99 must be defined).
# Override at build and install time. Also inject -lsqlite3 since
# configure leaves SVN_SQLITE_LIBS empty when using an external sqlite.
BUILD_OVERRIDE_VARS += CMODEFLAGS EXTRA_LDFLAGS
BUILD_OVERRIDE_VAR_CMODEFLAGS    = -std=c99
BUILD_OVERRIDE_VAR_EXTRA_LDFLAGS = -lsqlite3
INSTALL_OVERRIDE_VARS += CMODEFLAGS EXTRA_LDFLAGS
INSTALL_OVERRIDE_VAR_CMODEFLAGS    = -std=c99
INSTALL_OVERRIDE_VAR_EXTRA_LDFLAGS = -lsqlite3

post-configure:
	@find $(WORKSRC) -name "libtool" -type f -exec \
	    gsed -i 's/ECHO="print -r --"/ECHO="printf %s\\n"/g' {} \;
	@$(MAKECOOKIE)

include gar/category.mk
