Skip to content

Instantly share code, notes, and snippets.

@icetan
Created November 8, 2017 10:48
Show Gist options
  • Save icetan/eb560d96461fa86e1a044b5bcbee9f4d to your computer and use it in GitHub Desktop.
Save icetan/eb560d96461fa86e1a044b5bcbee9f4d to your computer and use it in GitHub Desktop.
Simple configure/Makefile
#!/usr/bin/env bash
prefix=${prefix:-/usr/local}
usage () {
echo >&2 \
"
Usage : configure [--prefix=PREFIX]
"
exit 1
}
while test "$1"; do
case "$1" in
--prefix=*)
prefix=`echo "$1" | sed 's/^--prefix=//'`
;;
--prefix)
shift
prefix="$1"
;;
--help)
usage
exit
;;
*)
echo >&2 "Warning: unknown argument $1"
usage
;;
esac
shift
done
echo -n "SUBDIRS = " > config.make
echo >&2 "
Configuration Summary
---------------------
MyApp has been configured with
prefix = $prefix
>> config.make
"
echo -n "prefix=$prefix" >> config.make
DOT = dot
MD = markdown
OUT = domain.svg README.html
prefix = /usr/local
-include ./config.make
%.svg: %.dot
$(DOT) -Tsvg -o $@ $<
%.html: %.md
$(MD) -o $@ $<
.PHONY: clean all install
all: $(OUT)
clean:
rm -rf $(OUT)
install: all
test -d $(prefix)/doc || mkdir -p $(prefix)/doc
for out in $(OUT); do \
install -m 644 $$out $(prefix)/doc/$$out; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment