1 # --------------------------------------------------------------------
2 # Copyright (c) 2007 MediaTek Inc.
4 # All rights reserved. Copying, compilation, modification, distribution
5 # or any other use whatsoever of this material is strictly prohibited
6 # except in accordance with a Software License Agreement with
8 # --------------------------------------------------------------------
10 # --------------------------------------------------------------------
11 # This file contains rules which are shared between multiple Makefiles.
12 # --------------------------------------------------------------------
20 # Special variables which should not be exported
35 SUB_DIRS := $(subdir-y)
42 @$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
44 all_targets: $(O_TARGET)
47 # Rule to compile a set of .o files into one .o file
52 ifneq "$(strip $(obj-y))" ""
53 @$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)
58 echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
59 echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
61 ) > $(dir $@)/.$(notdir $@).flags
65 # A rule to make subdirectories
67 subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
68 sub_dirs: dummy $(subdir-list)
71 $(subdir-list) : dummy
72 @$(MAKE) -C $(patsubst _subdir_%,%,$@)
77 # A rule to do nothing
82 # Find files whose flags have changed and force recompilation.
83 # For safety, this works in the converse direction:
84 # every file is forced, except those whose flags are positively up-to-date.
86 FILES_FLAGS_UP_TO_DATE :=
88 # For use in expunging commas from flags, which mung our checking.
91 FILES_FLAGS_EXIST := $(wildcard .*.flags)
92 ifneq ($(FILES_FLAGS_EXIST),)
93 include $(FILES_FLAGS_EXIST)
96 FILES_FLAGS_CHANGED := $(strip \
97 $(filter-out $(FILES_FLAGS_UP_TO_DATE), \
101 ifneq ($(FILES_FLAGS_CHANGED),)
102 $(FILES_FLAGS_CHANGED): dummy