44b98711998fd7ac3df0aeb5872630c3b7a680dd
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / mt5931_kk / drv_wlan / rules.make
1 # --------------------------------------------------------------------
2 # Copyright (c) 2007 MediaTek Inc.
3 #
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
7 # MediaTek Inc.
8 # --------------------------------------------------------------------
9
10 # --------------------------------------------------------------------
11 # This file contains rules which are shared between multiple Makefiles.
12 # --------------------------------------------------------------------
13
14 #
15 # False targets.
16 #
17 .PHONY: dummy
18
19 #
20 # Special variables which should not be exported
21 #
22 unexport O_TARGET
23 unexport obj-y
24 unexport subdir-y
25
26 comma   := ,
27
28
29 #
30 # Get things started.
31 #
32 first_rule: sub_dirs
33         @$(MAKE) all_targets
34
35 SUB_DIRS        := $(subdir-y)
36
37 #
38 # Common rules
39 #
40 %.o:    %.c
41         @echo "  [CC]   $@"
42         @$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
43
44 all_targets: $(O_TARGET)
45
46 #
47 # Rule to compile a set of .o files into one .o file
48 #
49 ifdef O_TARGET
50 $(O_TARGET): $(obj-y)
51         @rm -f $@
52     ifneq "$(strip $(obj-y))" ""
53         @$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)
54     else
55         @$(AR) rcs $@
56     endif
57         @ ( \
58             echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
59             echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
60             echo 'endif' \
61         ) > $(dir $@)/.$(notdir $@).flags
62 endif # O_TARGET
63
64 #
65 # A rule to make subdirectories
66 #
67 subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
68 sub_dirs: dummy $(subdir-list)
69
70 ifdef SUB_DIRS
71 $(subdir-list) : dummy
72         @$(MAKE) -C $(patsubst _subdir_%,%,$@)
73 endif
74
75
76 #
77 # A rule to do nothing
78 #
79 dummy:
80
81 #
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.
85 #
86 FILES_FLAGS_UP_TO_DATE :=
87
88 # For use in expunging commas from flags, which mung our checking.
89 comma = ,
90
91 FILES_FLAGS_EXIST := $(wildcard .*.flags)
92 ifneq ($(FILES_FLAGS_EXIST),)
93 include $(FILES_FLAGS_EXIST)
94 endif
95
96 FILES_FLAGS_CHANGED := $(strip \
97     $(filter-out $(FILES_FLAGS_UP_TO_DATE), \
98         $(O_TARGET) \
99         ))
100
101 ifneq ($(FILES_FLAGS_CHANGED),)
102 $(FILES_FLAGS_CHANGED): dummy
103 endif
104