summaryrefslogtreecommitdiff
path: root/util/cbfstool/Makefile
diff options
context:
space:
mode:
authorSol Boucher <solb@chromium.org>2015-02-26 11:47:19 -0800
committerPatrick Georgi <pgeorgi@google.com>2015-05-08 19:55:42 +0200
commit69b88bf1276d2cb0309e2fc96df9d33a893138e3 (patch)
tree2dc297765cb1f858e5f2f6865481eeafdad8e897 /util/cbfstool/Makefile
parent5f7e4f019e258a49fff78e90509d1fda280fc147 (diff)
fmaptool: Introduce the fmd ("flashmap descriptor") language and compiler
This adds a compiler for a language whose textual representation of flashmap regions will be used to describe the layout of flash chips that contain more than just a single CBFS. Direct integration with cbfstool (via a new command-line switch for the create action) is forthcoming but will be added separately. BUG=chromium:461875 TEST=Use Chromium OS's cros_bundle_firmware script on the fmap.dts file for panther. Using the latter file as a reference, write a corresponding fmap.fmd file and feed it through fmaptool. Run both binary output files though the flashmap project's own flashmap_decode utility. Observe only the expected differences. BRANCH=None Change-Id: I06b32d138dbef0a4e5ed43c81bd31c796fd5d669 Signed-off-by: Sol Boucher <solb@chromium.org> Original-Commit-Id: 005ab67eb594e21489cf31036aedaea87e0c7142 Original-Change-Id: Ia08f28688efdbbfc70c255916b8eb7eb0eb07fb2 Original-Signed-off-by: Sol Boucher <solb@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/255031 Original-Reviewed-by: Julius Werner <jwerner@chromium.org> Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org> Reviewed-on: http://review.coreboot.org/9942 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util/cbfstool/Makefile')
-rw-r--r--util/cbfstool/Makefile42
1 files changed, 39 insertions, 3 deletions
diff --git a/util/cbfstool/Makefile b/util/cbfstool/Makefile
index 86338dbb10..2c63e05cb7 100644
--- a/util/cbfstool/Makefile
+++ b/util/cbfstool/Makefile
@@ -6,7 +6,9 @@ CFLAGS += -g3
CFLAGS += -std=c99 -Werror -Wall -Wextra
CFLAGS += -Wcast-qual -Wmissing-prototypes -Wredundant-decls -Wshadow
CFLAGS += -Wstrict-prototypes -Wwrite-strings
+CPPFLAGS += -D_DEFAULT_SOURCE # memccpy() from string.h
CPPFLAGS += -D_POSIX_C_SOURCE=200809L # strdup() from string.h
+CPPFLAGS += -Iflashmap
LDFLAGS += -g3
CBFSTOOL_BINARY:=$(obj)/cbfstool
@@ -19,14 +21,28 @@ CBFSTOOL_COMMON+=lzma/C/LzFind.o lzma/C/LzmaDec.o lzma/C/LzmaEnc.o
CBFSTOOL_COMMON:=$(addprefix $(obj)/,$(CBFSTOOL_COMMON))
+FMAPTOOL_BINARY:=$(obj)/fmaptool
+FMAPTOOL_COMMON:=fmap_from_fmd.o fmd.o fmd_parser.o fmd_scanner.o
+# FMAP
+FMAPTOOL_COMMON+=flashmap/fmap.o
+FMAPTOOL_COMMON+=flashmap/kv_pair.o flashmap/valstr.o
+
+FMAPTOOL_COMMON:=$(addprefix $(obj)/,$(FMAPTOOL_COMMON))
RMODTOOL_BINARY:=$(obj)/rmodtool
RMODTOOL_COMMON:=rmodule.o common.o elfheaders.o xdr.o
RMODTOOL_COMMON:=$(addprefix $(obj)/,$(RMODTOOL_COMMON))
+FMAPTESTS_BINARY:=$(obj)/flashmap_tests
+FMAPTESTS_COMMON:=flashmap/fmap.o flashmap/valstr.o flashmap/kv_pair.o
+
+FMAPTESTS_COMMON:=$(addprefix $(obj)/,$(FMAPTESTS_COMMON))
+
+GENERATED:=fmd_parser.c fmd_parser.h fmd_scanner.c fmd_scanner.h
+
.PHONY: all
-all: .dependencies $(CBFSTOOL_BINARY) $(RMODTOOL_BINARY)
+all: .dependencies $(CBFSTOOL_BINARY) $(FMAPTOOL_BINARY) $(RMODTOOL_BINARY)
$(obj)/%: $(obj)/%.o
mkdir -p $(dir $@)
@@ -34,27 +50,47 @@ $(obj)/%: $(obj)/%.o
$(obj)/%.o: %.c
mkdir -p $(dir $@)
$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+%.c %.h: %.l
+ $(LEX) $(LFLAGS) -t --header-file=$*.h $< >$*.c
+%.c %.h: %.y
+ $(YACC) $(YFLAGS) -d $<
+ mv -f y.tab.c $*.c
+ mv -f y.tab.h $*.h
.PHONY: clean
clean:
$(RM) $(CBFSTOOL_COMMON) $(CBFSTOOL_BINARY).o $(CBFSTOOL_BINARY)
+ $(RM) $(FMAPTOOL_COMMON) $(FMAPTOOL_BINARY).o $(FMAPTOOL_BINARY)
$(RM) $(RMODTOOL_COMMON) $(RMODTOOL_BINARY).o $(RMODTOOL_BINARY)
+ $(RM) $(FMAPTESTS_COMMON) $(FMAPTESTS_BINARY).o $(FMAPTESTS_BINARY)
.PHONY: distclean
distclean: clean
$(RM) .dependencies
+.PHONY: maintainer-clean
+maintainer-clean: distclean
+ $(RM) $(GENERATED)
-tags:
+tags: $(GENERATED)
ctags *.[ch]
-.dependencies:
+.dependencies: $(GENERATED)
@$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -MM -MG *.c > $@
+ @$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -MM flashmap/*.c >> $@
@$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -MM lzma/*.c >> $@
@$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -MM lzma/C/*.c >> $@
@sed -i 's|.*:.*|$$(obj)/&|' $@
$(CBFSTOOL_BINARY): $(CBFSTOOL_COMMON)
+$(FMAPTOOL_BINARY): $(FMAPTOOL_COMMON)
$(RMODTOOL_BINARY): $(RMODTOOL_COMMON)
+# This target must be built manually
+$(FMAPTESTS_BINARY): $(FMAPTESTS_COMMON)
+
+# Yacc source is superset of header
+$(obj)/fmd_parser.o: CFLAGS += -Wno-redundant-decls
+# Lex generates unneeded functions
+$(obj)/fmd_scanner.o: CFLAGS += -Wno-unused-function
# Tolerate lzma sdk warnings
$(obj)/lzma/C/LzmaEnc.o: CFLAGS += -Wno-sign-compare -Wno-cast-qual