From 18b1e2818576b16363716b295092ac8eea1f4f8b Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sat, 7 Nov 2020 00:05:52 -0500 Subject: [PATCH] Script dir set in Makefile. Rename exec to `pl` Changed install dir. General cleanup of Makefile. Added `make uninstall` to Makefile. Tests still require that lib scripts already be installed to pass. --- src/Makefile | 27 ++++++++++++++++++--------- src/pebblisp.c | 4 ++-- src/tests.sh | 4 ++-- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/Makefile b/src/Makefile index d6ceea7..518d5c5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,23 +1,32 @@ files = pebblisp.c tokens.c object.c env.c -exe = pebblisp +exe = pl + +PREFIX ?= /usr/local +BINPREFIX ?= $(PREFIX)/bin +SCRIPTDIR ?= /usr/local/share/pebblisp + +GCC_COM ?= gcc -g -O0 -Wall -o $(exe) -D STANDALONE -DSCRIPTDIR=\"$(SCRIPTDIR)\" all: - gcc -g -O0 -Wall -o $(exe) -D STANDALONE $(files) && ./tests.sh + $(GCC_COM) $(files) && ./tests.sh notest: - gcc -g -O0 -Wall -o $(exe) -D STANDALONE $(files) + $(GCC_COM) $(files) val: - gcc -g -O0 -Wall -o $(exe) -D STANDALONE $(files) && ./tests.sh -val + $(GCC_COM) $(files) && ./tests.sh -val debug: - gcc -g -O0 -Wall -o $(exe) -D STANDALONE -D DEBUG $(files) + $(GCC_COM) -D DEBUG $(files) run: ./$(exe) install: - cp ./$(exe) /usr/bin/pl - mkdir -p /usr/share/pebblisp/ - rm /usr/share/pebblisp/* - cp ./examples/* /usr/share/pebblisp/ + cp -pf ./$(exe) $(BINPREFIX) + mkdir -p $(SCRIPTDIR) + cp ./examples/* $(SCRIPTDIR) + +uninstall: + rm $(BINPREFIX)/$(exe) + rm -r $(SCRIPTDIR) diff --git a/src/pebblisp.c b/src/pebblisp.c index 52b8350..cfe91ed 100644 --- a/src/pebblisp.c +++ b/src/pebblisp.c @@ -773,13 +773,13 @@ int readFile(const char *filename, struct Environment *env) { void repl(struct Environment *env) { - readFile("/usr/share/pebblisp/repl.pbl", env); + readFile(SCRIPTDIR "/repl.pbl", env); } int main(int argc, const char* argv[]) { struct Environment env = defaultEnv(); - readFile("/usr/share/pebblisp/lib.pbl", &env); + readFile(SCRIPTDIR "/lib.pbl", &env); if(argc >= 2) { if(readFile(argv[1], &env) != 0) { Object r = numberObject(0); diff --git a/src/tests.sh b/src/tests.sh index d6ba1f8..b763eb5 100755 --- a/src/tests.sh +++ b/src/tests.sh @@ -42,9 +42,9 @@ fail() { check() { local output if (($VALGRIND == 1)); then - local output=$($VALCOM ./pebblisp "$2") + local output=$($VALCOM ./pl "$2") else - local output=$(./pebblisp "$2") + local output=$(./pl "$2") fi if [ "$output" == "$3" ]; then