]> git.saurik.com Git - apple/xnu.git/blame - makedefs/MakeInc.rule
xnu-2422.110.17.tar.gz
[apple/xnu.git] / makedefs / MakeInc.rule
CommitLineData
39236c6e
A
1# -*- mode: makefile;-*-
2#
3# Copyright (C) 1999-2012 Apple Inc. All rights reserved.
4#
5# MakeInc.rule defines the targets and rules for
6# leaf directories once MakeInc.dir has recursed
7# into them. "do_XXX" may be double-colon rules
8# to allow the Makefile in the source directory
9# to augment the actions that will be performed.
10#
11
1c79356b
A
12#
13# Generic Install rules
14#
15
1c79356b
A
16ifndef INSTALL_MI_LCL_LIST
17 INSTALL_MI_LCL_LIST = $(INSTALL_MI_LIST)
18endif
19
20ifndef INSTALL_MI_LCL_GEN_LIST
21 INSTALL_MI_LCL_GEN_LIST = $(INSTALL_MI_GEN_LIST)
22endif
23
24ifndef INSTALL_MD_LCL_LIST
25 INSTALL_MD_LCL_LIST = $(INSTALL_MD_LIST)
26endif
27
28ifndef INSTALL_MD_LCL_GEN_LIST
29 INSTALL_MD_LCL_GEN_LIST = $(INSTALL_MD_GEN_LIST)
30endif
31
91447636
A
32ifndef INSTALL_KF_MI_LCL_LIST
33 INSTALL_KF_MI_LCL_LIST = $(EXPORT_MI_LIST)
34endif
1c79356b 35
91447636
A
36ifndef INSTALL_KF_MI_LCL_GEN_LIST
37 INSTALL_KF_MI_LCL_GEN_LIST = $(EXPORT_MI_GEN_LIST)
38endif
1c79356b 39
91447636
A
40ifndef INSTALL_KF_MD_LCL_LIST
41 INSTALL_KF_MD_LCL_LIST = $(EXPORT_MD_LIST)
42endif
1c79356b 43
91447636
A
44ifndef INSTALL_KF_MD_LCL_GEN_LIST
45 INSTALL_KF_MD_LCL_GEN_LIST = $(EXPORT_MD_GEN_LIST)
46endif
9bccf70c 47
91447636
A
48ifndef INSTALL_KF_MI_LIST
49 INSTALL_KF_MI_LIST = $(EXPORT_MI_LIST)
50endif
1c79356b 51
91447636
A
52ifndef INSTALL_KF_MI_GEN_LIST
53 INSTALL_KF_MI_GEN_LIST = $(EXPORT_MI_GEN_LIST)
54endif
9bccf70c 55
91447636
A
56ifndef INSTALL_KF_MD_LIST
57 INSTALL_KF_MD_LIST = $(EXPORT_MD_LIST)
58endif
9bccf70c 59
91447636
A
60ifndef INSTALL_KF_MD_GEN_LIST
61 INSTALL_KF_MD_GEN_LIST = $(EXPORT_MD_GEN_LIST)
62endif
63
39236c6e 64.PHONY: ALWAYS
2d21ac55 65
39236c6e 66ALWAYS:
91447636 67
39236c6e
A
68# $(1) is the list of install paths
69# $(2) is "1" if it's a "GEN"-style rule that looks locally, or else $(SOURCE)
70# $(3) is the local temp directory for processing
71# $(4) is the unifdef flags
72#
73# $$$$$$$$ is a double-escaped "$$" to represent the current pid
74# of the shell process for creating uniquely named temporary files
91447636 75
39236c6e 76define INSTALLHDRS_RULE_template
9bccf70c 77
39236c6e
A
78.PHONY: $(3)_MKDIR
79
80$(3)_MKDIR:
81 $$(_v)$$(MKDIR) ./$(3)
82 $$(_v)$$(MKDIR) $(dir $(firstword $(1)))
83
84$(1): $(dir $(firstword $(1)))% : $(if $(2),%,$$(SOURCE)/%) | $(3)_MKDIR
85 @echo INSTALLHDR $$*
86 $$(_v)$$(UNIFDEF) $(4) $$< > ./$(3)/$$*.unifdef.$$$$$$$$; \
87 if [ $$$$? -eq 2 ]; then \
88 echo Parse failure for $$<; \
89 exit 1; \
91447636 90 fi; \
39236c6e
A
91 $$(DECOMMENT) ./$(3)/$$*.unifdef.$$$$$$$$ r > \
92 ./$(3)/$$*.strip.$$$$$$$$ || exit 1; \
93 if [ -s ./$(3)/$$*.strip.$$$$$$$$ ]; then \
94 $$(INSTALL) $$(INSTALL_FLAGS) ./$(3)/$$*.unifdef.$$$$$$$$ $$@ || exit 1; \
91447636 95 fi; \
39236c6e
A
96 $$(RM) ./$(3)/$$*.unifdef.$$$$$$$$ ./$(3)/$$*.strip.$$$$$$$$
97endef
98
99#
100# Machine-independent (public) files
101#
102
103INSTALL_MI_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LIST))
104INSTALL_MI_INC_GEN_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_GEN_LIST))
105
106$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_MI_INC_FILES),,incmidir,$(SINCFRAME_UNIFDEF)))
107$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_MI_INC_GEN_FILES),1,incmigendir,$(SINCFRAME_UNIFDEF)))
1c79356b 108
39236c6e
A
109INSTALL_KF_MI_FILES = $(addprefix $(DSTROOT)/$(KINCDIR)/$(EXPORT_MI_DIR)/, $(INSTALL_KF_MI_LIST))
110INSTALL_KF_MI_GEN_FILES = $(addprefix $(DSTROOT)/$(KINCDIR)/$(EXPORT_MI_DIR)/, $(INSTALL_KF_MI_GEN_LIST))
111
112$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_KF_MI_FILES),,kincmidir,$(KINCFRAME_UNIFDEF)))
113$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_KF_MI_GEN_FILES),1,kincmigendir,$(KINCFRAME_UNIFDEF)))
1c79356b
A
114
115#
39236c6e 116# Machine-independent local (private) files
1c79356b 117#
1c79356b 118
39236c6e
A
119INSTALL_MI_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_LIST))
120INSTALL_MI_LCL_GEN_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_GEN_LIST))
1c79356b 121
39236c6e
A
122$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_MI_LCL_FILES),,pincmidir,$(SPINCFRAME_UNIFDEF)))
123$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_MI_LCL_GEN_FILES),1,pincmigendir,$(SPINCFRAME_UNIFDEF)))
1c79356b 124
39236c6e
A
125INSTALL_KF_MI_LCL_FILES = $(addprefix $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MI_DIR)/, $(INSTALL_KF_MI_LCL_LIST))
126INSTALL_KF_MI_LCL_GEN_FILES = $(addprefix $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MI_DIR)/, $(INSTALL_KF_MI_LCL_GEN_LIST))
1c79356b 127
39236c6e
A
128$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_KF_MI_LCL_FILES),,kpincmidir,$(KPINCFRAME_UNIFDEF)))
129$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_KF_MI_LCL_GEN_FILES),1,kpincmigendir,$(KPINCFRAME_UNIFDEF)))
1c79356b 130
39236c6e
A
131#
132# Machine-dependent (public) files
133#
1c79356b 134
39236c6e
A
135INSTALL_MD_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LIST))
136INSTALL_MD_INC_GEN_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_GEN_LIST))
1c79356b 137
39236c6e
A
138$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_MD_INC_FILES),,incdir,$(SINCFRAME_UNIFDEF)))
139$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_MD_INC_GEN_FILES),1,incgendir,$(SINCFRAME_UNIFDEF)))
1c79356b 140
39236c6e
A
141INSTALL_KF_MD_FILES = $(addprefix $(DSTROOT)/$(KINCDIR)/$(EXPORT_MD_DIR)/, $(INSTALL_KF_MD_LIST))
142INSTALL_KF_MD_GEN_FILES = $(addprefix $(DSTROOT)/$(KINCDIR)/$(EXPORT_MD_DIR)/, $(INSTALL_KF_MD_GEN_LIST))
1c79356b 143
39236c6e
A
144$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_KF_MD_FILES),,kincdir,$(KINCFRAME_UNIFDEF)))
145$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_KF_MD_GEN_FILES),1,kincgendir,$(KINCFRAME_UNIFDEF)))
1c79356b 146
39236c6e
A
147#
148# Machine-dependent local (private) files
149#
150
151INSTALL_MD_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_LIST))
152INSTALL_MD_LCL_GEN_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_GEN_LIST))
153
154$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_MD_LCL_FILES),,pincdir,$(SPINCFRAME_UNIFDEF)))
155$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_MD_LCL_GEN_FILES),1,pincgendir,$(SPINCFRAME_UNIFDEF)))
156
157INSTALL_KF_MD_LCL_FILES = $(addprefix $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MD_DIR)/, $(INSTALL_KF_MD_LCL_LIST))
158INSTALL_KF_MD_LCL_GEN_FILES = $(addprefix $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MD_DIR)/, $(INSTALL_KF_MD_LCL_GEN_LIST))
159
160$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_KF_MD_LCL_FILES),,kpincdir,$(KPINCFRAME_UNIFDEF)))
161$(eval $(call INSTALLHDRS_RULE_template,$(INSTALL_KF_MD_LCL_GEN_FILES),1,kpincgendir,$(KPINCFRAME_UNIFDEF)))
1c79356b 162
39236c6e
A
163.PHONY: do_installhdrs_mi
164
165# Double-colon rule so that MakeInc.kernel can add custom behaviors
166do_installhdrs_mi:: $(INSTALL_MI_INC_FILES) $(INSTALL_MI_INC_GEN_FILES) $(INSTALL_KF_MI_FILES) $(INSTALL_KF_MI_GEN_FILES) \
167 $(INSTALL_MI_LCL_FILES) $(INSTALL_MI_LCL_GEN_FILES) $(INSTALL_KF_MI_LCL_FILES) $(INSTALL_KF_MI_LCL_GEN_FILES)
168 @:
169
170.PHONY: do_installhdrs_md
171
172do_installhdrs_md: $(INSTALL_MD_INC_FILES) $(INSTALL_MD_INC_GEN_FILES) $(INSTALL_KF_MD_FILES) $(INSTALL_KF_MD_GEN_FILES) \
173 $(INSTALL_MD_LCL_FILES) $(INSTALL_MD_LCL_GEN_FILES) $(INSTALL_KF_MD_LCL_FILES) $(INSTALL_KF_MD_LCL_GEN_FILES)
174 @:
175
176#
177# Generic Export rules
178#
179EXPORT_MI_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/, $(EXPORT_MI_LIST))
1c79356b
A
180EXPORT_MI_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/, $(EXPORT_MI_GEN_LIST))
181
39236c6e 182.PHONY: EXP_MI_INC_DIR
1c79356b 183
39236c6e
A
184EXP_MI_INC_DIR:
185 $(_v)$(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)
1c79356b 186
39236c6e
A
187$(EXPORT_MI_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/% : % | EXP_MI_INC_DIR
188 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
189
190$(EXPORT_MI_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/% : $(SOURCE)/% | EXP_MI_INC_DIR
191 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
192
193EXPORT_MD_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/, $(EXPORT_MD_LIST))
1c79356b
A
194EXPORT_MD_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/, $(EXPORT_MD_GEN_LIST))
195
39236c6e 196.PHONY: EXP_MD_INC_DIR
1c79356b 197
39236c6e
A
198EXP_MD_INC_DIR:
199 $(_v)$(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)
200
201$(EXPORT_MD_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/% : % | EXP_MD_INC_DIR
202 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
203
204$(EXPORT_MD_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/% : $(SOURCE)/% | EXP_MD_INC_DIR
205 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
206
207.PHONY: do_exporthdrs_mi
208
209do_exporthdrs_mi: $(EXPORT_MI_GEN_INC_FILES) $(EXPORT_MI_INC_FILES)
210 @:
211
212.PHONY: do_exporthdrs_md
213
214do_exporthdrs_md: $(EXPORT_MD_GEN_INC_FILES) $(EXPORT_MD_INC_FILES)
215 @:
1c79356b 216
1c79356b
A
217#
218# Generic Compilation rules
219#
220
221#
222# Compilation rules to generate .o from .s
223#
2d21ac55 224
39236c6e
A
225S_RULE_0=@echo AS $@
226S_RULE_1A=$(_v)${S_KCC} -c ${SFLAGS} -MD -MF $(@:o=d) -MP -DASSEMBLER ${$@_SFLAGS_ADD} ${INCFLAGS} ${$@_INCFLAGS}
227S_RULE_1B=$(<F)
228S_RULE_2=
1c79356b
A
229
230#
231# Compilation rules to generate .o from .c for normal files
39236c6e
A
232#
233C_RULE_0=@echo CC $@
234C_RULE_1A=$(_v)${KCC} -c ${filter-out ${$@_CFLAGS_RM}, ${CFLAGS} ${CWARNFLAGS}} -MD -MF $(@:o=d) -MP ${$@_CFLAGS_ADD} ${$@_CWARNFLAGS_ADD} ${INCFLAGS} ${$@_INCFLAGS}
235C_RULE_1B=$(<F)
6d2010ae 236ifeq ($(BUILD_MACHO_OBJ),0)
39236c6e
A
237C_RULE_2=
238else ifeq ($(DO_CTFCONVERT),1)
239C_RULE_2=$(_v)if [ -z "${$@_SKIP_CTFCONVERT}" ]; then ${CTFCONVERT} -l xnu -v -o $@.ctf $@ > /dev/null || true; fi
2d21ac55 240else
39236c6e 241C_RULE_2=
316670eb 242endif
39236c6e
A
243ifeq ($(DO_CTFMACHO), 1)
244C_CTFRULE_1A=${C_RULE_1A} -o $@.non_lto $(CFLAGS_NOLTO_FLAG)
245C_CTFRULE_1B=$(<F)
246C_CTFRULE_2=$(_v)if [ -z "${$@_SKIP_CTFCONVERT}" ]; then ${CTFCONVERT} -l xnu -v -o $@.non_lto.ctf $@.non_lto > /dev/null || true; fi
247else
248C_CTFRULE_1A=@true
249C_CTFRULE_1B=
250C_CTFRULE_2=@true
316670eb
A
251endif
252
1c79356b
A
253#
254# Compilation rules to generate .o from .c for driver files
255#
39236c6e 256C_RULE_0_D=${C_RULE_0}
1c79356b
A
257C_RULE_1A_D=${C_RULE_1A}
258C_RULE_1B_D=${C_RULE_1B}
259C_RULE_2_D=${C_RULE_2}
39236c6e
A
260C_CTFRULE_1A_D=${C_CTFRULE_1A}
261C_CTFRULE_1B_D=${C_CTFRULE_1B}
262C_CTFRULE_2_D=${C_CTFRULE_2}
1c79356b 263
1c79356b
A
264#
265# Compilation rules to generate .co from .cp or .cpo from .cpp
266# The config tool slickly changes the last source filename char to 'o'
267# for the object filename.
39236c6e
A
268P_RULE_0=@echo C++ $@
269P_RULE_1A=$(_v)${KC++} -o $@ -c ${CXXFLAGS} ${filter-out ${$@_CFLAGS_RM}, ${CFLAGS} ${CXXWARNFLAGS}} -MD -MF $(@:o=d) -MP ${$@_CFLAGS_ADD} ${$@_CXXWARNFLAGS_ADD} ${INCFLAGS} ${$@_INCFLAGS}
1c79356b 270P_RULE_1B=$(<F)
39236c6e
A
271P_RULE_2=
272P_CTFRULE_1A=@true
273P_CTFRULE_1B=
274P_CTFRULE_2=@true
1c79356b 275
1c79356b 276
39236c6e 277.PHONY: do_build_all
1c79356b 278
39236c6e
A
279# Do-nothing rule, since not all levels of the recursive hierarchy might implement this
280# in their local Makefiles. Those that do will use a "::" rule to augment this.
281do_build_all::
282 @:
1c79356b 283
39236c6e 284.PHONY: do_build_install_primary
2d21ac55 285
39236c6e
A
286# Do-nothing rule, since not all levels of the recursive hierarchy might implement this
287# in their local Makefiles. Those that do will use a "::" rule to augment this.
288do_build_install_primary::
289 @:
2d21ac55 290
39236c6e 291.PHONY: do_build_install_non_primary
2d21ac55 292
39236c6e
A
293# Do-nothing rule, since not all levels of the recursive hierarchy might implement this
294# in their local Makefiles. Those that do will use a "::" rule to augment this.
295do_build_install_non_primary::
296 @:
1c79356b 297
39236c6e 298INSTALL_MAN_FILES = $(addprefix $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR)/, $(INSTALL_MAN_LIST))
1c79356b 299
39236c6e 300.PHONY: INSTALL_MAN_DIR
1c79356b 301
39236c6e
A
302INSTALL_MAN_DIR:
303 $(_v)$(MKDIR) $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR)
9bccf70c 304
39236c6e
A
305$(INSTALL_MAN_FILES): $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR)/% : % | INSTALL_MAN_DIR
306 @echo MAN $*
307 $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
308
309define MAN_LINKS_RULE_template
310$$(DSTROOT)/$$(MANDIR)/$$(INSTALL_MAN_DIR)/$(2): $$(DSTROOT)/$$(MANDIR)/$$(INSTALL_MAN_DIR)/$(1)
311 @echo MANLINK $(2)
312 $(_v)ln -f $$< $$@
313endef
314
315function_generate_man_links_rules = $(if $(word 1,$(1)),$(eval $(call MAN_LINKS_RULE_template,$(word 1,$(1)),$(word 2,$(1)))) $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR)/$(word 2,$(1)) $(call function_generate_man_links_rules,$(wordlist 3,$(words $(1)),$(1))))
316
317INSTALL_MAN_FILES_LINKS = $(call function_generate_man_links_rules,$(INSTALL_MAN_LINKS))
318
319.PHONY: do_installman
320
321do_installman: $(INSTALL_MAN_FILES) $(INSTALL_MAN_FILES_LINKS)
322 @:
1c79356b 323
39236c6e
A
324.PHONY: do_build_setup
325
326# Do-nothing rule, since not all levels of the recursive hierarchy might implement this
327# in their local Makefiles. Those that do will use a "::" rule to augment this.
328do_build_setup::
329 @:
330
331.PHONY: do_config_all
332
333# Do-nothing rule, since not all levels of the recursive hierarchy might implement this
334# in their local Makefiles. Those that do will use a "::" rule to augment this.
335do_config_all::
336 @:
337
338-include Makedep
b0d623f7 339
2d21ac55 340# vim: set ft=make: