summaryrefslogtreecommitdiff
path: root/util/cbfstool/Makefile
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@chromium.org>2015-09-16 16:34:15 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-09-17 07:41:02 +0000
commitae570d5cee7c8a416ad3887110f172763513e5a4 (patch)
treea886b32d3f4a1b95488d5709d2646dba802523b5 /util/cbfstool/Makefile
parentcdeb1c4f61b62cb161beb37d841757d3f764425d (diff)
cbfstool: deduplicate Makefiles
There's no need to maintain two lists of dependencies that need to be changed every. single. time. Change-Id: I26bb8c884e98afe74fd9df11464bcf88e130cd92 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/11674 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util/cbfstool/Makefile')
-rw-r--r--util/cbfstool/Makefile111
1 files changed, 12 insertions, 99 deletions
diff --git a/util/cbfstool/Makefile b/util/cbfstool/Makefile
index b6fb38cebb..e6d082cb07 100644
--- a/util/cbfstool/Makefile
+++ b/util/cbfstool/Makefile
@@ -1,107 +1,20 @@
-obj ?= .
+top ?= $(abspath ../..)
+objutil ?= $(top)/util
+obj ?= $(objutil)/cbfsutil
-HOSTCC ?= $(CC)
-
-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
-CBFSTOOL_COMMON:=common.o cbfs_image.o compress.o fit.o
-CBFSTOOL_COMMON+=elfheaders.o cbfs-mkstage.o cbfs-mkpayload.o xdr.o
-CBFSTOOL_COMMON+=partitioned_file.o linux_trampoline.o cbfs-payload-linux.o
-CBFSTOOL_COMMON+=rmodule.o
-# LZMA
-CBFSTOOL_COMMON+=lzma/lzma.o
-CBFSTOOL_COMMON+=lzma/C/LzFind.o lzma/C/LzmaDec.o lzma/C/LzmaEnc.o
-# FMAP
-CBFSTOOL_COMMON+=flashmap/fmap.o
-CBFSTOOL_COMMON+=flashmap/kv_pair.o flashmap/valstr.o
-
-CBFSTOOL_COMMON:=$(addprefix $(obj)/,$(CBFSTOOL_COMMON))
-
-FMAPTOOL_BINARY:=$(obj)/fmaptool
-FMAPTOOL_COMMON:=cbfs_sections.o fmap_from_fmd.o
-FMAPTOOL_COMMON+=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))
+CONFIG_FMD_GENPARSER := y
-GENERATED:=fmd_parser.c fmd_parser.h fmd_scanner.c fmd_scanner.h
+HOSTCC ?= $(CC)
.PHONY: all
-all: .dependencies $(CBFSTOOL_BINARY) $(FMAPTOOL_BINARY) $(RMODTOOL_BINARY)
-
-$(obj)/%: $(obj)/%.o
- mkdir -p $(dir $@)
- $(HOSTCC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
-$(obj)/%.o: %.c
- mkdir -p $(dir $@)
- $(HOSTCC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
-
-fmd_scanner.h: fmd_scanner.c
-fmd_scanner.c: fmd_scanner.l
- $(LEX) $(LFLAGS) -t --header-file=$*.h $< >$*.c
-
-fmd_parser.h: fmd_parser.c
-fmd_parser.c: fmd_parser.y
- $(YACC) $(YFLAGS) -d $<
- mv -f y.tab.c $*.c
- mv -f y.tab.h $*.h
+all: $(objutil)/cbfstool/cbfstool \
+ $(objutil)/cbfstool/fmaptool \
+ $(objutil)/cbfstool/rmodtool \
.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: $(GENERATED)
- ctags *.[ch]
-
-.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 and declarations
-$(obj)/fmd_scanner.o: CFLAGS += -Wno-redundant-decls
-$(obj)/fmd_scanner.o: CFLAGS += -Wno-unused-function
-# Tolerate lzma sdk warnings
-$(obj)/lzma/C/LzmaEnc.o: CFLAGS += -Wno-sign-compare -Wno-cast-qual
+ $(RM) $(objutil)/cbfstool/cbfstool $(cbfsobj)
+ $(RM) $(objutil)/cbfstool/fmaptool $(fmapobj)
+ $(RM) $(objutil)/cbfstool/rmodtool $(rmodobj)
--include .dependencies
+include Makefile.inc