ref: 1dcb9611241b518cc1681a967d76fbcad64c91cd
parent: 487c2a6e18f22dbd8a43aa150db10b19529848eb
author: Andrew Chambers <ac@acha.ninja>
date: Thu Apr 7 20:44:56 CDT 2022
Work on build.
--- a/Makefile
+++ b/Makefile
@@ -18,19 +18,16 @@
$(MANDIR) :
mkdir -p $(MANDIR)
+# Minipeg distributable amalgamation.
minipeg: minipeg.c
-minipeg-new: minipeg-new.c
-
+# Minipeg built from individual c files.
minipeg-split: $(SRC)
$(CC) $(CFLAGS) -o $@ compile.c tree.c peg.c
minipeg.c: $(SRC)
- sh amalg.sh $(SRC) > $@
+ sh amalgamate.sh $(SRC) > $@
-minipeg-new.c: $(NEWSRC)
- sh amalg.sh $(NEWSRC) > $@
-
peg-new.c: peg.leg minipeg
./minipeg -o $@ $<
@@ -37,6 +34,8 @@
peg-split.c: peg.leg minipeg-split
./minipeg-split -o $@ $<
+# The checked in peg.c matches the built peg-new.c.
+# We also test peg-split.c to test our amalgamation process.
check-self-host: peg.c peg-new.c peg-split.c .FORCE
diff -u peg-new.c peg.c
diff -u peg-split.c peg.c
@@ -45,6 +44,6 @@
$(SHELL) -ec '(cd examples; $(MAKE))'
clean : .FORCE
- rm -f minipeg minipeg.c minipeg-new.c *.o
+ rm -f minipeg minipeg-split minipeg.c minipeg-new.c peg-new.c *.o
.FORCE :
--- /dev/null
+++ b/amalgamate.sh
@@ -1,0 +1,9 @@
+# Amalgamate the source code, sqlite3 style.
+echo "/* This file is a generated distributable version of the minipeg project."
+echo " * Visit https://github.com/andrewchambers/minipeg for details. */"
+cat *.c | grep '^#include <' | sort -u
+for f in version.h tree.h compile.c tree.c peg.c
+do
+ echo "#line 0 \"$f\""
+ grep -v '^#include' "$f"
+done