about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-05 22:41:59 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-05 22:41:59 -0700
commit159359029603044014a62c26b63a60b17547400e (patch)
tree39228a47ff075dcb4dc1d0cdc949c62ec6f3062d
parentfaf521d94c942ea6ab42b301db303ed02e376c16 (diff)
downloadmu-159359029603044014a62c26b63a60b17547400e.tar.gz
3442
Support for a minimal OpenBSD without bash. Many of the scripts in the
repo won't work in that situation, but let's at least make the `mu`
script work.

I'd like to come up with a clean makefile that doesn't require GNU make.
-rw-r--r--Readme.md2
-rw-r--r--makefile18
-rwxr-xr-xmu8
3 files changed, 16 insertions, 12 deletions
diff --git a/Readme.md b/Readme.md
index d3cd3555..c6d6ed81 100644
--- a/Readme.md
+++ b/Readme.md
@@ -87,7 +87,7 @@ Mu is currently implemented in C++ and requires a Unix-like environment. It's
 been tested on Ubuntu and Mac OS X, on x86, x86\_64 and ARMv7 with recent
 versions of GCC and Clang. Since it uses no recent language features and has
 no exotic dependencies, it should work with most reasonable versions,
-compilers or processors.
+compilers or processors (though you do need GNU make or `gmake`).
 
 [![Build Status](https://api.travis-ci.org/akkartik/mu.svg)](https://travis-ci.org/akkartik/mu)
 
diff --git a/makefile b/makefile
index b87a5c74..1f5599d7 100644
--- a/makefile
+++ b/makefile
@@ -26,7 +26,7 @@ mu_bin: mu.cc makefile function_list test_list cleave/cleave
 	@# split mu.cc into separate compilation units under .build/ to speed up recompiles
 	./cleave/cleave mu.cc .build
 	@# recursive (potentially parallel) make to pick up BUILD_SRC after cleave
-	@make .build/mu_bin
+	@${MAKE} .build/mu_bin
 	cp .build/mu_bin .
 
 BUILD_SRC=$(wildcard .build/*.cc)
@@ -43,17 +43,17 @@ mu.cc: [0-9]*.cc enumerate/enumerate tangle/tangle
 	./tangle/tangle $$(./enumerate/enumerate --until zzz |grep -v '.mu$$') > mu.cc
 
 enumerate/enumerate: enumerate/*.cc
-	cd enumerate && make
+	cd enumerate && ${MAKE}
 
 tangle/tangle: tangle/*.cc
-	cd tangle && make && ./tangle test
+	cd tangle && ${MAKE} && ./tangle test
 
 cleave/cleave: cleave/*.cc
-	cd cleave && make
+	cd cleave && ${MAKE}
 	rm -rf .build
 
 termbox/libtermbox.a: termbox/*.c termbox/*.h termbox/*.inl
-	cd termbox && make
+	cd termbox && ${MAKE}
 
 # auto-generated files; by convention they end in '_list'.
 
@@ -76,10 +76,10 @@ test_list: mu.cc
 
 clena: clean
 clean: clean1
-	cd enumerate && make clean
-	cd tangle && make clean
-	cd cleave && make clean
-	cd termbox && make clean
+	cd enumerate && ${MAKE} clean
+	cd tangle && ${MAKE} clean
+	cd cleave && ${MAKE} clean
+	cd termbox && ${MAKE} clean
 
 clean1:
 	rm -rf mu.cc core.mu mu_bin* *_list .build
diff --git a/mu b/mu
index 7d82e32a..ad3222d9 100755
--- a/mu
+++ b/mu
@@ -1,9 +1,13 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Compile mu if necessary before running it.
 
+# I try to keep this script working even on a minimal OpenBSD without bash.
+# In such situations you might sometimes need GNU make.
+which gmake >/dev/null 2>&1 && export MAKE=gmake || export MAKE=make
+
 # show make output only if something needs doing
-make -q || make >&2 || exit 1
+$MAKE -q || $MAKE >&2 || exit 1
 
 ./mu_bin $FLAGS "$@"