Various Makefile fixes for cross-compilation

- Build libtcc1 for cross-compiler on arm (arm to X cross compilers)
- Install libtcc1 and includes for arm to i386 cross compiler
- Add basic check of cross-compilers (compile ex1.c)
master
Thomas Preud'homme 2014-01-09 17:15:08 +08:00
parent da0601e490
commit 767410b875
2 changed files with 19 additions and 5 deletions

View File

@ -135,6 +135,7 @@ else ifeq ($(ARCH),arm)
NATIVE_FILES=$(ARM_FILES)
PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(C67_CROSS)
LIBTCC1=libtcc1.a
LIBTCC1_CROSS=lib/i386-win32/libtcc1.a lib/x86_64-win32/libtcc1.a lib/i386/libtcc1.a
endif
PROGS_CROSS_LINK=$(foreach PROG_CROSS,$(PROGS_CROSS),$($(PROG_CROSS)_LINK))
@ -278,7 +279,7 @@ endif
ifdef CONFIG_CROSS
mkdir -p "$(tccdir)/win32/lib/32"
mkdir -p "$(tccdir)/win32/lib/64"
ifeq ($(ARCH),x86-64)
ifneq ($(ARCH),i386)
mkdir -p "$(tccdir)/i386"
$(INSTALL) -m644 lib/i386/libtcc1.a "$(tccdir)/i386"
cp -r "$(tccdir)/include" "$(tccdir)/i386"
@ -287,7 +288,7 @@ endif
$(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 $(top_srcdir)/win32/include/. "$(tccdir)/win32/include"
cp -r $(top_srcdir)/include/. "$(tccdir)/win32/include"
cp -r "$(tccdir)/include" "$(tccdir)/win32"
endif
uninstall:
@ -300,7 +301,7 @@ uninstall:
rm -fv "$(libdir)/libtcc.so*"
rm -rf "$(tccdir)/win32"
-rmdir $(tccdir)/include
ifeq ($(ARCH),x86-64)
ifneq ($(ARCH),i386)
rm -rf "$(tccdir)/i386"
endif
else
@ -346,7 +347,7 @@ tcc-doc.info: tcc-doc.texi
export LIBTCC1
%est:
$(MAKE) -C tests $@
$(MAKE) -C tests $@ "PROGS_CROSS=$(PROGS_CROSS)"
clean:
rm -vf $(PROGS) tcc_p$(EXESUF) tcc.pod *~ *.o *.a *.so* *.out *.exe libtcc_test$(EXESUF)

View File

@ -16,6 +16,9 @@ TESTS = \
abitest \
vla_test-run \
moretests
ifdef CONFIG_CROSS
TESTS += hello-cross
endif
# test4 -- problem with -static
# asmtest -- minor differences with gcc
@ -50,8 +53,9 @@ endif
# run local version of tcc with local libraries and includes
TCCFLAGS = -B$(TOP) -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include
ifdef CONFIG_WIN32
TCCFLAGS = -B$(top_srcdir)/win32 -I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP)
TCCFLAGS = -B$(top_srcdir)/win32 --I$(top_srcdir) -I$(top_srcdir)/include -I$(TOP) -L$(TOP)
endif
XTCCFLAGS = -B$(TOP) -B$(top_srcdir)/win32 -I$(TOP) -I$(top_srcdir) -I$(top_srcdir)/include
TCC = $(TOP)/tcc $(TCCFLAGS)
RUN_TCC = $(NATIVE_DEFINES) -DONE_SOURCE -run $(top_srcdir)/tcc.c $(TCCFLAGS)
@ -69,6 +73,15 @@ hello-exe: ../examples/ex1.c
@echo ------------ $@ ------------
$(TCC) $< -o hello$(EXESUF) || ($(TOP)/tcc -vv; exit 1) && ./hello$(EXESUF)
hello-cross: ../examples/ex1.c
@echo ------------ $@ ------------
for XTCC in $(PROGS_CROSS) ; \
do echo -n "Test of $$XTCC... "; \
out=$$($(TOP)/$$XTCC $(XTCCFLAGS) -c $< 2>&1); \
test $$? -ne 0 && { echo "Failed\n$$out\n" ; $(TOP)/$$XTCC -vv; exit 1; } ; \
echo "Success"; \
done
hello-run: ../examples/ex1.c
@echo ------------ $@ ------------
$(TCC) -run $<