summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mt5931/drv_wlan/rules.make
blob: 44b98711998fd7ac3df0aeb5872630c3b7a680dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# --------------------------------------------------------------------
# Copyright (c) 2007 MediaTek Inc.
#
# All rights reserved. Copying, compilation, modification, distribution
# or any other use whatsoever of this material is strictly prohibited
# except in accordance with a Software License Agreement with
# MediaTek Inc.
# --------------------------------------------------------------------

# --------------------------------------------------------------------
# This file contains rules which are shared between multiple Makefiles.
# --------------------------------------------------------------------

#
# False targets.
#
.PHONY: dummy

#
# Special variables which should not be exported
#
unexport O_TARGET
unexport obj-y
unexport subdir-y

comma   := ,


#
# Get things started.
#
first_rule: sub_dirs
	@$(MAKE) all_targets

SUB_DIRS	:= $(subdir-y)

#
# Common rules
#
%.o:	%.c
	@echo "  [CC]	$@"
	@$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<

all_targets: $(O_TARGET)

#
# Rule to compile a set of .o files into one .o file
#
ifdef O_TARGET
$(O_TARGET): $(obj-y)
	@rm -f $@
    ifneq "$(strip $(obj-y))" ""
	@$(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)
    else
	@$(AR) rcs $@
    endif
	@ ( \
	    echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
	    echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
	    echo 'endif' \
	) > $(dir $@)/.$(notdir $@).flags
endif # O_TARGET

#
# A rule to make subdirectories
#
subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
sub_dirs: dummy $(subdir-list)

ifdef SUB_DIRS
$(subdir-list) : dummy
	@$(MAKE) -C $(patsubst _subdir_%,%,$@)
endif


#
# A rule to do nothing
#
dummy:

#
# Find files whose flags have changed and force recompilation.
# For safety, this works in the converse direction:
#   every file is forced, except those whose flags are positively up-to-date.
#
FILES_FLAGS_UP_TO_DATE :=

# For use in expunging commas from flags, which mung our checking.
comma = ,

FILES_FLAGS_EXIST := $(wildcard .*.flags)
ifneq ($(FILES_FLAGS_EXIST),)
include $(FILES_FLAGS_EXIST)
endif

FILES_FLAGS_CHANGED := $(strip \
    $(filter-out $(FILES_FLAGS_UP_TO_DATE), \
	$(O_TARGET) \
	))

ifneq ($(FILES_FLAGS_CHANGED),)
$(FILES_FLAGS_CHANGED): dummy
endif