Browse Source

-fpic is not needed for MinGW, and MinGW32 issues a warning as a
result, which breaks gnu-efi compilation due to -Werror:
gnu-efi/lib/boxdraw.c:1:0: error: -fpic ignored for target
(all code is position independent) [-Werror]

This patch ensures that -fpic is disabled when MinGW is used.

Signed-off-by: Pete Batard <pbatard@users.sf.net>
Signed-off-by: Nigel Croxon <nigel.croxon@hpe.com>

Nigel Croxon 9 years ago
parent
commit
50b883773f
1 changed files with 8 additions and 2 deletions
  1. 8 2
      Make.defaults

+ 8 - 2
Make.defaults

@@ -139,12 +139,18 @@ endif
 INCDIR  += -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) \
            -I$(TOPDIR)/inc/protocol
 
+# Only enable -fpic for non MinGW compilers (unneeded on MinGW)
+GCCMACHINE := $(shell $(CC) -dumpmachine)
+ifneq (mingw32,$(findstring mingw32, $(GCCMACHINE)))
+  CFLAGS += -fpic
+endif
+
 ifeq (FreeBSD, $(findstring FreeBSD, $(OS)))
-CFLAGS  += $(ARCH3264) -g -O2 -fpic -Wall -Wextra -Werror \
+CFLAGS  += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
            -fshort-wchar -fno-strict-aliasing \
            -ffreestanding -fno-stack-protector
 else
-CFLAGS  += $(ARCH3264) -g -O2 -fpic -Wall -Wextra -Werror \
+CFLAGS  += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
            -fshort-wchar -fno-strict-aliasing \
            -fno-merge-constants -ffreestanding -fno-stack-protector \
            -fno-stack-check