1*705982a5SPatrick WilliamsSUMMARY = "GNU awk text processing utility"
2*705982a5SPatrick WilliamsDESCRIPTION = "The GNU version of awk, a text processing utility. \
3*705982a5SPatrick WilliamsAwk interprets a special-purpose programming language to do \
4*705982a5SPatrick Williamsquick and easy text pattern matching and reformatting jobs."
5*705982a5SPatrick WilliamsHOMEPAGE = "https://www.gnu.org/software/gawk/"
6*705982a5SPatrick WilliamsBUGTRACKER  = "bug-gawk@gnu.org"
7*705982a5SPatrick WilliamsSECTION = "console/utils"
8*705982a5SPatrick Williams
9*705982a5SPatrick Williams# gawk <= 3.1.5: GPL-2.0-only
10*705982a5SPatrick Williams# gawk >= 3.1.6: GPL-3.0-only
11*705982a5SPatrick WilliamsLICENSE = "GPL-3.0-only"
12*705982a5SPatrick WilliamsLIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
13*705982a5SPatrick Williams
14*705982a5SPatrick WilliamsPACKAGECONFIG ??= "readline"
15*705982a5SPatrick WilliamsPACKAGECONFIG[readline] = "--with-readline,--without-readline,readline"
16*705982a5SPatrick WilliamsPACKAGECONFIG[mpfr] = "--with-mpfr,--without-mpfr, mpfr"
17*705982a5SPatrick Williams
18*705982a5SPatrick WilliamsSRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.gz \
19*705982a5SPatrick Williams           file://run-ptest \
20*705982a5SPatrick Williams           "
21*705982a5SPatrick Williams
22*705982a5SPatrick WilliamsSRC_URI[sha256sum] = "378f8864ec21cfceaa048f7e1869ac9b4597b449087caf1eb55e440d30273336"
23*705982a5SPatrick Williams
24*705982a5SPatrick Williamsinherit autotools gettext texinfo update-alternatives
25*705982a5SPatrick Williams
26*705982a5SPatrick WilliamsFILES:${PN} += "${datadir}/awk"
27*705982a5SPatrick WilliamsFILES:${PN}-dev += "${libdir}/${BPN}/*.la"
28*705982a5SPatrick Williams
29*705982a5SPatrick WilliamsPACKAGES =+ "${PN}-gawkbug"
30*705982a5SPatrick WilliamsFILES:${PN}-gawkbug += "${bindir}/gawkbug"
31*705982a5SPatrick Williams
32*705982a5SPatrick WilliamsALTERNATIVE:${PN} = "awk"
33*705982a5SPatrick WilliamsALTERNATIVE_TARGET[awk] = "${bindir}/gawk"
34*705982a5SPatrick WilliamsALTERNATIVE_PRIORITY = "100"
35*705982a5SPatrick Williams
36*705982a5SPatrick Williamsdo_install:append() {
37*705982a5SPatrick Williams	# remove the link since we don't package it
38*705982a5SPatrick Williams	rm ${D}${bindir}/awk
39*705982a5SPatrick Williams	# Strip non-reproducible build flags (containing build paths)
40*705982a5SPatrick Williams	sed -i -e 's|^CC.*|CC=""|g' -e 's|^CFLAGS.*|CFLAGS=""|g' ${D}${bindir}/gawkbug
41*705982a5SPatrick Williams}
42*705982a5SPatrick Williams
43*705982a5SPatrick Williamsinherit ptest
44*705982a5SPatrick Williams
45*705982a5SPatrick Williamsdo_install_ptest() {
46*705982a5SPatrick Williams	mkdir ${D}${PTEST_PATH}/test
47*705982a5SPatrick Williams	ln -s ${bindir}/gawk ${D}${PTEST_PATH}/gawk
48*705982a5SPatrick Williams	# The list of tests is all targets in Maketests, apart from the dummy Gt-dummy
49*705982a5SPatrick Williams	TESTS=$(awk -F: '$1 == "Gt-dummy" { next } /[[:alnum:]]+:$/ { print $1 }' ${S}/test/Maketests)
50*705982a5SPatrick Williams	for i in $TESTS Maketests inclib.awk; do
51*705982a5SPatrick Williams		cp ${S}/test/$i* ${D}${PTEST_PATH}/test
52*705982a5SPatrick Williams	done
53*705982a5SPatrick Williams	sed -i \
54*705982a5SPatrick Williams	    -e 's|#!${base_bindir}/awk|#!${bindir}/awk|g' ${D}${PTEST_PATH}/test/*.awk
55*705982a5SPatrick Williams
56*705982a5SPatrick Williams	sed -i -e "s|GAWKLOCALE|LANG|g" ${D}${PTEST_PATH}/test/Maketests
57*705982a5SPatrick Williams
58*705982a5SPatrick Williams	# These tests require an unloaded host as otherwise timing sensitive tests can fail
59*705982a5SPatrick Williams	# https://bugzilla.yoctoproject.org/show_bug.cgi?id=14371
60*705982a5SPatrick Williams	rm -f ${D}${PTEST_PATH}/test/time.*
61*705982a5SPatrick Williams	rm -f ${D}${PTEST_PATH}/test/timeout.*
62*705982a5SPatrick Williams	for t in time timeout; do
63*705982a5SPatrick Williams		echo $t >> ${D}${PTEST_PATH}/test/skipped.txt
64*705982a5SPatrick Williams	done
65*705982a5SPatrick Williams}
66*705982a5SPatrick Williams
67*705982a5SPatrick Williamsdo_install_ptest:append:libc-musl() {
68*705982a5SPatrick Williams	# Reported  https://lists.gnu.org/archive/html/bug-gawk/2021-02/msg00005.html
69*705982a5SPatrick Williams	rm -f ${D}${PTEST_PATH}/test/clos1way6.*
70*705982a5SPatrick Williams	# Needs en_US.UTF-8 but then does not work with musl
71*705982a5SPatrick Williams	rm -f ${D}${PTEST_PATH}/test/backsmalls1.*
72*705982a5SPatrick Williams	# Needs en_US.UTF-8 but then does not work with musl
73*705982a5SPatrick Williams	rm -f ${D}${PTEST_PATH}/test/commas.*
74*705982a5SPatrick Williams	# The below two need LANG=C inside the make rule for musl
75*705982a5SPatrick Williams	rm -f ${D}${PTEST_PATH}/test/rebt8b1.*
76*705982a5SPatrick Williams	rm -f ${D}${PTEST_PATH}/test/regx8bit.*
77*705982a5SPatrick Williams	for t in clos1way6 backsmalls1 commas rebt8b1 regx8bit; do
78*705982a5SPatrick Williams		echo $t >> ${D}${PTEST_PATH}/test/skipped.txt
79*705982a5SPatrick Williams	done
80*705982a5SPatrick Williams}
81*705982a5SPatrick Williams
82*705982a5SPatrick WilliamsRDEPENDS:${PN}-ptest += "make locale-base-en-us coreutils"
83*705982a5SPatrick Williams
84*705982a5SPatrick WilliamsRDEPENDS:${PN}-ptest:append:libc-glibc = " locale-base-en-us.iso-8859-1"
85*705982a5SPatrick WilliamsRDEPENDS:${PN}-ptest:append:libc-musl = " musl-locales"
86*705982a5SPatrick Williams
87*705982a5SPatrick WilliamsBBCLASSEXTEND = "native nativesdk"
88