-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdepend.make
151 lines (123 loc) · 4.58 KB
/
depend.make
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
##
# Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
#
# @APPLE_LICENSE_HEADER_START@
#
# The contents of this file constitute Original Code as defined in and
# are subject to the Apple Public Source License Version 1.1 (the
# "License"). You may not use this file except in compliance with the
# License. Please obtain a copy of the License at
# http://www.apple.com/publicsource and read it before using this file.
#
# This Original Code and all software distributed under the License are
# distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
# License for the specific language governing rights and limitations
# under the License.
#
# @APPLE_LICENSE_HEADER_END@
##
#
# depend.make
#
# Rules for updating dependencies
#
# PUBLIC TARGETS
# depend: builds individual dependency files and consolidates them into
# Makefile.dependencies.
#
# IMPORTED VARIABLES
# AUTOMATIC_DEPENDENCY_INFO: if YES, then the dependency file is
# updated every time the project is built. If NO, the dependency
# file is only built when the depend target is invoked.
# This flag is set to YES by Makefile.dependencies, so once you
# have done a make depend, the dependency file will always remain
# up to date.
# BEFORE_DEPEND: targets to build before building dependencies for a
# subproject
# AFTER_DEPEND: targets to build after building dependencies for a
# subproject
#
-include $(SFILE_DIR)/Makefile.dependencies
#
# Implicit rule that creates a dependency file from a source file
#
.SUFFIXES: .d .dd
.c.d:
$(UNDEPENDED_CC) $(ALL_CFLAGS) -MM $< > $(SFILE_DIR)/$(*F).d
.m.d:
$(UNDEPENDED_CC) $(ALL_MFLAGS) -MM $< > $(SFILE_DIR)/$(*F).d
.C.d .cc.d .cxx.d .cpp.d:
$(UNDEPENDED_CC) $(ALL_CCFLAGS) -MM $< > $(SFILE_DIR)/$(*F).d
.M.d:
$(UNDEPENDED_CC) $(ALL_MMFLAGS) -MM $< > $(SFILE_DIR)/$(*F).d
.d.dd:
$(SED) 's/\.o[ :][ :]*/.d : /' < $< > $(SFILE_DIR)/$(*F).dd
ifeq "YES" "$(AUTOMATIC_DEPENDENCY_INFO)"
AFTER_BUILD += update-dependencies
endif
.PHONY: local-build depend local-depend recursive-depend announce-depend \
update-dependencies recompute-dependencies remove-Makefile.dependencies
#
# Variable definitions
#
ACTUAL_DEPEND = recompute-dependencies
UNDEPENDED_CC := $(CC)
# By asking gcc to generate dependency info as it compiles, we avoid the
# need to do this explicitly using the .m.d rule above. This optimization
# only works if the .d file already exists when the build first kicks off.
# Thus, the .d file will require two compiler invocations the first time
# the file is compiled after a clean, but we can piggypack on the .o rule
# thereafter.
ifeq "YES" "$(AUTOMATIC_DEPENDENCY_INFO)"
CC = $(RM) -rf $(SFILE_DIR)/$*.d && DEPENDENCIES_OUTPUT=$(SFILE_DIR)/$*.d $(UNDEPENDED_CC)
endif
DFILES = $(CLASSES:.m=.d) $(MFILES:.m=.d) $(CFILES:.c=.d) $(CAPCFILES:.C=.d) $(CXXFILES:.cxx=.d) $(CPPFILES:.cpp=.d) $(CAPMFILES:.M=.d) $(CCFILES:.cc=.d)
DDFILES = $(DFILES:.d=.dd)
#
# First we update local dependencies, then we recurse.
#
depend: prebuild local-depend recursive-depend
recursive-depend: $(ALL_SUBPROJECTS:%=depend@%) local-depend
$(ALL_SUBPROJECTS:%=depend@%): local-depend
#
# Local dependencies update
#
local-depend: announce-depend $(BEFORE_DEPEND) $(ACTUAL_DEPEND) $(AFTER_DEPEND)
$(BEFORE_DEPEND): announce-depend
$(ACTUAL_DEPEND): announce-depend $(BEFORE_DEPEND)
$(AFTER_DEPEND): announce-depend $(BEFORE_DEPEND) $(ACTUAL_DEPEND)
#
# Before we do anything we must announce our intentions.
# We don't announce our intentions if we were hooked in from the
# post-depend recursion, since the post-depend has already been announced.
#
announce-depend:
ifndef RECURSING
$(SILENT) $(ECHO) Updating Makefile.dependencies...
else
$(SILENT) $(ECHO) $(RECURSIVE_ELLIPSIS)in $(NAME)
endif
#
# We may want to delete the old dependencies file before creating a new
# one in case some dependencies in the old file must be deleted.
#
recompute-dependencies: remove-Makefile.dependencies Makefile.dependencies
update-dependencies: Makefile.dependencies
#
# Remove Makefile dependencies
#
remove-Makefile.dependencies:
$(RM) -f $(SFILE_DIR)/Makefile.dependencies
remove-dependency-info:
$(CD) $(SFILE_DIR) && $(RM) -f $(DFILES) $(DDFILES)
#
# Update Makefile.dependencies
#
Makefile.dependencies: $(DFILES) $(DDFILES)
ifneq "$(words $(DFILES) $(DDFILES))" "0"
$(ECHO) AUTOMATIC_DEPENDENCY_INFO=YES > $(SFILE_DIR)/$(@F)
$(CAT) $(DFILES) $(DDFILES) | $(SED) /=/d >> $(SFILE_DIR)/$(@F)
endif