ref: b001b66a7ebb6953dacd9845e90efa4d7561d142
parent: 45c44551552c6628a537c015c94812012ba6875d
author: grobe0ba <grobe0ba@tcp80.org>
date: Thu Jun 20 11:30:24 CDT 2024
two-stage build we build a bootstrap version of zuo that relies on the libraries in "./lib" to function. we then generate an embedded image that contains all of those libraries and build that as the final "zuo" executable. this allows us to install it without needing to copy around extra library files, and also allows zuo to still pick up extra library files from "./lib" if present. thanks to phil9 for pinging me to make it installable.
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,8 @@
/zuo.exe
/zuo.obj
/zuo.o
+/zuo.0
+/zuo_image.c
/build
--- a/mkfile
+++ b/mkfile
@@ -1,7 +1,18 @@
all:V: zuo
-zuo: zuo.c
- pcc -D_PLAN9_SOURCE -o zuo zuo.c
+zuo: zuo_image.c
+ pcc -D_PLAN9_SOURCE -o zuo zuo_image.c
+zuo.0: zuo.c
+ pcc -D_PLAN9_SOURCE -o zuo.0 zuo.c
+
+zuo_image.c: zuo.0
+ ./zuo.0 local/image.zuo -o zuo_image.c ++lib zuo \
+ `{for(i in `{walk -f -n1,1 lib/zuo}) echo ++lib zuo/^`{basename $i .zuo}}
+
+install:V: zuo
+ chmod 755 zuo
+ cp zuo /$objtype/bin/zuo
+
clean:V:
- rm -f zuo
+ rm -f zuo zuo.0 zuo_image.c