#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2022 Marcel Telka
#

%hook-no-license%
(
	cat "$SOURCE_DIR/README.txt" \
		| grep -v "^--------" \
		| gsed -e '0,/^Copyright & License:/d' -e '/^Installation:/,$d'
	printf "--- Artistic.txt ----------------------------------------------------------\n"
	cat "$SOURCE_DIR/license/Artistic.txt"
	printf "\n\n--- GNU_GPL.txt -----------------------------------------------------------\n\n"
	cat "$SOURCE_DIR/license/GNU_GPL.txt"
	printf "\n\n--- GNU_LGPL.txt ----------------------------------------------------------\n\n"
	cat "$SOURCE_DIR/license/GNU_LGPL.txt"
) > "$DISTRIBUTION.license"
USE_DEFAULT_PERL_LICENSE=0

%hook-manifest%
# During bootstrap we invoke perl-integrate-module with the -f flag and so we need
# to drop dependency on Date-Calc-XS.
((FORCE)) && sed -i -e '/^depend.*date-calc-xs/d' $MANIFEST

%include-3%
#
# There is circular runtime dependency:
#
#	Date-Calc recommends Date-Calc-XS
#	Date-Calc-XS requires Date-Calc
#
# To bootstrap both components we need to build Date-Calc first and remove any
# unresolved runtime dependency on Date-Calc-XS.
#
MANGLE_DEPEND_RUNTIME += | \
	$(GNU_GREP) -v '^depend type=require fmri=__TBD pkg\.debug\.depend\.file=Date/Calc/XS\.pm'