build: restore out-of-tree support

This commit is contained in:
grischka 2016-10-01 21:06:53 +02:00
parent 0a624782df
commit afdbc5b815
6 changed files with 58 additions and 48 deletions

View File

@ -4,7 +4,8 @@
TOP ?= .
include $(TOP)/config.mak
VPATH = $(TOP)
VPATH = $(TOPSRC)
CFLAGS += -I$(TOP)
ifeq (-$(findstring gcc,$(CC))-,-gcc-)
ifeq (-$(GCC_MAJOR)-$(findstring $(GCC_MINOR),56789)-,-4--)
@ -206,7 +207,7 @@ libtcc.dll : $(LIBTCC_OBJ) tiny_impdef$(EXESUF)
libtcc.dll : NATIVE_DEFINES += -DLIBTCC_AS_DLL
# windows : utilities
tiny_%$(EXESUF): $(SRCTOP)/win32/tools/tiny_%.c
tiny_%$(EXESUF): $(TOPSRC)/win32/tools/tiny_%.c
$(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) $(NATIVE_DEFINES)
ifneq ($(LIBTCC1),)
@ -246,21 +247,21 @@ install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
ifneq ($(LIBTCC1),)
$(INSTALL) -m644 $(LIBTCC1) "$(tccdir)"
endif
$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) tcclib.h "$(tccdir)/include"
$(INSTALL) -m644 $(addprefix $(TOPSRC)/include/,$(TCC_INCLUDES)) $(TOPSRC)/tcclib.h "$(tccdir)/include"
mkdir -p "$(libdir)"
$(INSTALL) -m644 $(LIBTCC) "$(libdir)"
mkdir -p "$(includedir)"
$(INSTALL) -m644 libtcc.h "$(includedir)"
$(INSTALL) -m644 $(TOPSRC)/libtcc.h "$(includedir)"
mkdir -p "$(docdir)"
-$(INSTALL) -m644 tcc-doc.html "$(docdir)"
ifdef CONFIG_CROSS
mkdir -p "$(tccdir)/win32/lib/32"
mkdir -p "$(tccdir)/win32/lib/64"
$(INSTALL) -m644 win32/lib/*.def "$(tccdir)/win32/lib"
$(INSTALL) -m644 $(TOPSRC)/win32/lib/*.def "$(tccdir)/win32/lib"
-$(INSTALL) -m644 lib/i386-win32/libtcc1.a "$(tccdir)/win32/lib/32"
-$(INSTALL) -m644 lib/x86_64-win32/libtcc1.a "$(tccdir)/win32/lib/64"
cp -r win32/include/. "$(tccdir)/win32/include"
cp -r "$(tccdir)/include" "$(tccdir)/win32"
cp -r $(TOPSRC)/include/. "$(tccdir)/win32/include"
cp -r $(TOPSRC)/win32/include/. "$(tccdir)/win32/include"
endif
uninstall:
@ -282,13 +283,13 @@ install: $(PROGS) $(TCCLIBS) $(TCCDOCS)
mkdir -p "$(tccdir)/doc"
mkdir -p "$(tccdir)/libtcc"
$(INSTALLBIN) -m755 $(PROGS) $(LIBTCC) "$(tccdir)"
$(INSTALL) -m644 libtcc1.a win32/lib/*.def "$(tccdir)/lib"
cp -r win32/include/. "$(tccdir)/include"
cp -r win32/examples/. "$(tccdir)/examples"
cp tests/libtcc_test.c "$(tccdir)/examples"
$(INSTALL) -m644 $(addprefix include/,$(TCC_INCLUDES)) tcclib.h "$(tccdir)/include"
$(INSTALL) -m644 tcc-doc.html win32/tcc-win32.txt "$(tccdir)/doc"
$(INSTALL) -m644 libtcc.h libtcc.def "$(tccdir)/libtcc"
$(INSTALL) -m644 libtcc1.a $(TOPSRC)/win32/lib/*.def "$(tccdir)/lib"
cp -r $(TOPSRC)/win32/include/. "$(tccdir)/include"
cp -r $(TOPSRC)/win32/examples/. "$(tccdir)/examples"
cp $(TOPSRC)/tests/libtcc_test.c "$(tccdir)/examples"
$(INSTALL) -m644 $(addprefix $(TOPSRC)/include/,$(TCC_INCLUDES)) $(TOPSRC)/tcclib.h "$(tccdir)/include"
$(INSTALL) -m644 tcc-doc.html $(TOPSRC)/win32/tcc-win32.txt "$(tccdir)/doc"
$(INSTALL) -m644 $(TOPSRC)/libtcc.h libtcc.def "$(tccdir)/libtcc"
ifdef CONFIG_CROSS
mkdir -p "$(tccdir)/lib/32"
mkdir -p "$(tccdir)/lib/64"

12
configure vendored
View File

@ -519,11 +519,11 @@ echo "@set VERSION $version" > config.texi
if test "$source_path_used" = "yes" ; then
case $source_path in
/*) echo "SRCTOP=$source_path";;
*) echo "SRCTOP=\$(TOP)/$source_path";;
/*) echo "TOPSRC=$source_path";;
*) echo "TOPSRC=\$(TOP)/$source_path";;
esac >>config.mak
else
echo 'SRCTOP=$(TOP)' >>config.mak
echo 'TOPSRC=$(TOP)' >>config.mak
fi
diff $TMPH config.h >/dev/null 2>&1
@ -553,7 +553,11 @@ fn_makelink()
esac
;;
esac
ln -sfn $tgt $2
if test "$mingw32" = "yes" ; then
cmd //c mklink `echo "$2 $tgt" | sed 's,/,\\\\,g'`
else
ln -sfn $tgt $2
fi
}
if test "$source_path_used" = "yes" ; then

View File

@ -4,7 +4,7 @@
TOP = ..
include $(TOP)/Makefile
VPATH = $(TOP)/lib $(TOP)/win32/lib
VPATH = $(TOPSRC)/lib $(TOPSRC)/win32/lib
ifndef TARGET
# we're building the native libtcc1.a
@ -51,31 +51,31 @@ PICFLAGS = -fPIC
ifeq "$(TARGET)" "i386-win32"
OBJ = $(addprefix $(DIR)/,$(WIN32_O))
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
XAR = $(DIR)/tiny_libmaker$(EXESUF)
XFLAGS = $(TGT)
else ifeq "$(TARGET)" "x86_64-win32"
OBJ = $(addprefix $(DIR)/,$(WIN64_O))
TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
XCC = $(TCC) -B$(TOP)/win32 -I$(TOP)/include
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
XAR = $(DIR)/tiny_libmaker$(EXESUF)
XFLAGS = $(TGT)
else ifeq "$(TARGET)" "i386"
OBJ = $(addprefix $(DIR)/,$(I386_O))
TGT = -DTCC_TARGET_I386
XCC ?= $(TCC) -B$(TOP)
XCC ?= $(TCC) -B$(TOPSRC)
else ifeq "$(TARGET)" "x86_64"
OBJ = $(addprefix $(DIR)/,$(X86_64_O))
TGT = -DTCC_TARGET_X86_64
XCC ?= $(TCC) -B$(TOP)
XCC ?= $(TCC) -B$(TOPSRC)
else ifeq "$(TARGET)" "arm"
OBJ = $(addprefix $(DIR)/,$(ARM_O))
TGT = -DTCC_TARGET_ARM
XCC ?= $(TCC) -B$(TOP)
XCC ?= $(TCC) -B$(TOPSRC)
else ifeq "$(TARGET)" "arm64"
OBJ = $(addprefix $(DIR)/,$(ARM64_O))
TGT = -DTCC_TARGET_ARM64
XCC ?= $(TCC) -B$(top_srcdir)
XCC ?= $(TCC) -B$(TOPSRC)
else
$(error libtcc1.a not supported on target '$(TARGET)')
endif
@ -99,7 +99,7 @@ $(DIR)/%.o : %.c
$(DIR)/%.o : %.S
$(XCC) -c $< -o $@ $(XFLAGS)
# windows : utilities
$(DIR)/tiny_%$(EXESUF) : $(TOP)/win32/tools/tiny_%.c
$(DIR)/tiny_%$(EXESUF) : $(TOPSRC)/win32/tools/tiny_%.c
$(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) $(TGT)
$(OBJ) $(XAR) : $(DIR)/exists

View File

@ -4,8 +4,8 @@
TOP = ..
include $(TOP)/Makefile
VPATH = $(TOP)/tests $(TOP)
CFLAGS = -I$(TOP)
VPATH = $(TOPSRC)/tests $(TOPSRC) $(TOP)
CFLAGS = -I$(TOPSRC) -I$(TOP)
# what tests to run
TESTS = \
@ -42,14 +42,14 @@ ifeq ($(CONFIG_arm_eabi),yes)
endif
# run local version of tcc with local libraries and includes
TCCFLAGS = -B$(TOP) -I$(TOP)
TCCFLAGS = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP)
ifdef CONFIG_WIN32
TCCFLAGS = -B$(TOP)/win32 -I$(TOP)/include -I$(TOP) -L$(TOP)
TCCFLAGS = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
PATH := $(CURDIR)/$(TOP):$(PATH) # for libtcc_test to find libtcc.dll
endif
TCC = $(TOP)/tcc $(TCCFLAGS)
RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOP)/tcc.c $(TCCFLAGS)
RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(TOPSRC)/tcc.c $(TCCFLAGS)
ifeq ($(TARGETOS),Darwin)
CFLAGS += -Wl,-flat_namespace,-undefined,warning
@ -154,9 +154,9 @@ btest: boundtest.c
speedtest: ex2 ex3
@echo ------------ $@ ------------
time ./ex2 1238 2 3 4 10 13 4
time $(TCC) -run $(TOP)/examples/ex2.c 1238 2 3 4 10 13 4
time $(TCC) -run $(TOPSRC)/examples/ex2.c 1238 2 3 4 10 13 4
time ./ex3 35
time $(TCC) -run $(TOP)/examples/ex3.c 35
time $(TCC) -run $(TOPSRC)/examples/ex3.c 35
weaktest: tcctest.c test.ref
$(TCC) -c $< -o weaktest.tcc.o
@ -165,7 +165,7 @@ weaktest: tcctest.c test.ref
objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt
diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK"
ex%: $(TOP)/examples/ex%.c
ex%: $(TOPSRC)/examples/ex%.c
$(CC) -o $@ $< $(CFLAGS)
# tiny assembler testing

View File

@ -2,8 +2,13 @@
# credits: 01..13.c from the pcc cpp-tests suite
#
TOP = ../..
include $(TOP)/config.mak
SRC = $(TOPSRC)/tests/pp
VPATH = $(SRC)
TCC = ../../tcc
files = $(patsubst %.$1,%.test,$(wildcard *.$1))
files = $(patsubst %.$1,%.test,$(notdir $(wildcard $(SRC)/*.$1)))
TESTS = $(call files,c) $(call files,S)
all test : $(sort $(TESTS))
@ -13,13 +18,13 @@ DIFF_OPTS = -Nu -b -B -I "^\#"
%.test: %.c %.expect
@echo PPTest $* ...
-@$(TCC) -E -P $< >$*.output 2>&1 ; \
diff $(DIFF_OPTS) $*.expect $*.output \
diff $(DIFF_OPTS) $(SRC)/$*.expect $*.output \
&& rm -f $*.output
%.test: %.S %.expect
@echo PPTest $* ...
-@$(TCC) -E -P $< >$*.output 2>&1 ; \
diff $(DIFF_OPTS) $*.expect $*.output \
diff $(DIFF_OPTS) $(SRC)/$*.expect $*.output \
&& rm -f $*.output
# automatically generate .expect files with gcc:

View File

@ -1,14 +1,16 @@
TOP = ../..
include $(TOP)/Makefile
include $(TOP)/config.mak
SRC = $(TOPSRC)/tests/tests2
VPATH = $(SRC)
# run local version of tcc with local libraries and includes
TCCFLAGS = -B$(TOP) -I$(TOP)
TCCFLAGS = -B$(TOP) -I$(TOPSRC)/include
ifdef CONFIG_WIN32
TCCFLAGS = -B$(TOP)/win32 -I$(TOP)/include -I$(TOP) -L$(TOP)
TCCFLAGS = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -L$(TOP)
endif
TCC = $(TOP)/tcc $(TCCFLAGS)
TESTS = $(patsubst %.c,%.test,$(sort $(wildcard *.c)))
TESTS = $(patsubst %.c,%.test,$(sort $(notdir $(wildcard $(SRC)/*.c))))
# 34_array_assignment.test -- array assignment is not in C standard
SKIP = 34_array_assignment.test
@ -34,15 +36,16 @@ endif
# Some tests might need arguments
ARGS =
31_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' 46_grep.c
46_grep.test : ARGS = '[^* ]*[:a:d: ]+\:\*-/: $$' $(SRC)/46_grep.c
# Some tests might need different flags
76_dollars_in_identifiers.test : TCCFLAGS += -fdollars-in-identifiers
# Filter source directory in warnings/errors (out-of-tree builds)
FILTER = 2>&1 | sed 's,$(SRC)/,,g'
# Filter some always-warning
FILTER =
ifeq (-$(findstring arm,$(ARCH))-,-arm-)
FILTER = 2>&1 | grep -v 'warning: soft float ABI currently not supported'
FILTER += 2>&1 | grep -v 'warning: soft float ABI currently not supported'
endif
all test: $(filter-out $(SKIP),$(TESTS))
@ -51,10 +54,7 @@ all test: $(filter-out $(SKIP),$(TESTS))
@echo Test: $*...
# test -run
@$(TCC) -run $< $(ARGS) $(FILTER) >$*.output 2>&1 || true
@diff -Nbu $*.expect $*.output && rm -f $*.output
# test exe (disabled for speed)
# @($(TCC) $(FLAGS) $< -o $*.exe && ./$*.exe $(ARGS)) $(FiLTER) >$*.output2 2>&1 ; \
# diff -Nbu $*.expect $*.output2 && rm -f $*.output2 $*.exe
@diff -Nbu $(SRC)/$*.expect $*.output && rm -f $*.output
# automatically generate .expect files with gcc:
%.expect :