Blob Blame History Raw
From f209086af1f0e11b41fdfb24a64bd6fdc4420b2a Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Tue, 18 Mar 2014 11:41:18 -0400
Subject: [PATCH] Changes to make sure we inherit CFLAGS properly from
 rpmbuild.

This makes sure we build with -fstack-protector-strong when invoked
correctly with it in CFLAGS="" from make.

Signed-off-by: Peter Jones <pesign-owner@fedoraproject.org>
---
 Make.defaults                          |   7 ++++---
 Make.efirules                          |   6 +++---
 Make.rules                             |  10 +++++-----
 libdpe/pe_allocspace.c                 |   1 +
 src/Makefile                           |   2 +-
 src/efikeygen.c                        |   2 +-
 util/Makefile                          |   2 +-
 10 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/Make.defaults b/Make.defaults
index e2c967b..0995e5b 100644
--- a/Make.defaults
+++ b/Make.defaults
@@ -5,7 +5,8 @@ HOSTARCH   = $(shell uname -m | sed s,i[3456789]86,ia32,)
 ARCH	   := $(shell uname -m | sed s,i[3456789]86,ia32,)
 INCDIR	   = -I$(TOPDIR)/include
 CPPFLAGS   = -DCONFIG_$(ARCH)
-CFLAGS	   = $(ARCH3264) -g -O0 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants --std=gnu99 -D_GNU_SOURCE
+CFLAGS	   = -g -O0
+BUILDFLAGS := $(CFLAGS) $(ARCH3264) -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants --std=gnu99 -D_GNU_SOURCE -Wno-unused-result -Wno-unused-function
 ASFLAGS    = $(ARCH3264)
 LDFLAGS	   = -nostdlib
 CCLDFLAGS  = -shared
@@ -21,7 +22,7 @@ RANLIB        = $(bindir)ranlib
 OBJCOPY       = $(bindir)objcopy
 
 ifeq ($(ARCH),ia64)
-  CFLAGS += -mfixed-range=f32-f127
+  BUILDFLAGS += -mfixed-range=f32-f127
   LIBDIR = $(PREFIX)/lib64
 endif
 
@@ -33,7 +34,7 @@ ifeq ($(ARCH), ia32)
 endif
 
 ifeq ($(ARCH), x86_64)
-  CFLAGS += -mno-red-zone
+  BUILDFLAGS += -mno-red-zone
   LIBDIR := $(PREFIX)/lib64
   ifeq ($(HOSTARCH), ia32)
     ARCH3264 := -m64
diff --git a/Make.efirules b/Make.efirules
index 9aa4b5b..bed36b1 100644
--- a/Make.efirules
+++ b/Make.efirules
@@ -6,10 +6,10 @@
 	$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
 
 %.o: %.c
-	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -D__UEFI__ -c $< -o $@
+	$(CC) $(INCDIR) $(BUILDFLAGS) $(CPPFLAGS) -D__UEFI__ -c $< -o $@
 
 %.S: %.c
-	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -D__UEFI__ -S $< -o $@
+	$(CC) $(INCDIR) $(BUILDFLAGS) $(CPPFLAGS) -D__UEFI__ -S $< -o $@
 
 %.E: %.c
-	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -D__UEFI__ -E $< -o $@
+	$(CC) $(INCDIR) $(BUILDFLAGS) $(CPPFLAGS) -D__UEFI__ -E $< -o $@
diff --git a/Make.rules b/Make.rules
index 999d717..2749521 100644
--- a/Make.rules
+++ b/Make.rules
@@ -5,18 +5,18 @@
 	$(CC) $(CCLDFLAGS) -o $@ $^ $(foreach lib,$(LIBS),-l$(lib)) $(foreach pklib,$(PKLIBS), $(shell pkg-config --libs-only-l --libs-only-other $(pklib))) -lpthread
 
 %.so : 
-	$(CC) $(INCDIR) $(CFLAGS) -Wl,-soname,$(SONAME) $(CCLDFLAGS) $^ -o $@
+	$(CC) $(INCDIR) $(BUILDFLAGS) -Wl,-soname,$(SONAME) $(CCLDFLAGS) $^ -o $@
 
 %.o: %.c
-	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
+	$(CC) $(INCDIR) $(BUILDFLAGS) $(CPPFLAGS) -c $< -o $@
 
 .%.P : %.c
-	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -M -MM -MF $@ $^
+	$(CC) $(INCDIR) $(BUILDFLAGS) $(CPPFLAGS) -M -MM -MF $@ $^
 
 %.S: %.c
-	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -S $< -o $@
+	$(CC) $(INCDIR) $(BUILDFLAGS) $(CPPFLAGS) -S $< -o $@
 
 %.E: %.c
-	$(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -E $< -o $@
+	$(CC) $(INCDIR) $(BUILDFLAGS) $(CPPFLAGS) -E $< -o $@
 
 %.c : %.h
diff --git a/libdpe/pe_allocspace.c b/libdpe/pe_allocspace.c
index 716373c..1f0f44a 100644
--- a/libdpe/pe_allocspace.c
+++ b/libdpe/pe_allocspace.c
@@ -19,6 +19,7 @@
 
 #include "libdpe.h"
 
+#include <assert.h>
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/types.h>
diff --git a/src/Makefile b/src/Makefile
index f478aa6..e45d2a3 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -8,7 +8,7 @@ LIBS = popt
 STATIC_LIBS = $(TOPDIR)/libdpe/libdpe.a
 LDFLAGS =
 CCLDFLAGS = -L../libdpe $(foreach pklib,$(PKLIBS), $(shell pkg-config --libs-only-L $(pklib)))
-CFLAGS += -I../include/ $(foreach pklib,$(PKLIBS), $(shell pkg-config --cflags $(pklib))) -Werror
+BUILDFLAGS += -I../include/ $(foreach pklib,$(PKLIBS), $(shell pkg-config --cflags $(pklib))) -Werror
 
 TARGETS = pesign authvar client efisiglist efikeygen peverify
 
diff --git a/src/efikeygen.c b/src/efikeygen.c
index ac27acc..45ee5c5 100644
--- a/src/efikeygen.c
+++ b/src/efikeygen.c
@@ -333,7 +333,7 @@ populate_extensions(cms_context *cms, CERTCertificate *cert,
 
 	oid = SECOID_FindOIDByTag(SEC_OID_PKCS9_EXTENSION_REQUEST);
 
-	for (int i; crq->attributes[i]; i++) {
+	for (int i = 0 ; crq->attributes[i]; i++) {
 		attr = crq->attributes[i];
 		if (attr->attrType.len != oid->oid.len)
 			continue;
diff --git a/util/Makefile b/util/Makefile
index 1cf782c..ff11cb8 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -7,7 +7,7 @@ FORMAT=efi-app-$(HOSTARCH)
 LDFLAGS = -nostdlib -T $(LIBDIR)/gnuefi/elf_$(HOSTARCH)_efi.lds -shared -Bsymbolic $(LIBDIR)/gnuefi/crt0-efi-$(HOSTARCH).o -L$(LIBDIR)
 LIBS=-lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name)
 CCLDFLAGS =
-CFLAGS = -I/usr/include/efi/ -I/usr/include/efi/$(HOSTARCH)/ -I/usr/include/efi/protocol -fpic -fshort-wchar -fno-reorder-functions -fno-strict-aliasing -fno-merge-constants -mno-red-zone -Wimplicit-function-declaration
+BUILDFLAGS = -I/usr/include/efi/ -I/usr/include/efi/$(HOSTARCH)/ -I/usr/include/efi/protocol -fpic -fshort-wchar -fno-reorder-functions -fno-strict-aliasing -fno-merge-constants -mno-red-zone -Wimplicit-function-declaration
 
 TARGETS = setupsb.efi dumpsb.efi clearpk.efi
 
-- 
1.8.5.3