From 77fe675d7566d9999a4de3485e20b52e4628e972 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Thu, 15 Feb 2018 18:38:19 -0800 Subject: gsctool: allow multiple source files With the upcoming extensions it would be beneficial to be able to keep gsctool functionality spread among multiple source files. The current Makefile is also not generating proper dependencies, which was fine when gsctool utility was first introduced, but is not adequate any more, and would be even more noticeable when more source files are added. In preparation let's just convert the build scheme into separately compiling .c files, generating .d files while at it, and then linking the .o files together in a separate link operation. BRANCH=none BUG=chromium:812880 TEST=verified that gsctool still builds fine and allows to update Cr50 image. Change-Id: I537bbe6bf76ac71e8d30040b276b78513d390bbf Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/923418 Reviewed-by: Randall Spangler --- extra/usb_updater/.gitignore | 2 ++ extra/usb_updater/Makefile | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'extra') diff --git a/extra/usb_updater/.gitignore b/extra/usb_updater/.gitignore index e356628d7d..870b0817e5 100644 --- a/extra/usb_updater/.gitignore +++ b/extra/usb_updater/.gitignore @@ -1,2 +1,4 @@ gsctool usb_updater2 +*.d +*.o diff --git a/extra/usb_updater/Makefile b/extra/usb_updater/Makefile index 49b8a1af2c..fedb959356 100644 --- a/extra/usb_updater/Makefile +++ b/extra/usb_updater/Makefile @@ -41,9 +41,16 @@ LIBS_common = -lfmap all: $(PROGRAMS) +GSCTOOL_SOURCES := gsctool.c +GSCTOOL_OBJS := $(patsubst %.c,%.o,$(GSCTOOL_SOURCES)) +DEPS := $(patsubst %.c,%.d,$(GSCTOOL_SOURCES)) + # chip/g updater -gsctool: gsctool.c Makefile - $(CC) $(CFLAGS) $(CFLAGS_g) $< $(LFLAGS) $(LIBS) $(LIBS_g) -o $@ +gsctool: $(GSCTOOL_OBJS) Makefile + $(CC) $(GSCTOOL_OBJS) $(LFLAGS) $(LIBS) $(LIBS_g) -o $@ + +%.o: %.c + $(CC) $(CFLAGS) $(CFLAGS_g) -c -MMD -MF $(basename $@).d -o $@ $< # common EC code USB updater usb_updater2: usb_updater2.c Makefile @@ -52,4 +59,6 @@ usb_updater2: usb_updater2.c Makefile .PHONY: clean clean: - rm -rf $(PROGRAMS) *~ + rm -rf $(PROGRAMS) *~ *.o *.d + +-include $(DEPS) -- cgit v1.2.1