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-03-14 01:19:42 +0000
commitf58c3776bc5bb66b907d2eb2a6b8aea06e4beedb (patch)
treea0cd4138253cf1bffe34b88d4151bfd0c8ad9b68
parentdea8458d610154787d49e9cc3847b07a5f09a457 (diff)
downloadchrome-ec-f58c3776bc5bb66b907d2eb2a6b8aea06e4beedb.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> (cherry picked from commit 77fe675d7566d9999a4de3485e20b52e4628e972) Reviewed-on: https://chromium-review.googlesource.com/961608
-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 34b257ef19..a12fcff75e 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)