diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2011-12-07 18:58:43 +0000 |
---|---|---|
committer | Vincent Palatin <vpalatin@chromium.org> | 2011-12-07 19:10:02 +0000 |
commit | e24fa592d2a215d8ae67917c1d89e68cdf847a03 (patch) | |
tree | 47fbe4c55e7f4089cad7d619eded337da3bae999 /Makefile.rules | |
parent | 6396911897e4cd40f52636d710cee2865acf15e3 (diff) | |
download | chrome-ec-e24fa592d2a215d8ae67917c1d89e68cdf847a03.tar.gz |
Initial sources import 3/3
source files mainly done by Vincent.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Change-Id: Ic2d1becd400c9b4b4a14d4a243af1bdf77d9c1e2
Diffstat (limited to 'Makefile.rules')
-rw-r--r-- | Makefile.rules | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/Makefile.rules b/Makefile.rules new file mode 100644 index 0000000000..c60ba7034e --- /dev/null +++ b/Makefile.rules @@ -0,0 +1,91 @@ +# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Embedded Controller firmware build system - common targets +# + +objs := $(all-objs) +deps := $(objs:%.o=%.o.d) +all-utils := $(foreach u,$(util-bin),$(out)/util/$(u)) + +# Create output directories if necessary +_dir_create := $(foreach d,$(dirs),$(shell [ -d $(out)/$(d) ] || mkdir -p $(out)/$(d))) + +section = $(subst .,,$(suffix $(1))) + +# Decrease verbosity unless you pass V=1 +quiet = $(if $(V),,@echo ' $(2)' $(subst $(out)/,,$@) ; )$(cmd_$(1)) +silent = $(if $(V),,1>/dev/null) + +# commands to build all targets +cmd_lds = $(CPP) -P -C -MMD -MF $@.d -MT $@ $(CPPFLAGS) \ + -DSECTION=$(call section,$*) $< -o $@ +cmd_obj_to_bin = $(OBJCOPY) --gap-fill=0xff -O binary $^ $@ +cmd_flat_to_obj = $(CC) -T $(out)/firmware_image.lds -nostdlib $(CPPFLAGS) \ + -DPROJECT=$* -Wl,--build-id=none -o $@ $< +cmd_elf_to_flat = $(OBJCOPY) -O binary $^ $@ +cmd_elf_to_dis = $(OBJDUMP) -D $< > $@ +cmd_elf = $(LD) $(LDFLAGS) $(objs) -o $@ -T $< -Map $(out)/$*.map +cmd_c_to_o = $(CC) $(CFLAGS) -MMD -MF $@.d -c $< -o $@ +cmd_c_to_host = $(HOSTCC) $(HOST_CFLAGS) -MMD -MF $@.d $< -o $@ +cmd_qemu = ./util/run_qemu_test --image=build/$(BOARD)/$*/$*.bin test/$*.py $(silent) + + +.PHONY: all tests utils +all: $(out)/$(PROJECT).bin $(foreach s,A B RO,$(out)/$(PROJECT).$(s).dis) utils + +utils: $(all-utils) + +test-targets=$(foreach t,$(test-list),test-$(t)) +qemu-test-targets=$(foreach t,$(test-list),qemu-$(t)) +.PHONY: $(qemu-test-target) $(test-targets) + +$(test-targets): test-%: + @set -e ; \ + echo " BUILD $(out)/$*" ; \ + $(MAKE) -s BOARD=$(BOARD) PROJECT=$* out=$(out)/$* + +$(qemu-test-targets): qemu-%: test-% + $(call quiet,qemu,TEST ) + +tests: $(test-targets) +qemu-tests: $(qemu-test-targets) + +$(out)/firmware_image.lds: common/firmware_image.lds.S + $(call quiet,lds,LDS ) +$(out)/%.lds: chip/$(CHIP)/ec.lds.S + $(call quiet,lds,LDS ) + +$(out)/%.bin: $(out)/%.obj + $(call quiet,obj_to_bin,OBJCOPY) + +$(out)/%.obj: common/firmware_image.S $(out)/firmware_image.lds \ + $(out)/%.RO.flat $(out)/%.A.flat $(out)/%.B.flat + $(call quiet,flat_to_obj,CAT ) + +$(out)/%.dis: $(out)/%.elf + $(call quiet,elf_to_dis,OBJDUMP) + +$(out)/%.flat: $(out)/%.elf + $(call quiet,elf_to_flat,OBJCOPY) + +$(out)/%.elf: $(out)/%.lds $(objs) + $(call quiet,elf,LD ) + +$(out)/%.o:%.c + $(call quiet,c_to_o,CC ) + +$(out)/%.o:%.S + $(call quiet,c_to_o,AS ) + +$(all-utils): $(out)/%:%.c + $(call quiet,c_to_host,HOSTCC ) + +.PHONY: clean +clean: + -rm -rf $(out) + +.SECONDARY: + +-include $(deps) |