CFLAGS += -fPIC
endif
+# Unconditionally set up the libunwind feature build flags as a
+# feature-dump build doesn't specify LIBUNWIND=1. This means that
+# dumping the libunwind features will be broken that can impact later
+# builds that use the feature dump.
+ifeq ($(SRCARCH),arm)
+ LIBUNWIND_LIBS = -lunwind -lunwind-arm
+endif
+ifeq ($(SRCARCH),arm64)
+ LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
+endif
+ifeq ($(SRCARCH),loongarch)
+ LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64
+endif
+ifeq ($(ARCH),mips)
+ LIBUNWIND_LIBS = -lunwind -lunwind-mips
+endif
+ifeq ($(SRCARCH),powerpc)
+ LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
+endif
+ifeq ($(SRCARCH),riscv)
+ LIBUNWIND_LIBS := -lunwind -lunwind-riscv
+endif
+ifeq ($(SRCARCH),s390)
+ LIBUNWIND_LIBS := -lunwind -lunwind-s390x
+endif
+ifeq ($(SRCARCH),x86)
+ ifeq (${IS_64_BIT}, 1)
+ LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
+ else
+ LIBUNWIND_LIBS = -lunwind-x86 -lunwind -llzma
+ endif
+endif
ifneq ($(LIBUNWIND),1)
NO_LIBUNWIND := 1
endif
-
-ifndef NO_LIBUNWIND
- ifeq ($(SRCARCH),arm)
- LIBUNWIND_LIBS = -lunwind -lunwind-arm
- endif
- ifeq ($(SRCARCH),arm64)
- LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
- endif
- ifeq ($(SRCARCH),loongarch)
- LIBUNWIND_LIBS = -lunwind -lunwind-loongarch64
- endif
- ifeq ($(ARCH),mips)
- LIBUNWIND_LIBS = -lunwind -lunwind-mips
- endif
- ifeq ($(SRCARCH),powerpc)
- LIBUNWIND_LIBS := -lunwind -lunwind-ppc64
- endif
- ifeq ($(SRCARCH),riscv)
- LIBUNWIND_LIBS := -lunwind -lunwind-riscv
- endif
- ifeq ($(SRCARCH),s390)
- LIBUNWIND_LIBS := -lunwind -lunwind-s390x
- endif
- ifeq ($(SRCARCH),x86)
- ifeq (${IS_64_BIT}, 1)
- LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
- else
- LIBUNWIND_LIBS = -lunwind-x86 -lunwind -llzma
- endif
- endif
- ifeq ($(LIBUNWIND_LIBS),)
- NO_LIBUNWIND := 1
- endif
+ifeq ($(LIBUNWIND_LIBS),)
+ NO_LIBUNWIND := 1
endif
#
#
LIBUNWIND_ARCHS:=aarch64 arm loongarch64 mips ppc32 ppc64 riscv s390x x86 x86_64
-ifndef NO_LIBUNWIND
- FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
- FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
- FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
- FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
-
- ifdef LIBUNWIND_DIR
- LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
- LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
-
- define libunwind_arch_set_flags
- FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
- FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib -lunwind -lunwind-$(1)
- endef
- $(foreach arch,$(LIBUNWIND_ARCHS), \
- $(eval $(call libunwind_arch_set_flags,$(arch))) \
- )
- endif
+# "Local" (no arch specified) feature test flags.
+FEATURE_CHECK_CFLAGS-libunwind = $(LIBUNWIND_CFLAGS)
+FEATURE_CHECK_LDFLAGS-libunwind = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
+FEATURE_CHECK_CFLAGS-libunwind-debug-frame = $(LIBUNWIND_CFLAGS)
+FEATURE_CHECK_LDFLAGS-libunwind-debug-frame = $(LIBUNWIND_LDFLAGS) $(LIBUNWIND_LIBS)
+
+# Add directory into the "remote" (build for a a specific arch) feature tests.
+ifdef LIBUNWIND_DIR
+ LIBUNWIND_CFLAGS = -I$(LIBUNWIND_DIR)/include
+ LIBUNWIND_LDFLAGS = -L$(LIBUNWIND_DIR)/lib
+
+ define libunwind_arch_set_flags
+ FEATURE_CHECK_CFLAGS-libunwind-$(1) = -I$(LIBUNWIND_DIR)/include
+ FEATURE_CHECK_LDFLAGS-libunwind-$(1) = -L$(LIBUNWIND_DIR)/lib -lunwind -lunwind-$(1)
+ endef
+ $(foreach arch,$(LIBUNWIND_ARCHS), \
+ $(eval $(call libunwind_arch_set_flags,$(arch))) \
+ )
endif
ifdef CSINCLUDES