]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: makefile: add CROSS_TOOLCHAIN to prefix the target's tools 20261001-oho-debug-syms
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 17 Sep 2026 09:18:48 +0000 (11:18 +0200)
committerOlivier Houchard <cognet@ci0.org>
Thu, 1 Oct 2026 15:06:32 +0000 (17:06 +0200)
Cross-building also needs the target's nm, objcopy and readelf, since the
host ones do not know a foreign object. Instead of setting each one,
CROSS_TOOLCHAIN=arm-linux-gnueabi- prefixes them all, giving arm-linux-
gnueabi-gcc, -nm and so on. Empty by default.

Makefile

index a968f26d935dfc873501d4995d9bcf53496874ef..c20ed3005a6dfb4108600b4535fe77b051f7ae44 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -181,11 +181,15 @@ $(call $(complain),the "ARCH" variable was forced to "$(ARCH)" but is no \
 endif
 
 #### Toolchain options.
-CC = cc
+# CROSS_TOOLCHAIN is an optional prefix for the target's tools, e.g.
+# CROSS_TOOLCHAIN=arm-linux-gnueabi- for arm-linux-gnueabi-gcc, -nm, etc.
+CROSS_TOOLCHAIN =
+CC = $(if $(CROSS_TOOLCHAIN),$(CROSS_TOOLCHAIN)gcc,cc)
 LD = $(CC)
-NM = nm
-OBJCOPY = objcopy
-READELF = readelf
+NM = $(CROSS_TOOLCHAIN)nm
+OBJCOPY = $(CROSS_TOOLCHAIN)objcopy
+OBJDUMP = $(CROSS_TOOLCHAIN)objdump
+READELF = $(CROSS_TOOLCHAIN)readelf
 XZ = xz
 
 #### Default optimizations
@@ -1121,7 +1125,7 @@ ifneq ($(USE_MINIDEBUG:0=),)
 endif
 
 objsize: haproxy
-       $(Q)objdump -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
+       $(Q)$(OBJDUMP) -t $^|grep ' g '|grep -F '.text'|awk '{print $$5 FS $$6}'|sort
 
 %.o:   %.c $(DEP)
        $(cmd_CC) $(COPTS) -c -o $@ $<