nvramcui: Update Makefile

- Add all, clean and distclean to .PHONY
- Rebuild nvramcui.elf when the makefile changes.
- Update libpayload target to $(LIBPAYLOAD_DIR) target - these are the
same thing, but by using the variable it makes it more obvious.
- Remove .config.old as well as .config when running distclean.
- Add CFLAGS to the LPGCC command line:
-- Enable all warnings, set warnings as errors.
-- Optimize for size
-- Enable '-ffreestanding -nostdinc -nostdlib' to keep from building in
system functions and to fix the warning:
libpayload.h: warning: conflicting types for built-in function 'log2'
static inline int log2(u32 x) { return sizeof(x) * 8 - clz(x) - 1; }

Change-Id: Icc6c70b259cd7c22dc960cdb732927f9c0c93ee8
Signed-off-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://review.coreboot.org/14482
Tested-by: build bot (Jenkins)
Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Martin Roth 2016-04-23 17:19:41 -06:00
parent ba3d626cfb
commit 9d8b2ffb49
1 changed files with 8 additions and 6 deletions

View File

@ -3,10 +3,11 @@ XCOMPILE=$(LIBPAYLOAD_DIR)/libpayload.xcompile
# build libpayload and put .config file in $(CURDIR) instead of ../libpayload # build libpayload and put .config file in $(CURDIR) instead of ../libpayload
# to avoid pollute the libpayload source directory and possible conflicts # to avoid pollute the libpayload source directory and possible conflicts
LPOPTS=obj="$(CURDIR)/build" DESTDIR="$(CURDIR)" DOTCONFIG="$(CURDIR)/.config" LPOPTS=obj="$(CURDIR)/build" DESTDIR="$(CURDIR)" DOTCONFIG="$(CURDIR)/.config"
CFLAGS += -Wall -Werror -Os -ffreestanding -nostdinc -nostdlib
all: nvramcui.elf all: nvramcui.elf
libpayload: $(LIBPAYLOAD_DIR):
$(MAKE) -C ../libpayload $(LPOPTS) defconfig $(MAKE) -C ../libpayload $(LPOPTS) defconfig
$(MAKE) -C ../libpayload $(LPOPTS) $(MAKE) -C ../libpayload $(LPOPTS)
$(MAKE) -C ../libpayload $(LPOPTS) install $(MAKE) -C ../libpayload $(LPOPTS) install
@ -14,19 +15,20 @@ libpayload:
ifneq ($(strip $(wildcard libpayload)),) ifneq ($(strip $(wildcard libpayload)),)
include $(XCOMPILE) include $(XCOMPILE)
LPGCC = CC="$(GCC_CC_x86_32)" "$(LIBPAYLOAD_DIR)/bin/lpgcc" LPGCC = CC="$(GCC_CC_x86_32)" "$(LIBPAYLOAD_DIR)/bin/lpgcc"
%.elf: %.c %.elf: %.c Makefile
$(LPGCC) -o $*.elf $*.c $(LPGCC) $(CFLAGS) -o $*.elf $*.c
else else
# If libpayload is not found, first build libpayload, # If libpayload is not found, first build libpayload,
# then do the make, this time it'll find libpayload # then do the make, this time it'll find libpayload
# and generate the nvramcui.elf target # and generate the nvramcui.elf target
%.elf: libpayload %.elf: $(LIBPAYLOAD_DIR)
$(MAKE) all $(MAKE) all
endif endif
.PHONY:
clean: clean:
rm -f nvramcui.elf rm -f nvramcui.elf
distclean: clean distclean: clean
rm -rf build libpayload .config rm -rf build libpayload .config .config.old
.PHONY: all clean distclean