This reverts commit 2507c7170443cf4cced4d2cda8ba3c8cc259adb1. Why crowd up search-paths for the normal native compiler with all sort of invalid stuff. Why -UCONFIG_TRIPLET if it isn't set at all for cross-compilers. Also, the patch still didn't do anything useful "out of the box". Instead I'd suggest to do something more simple and more effective. See Makefile: - set search paths for cross-compilers to /usr/<triplet> by default - Install any built "xxx-tcc" and "xxx-libtcc1.a", even if not listed with PROGS_CROSS/LIBTCC1_CROSS - Support ELF-<target> = ... to set the elf interpreter Some common gnu-triplets are supported by default TRIPLET-i386 ?= i386-linux-gnu TRIPLET-x86_64 ?= x86_64-linux-gnu TRIPLET-arm ?= arm-linux-gnueabihf TRIPLET-arm64 ?= aarch64-linux-gnu TRIPLET-riscv64 ?= riscv64-linux-gnu Other triplets can be given explicitly, for example like this: $ make cross-arm-eabi TRIPLET-arm-eabi=arm-linux-gnueabi $ sudo make install
Unified · Split
| @@ -171,6 +171,7 @@ DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"") · 170 unmodified lines | |||
| 171 | DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"") | 171 | DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"") |
| 172 | DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"") | 172 | DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"") |
| 173 | DEFINES += $(if $(INC-$T),-DCONFIG_TCC_SYSINCLUDEPATHS="\"$(INC-$T)\"") | 173 | DEFINES += $(if $(INC-$T),-DCONFIG_TCC_SYSINCLUDEPATHS="\"$(INC-$T)\"") |
| 174 | DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"") | ||
| 174 | DEFINES += $(DEF-$(or $(findstring win,$T),unx)) | 175 | DEFINES += $(DEF-$(or $(findstring win,$T),unx)) |
| 175 | 176 | ||
| 176 | ifneq ($(X),) | 177 | ifneq ($(X),) |
| @@ -186,6 +187,19 @@ endif · 9 unmodified lines | |||
| 186 | # include custom configuration (see make help) | 187 | # include custom configuration (see make help) |
| 187 | -include config-extra.mak | 188 | -include config-extra.mak |
| 188 | 189 | ||
| 190 | ifneq ($(X),) | ||
| 191 | # assume support files for cross-targets in "/usr/<triplet>" by default | ||
| 192 | TRIPLET-i386 ?= i386-linux-gnu | ||
| 193 | TRIPLET-x86_64 ?= x86_64-linux-gnu | ||
| 194 | TRIPLET-arm ?= arm-linux-gnueabihf | ||
| 195 | TRIPLET-arm64 ?= aarch64-linux-gnu | ||
| 196 | TRIPLET-riscv64 ?= riscv64-linux-gnu | ||
| 197 | TR = $(if $(TRIPLET-$T),$T,ignored) | ||
| 198 | CRT-$(TR) ?= /usr/$(TRIPLET-$T)/lib | ||
| 199 | LIB-$(TR) ?= {B}:/usr/$(TRIPLET-$T)/lib | ||
| 200 | INC-$(TR) ?= {B}/include:/usr/$(TRIPLET-$T)/include | ||
| 201 | endif | ||
| 202 | |||
| 189 | CORE_FILES = tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccdbg.c tccelf.c tccasm.c tccrun.c | 203 | CORE_FILES = tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccdbg.c tccelf.c tccasm.c tccrun.c |
| 190 | CORE_FILES += tcc.h config.h libtcc.h tcctok.h | 204 | CORE_FILES += tcc.h config.h libtcc.h tcctok.h |
| 191 | i386_FILES = $(CORE_FILES) i386-gen.c i386-link.c i386-asm.c i386-asm.h i386-tok.h | 205 | i386_FILES = $(CORE_FILES) i386-gen.c i386-link.c i386-asm.c i386-asm.h i386-tok.h |
| @@ -339,7 +353,7 @@ INSTALLBIN = install -m755 $(STRIP_$(CONFIG_strip)) · 147 unmodified lines | |||
| 339 | STRIP_yes = -s | 353 | STRIP_yes = -s |
| 340 | 354 | ||
| 341 | LIBTCC1_W = $(filter %-win32-libtcc1.a %-wince-libtcc1.a,$(LIBTCC1_CROSS)) | 355 | LIBTCC1_W = $(filter %-win32-libtcc1.a %-wince-libtcc1.a,$(LIBTCC1_CROSS)) |
| 342 | LIBTCC1_U = $(filter-out $(LIBTCC1_W),$(LIBTCC1_CROSS)) | 356 | LIBTCC1_U = $(filter-out $(LIBTCC1_W),$(wildcard *-libtcc1.a)) |
| 343 | IB = $(if $1,$(IM) mkdir -p $2 && $(INSTALLBIN) $1 $2) | 357 | IB = $(if $1,$(IM) mkdir -p $2 && $(INSTALLBIN) $1 $2) |
| 344 | IBw = $(call IB,$(wildcard $1),$2) | 358 | IBw = $(call IB,$(wildcard $1),$2) |
| 345 | IF = $(if $1,$(IM) mkdir -p $2 && $(INSTALL) $1 $2) | 359 | IF = $(if $1,$(IM) mkdir -p $2 && $(INSTALL) $1 $2) |
| @@ -351,7 +365,7 @@ B_O = bcheck.o bt-exe.o bt-log.o bt-dll.o · 5 unmodified lines | |||
| 351 | 365 | ||
| 352 | # install progs & libs | 366 | # install progs & libs |
| 353 | install-unx: | 367 | install-unx: |
| 354 | $(call IBw,$(PROGS) $(PROGS_CROSS),"$(bindir)") | 368 | $(call IBw,$(PROGS) *-tcc,"$(bindir)") |
| 355 | $(call IFw,$(LIBTCC1) $(B_O) $(LIBTCC1_U),"$(tccdir)") | 369 | $(call IFw,$(LIBTCC1) $(B_O) $(LIBTCC1_U),"$(tccdir)") |
| 356 | $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/include") | 370 | $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/include") |
| 357 | $(call $(if $(findstring .so,$(LIBTCC)),IBw,IFw),$(LIBTCC),"$(libdir)") | 371 | $(call $(if $(findstring .so,$(LIBTCC)),IBw,IFw),$(LIBTCC),"$(libdir)") |
| @@ -487,6 +501,8 @@ help: · 129 unmodified lines | |||
| 487 | @echo " LIB-i386 = {B}/i386-linux/lib:{B}/i386-linux/usr/lib" | 501 | @echo " LIB-i386 = {B}/i386-linux/lib:{B}/i386-linux/usr/lib" |
| 488 | @echo " INC-i386 = {B}/lib/include:{B}/i386-linux/usr/include" | 502 | @echo " INC-i386 = {B}/lib/include:{B}/i386-linux/usr/include" |
| 489 | @echo " DEF-i386 += -D__linux__" | 503 | @echo " DEF-i386 += -D__linux__" |
| 504 | @echo " Or to configure a cross compiler for system-files in /usr/<triplet>" | ||
| 505 | @echo " TRIPLET-arm-eabi = arm-linux-gnueabi" | ||
| 490 | 506 | ||
| 491 | # -------------------------------------------------------------------------- | 507 | # -------------------------------------------------------------------------- |
| 492 | endif # ($(INCLUDED),no) | 508 | endif # ($(INCLUDED),no) |
| @@ -1,27 +0,0 @@ | |||
| 1 | # | ||
| 2 | # during 'make', this file is included from the tcc Makefile | ||
| 3 | # | ||
| 4 | # this is an example, how to help tcc to find | ||
| 5 | # the c library and the startup files for cross compiling. | ||
| 6 | # | ||
| 7 | # we expect here, that the GNU libc is used and that the related development files | ||
| 8 | # are installed in a subdirectory with the target triplet used by gcc | ||
| 9 | # | ||
| 10 | |||
| 11 | # set CONFIG_TRIPLET for cross compiler targets | ||
| 12 | DEF-i386+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"i386-linux-gnu\" " | ||
| 13 | DEF-x86_64+=-UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"x86_64-linux-gnu\" " | ||
| 14 | |||
| 15 | # many api/fp combinations are possible for arm | ||
| 16 | DEF-arm+=-UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"arm-linux-gnueabihf\" " | ||
| 17 | DEF-arm64+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"aarch64-linux-gnu\" " | ||
| 18 | |||
| 19 | DEF-riscv64+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"riscv64-linux-gnu\" " | ||
| 20 | # For win32/win64 targets, we expect mingw 64 | ||
| 21 | # is is for additional packes, as tcc has ist own win32 startfiles | ||
| 22 | DEF-i386-win32+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"i686-w64-mingw32\" " | ||
| 23 | DEF-x86_64-win32+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"x86_64-w64-mingw32\" " | ||
| 24 | |||
| 25 | # is a free cross compile toolchain for macos available? | ||
| 26 | #DEF-x86_64-osx+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"x86_64-apple-darwin\" " | ||
| 27 | #DEF-arm64-osx+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"aarch64-apple-darwin\" " | ||
| @@ -260,9 +260,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 259 unmodified lines | |||
| 260 | 260 | ||
| 261 | /* path to find crt1.o, crti.o and crtn.o */ | 261 | /* path to find crt1.o, crti.o and crtn.o */ |
| 262 | #ifndef CONFIG_TCC_CRTPREFIX | 262 | #ifndef CONFIG_TCC_CRTPREFIX |
| 263 | # define CONFIG_TCC_CRTPREFIX \ | 263 | # define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) |
| 264 | ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ | ||
| 265 | ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib" | ||
| 266 | #endif | 264 | #endif |
| 267 | 265 | ||
| 268 | #ifndef CONFIG_USR_INCLUDE | 266 | #ifndef CONFIG_USR_INCLUDE |
| @@ -279,8 +277,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 10 unmodified lines | |||
| 279 | # define CONFIG_TCC_SYSINCLUDEPATHS \ | 277 | # define CONFIG_TCC_SYSINCLUDEPATHS \ |
| 280 | "{B}/include" \ | 278 | "{B}/include" \ |
| 281 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \ | 279 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \ |
| 282 | ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/include" \ | ||
| 283 | ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/include" \ | ||
| 284 | ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE) | 280 | ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE) |
| 285 | # endif | 281 | # endif |
| 286 | #endif | 282 | #endif |
| @@ -293,8 +289,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 6 unmodified lines | |||
| 293 | # define CONFIG_TCC_LIBPATHS \ | 289 | # define CONFIG_TCC_LIBPATHS \ |
| 294 | "{B}" \ | 290 | "{B}" \ |
| 295 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ | 291 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \ |
| 296 | ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib" \ | ||
| 297 | ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/lib" \ | ||
| 298 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \ | 292 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \ |
| 299 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR) | 293 | ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR) |
| 300 | # endif | 294 | # endif |