makefile: unify cross with native builds

supports building cross compilers on the fly without need
for configure --enable-cross

   $ make cross          # all compilers
   $ make cross-TARGET   # only TARGET-compiler & its libtcc1.a

with TARGET one from
   i386 x86_64 i386-win32 x86_64-win32 arm arm64 arm-wince c67

Type 'make help' for more information
This commit is contained in:
grischka
2017-02-25 12:49:47 +01:00
parent 669f61117d
commit bb93064d78
10 changed files with 334 additions and 309 deletions

View File

@ -17,6 +17,7 @@ TESTS = \
dlltest \
abitest \
vla_test-run \
cross-test \
tests2-dir \
pp-dir
@ -45,16 +46,13 @@ endif
ifeq (,$(filter i386 x86_64,$(ARCH)))
TESTS := $(filter-out dlltest,$(TESTS))
endif
# run local version of tcc with local libraries and includes
TCCFLAGS = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP)
ifdef CONFIG_WIN32
TCCFLAGS = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
PATH := $(CURDIR)/$(TOP):$(PATH) # for libtcc_test to find libtcc.dll
ifndef CONFIG_CROSS
TESTS := $(filter-out cross-%,$(TESTS))
endif
TCC = $(TOP)/tcc $(TCCFLAGS)
RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS)
ifdef CONFIG_WIN32
PATH := $(CURDIR)/$(TOP);$(PATH) # for libtcc_test to find libtcc.dll
endif
ifeq ($(TARGETOS),Darwin)
CFLAGS += -Wl,-flat_namespace,-undefined,warning
@ -62,6 +60,8 @@ ifeq ($(TARGETOS),Darwin)
export MACOSX_DEPLOYMENT_TARGET:=10.2
endif
RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS)
DISAS = objdump -d
all test : clean-s $(TESTS)
@ -236,6 +236,16 @@ vla_test-run: vla_test$(EXESUF)
@echo ------------ $@ ------------
./vla_test$(EXESUF)
cross-test :
@echo ------------ $@ ------------
$(TOP)/i386-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
$(TOP)/x86_64-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
$(TOP)/arm-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
$(TOP)/c67-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
$(TOP)/i386-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
$(TOP)/x86_64-win32-tcc$(EXESUF) $(TCCFLAGS-win) $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
$(TOP)/arm-wince-tcc$(EXESUF) $(TCCFLAGS-win) -c $(TOPSRC)/win32/examples/hello_win.c && echo "ok"
# targets for development
%.bin: %.c tcc
$(TCC) -g -o $@ $<

View File

@ -3,11 +3,10 @@
#
TOP = ../..
include $(TOP)/config.mak
include $(TOP)/Makefile
SRC = $(TOPSRC)/tests/pp
VPATH = $(SRC)
TCC = ../../tcc
files = $(patsubst %.$1,%.test,$(notdir $(wildcard $(SRC)/*.$1)))
TESTS = $(call files,c) $(call files,S)

View File

@ -1,15 +1,8 @@
TOP = ../..
include $(TOP)/config.mak
include $(TOP)/Makefile
SRC = $(TOPSRC)/tests/tests2
VPATH = $(SRC)
# run local version of tcc with local libraries and includes
TCCFLAGS = -B$(TOP) -I$(TOPSRC)/include
ifdef CONFIG_WIN32
TCCFLAGS = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -L$(TOP)
endif
TCC = $(TOP)/tcc $(TCCFLAGS)
TESTS = $(patsubst %.c,%.test,$(sort $(notdir $(wildcard $(SRC)/*.c))))
# 34_array_assignment.test -- array assignment is not in C standard