coreboot-kgpe-d16/util/cbfstool/Makefile

51 lines
1.3 KiB
Makefile
Raw Normal View History

obj ?= $(shell pwd)
HOSTCC ?= $(CC)
cbfs: fix issues with word size and endianness. Add XDR functions and use them to convert the ELF headers to native headers, using the Elf64 structs to ensure we accomodate all word sizes. Also, use these XDR functions for output. This may seem overly complex but it turned out to be much the easiest way to do this. Note that the basic elf parsing function in cbfs-mkstage.c now works over all ELF files, for all architectures, endian, and word size combinations. At the same time, the basic elf parsing in cbfs-mkstage.c is a loop that has no architecture-specific conditionals. Add -g to the LDFLAGS while we're here. It's on the CFLAGS so there is no harm done. This code has been tested on all chromebooks that use coreboot to date. I added most of the extra checks from ChromeOS and they triggered a lot of warnings, hence the other changes. I had to take -Wshadow back out due to the many errors it triggers in LZMA. BUG=None TEST=Build and boot for Peppy; works fine. Build and boot for nyan, works fine. Build for qemu targets and armv8 targets. BRANCH=None Change-Id: I5a4cee9854799189115ac701e22efc406a8d902f Signed-off-by: Ronald G. Minnich <rminnich@google.com> Reviewed-on: https://chromium-review.googlesource.com/178606 Reviewed-by: Ronald Minnich <rminnich@chromium.org> Commit-Queue: Ronald Minnich <rminnich@chromium.org> Tested-by: Ronald Minnich <rminnich@chromium.org> Reviewed-on: http://review.coreboot.org/4817 Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2013-12-03 20:13:35 +01:00
CFLAGS ?= -g
CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
CFLAGS += -Wstrict-aliasing -Wshadow -Werror
CBFSTOOL_BINARY:=$(obj)/cbfstool
CBFSTOOL_COMMON:=cbfstool.o common.o cbfs_image.o compress.o fit.o
CBFSTOOL_COMMON+=elfheaders.o cbfs-mkstage.o cbfs-mkpayload.o xdr.o
# LZMA
CBFSTOOL_COMMON+=lzma/lzma.o
CBFSTOOL_COMMON+=lzma/C/LzFind.o lzma/C/LzmaDec.o lzma/C/LzmaEnc.o
CBFSTOOL_COMMON+=linux_trampoline.o cbfs-payload-linux.o
CBFSTOOL_COMMON:=$(addprefix $(obj)/,$(CBFSTOOL_COMMON))
RMODTOOL_BINARY:=$(obj)/rmodtool
RMODTOOL_COMMON:=rmodtool.o rmodule.o common.o elfheaders.o xdr.o
RMODTOOL_COMMON:=$(addprefix $(obj)/,$(RMODTOOL_COMMON))
all: dep $(CBFSTOOL_BINARY) $(RMODTOOL_BINARY)
$(obj)/%.o: %.c
$(HOSTCC) $(CFLAGS) -c -o $@ $<
clean:
rm -f $(CBFSTOOL_COMMON) $(CBFSTOOL_BINARY)
rm -f $(RMODTOOL_COMMON) $(RMODTOOL_BINARY)
tags:
ctags *.[ch]
$(obj)/cbfstool:$(CBFSTOOL_COMMON)
$(HOSTCC) $(CFLAGS) -o $@ $^
$(obj)/rmodtool:$(RMODTOOL_COMMON)
$(HOSTCC) $(CFLAGS) -o $@ $^
dep:
@$(HOSTCC) $(CFLAGS) -MM *.c > .dependencies
@$(HOSTCC) $(CFLAGS) -MM lzma/*.c >> .dependencies
@$(HOSTCC) $(CFLAGS) -MM lzma/C/*.c >> .dependencies
-include .dependencies