diff --git a/.gitignore b/.gitignore index b53963d..8457898 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ -*.o +# Chicken dependencies +/.eggs +/.eggs.lock + +# Compilation artifacts sexc sex-tests +*.o diff --git a/Makefile b/Makefile index 50cd21a..007079a 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,26 @@ CHICKEN_C = csc CSC_FLAGS += -K prefix +CHICKEN_INSTALL = chicken-install + +prefix ?= /usr/local +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/bin MODULES = sexc fmt-c fmt-c-writer semen sex-macros sex-modules sex-reader utils OBJ = $(MODULES:%=%.o) +DEPSFILE = dependencies.txt +DEPSLOCK = .eggs.lock + +DEPENDENCIES = $(shell cat $(DEPSFILE)) +CHICKEN_EXTERNAL_REPOSITORY := $(shell chicken-install -repository) + +export CHICKEN_EGG_CACHE=$(abspath .eggs)/cache +export CHICKEN_REPOSITORY_PATH=$(abspath .eggs):$(CHICKEN_EXTERNAL_REPOSITORY) +export CHICKEN_INSTALL_REPOSITORY=$(abspath .eggs) + +all: sexc + sexc: main.o $(OBJ) $(CHICKEN_C) $(CSC_FLAGS) $^ -o $@ @@ -13,9 +30,33 @@ main.o: main.scm %.o: %.scm $(CHICKEN_C) $(CSC_FLAGS) $< -e -c -o $@ +install: sexc installdirs + install -m 755 ./sexc $(bindir) + +installdirs: + mkdir -pv $(bindir) + +uninstall: + rm -fv $(bindir)/sexc + sex-tests: $(OBJ) tests/*.scm cd ./tests && $(CHICKEN_C) $(CSC_FLAGS) run.scm -c -o sex-tests.o $(CHICKEN_C) $(CSC_FLAGS) $(OBJ) ./tests/sex-tests.o -o sex-tests +run-tests: sex-tests + ./sex-tests + +.eggs.lock: $(DEPSFILE) + env | grep CHICKEN + $(CHICKEN_INSTALL) $(DEPENDENCIES) + touch $(DEPSLOCK) + +deps: $(DEPSLOCK) + clean: rm -f $(OBJ) sexc sex-tests main.o ./tests/sex-tests.o + +depclean: + rm -rf .eggs $(DEPSLOCK) + +.PHONY: all deps depclean clean diff --git a/Readme.org b/Readme.org index fc041b4..fbc586c 100644 --- a/Readme.org +++ b/Readme.org @@ -21,7 +21,24 @@ https://wiki.call-cc.org/man/5/Extension%20tools#changing-the-repository-locatio ~chicken-install `cat dependencies.txt`~ ** Compilation -~make~ +#+begin_src sh + make +#+end_src + +** Static compilation +If you want to make a self-contained binary, you'll need `chicken` with `libchicken.a` installed. + +#+begin_src sh + CSC_FLAGS=-static make +#+end_src + +** Installation +#+begin_src sh + # default installation (/usr/local/bin/) + make install + # you can customize the prefix (will install to ~/.local/bin) + make prefix=~/.local install +#+end_src * Usage ** Summary