From a25dca2b70cbab75b95ab3b42b5ee28dbbc08843 Mon Sep 17 00:00:00 2001 From: Nikoli Date: Thu, 13 Feb 2014 12:21:03 +0400 Subject: [PATCH] Makefile/Make.rules: respect CFLAGS and LDFLAGS in CLI tools, use tabs --- Make.rules | 30 ++++++++++++++++-------------- Makefile | 14 +++++++------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Make.rules b/Make.rules index 309b231..88a89c9 100644 --- a/Make.rules +++ b/Make.rules @@ -1,11 +1,13 @@ -EFISIGNED = $(patsubst %.efi,%-signed.efi,$(EFIFILES)) -MANPAGES = $(patsubst doc/%.1.in,doc/%.1,$(wildcard doc/*.1.in)) -HELP2MAN = help2man -ARCH = $(shell uname -m) -INCDIR = -I$(TOPDIR)include/ -I/usr/include/efi -I/usr/include/efi/$(ARCH) -I/usr/include/efi/protocol -CPPFLAGS = -DCONFIG_$(ARCH) -CFLAGS = -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -mno-red-zone -fno-stack-protector -g -LDFLAGS = -nostdlib +EFISIGNED = $(patsubst %.efi,%-signed.efi,$(EFIFILES)) +MANPAGES = $(patsubst doc/%.1.in,doc/%.1,$(wildcard doc/*.1.in)) +HELP2MAN = help2man +ARCH = $(shell uname -m) +INCDIR = -I$(TOPDIR)include/ -I/usr/include/efi -I/usr/include/efi/$(ARCH) -I/usr/include/efi/protocol +CPPFLAGS_EFI = -DCONFIG_$(ARCH) +CFLAGS ?= -O2 -g +LDFLAGS ?= -Wl,-O1 -Wl,--as-needed +CFLAGS_EFI = -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -mno-red-zone -fno-stack-protector -g +LDFLAGS_EFI = -nostdlib CRTOBJ = crt0-efi-$(ARCH).o CRTPATHS = /lib /lib64 /lib/efi /lib64/efi /usr/lib /usr/lib64 /usr/lib/efi /usr/lib64/efi CRTPATH = $(shell for f in $(CRTPATHS); do if [ -e $$f/$(CRTOBJ) ]; then echo $$f; break; fi; done) @@ -13,7 +15,7 @@ CRTOBJS = $(CRTPATH)/$(CRTOBJ) # there's a bug in the gnu tools ... the .reloc section has to be # aligned otherwise the file alignment gets screwed up LDSCRIPT = $(TOPDIR)/elf_$(ARCH)_efi.lds -LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic $(CRTOBJS) -L $(CRTPATH) +LDFLAGS_EFI += -T $(LDSCRIPT) -shared -Bsymbolic $(CRTOBJS) -L $(CRTPATH) LOADLIBES = -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name) FORMAT = efi-app-$(ARCH) OBJCOPY = objcopy @@ -25,7 +27,7 @@ EFIDIR = $(DESTDIR)/usr/share/efitools/efi DOCDIR = $(DESTDIR)/usr/share/efitools ifeq ($(ARCH),x86_64) - CFLAGS += -DEFI_FUNCTION_WRAPPER + CFLAGS_EFI += -DEFI_FUNCTION_WRAPPER endif %.efi: %.so @@ -33,7 +35,7 @@ endif -j .rela -j .reloc --target=$(FORMAT) $*.so $@ %.so: %.o - $(LD) $(LDFLAGS) $^ -o $@ $(LOADLIBES) + $(LD) $(LDFLAGS_EFI) $^ -o $@ $(LOADLIBES) # check we have no undefined symbols nm -D $@ | grep ' U ' && exit 1 || exit 0 @@ -47,13 +49,13 @@ endif ./cert-to-efi-sig-list -g $(MYGUID) $< $@ %.o: %.c - $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + $(CC) $(INCDIR) $(CFLAGS_EFI) $(CPPFLAGS_EFI) -c $< -o $@ %.efi.o: %.c - $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -fno-toplevel-reorder -DBUILD_EFI -c $< -o $@ + $(CC) $(INCDIR) $(CFLAGS_EFI) $(CPPFLAGS_EFI) -fno-toplevel-reorder -DBUILD_EFI -c $< -o $@ %.efi.s: %.c - $(CC) -S $(INCDIR) $(CFLAGS) $(CPPFLAGS) -fno-toplevel-reorder -DBUILD_EFI -c $< -o $@ + $(CC) -S $(INCDIR) $(CFLAGS_EFI) $(CPPFLAGS_EFI) -fno-toplevel-reorder -DBUILD_EFI -c $< -o $@ %.cer: %.crt diff --git a/Makefile b/Makefile index a39cafe..e3322f0 100644 --- a/Makefile +++ b/Makefile @@ -76,25 +76,25 @@ PreLoader.so: lib/lib-efi.a HelloWorld.so: lib/lib-efi.a cert-to-efi-sig-list: cert-to-efi-sig-list.o lib/lib.a - $(CC) -o $@ $< -lcrypto lib/lib.a + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) -lcrypto lib/lib.a sig-list-to-certs: sig-list-to-certs.o lib/lib.a - $(CC) -o $@ $< -lcrypto lib/lib.a + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) -lcrypto lib/lib.a sign-efi-sig-list: sign-efi-sig-list.o lib/lib.a - $(CC) -o $@ $< -lcrypto lib/lib.a + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) -lcrypto lib/lib.a hash-to-efi-sig-list: hash-to-efi-sig-list.o lib/lib.a - $(CC) -o $@ $< lib/lib.a + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) lib/lib.a efi-keytool: efi-keytool.o lib/lib.a - $(CC) -o $@ $< lib/lib.a + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) lib/lib.a efi-readvar: efi-readvar.o lib/lib.a - $(CC) -o $@ $< -lcrypto lib/lib.a + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) -lcrypto lib/lib.a efi-updatevar: efi-updatevar.o lib/lib.a - $(CC) -o $@ $< -lcrypto lib/lib.a + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) -lcrypto lib/lib.a clean: rm -f PK.* KEK.* DB.* $(EFIFILES) $(EFISIGNED) $(BINARIES) *.o *.so -- 1.8.3.2