ALL_COMPILERFLAGS = $(ALL_CFLAGS)
# This is where we get libiberty.a from.
-ifeq ($(PICFLAG),)
-LIBIBERTY = ../../libiberty/libiberty.a
-else
+ifneq ($(findstring $(PICFLAG),-fPIC -fPIE),)
LIBIBERTY = ../../libiberty/pic/libiberty.a
+else
+LIBIBERTY = ../../libiberty/libiberty.a
endif
# We need to link against libbacktrace because diagnostic.c in
$(LIBGNAT) $(LIBINTL) $(LIBICONV) ../$(LIBBACKTRACE) ../$(LIBIBERTY) \
$(SYSLIBS) $(TGT_LIB)
+# Add -no-pie to TOOLS_LIBS since some of them are compiled with -fno-PIE.
+TOOLS_LIBS += @LD_PICFLAG@
+
# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order,
# so that tm.h and config.h will be found in the compilation