commit: 3970ee7d1ace219b7f0799686f2cec51d14b6d83
parent 86e1a5e7f61ae29c66f6ea78c72717b4162bb0df
Author: Gábor Stefanik <netrolller.3d@gmail.com>
Date: Sun, 14 Apr 2024 05:51:30 +0200
Add byacc parser generator
This is meant to replace heirloom yacc for compiling pre-musl parsers.
Unlike heirloom yacc, it's in the public domain, and can be linked with
meslibc without licensing concerns.
Diffstat:
5 files changed, 137 insertions(+), 0 deletions(-)
diff --git a/steps/byacc-20240109/byacc-20240109.checksums b/steps/byacc-20240109/byacc-20240109.checksums
@@ -0,0 +1 @@
+608651c4836eff7f164a0c6d238337a254fca964677bec76d87f85692ce71b59 /usr/bin/yacc
diff --git a/steps/byacc-20240109/files/Makefile b/steps/byacc-20240109/files/Makefile
@@ -0,0 +1,83 @@
+DEST = .
+
+HDRS = defs.h
+
+CFLAGS ?= -O -DNDEBUG
+
+LDFLAGS ?=
+
+LIBS ?=
+
+LINKER ?= $(CC)
+
+MAKEFILE = Makefile
+
+OBJS = closure.o \
+ error.o graph.o \
+ lalr.o \
+ lr0.o \
+ main.o \
+ mkpar.o mstring.o \
+ output.o \
+ reader.o \
+ symtab.o \
+ verbose.o \
+ warshall.o yaccpar.o
+
+PRINT = pr -f -l88
+
+PROGRAM = yacc
+
+SRCS = closure.c \
+ error.c graph.c \
+ lalr.c \
+ lr0.c \
+ main.c \
+ mkpar.c mstring.c \
+ output.c \
+ reader.c \
+ symtab.c \
+ verbose.c \
+ warshall.c yaccpar.c
+
+all: $(PROGRAM)
+
+$(PROGRAM): $(OBJS) $(LIBS)
+ @$(LINKER) $(LDFLAGS) -o $(PROGRAM) $(OBJS) $(LIBS)
+
+clean:; @rm -f $(OBJS)
+
+clobber:; @rm -f $(OBJS) $(PROGRAM)
+
+depend:; @mkmf -f $(MAKEFILE) PROGRAM=$(PROGRAM) DEST=$(DEST)
+
+index:; @ctags -wx $(HDRS) $(SRCS)
+
+install: $(PROGRAM)
+ @echo Installing $(PROGRAM) in $(DEST)
+ @install -s $(PROGRAM) $(DEST)
+
+listing:; @$(PRINT) Makefile $(HDRS) $(SRCS) | lpr
+
+lint:; @lint $(SRCS)
+
+program: $(PROGRAM)
+
+tags: $(HDRS) $(SRCS); @ctags $(HDRS) $(SRCS)
+
+###
+closure.o: defs.h
+error.o: defs.h
+lalr.o: defs.h
+lr0.o: defs.h
+main.o: defs.h
+mkpar.o: defs.h
+output.o: defs.h
+reader.o: defs.h
+symtab.o: defs.h
+verbose.o: defs.h
+warshall.o: defs.h
+btyaccpar.o: defs.h
+yaccpar.o: defs.h
+graph.o: defs.h
+mstring.o: defs.h
diff --git a/steps/byacc-20240109/pass1.kaem b/steps/byacc-20240109/pass1.kaem
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+# SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
+# SPDX-FileCopyrightText: 2021-22 fosslinux <fosslinux@aussies.space>
+# SPDX-FileCopyrightText: 2024 Gábor Stefanik <netrolller.3d@gmail.com>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+set -ex
+
+# Check tarball checksums
+checksum-transcriber sources
+sha256sum -c sources.SHA256SUM
+
+mkdir build src
+cd build
+
+# Extract
+cp ${DISTFILES}/${pkg}.tgz ../src/${pkg}.tar.gz
+gunzip -f ../src/${pkg}.tar.gz
+tar xf ../src/${pkg}.tar
+rm -r ../src/
+cd ${pkg}
+
+# Prepare
+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
+
+# 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}
+
+cd ../..
+
+# Checksums
+if match x${UPDATE_CHECKSUMS} xTrue; then
+ sha256sum -o ${pkg}.checksums \
+ /usr/bin/yacc
+
+ install ${pkg}.checksums ${SRCDIR}
+else
+ sha256sum -c ${pkg}.checksums
+fi
diff --git a/steps/byacc-20240109/sources b/steps/byacc-20240109/sources
@@ -0,0 +1 @@
+https://invisible-island.net/archives/byacc/byacc-20240109.tgz f2897779017189f1a94757705ef6f6e15dc9208ef079eea7f28abec577e08446
diff --git a/steps/manifest b/steps/manifest
@@ -49,6 +49,7 @@ build: tar-1.12
build: sed-4.0.9
build: bzip2-1.0.8
build: coreutils-5.0
+build: byacc-20240109
build: heirloom-devtools-070527
build: bash-2.05b
improve: setup_repo