shithub: 9pro

Download patch

ref: d1d3a8d1fe4af711ca6628b457489b4a56e0908c
parent: 5409aae3e7195e5f71ec001bc1e4bf69d12ac08f
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Feb 23 18:49:36 EST 2023

replace build.sh with a makefile (thanks mkf)

--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 9pex
 9gc
+*.o
--- /dev/null
+++ b/Makefile
@@ -1,0 +1,34 @@
+PROGS=9pex 9gc
+PREFIX?=/usr/local
+BIN=${DESTDIR}${PREFIX}/bin
+CFLAGS?=-g -O2
+CFLAGS+=-std=c99 -Wall -Wextra -Wshadow -Ic9 -Iparg
+PEX_O=9pex.o crc32.o
+GC_O=9gc.o
+COMMON_O=c9/c9.o parg/parg.o
+
+all: default
+
+default: 9pex 9gc
+
+9pex: ${COMMON_O} ${PEX_O}
+	${CC} -o $@ ${COMMON_O} ${PEX_O}
+
+9gc: ${COMMON_O} ${GC_O}
+	${CC} -o $@ ${COMMON_O} ${GC_O}
+
+install: progs
+	install -d ${BIN}
+	install -m 755 ${PROG} ${BIN}
+
+uninstall:
+	cd ${BIN} && rm -f ${TARGET}
+
+clean:
+	rm -f ${PROGS} ${COMMON_O} ${PEX_O} ${GC_O}
+
+.SUFFIXES: .c .o
+.c.o:
+	${CC} -o $@ -c $< ${CFLAGS}
+
+.PHONY: all default install uninstall clean
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
 To build static binaries with musl:
 
 ```
-CC=musl-gcc CFLAGS="-Os -s -g0 -static" ./build.sh
+CC=musl-gcc CFLAGS="-Os -s -g0 -static" make
 ```
 
 # Why
--- a/build.sh
+++ /dev/null
@@ -1,5 +1,0 @@
-#!/bin/sh
-set -e
-set -x
-${CC:-gcc} -std=c99 -DC9_NO_SERVER -O2 -g -Wall -Wextra -Wshadow $CFLAGS c9/*.c parg/*.c -Ic9 -Iparg 9gc.c -o 9gc || rm -f 9gc
-${CC:-gcc} -std=c99 -DC9_NO_CLIENT -O2 -g -Wall -Wextra -Wshadow $CFLAGS c9/*.c parg/*.c -Ic9 -Iparg 9pex.c crc32.c -o 9pex || rm -f 9pex