From 3a240221f016bceb4514faabd9111491cae99f00 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 28 May 2017 18:32:53 +0200 Subject: [PATCH] build: Skip gcc, mlibc, guile or mes builds using CC=, CC32=, GUILE= or MES=. * GNUmakefile (build-scripts): New target (HELP_TOP): Mention it. * configure (main): Write GUILE_FOR_BUILD. * make/bin-mlibc.make: Skip if CC32 is not set. * make/bin.make: Skip if CC is not set. * make/install.make (install): Only install $(OUT)/mes.mes if MES_BOOTSTRAP is set. * make/mescc-guile.make: Skip if GUILE is not set. * make/mescc-mes.make: Skip if MES is not set. * HACKING: write something about --- GNUmakefile | 10 ++++++++++ HACKING | 34 ++++++++++++++++++++++++++++++++++ configure | 1 + make/bin-mlibc.make | 2 ++ make/bin.make | 2 ++ make/install.make | 2 +- make/mescc-guile.make | 2 ++ make/mescc-mes.make | 2 ++ scaffold/scaffold.make | 4 ++-- src/src.make | 3 +-- 10 files changed, 57 insertions(+), 5 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index e8c18f9a..5d49d1f7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -21,6 +21,15 @@ SUBDIRS:=\ 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 @@ -34,6 +43,7 @@ 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) diff --git a/HACKING b/HACKING index c4c971ff..3038bfb7 100644 --- a/HACKING +++ b/HACKING @@ -3,6 +3,40 @@ * SETUP guix environment -l guix.scm #64 bit + 32bit guix environment --system=i686-linux -l guix.scm #32 bit only +* BUILD +There are two major modes to build Mes: true bootstrap and +development. + +** DEVELOPMENT BUILD +To help development we assume ./configure sets these variables for make + + CC -- gcc + CC32 -- i686-unknown-linux-gnu-gcc (or on x86, also gcc) + GUILE -- guile + MES -- unset + +Mes is supposed to serve as a full equivalent for GUILE, however mes is much, much +slower than guile. That's why we usually don't use mes during development. + +gcc is used to verify the sanity of our C sources. + +i686-unknown-linux-gnu-gcc is used to compare hex/assembly, to test +the gcc variant of mlbic: libc/libc-gcc.c and steal ideas. + +guile is used to develop mescc, the C compiler in Scheme that during +bootstrapping will be executed by mes. + +** BOOTSTRAP BUILD +In bootstrap mode, we don't have gcc (CC), we don't have pa 32 bit gcc +(CC32), we have no guile (GUILE)...but we should have a bootstrap mes +(MES). FIXME. + +mes is built from src/*.c and some out/src/*.h files that are snarfed from +src/*.c by build-aux/mes-snarf.scm. + +Also, during bootstrap we don't have make. Running `make build-scripts' +generates several recipies of sh build scripts in out/. + * ROADMAP ** TODO *** release 0.x, unsorted diff --git a/configure b/configure index 6b7cc98b..bbb14ec5 100755 --- a/configure +++ b/configure @@ -237,6 +237,7 @@ Usage: ./configure [OPTION]... (stdout "CC:=~a\n" CC) (stdout "CC32:=~a\n" CC32) (stdout "GUILE:=~a\n" GUILE) + (stdout "GUILE_FOR_BUILD:=~a\n" GUILE) (stdout "GUILE_EFFECTIVE_VERSION:=~a\n" GUILE_EFFECTIVE_VERSION) (stdout "GUIX_P:=~a\n" (if guix? guix? "")) (stdout "PACKAGE:=~a\n" PACKAGE) diff --git a/make/bin-mlibc.make b/make/bin-mlibc.make index df30bc20..e898a57c 100644 --- a/make/bin-mlibc.make +++ b/make/bin-mlibc.make @@ -1,5 +1,7 @@ +ifneq ($(CC32),) C_FLAGS:=-nostdinc -fno-builtin LD_FLAGS:=-nostdlib CROSS:=$(CC32:%gcc=%) include make/bin.make +endif diff --git a/make/bin.make b/make/bin.make index 42196b3b..c57bd4bc 100644 --- a/make/bin.make +++ b/make/bin.make @@ -1,3 +1,4 @@ +ifneq ($(CC),) O_FILES := $(C_FILES:%.c=$(OUT)/%.$(CROSS)o) D_FILES := $(O_FILES:%o=%d) @@ -23,3 +24,4 @@ $(OUT)/$(TARGET): $(O_FILES) $(QUIET)$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@ include make/compile.make +endif diff --git a/make/install.make b/make/install.make index 65c64cab..17535db3 100644 --- a/make/install.make +++ b/make/install.make @@ -62,7 +62,7 @@ INSTALL_GO_FILES:= install: $(CLEAN) ChangeLog mkdir -p $(DESTDIR)$(PREFIX)/bin install $(OUT)/mes $(DESTDIR)$(PREFIX)/bin/mes -ifeq (0,1) # No bootstrap mes.mes ATM +ifneq ($(MES_BOOTSTRAP),) install $(OUT)/mes.mes $(DESTDIR)$(PREFIX)/bin/mes.mes endif install scripts/mescc.mes $(DESTDIR)$(PREFIX)/bin/mescc.mes diff --git a/make/mescc-guile.make b/make/mescc-guile.make index fb46365c..f89e1601 100644 --- a/make/mescc-guile.make +++ b/make/mescc-guile.make @@ -1,3 +1,4 @@ +ifneq ($(GUILE),) CROSS:=guile- C_FILES:=libc/libc-mes.c $(C_FILES) #C_FILES:=libc/mini-libc-mes.c $(C_FILES) @@ -83,4 +84,5 @@ $(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.scm-c-pre $(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 diff --git a/make/mescc-mes.make b/make/mescc-mes.make index 06022400..b6f49ac8 100644 --- a/make/mescc-mes.make +++ b/make/mescc-mes.make @@ -1,3 +1,4 @@ +ifneq ($(MES),) CROSS:=mes- C_FILES:=libc/libc-mes.c $(C_FILES) O_FILES:=$(C_FILES:%.c=$(OUT)/%.$(CROSS)o) @@ -93,4 +94,5 @@ $(foreach c-file,$(strip $(filter %.c,$(C_FILES))),$(eval $(call mescc.mes-c-pre $(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 diff --git a/scaffold/scaffold.make b/scaffold/scaffold.make index fbc215d7..6939d4c3 100644 --- a/scaffold/scaffold.make +++ b/scaffold/scaffold.make @@ -94,7 +94,7 @@ TARGET:=t.guile include make/check.make # scripts/mescc.mes -ifeq ($(MES_SKIP_MES),) +ifneq ($(MES),) TARGET:=m.mes C_FILES:=$(DIR)/m.c include make/mescc-mes.make @@ -103,7 +103,7 @@ TARGET:=m.mes EXPECT:=255 include make/check.make -ifneq ($(SCAFFOLD),) +ifneq ($(MES_SCAFFOLD),) TARGET:=hello.mes C_FILES:=$(DIR)/hello.c include make/mescc-mes.make diff --git a/src/src.make b/src/src.make index 33743ff5..0cf248ea 100644 --- a/src/src.make +++ b/src/src.make @@ -40,7 +40,6 @@ snarf-mes: $(SNARF.MES) include make/reset.make -# TARGET:=$(CROSS)mes CROSS:=$(CC32:%gcc=%) $(OUT)/$(CROSS)%: $(OUT)/%.mlibc @ln -sf $(