summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@google.com>2018-02-15 18:38:19 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-02-21 14:19:49 -0800
commit77fe675d7566d9999a4de3485e20b52e4628e972 (patch)
tree5edc6972fea6d2e5211ed877bebf1878ddce5746
parentecfb2877e48335493d62e26a5d494b0568a60e4e (diff)
downloadchrome-ec-77fe675d7566d9999a4de3485e20b52e4628e972.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>
-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)