configure: --triplet= option, Makefile: cleanup

This commit is contained in:
grischka 2016-10-17 23:22:21 +02:00
parent 0be098929a
commit 02919cd275
4 changed files with 69 additions and 83 deletions

View File

@ -90,17 +90,17 @@ ARM64_FILES = $(CORE_FILES) arm64-gen.c
C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c C67_FILES = $(CORE_FILES) c67-gen.c tcccoff.c
ifdef CONFIG_WIN32 ifdef CONFIG_WIN32
PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF) PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF) $(LIBTCC)
ifeq ($(ARCH),x86-64) ifeq ($(ARCH),x86-64)
NATIVE_FILES=$(WIN64_FILES) NATIVE_FILES=$(WIN64_FILES)
PROGS_CROSS=$(WIN32_CROSS) PROGS_CROSS=$(WIN32_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
LIBTCC1_CROSS=lib/i386-win32/libtcc1.a LIBTCC1_CROSS=lib/i386-win32/libtcc1.a
else else
NATIVE_FILES=$(WIN32_FILES) NATIVE_FILES=$(WIN32_FILES)
PROGS_CROSS=$(WIN64_CROSS) PROGS_CROSS=$(WIN64_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
LIBTCC1_CROSS=lib/x86_64-win32/libtcc1.a LIBTCC1_CROSS=lib/x86_64-win32/libtcc1.a
endif endif
PROGS_CROSS+=$(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
else ifeq ($(ARCH),i386) else ifeq ($(ARCH),i386)
NATIVE_FILES=$(I386_FILES) NATIVE_FILES=$(I386_FILES)
PROGS_CROSS=$(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS) PROGS_CROSS=$(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS)
@ -217,39 +217,32 @@ lib/%/libtcc1.a : FORCE $(PROGS_CROSS)
FORCE: FORCE:
# install # install
TCC_INCLUDES = stdarg.h stddef.h stdbool.h float.h varargs.h INSTALL = install
INSTALL=install INSTALLBIN = install $(STRIP_$(STRIP_BINARIES))
STRIP_yes = -s
ifdef STRIP_BINARIES
INSTALLBIN=$(INSTALL) -s
else
INSTALLBIN=$(INSTALL)
endif
install-strip: install install-strip: install
$(STRIP) $(foreach PROG,$(PROGS),"$(bindir)"/$(PROG)) install-strip: STRIP_BINARIES = yes
ifdef CONFIG_WIN32
$(STRIP) "$(bindir)/$(LIBTCC)"
endif
ifndef CONFIG_WIN32 ifndef CONFIG_WIN32
install: $(PROGS) $(TCCLIBS) $(TCCDOCS) install:
mkdir -p "$(bindir)" mkdir -p "$(bindir)"
$(INSTALLBIN) -m755 $(PROGS) "$(bindir)" $(INSTALLBIN) -m755 $(PROGS) "$(bindir)"
mkdir -p "$(mandir)/man1"
-$(INSTALL) -m644 tcc.1 "$(mandir)/man1"
mkdir -p "$(infodir)"
-$(INSTALL) -m644 tcc-doc.info "$(infodir)"
mkdir -p "$(tccdir)" mkdir -p "$(tccdir)"
mkdir -p "$(tccdir)/include"
ifneq ($(LIBTCC1),) ifneq ($(LIBTCC1),)
$(INSTALL) -m644 $(LIBTCC1) "$(tccdir)" $(INSTALL) -m644 $(LIBTCC1) "$(tccdir)"
endif endif
$(INSTALL) -m644 $(addprefix $(TOPSRC)/include/,$(TCC_INCLUDES)) $(TOPSRC)/tcclib.h "$(tccdir)/include" mkdir -p "$(tccdir)/include"
$(INSTALL) -m644 $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/include"
mkdir -p "$(libdir)" mkdir -p "$(libdir)"
$(INSTALL) -m644 $(LIBTCC) "$(libdir)" $(INSTALL) -m644 $(LIBTCC) "$(libdir)"
mkdir -p "$(includedir)" mkdir -p "$(includedir)"
$(INSTALL) -m644 $(TOPSRC)/libtcc.h "$(includedir)" $(INSTALL) -m644 $(TOPSRC)/libtcc.h "$(includedir)"
mkdir -p "$(mandir)/man1"
-$(INSTALL) -m644 tcc.1 "$(mandir)/man1"
mkdir -p "$(infodir)"
-$(INSTALL) -m644 tcc-doc.info "$(infodir)"
mkdir -p "$(docdir)" mkdir -p "$(docdir)"
-$(INSTALL) -m644 tcc-doc.html "$(docdir)" -$(INSTALL) -m644 tcc-doc.html "$(docdir)"
ifdef CONFIG_CROSS ifdef CONFIG_CROSS
@ -264,28 +257,25 @@ endif
uninstall: uninstall:
rm -fv $(foreach P,$(PROGS),"$(bindir)/$P") rm -fv $(foreach P,$(PROGS),"$(bindir)/$P")
rm -fv $(foreach P,$(LIBTCC1),"$(tccdir)/$P")
rm -fv $(foreach P,$(TCC_INCLUDES),"$(tccdir)/include/$P")
rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h" rm -fv "$(libdir)/$(LIBTCC)" "$(includedir)/libtcc.h"
rm -fv $(libdir)/libtcc.so* rm -fv "$(mandir)/man1/tcc.1" "$(infodir)/tcc-doc.info"
rm -rv "$(tccdir)"
rm -fv "$(docdir)/tcc-doc.html" rm -fv "$(docdir)/tcc-doc.html"
rm -rv "$(tccdir)"
else else
# on windows # on windows
install: $(PROGS) $(TCCLIBS) $(TCCDOCS) install:
mkdir -p "$(tccdir)" mkdir -p "$(tccdir)"
mkdir -p "$(tccdir)/lib" mkdir -p "$(tccdir)/lib"
mkdir -p "$(tccdir)/include" mkdir -p "$(tccdir)/include"
mkdir -p "$(tccdir)/examples" mkdir -p "$(tccdir)/examples"
mkdir -p "$(tccdir)/doc" mkdir -p "$(tccdir)/doc"
mkdir -p "$(tccdir)/libtcc" mkdir -p "$(tccdir)/libtcc"
$(INSTALLBIN) -m755 $(PROGS) $(LIBTCC) "$(tccdir)" $(INSTALLBIN) -m755 $(PROGS) "$(tccdir)"
$(INSTALL) -m644 libtcc1.a $(TOPSRC)/win32/lib/*.def "$(tccdir)/lib" $(INSTALL) -m644 libtcc1.a $(TOPSRC)/win32/lib/*.def "$(tccdir)/lib"
cp -r $(TOPSRC)/win32/include/. "$(tccdir)/include" cp -r $(TOPSRC)/win32/include/. "$(tccdir)/include"
cp -r $(TOPSRC)/win32/examples/. "$(tccdir)/examples" cp -r $(TOPSRC)/win32/examples/. "$(tccdir)/examples"
cp $(TOPSRC)/tests/libtcc_test.c "$(tccdir)/examples" cp $(TOPSRC)/tests/libtcc_test.c "$(tccdir)/examples"
$(INSTALL) -m644 $(addprefix $(TOPSRC)/include/,$(TCC_INCLUDES)) $(TOPSRC)/tcclib.h "$(tccdir)/include" $(INSTALL) -m644 $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/include"
$(INSTALL) -m644 tcc-doc.html $(TOPSRC)/win32/tcc-win32.txt "$(tccdir)/doc" $(INSTALL) -m644 tcc-doc.html $(TOPSRC)/win32/tcc-win32.txt "$(tccdir)/doc"
$(INSTALL) -m644 $(TOPSRC)/libtcc.h libtcc.def "$(tccdir)/libtcc" $(INSTALL) -m644 $(TOPSRC)/libtcc.h libtcc.def "$(tccdir)/libtcc"
ifdef CONFIG_CROSS ifdef CONFIG_CROSS

46
configure vendored
View File

@ -42,6 +42,7 @@ tcc_sysincludepaths=""
tcc_libpaths="" tcc_libpaths=""
tcc_crtprefix="" tcc_crtprefix=""
tcc_elfinterp="" tcc_elfinterp=""
triplet=
tcc_lddir= tcc_lddir=
confvars= confvars=
cpu= cpu=
@ -116,6 +117,8 @@ for opt do
;; ;;
--elfinterp=*) tcc_elfinterp=`echo $opt | cut -d '=' -f 2` --elfinterp=*) tcc_elfinterp=`echo $opt | cut -d '=' -f 2`
;; ;;
--triplet=*) triplet=`echo $opt | cut -d '=' -f 2`
;;
--cpu=*) cpu=`echo $opt | cut -d '=' -f 2` --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
;; ;;
--enable-gprof) gprof="yes" --enable-gprof) gprof="yes"
@ -293,6 +296,7 @@ Advanced options (experts only):
--libpaths=... specify system library paths, colon separated --libpaths=... specify system library paths, colon separated
--crtprefix=... specify locations of crt?.o, colon separated --crtprefix=... specify locations of crt?.o, colon separated
--elfinterp=... specify elf interpreter --elfinterp=... specify elf interpreter
--triplet=... specify system library/include directory triplet
EOF EOF
#echo "NOTE: The object files are build at the place where configure is launched" #echo "NOTE: The object files are build at the place where configure is launched"
exit 1 exit 1
@ -312,12 +316,18 @@ if test -z "$cross_prefix" ; then
gcc_major="$($CONFTEST version)" gcc_major="$($CONFTEST version)"
gcc_minor="$($CONFTEST minor)" gcc_minor="$($CONFTEST minor)"
if test "$mingw32" = "no" ; then if test "$mingw32" = "no" ; then
triplet="$($CONFTEST triplet)"
if test -f "/usr/lib/$triplet/crti.o" ; then if test -z "$triplet"; then
tcc_lddir="lib" tt="$($CONFTEST triplet)"
multiarch_triplet="$triplet" if test -n "$tt" -a -f "/usr/lib/$tt/crti.o" ; then
elif test "$cpu" != "x86" -a -f "/usr/lib64/crti.o" ; then triplet="$tt"
tcc_lddir="lib64" fi
fi
if test -z "$triplet"; then
if test ! -f "/usr/lib/crti.o" -a -f "/usr/lib64/crti.o" ; then
tcc_lddir="lib64"
fi
fi fi
if test "$cpu" = "armv4l" ; then if test "$cpu" = "armv4l" ; then
@ -331,21 +341,10 @@ if test -z "$cross_prefix" ; then
fi fi
fi fi
# multiarch_triplet=${libc_dir#*/}
# multiarch_triplet=${multiarch_triplet%/}
# tcc_lddir="${libc_dir%%/*}"
# if test -n "$multiarch_triplet" ; then
# tcc_lddir="$tcc_lddir/$multiarch_triplet"
# fi
if test -f "/lib/ld-uClibc.so.0" ; then if test -f "/lib/ld-uClibc.so.0" ; then
confvars="$confvars uClibc" confvars="$confvars uClibc"
fi fi
# if test -z "$tcc_elfinterp" ; then
# tcc_elfinterp="$(ldd $CONFTEST | grep '/ld-.*.so' | sed 's,\s*\(\S\+\).*,\1,')"
# fi
fi fi
fi fi
else else
@ -374,6 +373,8 @@ for i in $F_OPTIONS; do
done done
rm -f cc_help.txt rm -f cc_help.txt
fcho() { if test -n "$2"; then echo "$1$2"; else echo "$1-"; fi }
echo "Binary directory $bindir" echo "Binary directory $bindir"
echo "TinyCC directory $tccdir" echo "TinyCC directory $tccdir"
echo "Library directory $libdir" echo "Library directory $libdir"
@ -381,15 +382,16 @@ echo "Include directory $includedir"
echo "Manual directory $mandir" echo "Manual directory $mandir"
echo "Info directory $infodir" echo "Info directory $infodir"
echo "Doc directory $docdir" echo "Doc directory $docdir"
echo "Target root prefix $sysroot" fcho "Target root prefix " "$sysroot"
echo "Source path $source_path" echo "Source path $source_path"
echo "C compiler $cc" echo "C compiler $cc"
echo "Target OS $targetos" echo "Target OS $targetos"
echo "CPU $cpu" echo "CPU $cpu"
echo "Big Endian $bigendian" echo "Big Endian $bigendian"
echo "gprof enabled $gprof" echo "Profiling $gprof"
echo "cross compilers $build_cross" echo "Cross compilers $build_cross"
echo "use libgcc $use_libgcc" echo "Use libgcc $use_libgcc"
fcho "Triplet " "$triplet"
echo "Creating config.mak and config.h" echo "Creating config.mak and config.h"
@ -437,7 +439,7 @@ print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths"
print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix" print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp" print_mak CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
print_mak CONFIG_LDDIR "$tcc_lddir" print_mak CONFIG_LDDIR "$tcc_lddir"
print_mak CONFIG_MULTIARCHDIR "$multiarch_triplet" print_mak CONFIG_TRIPLET "$triplet"
echo "#define GCC_MAJOR $gcc_major" >> $TMPH echo "#define GCC_MAJOR $gcc_major" >> $TMPH
echo "#define GCC_MINOR $gcc_minor" >> $TMPH echo "#define GCC_MINOR $gcc_minor" >> $TMPH

View File

@ -41,22 +41,21 @@ cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O) I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O) X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BCHECK_O)
ARM_O = libtcc1.o armeabi.o alloca-arm.o ARM_O = libtcc1.o armeabi.o alloca-arm.o
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
ARM64_O = lib-arm64.o ARM64_O = lib-arm64.o
WIN32_O = crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
# build TCC runtime library to contain PIC code, so it can be linked # build TCC runtime library to contain PIC code, so it can be linked
# into shared libraries # into shared libraries
PICFLAGS = -fPIC PICFLAGS = -fPIC
ifeq "$(TARGET)" "i386-win32" ifeq "$(TARGET)" "i386-win32"
OBJ = $(addprefix $(DIR)/,$(WIN32_O)) OBJ = $(addprefix $(DIR)/,$(I386_O) $(WIN32_O))
TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE TGT = -DTCC_TARGET_I386 -DTCC_TARGET_PE
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
XAR = $(DIR)/tiny_libmaker$(EXESUF) XAR = $(DIR)/tiny_libmaker$(EXESUF)
XFLAGS = $(TGT) XFLAGS = $(TGT)
else ifeq "$(TARGET)" "x86_64-win32" else ifeq "$(TARGET)" "x86_64-win32"
OBJ = $(addprefix $(DIR)/,$(WIN64_O)) OBJ = $(addprefix $(DIR)/,$(X86_64_O) $(WIN32_O))
TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE TGT = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include XCC = $(TCC) -B$(TOPSRC)/win32 -I$(TOPSRC)/include
XAR = $(DIR)/tiny_libmaker$(EXESUF) XAR = $(DIR)/tiny_libmaker$(EXESUF)
@ -110,4 +109,4 @@ $(OBJ) $(XAR) : $(DIR)/exists
@echo $@ > $@ @echo $@ > $@
clean : clean :
rm -rfv i386-win32 x86_64-win32 i386 x86_64 arm arm64 rm -rf i386-win32 x86_64-win32 i386 x86_64 arm arm64

31
tcc.h
View File

@ -173,24 +173,19 @@
# define CONFIG_TCCDIR "." # define CONFIG_TCCDIR "."
#endif #endif
#ifndef CONFIG_LDDIR #ifndef CONFIG_LDDIR
# ifdef TCC_TARGET_X86_64 # define CONFIG_LDDIR "lib"
# define CONFIG_LDDIR "lib64"
# else
# define CONFIG_LDDIR "lib"
# endif
#endif #endif
#ifdef CONFIG_TRIPLET
#ifdef CONFIG_MULTIARCHDIR # define USE_TRIPLET(s) s "/" CONFIG_TRIPLET
# define USE_MUADIR(s) s "/" CONFIG_MULTIARCHDIR # define ALSO_TRIPLET(s) USE_TRIPLET(s) ":" s
# define ALSO_MUADIR(s) s "/" CONFIG_MULTIARCHDIR ":" s
#else #else
# define USE_MUADIR(s) s # define USE_TRIPLET(s) s
# define ALSO_MUADIR(s) s # define ALSO_TRIPLET(s) s
#endif #endif
/* path to find crt1.o, crti.o and crtn.o */ /* path to find crt1.o, crti.o and crtn.o */
#ifndef CONFIG_TCC_CRTPREFIX #ifndef CONFIG_TCC_CRTPREFIX
# define CONFIG_TCC_CRTPREFIX USE_MUADIR(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) # define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR)
#endif #endif
/* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */ /* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
@ -202,8 +197,8 @@
# else # else
# define CONFIG_TCC_SYSINCLUDEPATHS \ # define CONFIG_TCC_SYSINCLUDEPATHS \
"{B}/include" \ "{B}/include" \
":" ALSO_MUADIR(CONFIG_SYSROOT "/usr/local/include") \ ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
":" ALSO_MUADIR(CONFIG_SYSROOT "/usr/include") ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include")
# endif # endif
#endif #endif
@ -213,9 +208,9 @@
# define CONFIG_TCC_LIBPATHS "{B}/lib" # define CONFIG_TCC_LIBPATHS "{B}/lib"
# else # else
# define CONFIG_TCC_LIBPATHS \ # define CONFIG_TCC_LIBPATHS \
ALSO_MUADIR(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
":" ALSO_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) \ ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
":" ALSO_MUADIR(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR) ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
# endif # endif
#endif #endif
@ -261,7 +256,7 @@
#endif #endif
/* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */ /* library to use with CONFIG_USE_LIBGCC instead of libtcc1.a */
#define TCC_LIBGCC USE_MUADIR(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1" #define TCC_LIBGCC USE_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) "/libgcc_s.so.1"
/* -------------------------------------------- */ /* -------------------------------------------- */