summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2013-11-07 18:46:39 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-11-14 17:52:39 +0000
commit4b59746600936bfec377e19a01e5ccb90e6e1c48 (patch)
tree00c7d22cbfbef1580153a9f3d835141bb29181cb
parentd44932402ad99bfaeba3e3a6641e84595401df39 (diff)
downloadchrome-ec-4b59746600936bfec377e19a01e5ccb90e6e1c48.tar.gz
util: declare all host utils source dependencies in build.mk
Instead of hardcoding the common files for host utils in the generic rules, let's declare them in the build.mk file using the same system as the Linux kernel build. if a binary "foo" declared in "host-util-bin" or "build-util-bin" has a matching "foo-objs" variable, it will be build from all objects declared in "foo-objs" else it uses directly "foo.o" (single source file). This is preparatory to add new "build" tools sharing common sources. note: the dependencies on the utils are a bit less fine-grained as a result of this change, but given the low number of tools, that should be acceptable. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=./util/make_all.sh Change-Id: Ieffce7ca6f5b685ffb7d1f4626b99aff07b61443 Reviewed-on: https://chromium-review.googlesource.com/176174 Reviewed-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--Makefile.rules13
-rw-r--r--util/build.mk11
-rw-r--r--util/lock/build.mk2
3 files changed, 17 insertions, 9 deletions
diff --git a/Makefile.rules b/Makefile.rules
index 6360edcf3b..7c0af672d0 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -10,6 +10,8 @@ objs := $(all-y)
deps := $(objs:%.o=%.o.d)
build-utils := $(foreach u,$(build-util-bin),$(out)/util/$(u))
host-utils := $(foreach u,$(host-util-bin),$(out)/util/$(u))
+build-srcs := $(foreach u,$(build-util-bin),$(sort $($(u)-objs:%.o=util/%.c) util/$(u).c))
+host-srcs := $(foreach u,$(host-util-bin),$(sort $($(u)-objs:%.o=util/%.c) util/$(u).c))
# Create output directories if necessary
_dir_create := $(foreach d,$(dirs),$(shell [ -d $(out)/$(d) ] || \
@@ -37,8 +39,10 @@ cmd_elf = $(LD) $(LDFLAGS) $(objs) -o $@ -T $< -Map $(out)/$*.map
cmd_exe = $(CC) $(HOST_TEST_LDFLAGS) $(objs) -o $@
cmd_c_to_o = $(CC) $(CFLAGS) -MMD -MF $@.d -c $< -o $@
cmd_c_to_build = $(BUILDCC) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) \
- -MMD -MF $@.d $< -o $@
-cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d $(filter %.c, $^) -o $@
+ $(sort $(foreach c,$($(*F)-objs),util/$(c:%.o=%.c)) $*.c) \
+ -MMD -MF $@.d -o $@
+cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d -o $@ \
+ $(sort $(foreach c,$($(*F)-objs),util/$(c:%.o=%.c)) $*.c)
cmd_host_test = ./util/run_host_test $* $(silent)
cmd_version = ./util/getversion.sh > $@
cmd_mv_from_tmp = mv $(out)/$*.bin.tmp $(out)/$*.bin
@@ -153,11 +157,10 @@ $(out)/common/version.o: $(out)/ec_version.h
$(out)/ec_version.h: $(filter-out $(out)/common/version.o,$(objs))
$(call quiet,version,VERSION)
-$(build-utils): $(out)/%:%.c
+$(build-utils): $(out)/%:$(build-srcs)
$(call quiet,c_to_build,BUILDCC)
-$(host-utils): $(out)/%:%.c $(foreach u,$(host-util-common),util/$(u).c) \
- $(foreach u,$(util-lock-objs),util/lock/$(u).c)
+$(host-utils): $(out)/%:$(host-srcs)
$(call quiet,c_to_host,HOSTCC )
$(out)/util/burn_my_ec: $(out)/$(PROJECT).bin
diff --git a/util/build.mk b/util/build.mk
index e9922b4f24..29beb3ef75 100644
--- a/util/build.mk
+++ b/util/build.mk
@@ -7,10 +7,15 @@
#
host-util-bin=ectool lbplay burn_my_ec
-host-util-common=ectool_keyscan comm-host comm-dev misc_util ec_flash
+
+comm-objs=$(util-lock-objs:%=lock/%) comm-host.o comm-dev.o
ifeq ($(CONFIG_LPC),y)
-host-util-common+=comm-lpc
+comm-objs+=comm-lpc.o
else
-host-util-common+=comm-i2c
+comm-objs+=comm-i2c.o
endif
+ectool-objs=ectool.o ectool_keyscan.o misc_util.o ec_flash.o $(comm-objs)
+lbplay-objs=lbplay.o $(comm-objs)
+burn_my_ec-objs=ec_flash.o $(comm-objs) misc_util.o
+
build-util-bin=ec_uartd stm32mon iteflash
diff --git a/util/lock/build.mk b/util/lock/build.mk
index 1b74bc4cea..91987d4d43 100644
--- a/util/lock/build.mk
+++ b/util/lock/build.mk
@@ -6,4 +6,4 @@
# Lock library
#
-util-lock-objs=csem ipc_lock gec_lock
+util-lock-objs=csem.o ipc_lock.o gec_lock.o