Make byacc actually work when compiled against meslibc

This replaces the previous sed hackery with a proper patch, and removes
a few more libc functions that meslibc is missing.
The binary name is changed to "byacc" so it doesn't get overwritten by
heirloom yacc.

The bsearch() replacement code comes from an earlier version of byacc.
This commit is contained in:
Gábor Stefanik 2024-04-14 20:59:57 +02:00
parent 3970ee7d1a
commit 6567973a04
3 changed files with 175 additions and 11 deletions

View file

@ -22,28 +22,22 @@ tar xf ../src/${pkg}.tar
rm -r ../src/
cd ${pkg}
# Prepare
# Prepare and patch
cp ../../files/Makefile .
# meslibc has no fgetpos/fsetpos - emulate using fseek/ftell
sed -i -e "s/fpos_t/long/" -e "s/fgetpos(f, &save_area.line_fpos) != 0/(save_area.line_fpos = ftell(f)) == -1/" \
-e "s/fsetpos(input_file, &save_area.line_fpos)/fseek(input_file, save_area.line_fpos, SEEK_SET)/" reader.c
# likewise, meslibc has no tmpfile()
sed -i -e "s/tmpfile()/fopen(label, \"w+\")/" main.c
patch -Np0 -i ../../patches/meslibc.patch
# Build yacc
make CC=tcc AR=tcc\ -ar CFLAGS=-DMAXPATHLEN=100\ -DEILSEQ=84\ -DMB_LEN_MAX=100 LDFLAGS=-lgetopt\ -static RANLIB=true
# Install yacc
install yacc ${BINDIR}
install yacc ${BINDIR}/byacc
cd ../..
# Checksums
if match x${UPDATE_CHECKSUMS} xTrue; then
sha256sum -o ${pkg}.checksums \
/usr/bin/yacc
/usr/bin/byacc
install ${pkg}.checksums ${SRCDIR}
else