From 79ce3dace2b6658b199e53206fec41d98ac0a955 Mon Sep 17 00:00:00 2001 From: Pavel Kulyov Date: Wed, 1 Oct 2025 14:35:37 +0300 Subject: [PATCH 1/7] Add project-local dependencies installation --- Makefile | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 76857fa..7a4d348 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -CHICKEN_C = csc +CHICKEN_C ?= csc +CHICKEN_INSTALL ?= chicken-install +CHICKEN_STATUS ?= chicken-status CSC_FLAGS += -K prefix -static # What and why: # -emit-all-import-libraries: Emit import-libraries for all defined modules. @@ -18,11 +20,29 @@ MODULE_FLAGS = -emit-all-import-libraries -module-registration -c MODULES = utils types sex-macros reader sex-modules semen sex-fmt-c fmt-c-writer sexc OBJ = $(MODULES:%=%.o) -sexc: $(OBJ) main.scm +DEPSFILE = dependencies.txt +DEPSLOCK = eggs.lock +EGGS_DIR := $(abspath .eggs) + +# Compiler's own repository (types.db, chicken.*), ignoring ambient venv vars. +SYSTEM_CHICKEN_REPO := $(shell env -u CHICKEN_INSTALL_REPOSITORY -u CHICKEN_REPOSITORY_PATH -u CHICKEN_EGG_CACHE -u CHICKEN_INSTALL_PREFIX $(CHICKEN_INSTALL) -repository 2>/dev/null) +CHICKEN_ABI := $(notdir $(SYSTEM_CHICKEN_REPO)) +EGGS_STAMP := $(EGGS_DIR)/.installed-$(CHICKEN_ABI) + +export CHICKEN_EGG_CACHE := $(EGGS_DIR)/cache +export CHICKEN_INSTALL_REPOSITORY := $(EGGS_DIR) +export CHICKEN_INSTALL_PREFIX := $(EGGS_DIR) +export CHICKEN_REPOSITORY_PATH := $(EGGS_DIR):$(SYSTEM_CHICKEN_REPO) + +all: sexc + +sexc: $(EGGS_STAMP) $(OBJ) main.scm $(CHICKEN_C) $(CSC_FLAGS) main.scm -o sexc-tmp -link sexc # otherwise csc hangs, probably because it tries to compile to sexc.o first mv sexc-tmp sexc +$(OBJ): $(EGGS_STAMP) + #------------------------------------------------------------------ utils.o: utils.module.scm utils.scm @@ -53,11 +73,11 @@ sexc.o: sexc.module.scm types.o sexc.scm fmt-c-writer.o sex-macros.o sex-modules $(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) sexc.module.scm -o sexc.o -unit sexc -link fmt-c-writer,sex-macros,sex-modules,reader,semen,types,utils # Unit testing -sex-tests: +sex-tests: $(EGGS_STAMP) $(MAKE) -C ./tests sex-tests cp ./tests/sex-tests ./ -sextest: +sextest: $(EGGS_STAMP) $(MAKE) -C ./tools/sextest sextest cp ./tools/sextest/sextest . @@ -74,6 +94,36 @@ check-exit-code: sexc run-tests: sexc sex-tests sextest ./sex-tests && ./sextest --sexc=./sexc $(SEX_TEST_PROGRAMS:%=./tests/sex-programs/%.sex) && $(MAKE) check-modules && $(MAKE) check-exit-code +install: all installdirs + $(INSTALL_PROGRAM) sexc $(DESTDIR)$(bindir)/sexc + +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install + +installdirs: + $(INSTALL) -d $(DESTDIR)$(bindir) + +uninstall: + rm -f $(DESTDIR)$(bindir)/sexc + +# eggs.lock is the pin file (chicken-status -list). Install from it; +# do not float versions on a normal build. Regenerating the lock: +# make deps-update +$(EGGS_STAMP): $(DEPSLOCK) + mkdir -p $(CHICKEN_EGG_CACHE) + $(CHICKEN_INSTALL) -force -from-list $(DEPSLOCK) + touch $@ + +deps: $(EGGS_STAMP) + +deps-update: $(DEPSFILE) + rm -rf $(EGGS_DIR) + mkdir -p $(CHICKEN_EGG_CACHE) + $(CHICKEN_INSTALL) -force $$(cat $(DEPSFILE)) + CHICKEN_REPOSITORY_PATH=$(EGGS_DIR) $(CHICKEN_STATUS) -list | sort > $(DEPSLOCK).tmp + mv $(DEPSLOCK).tmp $(DEPSLOCK) + touch $(EGGS_STAMP) + clean: rm -f $(OBJ) main.o rm -f *.import.scm @@ -81,4 +131,4 @@ clean: rm -f sexc sex-tests sextest $(MAKE) -C ./tests/modules clean -.PHONY: clean run-tests sex-tests sextest check-modules check-exit-code +.PHONY: clean depclean deps run-tests sex-tests sextest check-modules check-exit-code -- 2.52.0 From e3da2a1e7933e7aa534db31d096af9132804232e Mon Sep 17 00:00:00 2001 From: Pavel Kulyov Date: Sat, 27 Sep 2025 20:16:45 +0300 Subject: [PATCH 2/7] Update gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index e50abab..d588d9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# Project-local Chicken egg repository +/.eggs + +# Compilation artifacts *.o *.import.scm *.link -- 2.52.0 From e2fb4adae5d0f7e6734c456ddc63774a0e4fd3c3 Mon Sep 17 00:00:00 2001 From: Pavel Kulyov Date: Fri, 31 Oct 2025 15:57:32 +0300 Subject: [PATCH 3/7] readme: add docs about static compilation --- Readme.org | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Readme.org b/Readme.org index 9e0b73a..8b76d6a 100644 --- a/Readme.org +++ b/Readme.org @@ -21,7 +21,22 @@ 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 +The default ~CSC_FLAGS~ include ~-static~, so ~sexc~ does not need +~.eggs~ at runtime and ~make install~ stays relocatable. Chicken must +provide ~libchicken.a~ (E.g. for gentoo: ~dev-scheme/chicken~ with +~static-libs~ use flag). + +To link dynamically instead (the binary will look for eggs under this +tree's ~.eggs~ path): + +#+begin_src sh + make CSC_FLAGS='-K prefix' +#+end_src * Usage ** Summary -- 2.52.0 From 94c4a7008f176c33a1819fc80014085028e24590 Mon Sep 17 00:00:00 2001 From: Pavel Kulyov Date: Fri, 31 Oct 2025 15:57:55 +0300 Subject: [PATCH 4/7] infra: pepper some GNU on top of Makefile --- Makefile | 20 ++++++++++++++++++-- Readme.org | 12 ++++++++++++ tests/Makefile | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7a4d348..ebb1898 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,15 @@ CSC_FLAGS += -K prefix -static # error. # -c: Stop after compilation to object files. This one is obvious. +# GNU directory variables. Command line overrides, e.g. +# make prefix=$(HOME)/.local install +# make DESTDIR=/tmp/stage prefix=/usr install +prefix = /usr/local +exec_prefix = $(prefix) +bindir = $(exec_prefix)/bin +INSTALL = install +INSTALL_PROGRAM = $(INSTALL) + MODULE_FLAGS = -emit-all-import-libraries -module-registration -c # Order matters, since module check correctness on compilation @@ -91,7 +100,7 @@ check-modules: sexc check-exit-code: sexc @$(MAKE) --no-print-directory -C ./tests/exit-code check SEXC=../../sexc -run-tests: sexc sex-tests sextest +check run-tests: sexc sex-tests sextest ./sex-tests && ./sextest --sexc=./sexc $(SEX_TEST_PROGRAMS:%=./tests/sex-programs/%.sex) && $(MAKE) check-modules && $(MAKE) check-exit-code install: all installdirs @@ -129,6 +138,13 @@ clean: rm -f *.import.scm rm -f *.link rm -f sexc sex-tests sextest + $(MAKE) -C ./tests clean $(MAKE) -C ./tests/modules clean + $(MAKE) -C ./tools/sextest clean -.PHONY: clean depclean deps run-tests sex-tests sextest check-modules check-exit-code +deps-clean: + rm -rf $(EGGS_DIR) + +.PHONY: all check run-tests check-modules check-exit-code \ + install install-strip installdirs uninstall \ + deps deps-update deps-clean clean sex-tests sextest diff --git a/Readme.org b/Readme.org index 8b76d6a..fd13fe6 100644 --- a/Readme.org +++ b/Readme.org @@ -38,6 +38,18 @@ tree's ~.eggs~ path): make CSC_FLAGS='-K prefix' #+end_src +** Installation +GNU directory variables: ~prefix~, ~exec_prefix~, ~bindir~, ~DESTDIR~. + +#+begin_src sh + # default installation (/usr/local/bin/) + make install + # customize the prefix (installs to ~/.local/bin) + make prefix=$(HOME)/.local install + # staged install for packaging + make DESTDIR=/tmp/stage prefix=/usr install +#+end_src + * Usage ** Summary #+begin_src diff --git a/tests/Makefile b/tests/Makefile index b40a19e..7297715 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -46,3 +46,5 @@ clean: rm -f *.import.scm rm -f *.link rm -f sex-tests + +.PHONY: clean -- 2.52.0 From c0a34fc64cf82365c2e209c6e598613147399a7e Mon Sep 17 00:00:00 2001 From: Pavel Kulyov Date: Fri, 18 Sep 2026 00:03:12 +0300 Subject: [PATCH 5/7] readme: update installation docs --- Readme.org | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Readme.org b/Readme.org index fd13fe6..e335085 100644 --- a/Readme.org +++ b/Readme.org @@ -12,19 +12,22 @@ Sex is statically typed, compiled general purpose language. First, get yourself a Chicken, then, some Chicken deps. You also will need a C compiler. -** Install Chicken Eggs -Tip: there's a way to make Chicken install eggs non-globally. You need -to export ~CHICKEN_INSTALL_REPOSITORY~ and ~CHICKEN_REPOSITORY_PATH~ -environment variables. Refer to the documentation for more info: -https://wiki.call-cc.org/man/5/Extension%20tools#changing-the-repository-location - -~chicken-install `cat dependencies.txt`~ +Eggs are installed into a project-local ~.eggs/~ repository; they do not +touch the Chicken system repository. ** Compilation #+begin_src sh make #+end_src +That installs pinned eggs from ~eggs.lock~ into ~.eggs/~ if needed, then +builds ~sexc~. ~dependencies.txt~ is the unpinned request list. To +refresh ~eggs.lock~ after changing it: + +#+begin_src sh + make deps-update +#+end_src + ** Static compilation The default ~CSC_FLAGS~ include ~-static~, so ~sexc~ does not need ~.eggs~ at runtime and ~make install~ stays relocatable. Chicken must -- 2.52.0 From 0256aa8a22486050d35e63435c278679a83d72d2 Mon Sep 17 00:00:00 2001 From: Pavel Kulyov Date: Fri, 18 Sep 2026 00:37:56 +0300 Subject: [PATCH 6/7] deps: lock versions --- eggs.lock | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 eggs.lock diff --git a/eggs.lock b/eggs.lock new file mode 100644 index 0000000..aeca254 --- /dev/null +++ b/eggs.lock @@ -0,0 +1,8 @@ +(brev-separate "1.100") +(fmt "0.8.14") +(getopt-long "4.0") +(matchable "1.2") +(srfi-1 "0.5.1") +(srfi-13 "0.3.8") +(srfi-69 "0.5.3") +(test "1.3") -- 2.52.0 From ca71ae6e91d90ea42aa3f78e03551079a32ee054 Mon Sep 17 00:00:00 2001 From: Pavel Kulyov Date: Fri, 18 Sep 2026 00:43:29 +0300 Subject: [PATCH 7/7] ci: drop manual eggs installation --- .gitea/workflows/build.yaml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 3651e89..1b9a55d 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -57,20 +57,9 @@ jobs: hash -r csc -version - - name: Install eggs - run: | - set -eu - mkdir -p .eggs - repo="$(chicken-install -repository)" - echo "CHICKEN_INSTALL_REPOSITORY=${PWD}/.eggs" >> "$GITHUB_ENV" - echo "CHICKEN_REPOSITORY_PATH=${PWD}/.eggs:${repo}" >> "$GITHUB_ENV" - export CHICKEN_INSTALL_REPOSITORY="${PWD}/.eggs" - export CHICKEN_REPOSITORY_PATH="${PWD}/.eggs:${repo}" - # shellcheck disable=SC2046 - chicken-install $(cat dependencies.txt) - + # Eggs are pinned in eggs.lock and installed by the Makefile into .eggs/. - name: Build sexc - run: make sexc && ./sexc --help + run: make && ./sexc --help - name: Run tests - run: make run-tests + run: make check -- 2.52.0