4 Commits

Author SHA1 Message Date
Pavel Kulyov
7c0b511aeb infra: pepper some GNU on top of Makefile 2025-12-02 20:46:11 +03:00
Pavel Kulyov
37ec122054 readme: add docs about static compilation 2025-12-02 20:45:28 +03:00
Pavel Kulyov
601b687d1b Update gitignore 2025-12-02 20:45:28 +03:00
Pavel Kulyov
e0803e4c3d Add project-local dependencies installation 2025-12-02 20:45:19 +03:00
3 changed files with 65 additions and 2 deletions

7
.gitignore vendored
View File

@@ -1,3 +1,8 @@
*.o
# Chicken dependencies
/.eggs
/.eggs.lock
# Compilation artifacts
sexc
sex-tests
*.o

View File

@@ -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

View File

@@ -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