build the programs the way the modules are built
All checks were successful
Sex CI / build-linux (pull_request) Successful in 5m17s
All checks were successful
Sex CI / build-linux (pull_request) Successful in 5m17s
Each program had its own recipe: a hand-written link list, a cd into tests/ to keep its includes off the modules' namesakes, and an output renamed so as not to overwrite sexc.o. Read off their imports and built from an object named after their source, they share one rule.
This commit is contained in:
57
Makefile
57
Makefile
@@ -37,20 +37,17 @@ all: sexc
|
||||
|
||||
include eggs.mk
|
||||
|
||||
# MODULES, and a line for each naming the modules it imports, read off
|
||||
# the import forms. Not for clean, which has to work when they cannot
|
||||
# be read
|
||||
# Each program, and the source it is built from
|
||||
PROGRAMS = sexc=main.scm sextest=tools/sextest/sextest.scm sex-tests=tests/run.scm
|
||||
PROGRAM_NAMES = $(foreach p,$(PROGRAMS),$(firstword $(subst =, ,$(p))))
|
||||
PROGRAM_OBJ = $(foreach p,$(PROGRAMS),$(patsubst %.scm,%.o,$(lastword $(subst =, ,$(p)))))
|
||||
|
||||
# MODULES, and a line for each module and program naming what it
|
||||
# imports, read off the import forms. Not for clean, which has to work
|
||||
# when they cannot be read
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
include modules.mk
|
||||
endif
|
||||
OBJ = $(MODULES:%=%.o)
|
||||
|
||||
sexc: $(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
|
||||
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# The scan is redone whenever a source may have changed what it
|
||||
# imports, or a NAME.scm may have come to be the module an import
|
||||
@@ -59,34 +56,28 @@ sexc: $(OBJ) main.scm
|
||||
# have it start over for good
|
||||
modules.mk: modules.stamp ;
|
||||
|
||||
modules.stamp: $(filter-out %.import.scm,$(wildcard *.scm)) tools/module-deps.scm
|
||||
$(CSI) -s tools/module-deps.scm main.scm > modules.mk.tmp \
|
||||
modules.stamp: $(SOURCES) $(filter-out %.import.scm,$(wildcard *.scm)) \
|
||||
tools/module-deps.scm dependencies.txt Makefile
|
||||
$(CSI) -s tools/module-deps.scm $(PROGRAMS) > modules.mk.tmp \
|
||||
|| { rm -f modules.mk.tmp; exit 1; }
|
||||
if cmp -s modules.mk.tmp modules.mk; then rm modules.mk.tmp; \
|
||||
else mv modules.mk.tmp modules.mk; fi
|
||||
touch $@
|
||||
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# A module is one file that declares its own exports, made a module by
|
||||
# -module
|
||||
|
||||
# -module, except the vendored sex-fmt-c, a (module ...) form of its own
|
||||
%.o: %.scm
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) $< -module $* -o $@ -unit $*
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) $< $(if $(filter sex-fmt-c,$*),,-module $*) -o $@ -unit $*
|
||||
|
||||
# Vendored, and a (module ...) form of its own
|
||||
sex-fmt-c.o: sex-fmt-c.scm
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $(MODULE_FLAGS) $< -o $@ -unit sex-fmt-c
|
||||
# A program's object is named after its source: csc names its own after
|
||||
# -o, and sexc.o is the module's
|
||||
$(PROGRAM_OBJ): %.o: %.scm
|
||||
$(CHICKEN_C) $(CSC_FLAGS) -c $< -o $@
|
||||
|
||||
# Both link the modules built here, whose import libraries they find
|
||||
# with the root on the repository path. The tests are built in their
|
||||
# own directory, where their includes would otherwise find the modules'
|
||||
# namesakes
|
||||
WITH_ROOT_REPO = CHICKEN_REPOSITORY_PATH=$(CURDIR):$(CHICKEN_REPOSITORY_PATH)
|
||||
|
||||
sex-tests: $(wildcard tests/*.scm) $(OBJ)
|
||||
cd tests && $(WITH_ROOT_REPO) $(CHICKEN_C) $(CSC_FLAGS) run.scm -o ../$@ -link sexc
|
||||
|
||||
sextest: tools/sextest/sextest.scm reader.o utils.o
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $< -o $@ -link reader,utils
|
||||
$(PROGRAM_NAMES):
|
||||
$(CHICKEN_C) $(CSC_FLAGS) $< -o $@
|
||||
|
||||
# A program directly in tests/sex-programs is a test; lib/ holds what
|
||||
# they import
|
||||
@@ -118,9 +109,9 @@ uninstall:
|
||||
-rmdir $(DESTDIR)$(sexlibdir)
|
||||
|
||||
clean:
|
||||
rm -f *.o modules.mk modules.stamp
|
||||
rm -f *.o $(PROGRAM_OBJ) modules.mk modules.stamp
|
||||
rm -f *.import.scm
|
||||
rm -f *.link
|
||||
rm -f sexc sex-tests sextest
|
||||
rm -f *.link $(PROGRAM_OBJ:.o=.link)
|
||||
rm -f $(PROGRAM_NAMES)
|
||||
|
||||
.PHONY: all check run-tests check-modules check-exit-code install install-strip installdirs uninstall clean
|
||||
|
||||
Reference in New Issue
Block a user