summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@google.com>2018-02-15 18:38:19 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-12-05 00:35:43 +0000
commit27987233acb1b3029992cf46a0895288355db739 (patch)
treed46deed69605289d7a4c927b05c5796e2a2842ae
parentdc24a207cf88cf8655281d3792128ad66f08a8fd (diff)
downloadchrome-ec-27987233acb1b3029992cf46a0895288355db739.tar.gz
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 <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/923418 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/1358188 Reviewed-by: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com> Reviewed-by: Marco Chen <marcochen@chromium.org> Commit-Queue: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com> Tested-by: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com>
-rw-r--r--extra/usb_updater/.gitignore2
-rw-r--r--extra/usb_updater/Makefile15
2 files changed, 14 insertions, 3 deletions
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)