@@ -16,9 +16,6 @@ CFLAGS := -O -g \
1616
1717BUILD_SESSION := .session.mk
1818
19- include mk/common.mk
20- include mk/arm.mk
21- include mk/riscv.mk
2219-include $(BUILD_SESSION )
2320
2421STAGE0 := shecc
@@ -28,6 +25,7 @@ STAGE2 := shecc-stage2.elf
2825OUT ?= out
2926ARCHS = arm riscv
3027ARCH ?= $(firstword $(ARCHS ) )
28+ HOST_ARCH = $(shell arch 2>/dev/null)
3129SRCDIR := $(shell find src -type d)
3230LIBDIR := $(shell find lib -type d)
3331
@@ -43,17 +41,15 @@ all: config bootstrap
4341ifeq (,$(filter $(ARCH ) ,$(ARCHS ) ) )
4442$(error Support ARM and RISC-V only. Select the target with "ARCH=arm" or "ARCH=riscv")
4543endif
46-
47- ifneq ("$(wildcard $(PWD ) /config) ","")
48- TARGET_EXEC := $($(shell head -1 config | sed 's/.* : \([^ ]* \) .*/\1/') _EXEC)
49- endif
50- export TARGET_EXEC
44+ include mk/$(ARCH ) .mk
45+ include mk/common.mk
5146
5247config :
5348 $(Q ) ln -s $(PWD ) /$(SRCDIR ) /$(ARCH ) -codegen.c $(SRCDIR ) /codegen.c
54- $(call $( ARCH ) -specific-defs ) > $@
49+ $(Q )$( PRINTF ) $( ARCH_DEFS ) > $@
5550 $(VECHO ) " Target machine code switch to %s\n" $(ARCH )
5651 $(Q )$(MAKE ) $(BUILD_SESSION ) --silent
52+ $(Q )$(CONFIG_CHECK_CMD )
5753
5854$(OUT ) /tests/% .elf : tests/% .c $(OUT ) /$(STAGE0 )
5955 $(VECHO ) " SHECC\t$@ \n"
@@ -109,6 +105,7 @@ $(OUT)/$(STAGE0): $(OUT)/libc.inc $(OBJS)
109105 $(Q )$(CC ) $(OBJS ) -o $@
110106
111107$(OUT ) /$(STAGE1 ) : $(OUT ) /$(STAGE0 )
108+ $(Q )$(STAGE1_CHECK_CMD )
112109 $(VECHO ) " SHECC\t$@ \n"
113110 $(Q )$(OUT ) /$(STAGE0 ) --dump-ir -o $@ $(SRCDIR ) /main.c > $(OUT ) /shecc-stage1.log
114111 $(Q ) chmod a+x $@
0 commit comments