2015-03-06 00:38:03 +01:00
|
|
|
obj ?= .
|
2009-04-04 20:24:21 +02:00
|
|
|
|
2014-01-28 00:17:29 +01:00
|
|
|
HOSTCC ?= $(CC)
|
2009-09-14 15:29:27 +02:00
|
|
|
|
2015-04-26 21:41:41 +02:00
|
|
|
CFLAGS += -g3
|
2015-03-06 00:38:03 +01:00
|
|
|
CFLAGS += -std=c99 -Werror -Wall -Wextra
|
|
|
|
CFLAGS += -Wcast-qual -Wmissing-prototypes -Wredundant-decls -Wshadow
|
|
|
|
CFLAGS += -Wstrict-prototypes -Wwrite-strings
|
2015-02-26 20:47:19 +01:00
|
|
|
CPPFLAGS += -D_DEFAULT_SOURCE # memccpy() from string.h
|
2015-03-06 00:38:03 +01:00
|
|
|
CPPFLAGS += -D_POSIX_C_SOURCE=200809L # strdup() from string.h
|
2015-02-26 20:47:19 +01:00
|
|
|
CPPFLAGS += -Iflashmap
|
2015-05-03 09:35:32 +02:00
|
|
|
LDFLAGS += -g3
|
2009-05-26 14:22:10 +02:00
|
|
|
|
2015-03-06 00:38:03 +01:00
|
|
|
CBFSTOOL_BINARY:=$(obj)/cbfstool
|
|
|
|
CBFSTOOL_COMMON:=common.o cbfs_image.o compress.o fit.o
|
2014-03-07 22:11:53 +01:00
|
|
|
CBFSTOOL_COMMON+=elfheaders.o cbfs-mkstage.o cbfs-mkpayload.o xdr.o
|
2015-03-06 00:38:03 +01:00
|
|
|
CBFSTOOL_COMMON+=linux_trampoline.o cbfs-payload-linux.o
|
2012-10-30 22:02:45 +01:00
|
|
|
# LZMA
|
2014-03-07 22:11:53 +01:00
|
|
|
CBFSTOOL_COMMON+=lzma/lzma.o
|
|
|
|
CBFSTOOL_COMMON+=lzma/C/LzFind.o lzma/C/LzmaDec.o lzma/C/LzmaEnc.o
|
2009-04-04 20:24:21 +02:00
|
|
|
|
2014-03-07 22:11:53 +01:00
|
|
|
CBFSTOOL_COMMON:=$(addprefix $(obj)/,$(CBFSTOOL_COMMON))
|
2009-03-31 13:57:36 +02:00
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
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))
|
2014-03-07 22:11:53 +01:00
|
|
|
|
|
|
|
RMODTOOL_BINARY:=$(obj)/rmodtool
|
2015-03-06 00:38:03 +01:00
|
|
|
RMODTOOL_COMMON:=rmodule.o common.o elfheaders.o xdr.o
|
2014-03-07 22:11:53 +01:00
|
|
|
|
|
|
|
RMODTOOL_COMMON:=$(addprefix $(obj)/,$(RMODTOOL_COMMON))
|
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
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
|
|
|
|
|
2015-03-06 00:38:03 +01:00
|
|
|
.PHONY: all
|
2015-02-26 20:47:19 +01:00
|
|
|
all: .dependencies $(CBFSTOOL_BINARY) $(FMAPTOOL_BINARY) $(RMODTOOL_BINARY)
|
2012-08-16 01:02:52 +02:00
|
|
|
|
2015-03-06 00:38:03 +01:00
|
|
|
$(obj)/%: $(obj)/%.o
|
|
|
|
mkdir -p $(dir $@)
|
2015-05-03 09:35:32 +02:00
|
|
|
$(HOSTCC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
|
2009-09-14 15:29:27 +02:00
|
|
|
$(obj)/%.o: %.c
|
2015-03-06 00:38:03 +01:00
|
|
|
mkdir -p $(dir $@)
|
|
|
|
$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
2015-02-26 20:47:19 +01:00
|
|
|
%.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
|
2009-03-31 13:57:36 +02:00
|
|
|
|
2015-03-06 00:38:03 +01:00
|
|
|
.PHONY: clean
|
2009-09-14 15:29:27 +02:00
|
|
|
clean:
|
2015-03-06 00:38:03 +01:00
|
|
|
$(RM) $(CBFSTOOL_COMMON) $(CBFSTOOL_BINARY).o $(CBFSTOOL_BINARY)
|
2015-02-26 20:47:19 +01:00
|
|
|
$(RM) $(FMAPTOOL_COMMON) $(FMAPTOOL_BINARY).o $(FMAPTOOL_BINARY)
|
2015-03-06 00:38:03 +01:00
|
|
|
$(RM) $(RMODTOOL_COMMON) $(RMODTOOL_BINARY).o $(RMODTOOL_BINARY)
|
2015-02-26 20:47:19 +01:00
|
|
|
$(RM) $(FMAPTESTS_COMMON) $(FMAPTESTS_BINARY).o $(FMAPTESTS_BINARY)
|
2015-03-06 00:38:03 +01:00
|
|
|
.PHONY: distclean
|
|
|
|
distclean: clean
|
|
|
|
$(RM) .dependencies
|
2015-02-26 20:47:19 +01:00
|
|
|
.PHONY: maintainer-clean
|
|
|
|
maintainer-clean: distclean
|
|
|
|
$(RM) $(GENERATED)
|
2009-03-31 13:57:36 +02:00
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
tags: $(GENERATED)
|
2009-09-14 15:29:27 +02:00
|
|
|
ctags *.[ch]
|
2009-04-04 20:24:21 +02:00
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
.dependencies: $(GENERATED)
|
2015-03-06 00:38:03 +01:00
|
|
|
@$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -MM -MG *.c > $@
|
2015-02-26 20:47:19 +01:00
|
|
|
@$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -MM flashmap/*.c >> $@
|
2015-03-06 00:38:03 +01:00
|
|
|
@$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -MM lzma/*.c >> $@
|
|
|
|
@$(HOSTCC) $(CPPFLAGS) $(CFLAGS) -MM lzma/C/*.c >> $@
|
|
|
|
@sed -i 's|.*:.*|$$(obj)/&|' $@
|
2014-03-07 22:11:53 +01:00
|
|
|
|
2015-03-06 00:38:03 +01:00
|
|
|
$(CBFSTOOL_BINARY): $(CBFSTOOL_COMMON)
|
2015-02-26 20:47:19 +01:00
|
|
|
$(FMAPTOOL_BINARY): $(FMAPTOOL_COMMON)
|
2015-03-06 00:38:03 +01:00
|
|
|
$(RMODTOOL_BINARY): $(RMODTOOL_COMMON)
|
2012-08-16 01:02:52 +02:00
|
|
|
|
2015-02-26 20:47:19 +01:00
|
|
|
# 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
|
2015-03-06 00:38:03 +01:00
|
|
|
# Tolerate lzma sdk warnings
|
|
|
|
$(obj)/lzma/C/LzmaEnc.o: CFLAGS += -Wno-sign-compare -Wno-cast-qual
|
2012-08-16 01:02:52 +02:00
|
|
|
|
|
|
|
-include .dependencies
|