build: Remove make.

* GNUmakefile: trivial convenience-frontend to ./make.scm
* make/*.make: Remove.
* */*.make: Remove.
This commit is contained in:
Jan Nieuwenhuizen 2017-07-02 12:03:29 +02:00
parent 83a43b81b3
commit fa4fdad623
22 changed files with 7 additions and 1025 deletions

View file

@ -1,61 +1,10 @@
SHELL:=bash GUILE:=guile
export SHELL GUILE_FLAGS:=--no-auto-compile -L guile -C guile
.export: SHELL
QUIET:=@
default: all include .config.make
MES_DEBUG:=1 PHONY_TARGETS:= all check clean default help
CFLAGS:=--std=gnu99 -O0 -g --include libc-gcc.c .PHONY: $(PHONY_TARGETS)
HEX2_FLAGS:=--LittleEndian --Architecture 1 --BaseAddress 0x1000000
OUT:=out
SUBDIRS:=\ $(PHONY_TARGETS):
module\ $(GUILE) $(GUILE_FLAGS) -s make.scm $@
src\
scaffold\
scripts\
stage0\
tests\
tinycc\
#
include make/common.make
-include .local.make
build-scripts:
make --dry-run MES=$(OUT)/mes CC= CC32= GUILE= MES_BOOTSTRAP=1 > $(OUT)/make.sh
make --dry-run MES=$(OUT)/mes CC= CC32= GUILE= MES_BOOTSTRAP=1 | tail +$(wc -l make.sh) > $(OUT)/make-check.sh
make --dry-run MES=$(OUT)/mes CC= CC32= GUILE= MES_BOOTSTRAP=1 | tail +$(wc -l make.sh) > $(OUT)/make-install.sh
make --dry-run > $(OUT)/make-dev.sh
make --dry-run | tail +$(wc -l make.sh) > $(OUT)/make-dev-check.sh
make --dry-run | tail +$(wc -l make.sh) > $(OUT)/make-dev-install.sh
help: help-top
install: all
release: all
help:
@echo
define HELP_TOP
Usage: make [OPTION]... [TARGET]...
Targets:
all update everything
build-scripts generate build scripts
check run unit tests
clean remove all generated stuff
dist create tarball in $(TARBALL)
distclean also clean configuration
maintainer-clean also clean expensive targets [$(strip $(MAINTAINER-CLEAN))]
mescc compile cc/main.c to a.out
install install in $$(DESTDIR)$$(PREFIX) [$(DESTDIR)$(PREFIX)]
release make a release
update-hash update hash in guix.scm
endef
export HELP_TOP
help-top:
@echo "$$HELP_TOP"

View file

@ -1,7 +0,0 @@
ifneq ($(CC32),)
C_FLAGS:=-nostdinc -fno-builtin
LD_FLAGS:=-nostdlib
CROSS:=$(CC32:%gcc=%)
include make/bin.make
endif

View file

@ -1,27 +0,0 @@
ifneq ($(CC),)
O_FILES := $(C_FILES:%.c=$(OUT)/%.$(CROSS)o)
D_FILES := $(O_FILES:%o=%d)
ifneq ($(DEBUG),)
$(info TARGET=$(TARGET))
$(info C_FILES=$(C_FILES))
$(info O_FILES=$(O_FILES))
$(info D_FILES=$(D_FILES))
endif
CLEAN+=$(O_FILES) $(OUT)/$(TARGET)
DIST-CLEAN+=$(D_FILES)
INCLUDES+=mlibc/include mlibc $(OUT)/$(DIR)
$(OUT)/$(TARGET): ld:=$(CROSS)LD
$(OUT)/$(TARGET): LD:=$(CROSS)$(LD)
$(OUT)/$(TARGET): CC:=$(CROSS)$(CC)
$(OUT)/$(TARGET): LDFLAGS:=$(LDFLAGS) $(LD_FLAGS) $(LINK)
$(OUT)/$(TARGET): O_FILES:=$(O_FILES)
$(OUT)/$(TARGET): $(O_FILES)
@echo " $(ld) $(notdir $^) -> $(notdir $@)"
$(QUIET)$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@
include make/compile.make
endif

View file

@ -1,3 +0,0 @@
ifneq ($(CC),)
include make/check.make
endif

View file

@ -1,3 +0,0 @@
ifneq ($(CC32),)
include make/check.make
endif

View file

@ -1,21 +0,0 @@
ifeq ($(TEST),)
TEST:=$(TARGET)-check
$(TEST): EXT:=$(EXT)
$(TEST): EXPECT:=$(EXPECT)
$(TEST): SHELL:=$(SHELL)
$(TEST): $(OUT)/$(TARGET)
@export SHELL=$(SHELL)
ifeq ($(EXPECT),)
$< - arg1 arg2 arg3 arg4 > $(<:.$(EXT)=.stdout)
else
$<; r=$$?; [ $$r = $(EXPECT) ]
endif
$(QUIETx)if diff -bu $(TINYCC_TEST2)/$(<F:.$(EXT)=.expect) $(<:.$(EXT)=.stdout); \
then rm -f $(<:.$(EXT)=.stdout); \
else exit 1; \
fi
endif
CHECK+=$(TEST)
$(TEST): TEST:=$(TEST)
$(DIR)-check: $(TEST)
include make/reset.make

View file

@ -1,16 +0,0 @@
ifeq ($(TEST),)
TEST:=$(TARGET)-check
$(TEST): EXPECT:=$(EXPECT)
$(TEST): SHELL:=$(SHELL)
$(TEST): $(OUT)/$(TARGET)
@export SHELL=$(SHELL)
ifeq ($(EXPECT),)
$<
else
$<; r=$$?; [ $$r = $(EXPECT) ]
endif
endif
CHECK+=$(TEST)
$(TEST): TEST:=$(TEST)
$(DIR)-check: $(TEST)
include make/reset.make

View file

@ -1,17 +0,0 @@
$(OUT):
$(QUIET)mkdir -p $@
clean:
$(QUIET)rm -rf $(CLEAN)
$(QUIET)mkdir -p $(OUT)
dist-clean: clean
$(QUIET)rm -rf $(DIST-CLEAN)
distclean: dist-clean
mostly-clean: dist-clean
mostlyclean: mostly-clean
maintainer-clean: dist-clean
$(QUIET)rm -rf $(MAINTAINER-CLEAN)
maintainerclean: maintainer-clean

View file

@ -1,49 +0,0 @@
.PHONY: all check clean distclean mostlyclean maintainer-clean install
cleaning?:=$(filter clean,$(MAKECMDGOALS))
ifeq ($(cleaning?),)
.config.make: configure $(filter-out .config.make,$(MAKEFILE_LIST))
./configure
endif
CC32:=arch-gcc
-include .config.make
CLEAN:=$(OUT)
DIST-CLEAN:=.config.make
MAINTAINER-CLEAN:=
CHECK:=
all: $(OUT)
include make/install.make
define subdir
ifneq ($(DEBUG),)
$$(info SUBDIR $(1))
endif
DIR:=$(patsubst %/,%,$(dir $(1)))
DOUT:=$(OUT)/$$(DIR)
include $(1)
endef
$(foreach dir,$(SUBDIRS),$(eval $(call subdir,$(dir)/$(dir).make)))
all: $(CLEAN)
ifneq ($(DEBUG),)
$(info CLEAN=$(CLEAN))
endif
subdirs: $(CLEAN)
check: $(CLEAN) $(CHECK)
include make/clean.make
CROSS_PREFIX:=$(CC32:%gcc=%)
ifeq ($(findstring clean,$(MAKECMDGOALS)),)
ifneq ($(DEBUG),)
$(info DEPS:=$(filter %.d %.$(CROSS_PREFIX)d,$(DIST-CLEAN)))
endif
-include $(filter %.d %.$(CROSS_PREFIX)d,$(DIST-CLEAN))
endif

View file

@ -1,17 +0,0 @@
define c-compile
$(OUT)/$(1:.c=.$(CROSS)o): CROSS:=$(CROSS)
$(OUT)/$(1:.c=.$(CROSS)o): CC:=$(CC)
$(OUT)/$(1:.c=.$(CROSS)o): cc:=$(CROSS)CC
$(OUT)/$(1:.c=.$(CROSS)o): CC:=$(CROSS)$(CC)
$(OUT)/$(1:.c=.$(CROSS)o): CPPFLAGS:=$(CPPFLAGS) $(CPP_FLAGS) $(2:%=-D%) $(3:%=-I%)
$(OUT)/$(1:.c=.$(CROSS)o): CFLAGS:=$(CFLAGS) $(C_FLAGS)
$(OUT)/$(1:.c=.$(CROSS)o): COMPILE.c:=$$(CC) $$(CFLAGS) $$(CPPFLAGS) $(TARGET_ARCH) -c
$(OUT)/$(1:.c=.$(CROSS)o): $(MAKEFILE_LIST)
$(OUT)/$(1:.c=.$(CROSS)o): $(1)
@echo " $$(cc) $$(notdir $$<) -> $$(notdir $$@)"
@mkdir -p $$(dir $$@)
$$(QUIET)$$(COMPILE.c) $$(OUTPUT_OPTION) -MMD -MF $$(@:%.$(CROSS)o=%.$(CROSS)d) -MT '$$(@:.%$(CROSS)o=%.$(CROSS)d)' $$<
endef
$(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call c-compile,$(c-file),$(DEFINES),$(INCLUDES))))
include make/reset.make

View file

@ -1,33 +0,0 @@
GO_FILES:=$(SCM_FILES:%.scm=%.go)
CLEAN+=$(GO_FILES)
clean-go: GO_FILES:=$(GO_FILES)
clean-go:
@$(QUIET)rm -f $(GO_FILES)
INSTALL_SCM_FILES+=$(SCM_FILES)
INSTALL_GO_FILES+=$(GO_FILES)
INSTALL_MES_FILES+=$(MES_FILES)
GUILE_FLAGS:=\
--no-auto-compile\
-L guile\
-C guile\
#
all-go: DIR:=$(DIR)
all-go: SCM_FILES:=$(SCM_FILES)
all-go: GUILE_FLAGS:=$(GUILE_FLAGS)
all-go: $(SCM_FILES)
$(QUIET)rm -f $@
$(QUIET)cd guile && srcdir=$(srcdir) host=$(host) $(GUILE) $(GUILE_FLAGS:guile=.) -s ../build-aux/compile-all.scm $(SCM_FILES:$(DIR)/%=%)
$(GO_FILES): all-go
# these .scm files include its .mes counterpart; must add dependency to be be remade
SCM_BASES:=$(SCM_FILES:%.scm=%)
SCM_MES_FILES:=$(filter $(SCM_BASES:%=%.mes),$(MES_FILES))
$(foreach scm_mes,$(SCM_MES_FILES),$(eval $(scm_mes:%.mes=%.go): $(scm_mes)))
CHECK := $(CHECK) $(TEST)
include make/reset.make

View file

@ -1,125 +0,0 @@
.PHONY: tree-clean-p
READMES:=\
AUTHORS\
COPYING\
HACKING\
INSTALL\
NEWS\
README\
#
COMMIT:=$(shell test -d .git && (git show 2>/dev/null | head -1 | cut -d' ' -f 2) || cat .tarball-version)
GUIX-HASH:=out/guix-hash
TARBALL_DIR:=$(PACKAGE)-$(VERSION)
TARBALL:=$(OUT)/$(TARBALL_DIR).tar.gz
OPT_CLEAN:=$(OPT_CLEAN) $(TARBALL) .tarball-version
GIT_ARCHIVE_HEAD:=git archive HEAD --
GIT_LS_FILES:=git ls-files
ifeq ($(wildcard .git/HEAD),)
GIT_ARCHIVE_HEAD:=tar -cf-
GIT_LS_FILES:=find
endif
ifeq ($(GUIX),)
DATADIR:=$(PREFIX)/share/mes
DOCDIR:=$(DATADIR)/doc/mes
else
DATADIR:=$(PREFIX)/share
DOCDIR:=$(DATADIR)/doc
endif
LIBDIR:=$(PREFIX)/lib
GODIR:=$(LIBDIR)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache
GUILEDIR:=$(PREFIX)/share/guile/site/$(GUILE_EFFECTIVE_VERSION)
MODULEDIR:=$(DATADIR)/module/
.tarball-version: tree-clean-p
echo $(COMMIT) > $@
dist: $(TARBALL)
tree-clean-p:
test ! -d .git || git diff --exit-code > /dev/null
test ! -d .git || git diff --cached --exit-code > /dev/null
@echo commit:$(COMMIT)
$(TARBALL): tree-clean-p .tarball-version ChangeLog
mkdir -p $(OUT)
($(GIT_LS_FILES) --exclude=$(OUT);\
echo $^ | tr ' ' '\n' | grep -Ev 'tree-clean-p')\
| tar --transform=s,^,$(TARBALL_DIR)/,S -T- -czf $@
ChangeLog:
build-aux/gitlog-to-changelog > $@
#FIXME: INSTALL like CLEAN
INSTALL_SCM_FILES:=
INSTALL_GO_FILES:=
install: $(CLEAN) ChangeLog
mkdir -p $(DESTDIR)$(PREFIX)/bin
install $(OUT)/mes $(DESTDIR)$(PREFIX)/bin/mes
ifneq ($(MES_BOOTSTRAP),)
install $(OUT)/mes.mes $(DESTDIR)$(PREFIX)/bin/mes.mes
endif
install scripts/mescc.mes $(DESTDIR)$(PREFIX)/bin/mescc.mes
install scripts/repl.mes $(DESTDIR)$(PREFIX)/bin/repl.mes
install guile/mescc.scm $(DESTDIR)$(PREFIX)/bin/mescc.scm
mkdir -p $(DESTDIR)$(DATADIR)
$(GIT_ARCHIVE_HEAD) module\
| tar -C $(DESTDIR)$(DATADIR) -xf-
$(GIT_ARCHIVE_HEAD) guile\
| tar -C $(DESTDIR)$(DATADIR) -xf-
sed -i \
-e 's,module/,$(DATADIR)/module/,' \
-e 's,@DATADIR@,$(DATADIR)/,g' \
-e 's,@DOCDIR@,$(DOCDIR)/,g' \
-e 's,@GODIR@,$(GODIR)/,g' \
-e 's,@GUILEDIR@,$(GUILEDIR)/,g' \
-e 's,@MODULEDIR@,$(MODULEDIR),g' \
-e 's,@PREFIX@,$(PREFIX)/,g' \
-e 's,@VERSION@,$(VERSION),g' \
$(DESTDIR)$(DATADIR)/module/mes/base-0.mes \
$(DESTDIR)$(DATADIR)/module/language/c99/compiler.mes \
$(DESTDIR)$(PREFIX)/bin/mescc.mes \
$(DESTDIR)$(PREFIX)/bin/mescc.scm \
$(DESTDIR)$(PREFIX)/bin/repl.mes
mkdir -p $(DESTDIR)$(DOCDIR)
$(GIT_ARCHIVE_HEAD) $(READMES) \
| tar -C $(DESTDIR)$(DOCDIR) -xf-
$(GIT_ARCHIVE_HEAD) doc \
| tar -C $(DESTDIR)$(DOCDIR) --strip=1 -xf-
cp ChangeLog $(DESTDIR)$(DOCDIR)
mkdir -p $(DESTDIR)$(GUILEDIR)
tar -cf- -C module $(INSTALL_SCM_FILES:module/%=%)\
| tar -C $(DESTDIR)$(GUILEDIR) -xf-
mkdir -p $(DESTDIR)$(GODIR)
tar -cf- -C module $(INSTALL_GO_FILES:module/%=%)\
| tar -C $(DESTDIR)$(GODIR) -xf-
mkdir -p $(DESTDIR)$(PREFIX)/lib
$(GIT_ARCHIVE_HEAD) mlibc/include \
| tar -C $(DESTDIR)$(PREFIX)/share -xf-
cp out/mlibc/libc-mes.guile-o $(DESTDIR)$(PREFIX)/lib/libc-mes.o
release: tree-clean-p check dist
git tag v$(VERSION)
git push --tags origin master
git push origin master
$(GUIX-HASH): tree-clean-p
rm -rf out/mes && mkdir -p out && git clone . out/mes && guix hash -rx out/mes > $@
update-hash: $(GUIX-HASH) .tarball-version
@echo -n hash:
cat $^
sed -i \
-e 's,(base32 "[^"]*"),(base32 "$(shell cat $<)"),'\
-e 's,(commit "[^"]*"),(commit "$(shell cat .tarball-version)"),'\
-e 's,(version "[^g][^"]*"),(version "$(VERSION)"),'\
guix.scm
! git diff --exit-code
git commit -m 'guix hash: $(shell cat $<)' guix.scm

View file

@ -1,94 +0,0 @@
ifneq ($(GUILE),)
CROSS:=guile-
C_FILES:=mlibc/libc-mes.c $(C_FILES)
#C_FILES:=mlibc/mini-libc-mes.c $(C_FILES)
O_FILES:=$(C_FILES:%.c=$(OUT)/%.$(CROSS)o)
ifneq ($(DEBUG),)
$(info TARGET=$(TARGET))
$(info C_FILES=$(C_FILES))
$(info O_FILES=$(O_FILES))
endif
CLEAN+=$(O_FILES) $(OUT)/$(TARGET)
CLEAN+=$(OUT)/$(TARGET)
INCLUDES+=mlibc/include mlibc $(OUT)/$(DIR)
MESCC.scm:=guile/mescc.scm -g
LINK.hex2:=$(HEX2)
#ELF_HEADER:=stage0/elf32-0header.hex2
#ELF_FOOTER:=stage0/elf-0footer.hex2
ELF_HEADER:=stage0/elf32-header.hex2
ELF_FOOTER:=stage0/elf32-footer-single-main.hex2
$(OUT)/$(TARGET): ld:=$(LINK.hex2)
$(OUT)/$(TARGET): LD:=$(MESLD.scm)
$(OUT)/$(TARGET): CC:=$(MESCC.scm)
$(OUT)/$(TARGET): CFLAGS:=
$(OUT)/$(TARGET): LDFLAGS:=
$(OUT)/$(TARGET): O_FILES:=$(O_FILES)
$(OUT)/$(TARGET): $(O_FILES)
@echo " $(ld) $(notdir $(O_FILES)) -> $(notdir $@)"
$(QUIET)$(LINK.hex2) $(HEX2_FLAGS) -f $(ELF_HEADER) $(O_FILES:%=-f %) $(LOADLIBES:%=-f %) $(LDLIBS:%=-f %) -f $(ELF_FOOTER) > $@ || { rm -f $@; exit 1;}
@chmod +x $@
define mescc.scm-c-compile
$(OUT)/$(1:.c=.$(CROSS)o): CROSS:=$(CROSS)
$(OUT)/$(1:.c=.$(CROSS)o): cc:=MESCC.scm
$(OUT)/$(1:.c=.$(CROSS)o): CC:=$(MESCC.scm)
$(OUT)/$(1:.c=.$(CROSS)o): CPPFLAGS:=$(2:%=-D %) $(3:%=-I %)
$(OUT)/$(1:.c=.$(CROSS)o): COMPILE.c:=$(MESCC.scm) -c $(CPPFLAGS)
$(OUT)/$(1:.c=.$(CROSS)o): $(MAKEFILE_LIST)
$(OUT)/$(1:.c=.$(CROSS)o): $(INSTALL_GO_FILES)
$(OUT)/$(1:.c=.$(CROSS)o): $(1)
@echo " $$(cc) $$(notdir $(1)) -> $$(notdir $$@)"
@mkdir -p $$(dir $$@)
$$(QUIET)$$(COMPILE.c) $$(CPPFLAGS) $$(OUTPUT_OPTION) $(1)
endef
define mescc.scm-c-preprocess
$(OUT)/$(1:.c=.$(CROSS)E): CROSS:=$(CROSS)
$(OUT)/$(1:.c=.$(CROSS)E): cc:=MESCC.scm
$(OUT)/$(1:.c=.$(CROSS)E): CC:=$(MESCC.scm)
$(OUT)/$(1:.c=.$(CROSS)E): CPPFLAGS:=$(2:%=-D %) $(3:%=-I %)
$(OUT)/$(1:.c=.$(CROSS)E): PREPROCESS.c:=$(MESCC.scm) -E $(CPPFLAGS)
$(OUT)/$(1:.c=.$(CROSS)E): $(MAKEFILE_LIST)
$(OUT)/$(1:.c=.$(CROSS)E): $(INSTALL_GO_FILES)
$(OUT)/$(1:.c=.$(CROSS)E): $(1)
@echo " $$(cc) $$(notdir $(1)) -> $$(notdir $$@)"
@mkdir -p $$(dir $$@)
$$(QUIET)$$(PREPROCESS.c) $$(CPPFLAGS) $$(OUTPUT_OPTION) $(1)
endef
define mescc.scm-c-compile-E
$(1:.$(CROSS)E=.$(CROSS)o): CROSS:=$(CROSS)
$(1:.$(CROSS)E=.$(CROSS)o): cc:=MESCC.scm
$(1:.$(CROSS)E=.$(CROSS)o): CC:=$(MESCC.scm)
$(1:.$(CROSS)E=.$(CROSS)o): CPPFLAGS:=$(2:%=-D %) $(3:%=-I %)
$(1:.$(CROSS)E=.$(CROSS)o): COMPILE.c:=$(MESCC.scm) -c $(CPPFLAGS)
$(1:.$(CROSS)E=.$(CROSS)o): $(MAKEFILE_LIST)
$(1:.$(CROSS)E=.$(CROSS)o): $(INSTALL_GO_FILES)
$(1:.$(CROSS)E=.$(CROSS)o): $(1)
@echo " $$(cc) $$(notdir $(1)) -> $$(notdir $$@)"
@mkdir -p $$(dir $$@)
$$(QUIET)$$(COMPILE.c) $$(CPPFLAGS) $$(OUTPUT_OPTION) $(1)
endef
ifeq ($(MLIBC.scm),)
MLIBC.scm:=DONE
else
C_FILES:=$(filter-out mlibc/libc-mes.c,$(C_FILES))
C_FILES:=$(filter-out mlibc/mini-libc-mes.c,$(C_FILES))
endif
ifneq ($(MESC_DIRECT),)
$(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.scm-c-compile,$(c-file),$(DEFINES),$(INCLUDES))))
else
$(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.scm-c-preprocess,$(c-file),$(DEFINES),$(INCLUDES))))
$(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.scm-c-compile-E,$(c-file:%.c=$(OUT)/%.$(CROSS)E),$(DEFINES),$(INCLUDES))))
endif
endif
include make/reset.make

View file

@ -1,104 +0,0 @@
ifneq ($(MES),)
CROSS:=mes-
C_FILES:=mlibc/libc-mes.c $(C_FILES)
O_FILES:=$(C_FILES:%.c=$(OUT)/%.$(CROSS)o)
ifneq ($(DEBUG),)
$(info TARGET=$(TARGET))
$(info C_FILES=$(C_FILES))
$(info O_FILES=$(O_FILES))
endif
CLEAN+=$(O_FILES) $(OUT)/$(TARGET)
CLEAN+=$(OUT)/$(TARGET)
INCLUDES+=mlibc/include mlibc $(OUT)/$(DIR)
MESCC.mes:=scripts/mescc.mes -g
MESLD.mes:=scripts/mescc.mes -g
LINK.hex2:=$(HEX2)
#ELF_HEADER:=stage0/elf32-0header.hex2
#ELF_FOOTER:=stage0/elf-0footer.hex2
ELF_HEADER:=stage0/elf32-header.hex2
ELF_FOOTER:=stage0/elf32-footer-single-main.hex2
$(OUT)/$(TARGET): ld:=MESLD.mes
$(OUT)/$(TARGET): LD:=$(MESLD.mes)
$(OUT)/$(TARGET): CC:=$(MESCC.mes)
$(OUT)/$(TARGET): CFLAGS:=
$(OUT)/$(TARGET): LDFLAGS:=
$(OUT)/$(TARGET): $(MAKEFILE_LIST)
$(OUT)/$(TARGET): scripts/mes
$(OUT)/$(TARGET): O_FILES:=$(O_FILES)
$(OUT)/$(TARGET): $(O_FILES)
@echo " $(ld) $(notdir $(O_FILES)) -> $(notdir $@)"
$(QUIET)$(LINK.hex2) $(HEX2_FLAGS) -f $(ELF_HEADER) $(O_FILES:%=-f %) $(LOADLIBES:%=-f %) $(LDLIBS:%=-f %) -f $(ELF_FOOTER) > $@ || { rm -f $@; exit 1;}
@chmod +x $@
define mescc.mes-c-compile
$(OUT)/$(1:.c=.$(CROSS)o): CROSS:=$(CROSS)
$(OUT)/$(1:.c=.$(CROSS)o): cc:=MESCC.mes
$(OUT)/$(1:.c=.$(CROSS)o): CC:=$(MESCC.mes)
$(OUT)/$(1:.c=.$(CROSS)o): COMPILE.c:=$(MESCC.mes) -c
$(OUT)/$(1:.c=.$(CROSS)o): CPPFLAGS:=$(2:%=-D %) $(3:%=-I %)
$(OUT)/$(1:.c=.$(CROSS)o): COMPILE.c:=$(MESCC.mes) -c $(CPPFLAGS)
$(OUT)/$(1:.c=.$(CROSS)o): OUT:=$(OUT)
$(OUT)/$(1:.c=.$(CROSS)o): $(MAKEFILE_LIST)
$(OUT)/$(1:.c=.$(CROSS)o): $(OUT)/mes
$(OUT)/$(1:.c=.$(CROSS)o): scripts/mes
$(OUT)/$(1:.c=.$(CROSS)o): $(INSTALL_MES_FILES)
$(OUT)/$(1:.c=.$(CROSS)o): $(1)
@echo " $$(cc) $$(notdir $(1)) -> $$(notdir $$@)"
@mkdir -p $$(dir $$@)
$$(QUIET)$$(COMPILE.c) $$(OUTPUT_OPTION) $(1)
endef
define mescc.mes-c-preprocess
$(OUT)/$(1:.c=.$(CROSS)E): CROSS:=$(CROSS)
$(OUT)/$(1:.c=.$(CROSS)E): cc:=MESCC.mes
$(OUT)/$(1:.c=.$(CROSS)E): CC:=$(MESCC.mes)
$(OUT)/$(1:.c=.$(CROSS)E): CPPFLAGS:=$(2:%=-D %) $(3:%=-I %)
$(OUT)/$(1:.c=.$(CROSS)E): OUT:=$(OUT)
$(OUT)/$(1:.c=.$(CROSS)E): PREPROCESS.c:=$(MESCC.mes) -E $(CPPFLAGS)
$(OUT)/$(1:.c=.$(CROSS)E): $(MAKEFILE_LIST)
$(OUT)/$(1:.c=.$(CROSS)E): $(OUT)/mes
$(OUT)/$(1:.c=.$(CROSS)E): scripts/mes
$(OUT)/$(1:.c=.$(CROSS)E): $(INSTALL_MES_FILES)
$(OUT)/$(1:.c=.$(CROSS)E): $(1)
@echo " $$(cc) $$(notdir $(1)) -> $$(notdir $$@)"
@mkdir -p $$(dir $$@)
$$(QUIET)$$(PREPROCESS.c) $$(CPPFLAGS) $$(OUTPUT_OPTION) $(1)
endef
define mescc.mes-c-compile-E
$(1:.$(CROSS)E=.$(CROSS)o): CROSS:=$(CROSS)
$(1:.$(CROSS)E=.$(CROSS)o): cc:=MESCC.mes
$(1:.$(CROSS)E=.$(CROSS)o): CC:=$(MESCC.mes)
$(1:.$(CROSS)E=.$(CROSS)o): CPPFLAGS:=$(2:%=-D %) $(3:%=-I %)
$(1:.$(CROSS)E=.$(CROSS)o): COMPILE.c:=$(MESCC.mes) -c $(CPPFLAGS)
$(1:.$(CROSS)E=.$(CROSS)o): OUT:=$(OUT)
$(1:.$(CROSS)E=.$(CROSS)o): $(MAKEFILE_LIST)
$(1:.$(CROSS)E=.$(CROSS)o): $(OUT)/mes
$(1:.$(CROSS)E=.$(CROSS)o): scripts/mes
$(1:.$(CROSS)E=.$(CROSS)o): $(INSTALL_MES_FILES)
$(1:.$(CROSS)E=.$(CROSS)o): $(1)
@echo " $$(cc) $$(notdir $(1)) -> $$(notdir $$@)"
@mkdir -p $$(dir $$@)
$$(QUIET)$$(COMPILE.c) $$(CPPFLAGS) $$(OUTPUT_OPTION) $(1)
endef
ifeq ($(MLIBC.mes),)
MLIBC.mes:=DONE
else
C_FILES:=$(filter-out mlibc/libc-mes.c,$(C_FILES))
endif
ifneq ($(MESC_DIRECT),)
$(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.mes-c-compile,$(c-file),$(DEFINES),$(INCLUDES))))
else
$(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.mes-c-preprocess,$(c-file),$(DEFINES),$(INCLUDES))))
$(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.mes-c-compile-E,$(c-file:%.c=$(OUT)/%.$(CROSS)E),$(DEFINES),$(INCLUDES))))
endif
endif
include make/reset.make

View file

@ -1,16 +0,0 @@
C_FILES:=
C_FLAGS:=
CPP_FLAGS:=
CROSS:=
DEFINES:=
EXPECT:=
EXT:=
GO_FILES:=
INCLUDES:=
LD_FLAGS:=
MES_FILES:=
O_FILES:=
SCM_FILES:=
TARGET:=
TEST:=

View file

@ -1,21 +0,0 @@
MES_FILES:=$(shell $(GIT_LS_FILES) module/*.mes)
SCM_FILES:=$(shell $(GIT_LS_FILES) module/language/ module/nyacc/ module/mes/)
SCM_FILES:=$(filter %.scm, $(SCM_FILES))
SCM_FILES:=$(filter-out %match.scm, $(SCM_FILES))
SCM_FILES:=$(filter-out %mes/lalr.scm, $(SCM_FILES))
SCM_FILES:=$(filter-out %optargs.scm, $(SCM_FILES))
SCM_FILES:=$(filter-out %pretty-print.scm, $(SCM_FILES))
SCM_FILES:=$(filter-out %syntax.scm, $(SCM_FILES))
SCM_FILES:=$(filter-out module/mes/peg/%.scm, $(SCM_FILES))
include make/guile.make
# FIXME: https://gitlab.com/janneke/guile/commits/1.8
# Include patches here
GUILE_GIT:=../guile-1.8
GUILE_COMMIT:=ba8a7097699f69b206c9f28c546fa6da88b8656f
psyntax-import: module/mes/psyntax.ss module/mes/psyntax.pp
module/mes/psyntax.%: $(GUILE_GIT)/ice-9/psyntax.%
git --git-dir=$(GUILE_GIT)/.git --work-tree=$(GUILE_GIT) show $(GUILE_COMMIT):ice-9/$(@F > $@
MAINTAINER-CLEAN+=module/mes/psyntax.pp

View file

@ -1,159 +0,0 @@
TARGET:=m
C_FILES:=$(DIR)/m.c
DEFINES:=POSIX=1
INCLUDES:=mlibc
include make/bin.make
TARGET:=m
EXPECT:=255
include make/check-cc.make
TARGET:=hello
C_FILES:=$(DIR)/hello.c
DEFINES:=POSIX=1
INCLUDES:=mlibc
include make/bin.make
TARGET:=hello
EXPECT:=42
include make/check-cc.make
TARGET:=t
C_FILES:=$(DIR)/t.c
DEFINES:=POSIX=1
INCLUDES:=mlibc
include make/bin.make
TARGET:=t
include make/check-cc.make
TARGET:=t-tcc
C_FILES:=$(DIR)/t-tcc.c
DEFINES:=POSIX=1
INCLUDES:=mlibc
include make/bin.make
TARGET:=t-tcc
include make/check-cc.make
TARGET:=m.mlibc
C_FILES:=$(DIR)/m.c
include make/bin-mlibc.make
TARGET:=m.mlibc
EXPECT:=255
include make/check-mlibc.make
TARGET:=hello.mlibc
C_FILES:=$(DIR)/hello.c
include make/bin-mlibc.make
TARGET:=hello.mlibc
EXPECT:=42
include make/check-mlibc.make
TARGET:=micro-mes.mlibc
C_FILES:=$(DIR)/micro-mes.c
include make/bin-mlibc.make
TEST:=micro-mes.mlibc-check
$(TEST): $(OUT)/micro-mes.mlibc
$< 2 3; r=$$?; [ $$r = 3 ]
include make/check-mlibc.make
TARGET:=t.mlibc
C_FILES:=$(DIR)/t.c
include make/bin-mlibc.make
TARGET:=t.mlibc
include make/check-mlibc.make
TARGET:=t-tcc.mlibc
C_FILES:=$(DIR)/t-tcc.c
include make/bin-mlibc.make
TARGET:=t-tcc.mlibc
include make/check-mlibc.make
CROSS:=$(CC32:%gcc=%)
#$(OUT)/$(DIR)/mini-mes.$(CROSS)o: $(SNARF.MES)
$(OUT)/mini-mes: $(SNARF.MES)
TARGET:=mini-mes.mlibc
# guile/mescc.scm
TARGET:=m.guile
C_FILES:=$(DIR)/m.c
include make/mescc-guile.make
TARGET:=m.guile
EXPECT:=255
include make/check.make
TARGET:=hello.guile
C_FILES:=$(DIR)/hello.c
include make/mescc-guile.make
TARGET:=hello.guile
EXPECT:=42
include make/check.make
TARGET:=micro-mes.guile
C_FILES:=$(DIR)/micro-mes.c
include make/mescc-guile.make
TEST:=micro-mes.guile-check
$(TEST): $(OUT)/micro-mes.guile
$< 2 3; r=$$?; [ $$r = 3 ]
include make/check.make
TARGET:=t.guile
C_FILES:=$(DIR)/t.c
include make/mescc-guile.make
TARGET:=t.guile
include make/check.make
TARGET:=t-tcc.guile
C_FILES:=$(DIR)/t-tcc.c
include make/mescc-guile.make
TARGET:=t-tcc.guile
include make/check.make
# scripts/mescc.mes
ifneq ($(MES),)
TARGET:=m.mes
C_FILES:=$(DIR)/m.c
include make/mescc-mes.make
TARGET:=m.mes
EXPECT:=255
include make/check.make
ifneq ($(MES_SCAFFOLD),)
TARGET:=hello.mes
C_FILES:=$(DIR)/hello.c
include make/mescc-mes.make
TARGET:=hello.mes
EXPECT:=42
include make/check.make
TARGET:=micro-mes.mes
C_FILES:=$(DIR)/micro-mes.c
include make/mescc-mes.make
TEST:=micro-mes.mes-check
$(TEST): $(OUT)/micro-mes.mes
$< 2 3; r=$$?; [ $$r = 3 ]
include make/check.make
endif # !SCAFFOLD
TARGET:=t.mes
C_FILES:=$(DIR)/t.c
include make/mescc-mes.make
TARGET:=t.mes
include make/check.make
endif

View file

@ -1,6 +0,0 @@
ifneq ($(CC),)
CLEAN+=$(DIR)/mes
$(DIR)/mes: $(OUT)/mes
ln -sf ../$< $@
endif

View file

@ -1,70 +0,0 @@
MODULES:=\
src/gc.c\
src/lib.c\
src/math.c\
src/mes.c\
src/posix.c\
src/reader.c\
src/vector.c
#
$(OUT)/%.h $(OUT)/%.i $(OUT)/%.environment.i $(OUT)/%.symbols.i: DIR:=$(DIR)
$(OUT)/%.h $(OUT)/%.i $(OUT)/%.environment.i $(OUT)/%.symbols.i: %.c build-aux/mes-snarf.scm
@echo " SNARF $(notdir $<) -> $(notdir $@)"
@mkdir -p $(dir $@)
$(QUIET)OUT=$(dir $@) build-aux/mes-snarf.scm $<
SNARF.GCC:=$(MODULES:%.c=$(OUT)/%.h) $(MODULES:%.c=$(OUT)/%.i) $(MODULES:%.c=$(OUT)/%.environment.i)
SNARF.GCC+=$(OUT)/$(DIR)/mes.symbols.i
CLEAN+=$(SNARF.GCC)
snarf-gcc: $(SNARF.GCC)
$(OUT)/$(DIR)/mes.o: $(SNARF.GCC)
DEFINES:=FIXED_PRIMITIVES=1 MES_FULL=1 POSIX=1 VERSION='"$(VERSION)"' MODULEDIR='"$(MODULEDIR)"' PREFIX='"$(PREFIX)"'
INCLUDES:=mlibc $(OUT)/$(DIR)
TARGET:=mes
C_FILES:=$(DIR)/mes.c
include make/bin.make
$(OUT)/%.mes.h $(OUT)/%.mes.i $(OUT)/%.mes.environment.i $(OUT)/%.mes.symbols.i: DIR:=$(DIR)
$(OUT)/%.mes.h $(OUT)/%.mes.i $(OUT)/%.mes.environment.i $(OUT)/%.mes.symbols.i: %.c build-aux/mes-snarf.scm
@echo " SNARF $(notdir $<) -> $(notdir $@)"
@mkdir -p $(dir $@)
$(QUIET)OUT=$(dir $@) build-aux/mes-snarf.scm --mes $<
SNARF.MES:=$(MODULES:%.c=$(OUT)/%.mes.h) $(MODULES:%.c=$(OUT)/%.mes.i) $(MODULES:%.c=$(OUT)/%.mes.environment.i)
SNARF.MES+=$(OUT)/$(DIR)/mes.mes.symbols.i
CLEAN+=$(SNARF.MES)
snarf-mes: $(SNARF.MES)
include make/reset.make
CROSS:=$(CC32:%gcc=%)
$(OUT)/$(CROSS)%: $(OUT)/%.mlibc
@ln -sf $(<F) $@
TARGET:=mes.mlibc
$(OUT)/$(DIR)/mes.$(CROSS)o: $(SNARF.MES)
C_FILES:=$(DIR)/mes.c
DEFINES:=FIXED_PRIMITIVES=1 MES_FULL=1 VERSION='"$(VERSION)"' MODULEDIR='"$(MODULEDIR)"' PREFIX='"$(PREFIX)"'
include make/bin-mlibc.make
TARGET:=mes.guile
$(OUT)/$(DIR)/mes.guile-E: $(SNARF.MES)
$(OUT)/mes.guile: $(SNARF.MES)
C_FILES:=$(DIR)/mes.c
include make/mescc-guile.make
ifneq ($(MES_BOOTSTRAP),)
safe-MES_MAX_ARENA:=$(MES_MAX_ARENA)
MES_MAX_ARENA:=80000000
TARGET:=mes.mes
$(OUT)/$(DIR)/mes.mes-E: $(SNARF.MES)
$(OUT)/mes.mes: $(SNARF.MES)
mes.mes: $(OUT)/mes.mes
cp $< $@
C_FILES:=$(DIR)/mes.c
include make/mescc-mes.make
MES_MAX_ARENA=$(safe-MES_MAX_ARENA)
endif

View file

@ -1,37 +0,0 @@
ifneq ($(HEX2),)
CLEAN+=$(OUT)/0exit-42
$(OUT)/0exit-42: stage0/elf32-0header.hex2 stage0/elf32-body-exit-42.hex2 stage0/elf-0footer.hex2 | $(OUT)
@echo " HEX2 $(notdir $^) -> $(notdir $@)"
$(QUIET)$(HEX2) $(HEX2_FLAGS) $(^:%=-f %) > $@ || rm -f $@
chmod +x $@
TARGET:=0exit-42
EXPECT:=42
include make/check.make
CLEAN+=$(OUT)/exit-42
$(OUT)/exit-42: stage0/elf32-header.hex2 stage0/elf32-body-exit-42.hex2 stage0/elf32-footer-single-main.hex2 | $(OUT)
@echo " HEX2 $(notdir $^) -> $(notdir $@)"
$(QUIET)$(HEX2) $(HEX2_FLAGS) $(^:%=-f %) > $@ || rm -f $@
chmod +x $@
TARGET:=exit-42
EXPECT:=42
include make/check.make
CLEAN+=$(OUT)/exit-42.guile
$(OUT)/exit-42.guile: stage0/elf32-header.hex2 $(OUT)/mlibc/mini-libc-mes.hex2 $(OUT)/stage0/exit-42.hex2 stage0/elf32-footer-single-main.hex2 | $(OUT)
@echo " HEX2 $(notdir $^) -> $(notdir $@)"
$(QUIET)$(HEX2) $(HEX2_FLAGS) $(^:%=-f %) > $@ || rm -f $@
chmod +x $@
MESCC.scm:=guile/mescc.scm
$(OUT)/%.hex2: %.c | all-go
@echo " MESCC.scm $(notdir $<) -> $(notdir $@)"
@mkdir -p $(dir $@)
$(QUIET) $(MESCC.scm) -c -o $@ $^
TARGET:=exit-42.guile
EXPECT:=42
include make/check.make
endif

View file

@ -1,38 +0,0 @@
TESTS:=\
tests/read.test\
tests/base.test\
tests/closure.test\
tests/quasiquote.test\
tests/let.test\
tests/scm.test\
tests/display.test\
tests/cwv.test\
tests/math.test\
tests/vector.test\
tests/srfi-1.test\
tests/srfi-13.test\
tests/srfi-14.test\
tests/optargs.test\
tests/fluids.test\
tests/catch.test\
tests/psyntax.test\
tests/pmatch.test\
tests/let-syntax.test\
tests/guile.test\
tests/record.test\
tests/match.test\
tests/peg.test\
#
MES-0:=guile/mes-0.scm
TEST:=guile-check
$(TEST):
set -e; for i in $(TESTS); do\
$(GUILE) -s <(cat $(MES-0) module/mes/test.mes $$i);\
done
include make/check.make
TEST:=mes-check
$(TEST): $(OUT)/mes
set -e; for i in $(TESTS); do MES_MAX_ARENA=20000000 ./$$i; done
include make/check.make

View file

@ -1,104 +0,0 @@
TINYCC_ROOT:=../tinycc
TINYCC_TEST2:=$(TINYCC_ROOT)/tests/tests2
TINYCC_TESTS:=\
00_assignment\
01_comment\
02_printf\
03_struct\
04_for\
05_array\
06_case\
07_function\
08_while\
09_do_while\
10_pointer\
11_precedence\
12_hashdefine\
13_integer_literals\
14_if\
15_recursion\
16_nesting\
17_enum\
18_include\
19_pointer_arithmetic\
20_pointer_comparison\
21_char_array\
25_quicksort\
29_array_address\
33_ternary_op\
35_sizeof\
41_hashif\
43_void_param\
44_scoped_declarations\
47_switch_return\
48_nested_break\
54_goto\
#
TINYCC_NYACC:=\
26_character_constants\
#
TINYCC_FLOAT:=\
22_floating_point\
23_type_coercion\
24_math_library\
27_sizeof\
#
# Does not compile/run with GCC
TINYCC_GCC:=\
30_hanoi\
34_array_assignment\
#
TINYCC_REST:=\
28_strings\
31_args\
32_led\
36_array_initialisers\
37_sprintf\
38_multiple_array_index\
39_typedef\
40_stdio\
42_function_pointer\
45_empty_for\
46_grep\
49_bracket_evaluation\
50_logical_second_arg\
51_static\
52_unnamed_enum\
55_lshift_type\
#
define tinycc-test
ifneq ($(CC32),)
EXT:=mlibc
TARGET:=$(1).mlibc
C_FILES:=$$(TINYCC_TEST2)/$(1).c
INCLUDES:=$$(TINYCC_TEST2)
include make/bin-mlibc.make
EXT:=mlibc
TARGET:=$(1).mlibc
include make/check-tinycc.make
endif
EXT:=guile
TARGET:=$(1).guile
C_FILES:=$$(TINYCC_TEST2)/$(1).c
INCLUDES:=$$(TINYCC_TEST2)
include make/mescc-guile.make
EXT:=guile
TARGET:=$(1).guile
include make/check-tinycc.make
endef
ifeq ($(wildcard $(TINYCC_TEST2)/00_assignment.c),$(TINYCC_TEST2)/00_assignment.c)
$(foreach t,$(TINYCC_TESTS),$(eval $(call tinycc-test,$(t))))
else
tinycc-check:
@echo skipping tinycc tests: $(TINYCC_TEST2)/00_assignment.c not available
endif