]> git.saurik.com Git - apple/xnu.git/blob - makedefs/MakeInc.rule
fc63338f65685d60cf002da01145416cb085bf76
[apple/xnu.git] / makedefs / MakeInc.rule
1 #
2 # Generic Install rules
3 #
4
5 #
6 # gvdl: Let's optionally have a different list of local installs and
7 # regular installs.
8 #
9 ifndef INSTALL_MI_LCL_LIST
10 INSTALL_MI_LCL_LIST = $(INSTALL_MI_LIST)
11 endif
12
13 ifndef INSTALL_MI_LCL_GEN_LIST
14 INSTALL_MI_LCL_GEN_LIST = $(INSTALL_MI_GEN_LIST)
15 endif
16
17 ifndef INSTALL_MD_LCL_LIST
18 INSTALL_MD_LCL_LIST = $(INSTALL_MD_LIST)
19 endif
20
21 ifndef INSTALL_MD_LCL_GEN_LIST
22 INSTALL_MD_LCL_GEN_LIST = $(INSTALL_MD_GEN_LIST)
23 endif
24
25 ifeq ($(INCR_INSTALLHDRS), TRUE)
26
27 INSTALL_MI_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LIST))
28 INSTALL_MI_GEN_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_GEN_LIST))
29 INSTALL_MI_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_LIST))
30 INSTALL_MI_GEN_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_GEN_LIST))
31
32 $(INSTALL_MI_INC_FILES) $(INSTALL_MI_GEN_INC_FILES): $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/% : %
33 @true echo Installing $< in $(dir $@); \
34 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
35 filename=`$(BASENAME) $<`; \
36 filename_strip=$(addsuffix .strip,$${filename}); \
37 $(RM) $(RMFLAGS) $@; \
38 $(MKDIR) ./incdir; \
39 echo garbage > ./incdir/$${filename_strip}; \
40 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
41 $< > ./incdir/$${filename} || \
42 $(DECOMMENT) ./incdir/$${filename} r > \
43 ./incdir/$${filename_strip}; \
44 if [ -s ./incdir/$${filename_strip} ]; \
45 then ( \
46 install $(INSTALL_FLAGS) ./incdir/$${filename} $(dir $@);\
47 ); \
48 else \
49 echo Header file $< not exported; \
50 fi; \
51 $(RM) -rf ./incdir;
52
53 $(INSTALL_MI_LCL_FILES) $(INSTALL_MI_GEN_LCL_FILES): $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/% : %
54 @true echo Installing $< in $(dir $@); \
55 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
56 $(RM) $(RMFLAGS) $@; \
57 install $(INSTALL_FLAGS) $< $(dir $@);
58
59 INSTALL_MD_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LIST))
60 INSTALL_MD_GEN_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_GEN_LIST))
61 INSTALL_MD_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_LIST))
62 INSTALL_MD_GEN_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_GEN_LIST))
63
64 $(INSTALL_MD_INC_FILES) $(INSTALL_MD_GEN_INC_FILES): $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/% : %
65 @true echo Installing $< in $(dir $@); \
66 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
67 filename=`$(BASENAME) $<`; \
68 filename_strip=$(addsuffix .strip,$${filename}); \
69 $(RM) $(RMFLAGS) $@; \
70 $(MKDIR) ./incdir; \
71 echo garbage > ./incdir/$${filename_strip}; \
72 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
73 $< > ./incdir/$${filename} || \
74 $(DECOMMENT) ./incdir/$${filename} r > \
75 ./incdir/$${filename_strip}; \
76 if [ -s ./incdir/$${filename_strip} ]; \
77 then ( \
78 install $(INSTALL_FLAGS) ./incdir/$${filename} $(dir $@);\
79 ); \
80 else \
81 echo Header file $< not exported; \
82 fi; \
83 $(RM) -rf ./incdir;
84
85 $(INSTALL_MD_LCL_FILES) $(INSTALL_MD_GEN_LCL_FILES): $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/% : %
86 @true echo Installing $< in $(dir $@); \
87 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
88 $(RM) $(RMFLAGS) $@; \
89 install $(INSTALL_FLAGS) $< $(dir $@);
90
91 setup_installhdrs_mi:
92 @echo "[ $(SOURCE) ] make setup_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
93
94 do_installhdrs_mi: $(INSTALL_MI_INC_FILES) $(INSTALL_MI_GEN_INC_FILES) $(INSTALL_MI_LCL_FILES) $(INSTALL_MI_GEN_LCL_FILES)
95 @echo "[ $(SOURCE) ] make do_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
96
97 setup_installhdrs_md:
98 @echo "[ $(SOURCE) ] make setup_installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
99
100 do_installhdrs_md: $(INSTALL_MD_INC_FILES) $(INSTALL_MD_GEN_INC_FILES) $(INSTALL_MD_LCL_FILES) $(INSTALL_MD_GEN_LCL_FILES)
101 @echo "[ $(SOURCE) ] make do_installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
102
103 else
104
105 INSTALL_MI_INC_FILES = $(addprefix $(SOURCE), $(INSTALL_MI_LIST))
106 INSTALL_MI_GEN_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_GEN_LIST))
107
108 INSTALL_MI_LCL_FILES = $(addprefix $(SOURCE), $(INSTALL_MI_LCL_LIST))
109 INSTALL_MI_GEN_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_GEN_LIST))
110
111
112 $(INSTALL_MI_GEN_INC_FILES): $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/% : %
113 @true echo Installing $< in $(dir $@); \
114 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
115 filename=`$(BASENAME) $<`; \
116 filename_strip=$(addsuffix .strip,$${filename}); \
117 $(RM) $(RMFLAGS) $@; \
118 $(MKDIR) ./incdir; \
119 echo garbage > ./incdir/$${filename_strip}; \
120 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
121 $< > ./incdir/$${filename} || \
122 $(DECOMMENT) ./incdir/$${filename} r > \
123 ./incdir/$${filename_strip}; \
124 if [ -s ./incdir/$${filename_strip} ]; \
125 then ( \
126 install $(INSTALL_FLAGS) ./incdir/$${filename} $(dir $@);\
127 ); \
128 else \
129 echo Header file $< not exported; \
130 fi; \
131 $(RM) -rf ./incdir;
132
133 $(INSTALL_MI_GEN_LCL_FILES): $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/% : %
134 @true echo Installing $< in $(dir $@); \
135 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
136 $(RM) $(RMFLAGS) $@; \
137 install $(INSTALL_FLAGS) $< $(dir $@);
138
139 INSTALL_MD_INC_FILES = $(addprefix $(SOURCE), $(INSTALL_MD_LIST))
140 INSTALL_MD_GEN_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_GEN_LIST))
141
142 INSTALL_MD_LCL_FILES = $(addprefix $(SOURCE), $(INSTALL_MD_LCL_LIST))
143 INSTALL_MD_GEN_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_GEN_LIST))
144
145 $(INSTALL_MD_GEN_INC_FILES): $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/% : %
146 @true echo Installing $< in $(dir $@); \
147 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
148 filename=`$(BASENAME) $<`; \
149 filename_strip=$(addsuffix .strip,$${filename}); \
150 $(RM) $(RMFLAGS) $@; \
151 $(MKDIR) ./incdir; \
152 echo garbage > ./incdir/$${filename_strip}; \
153 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
154 $< > ./incdir/$${filename} || \
155 $(DECOMMENT) ./incdir/$${filename} r > \
156 ./incdir/$${filename_strip}; \
157 if [ -s ./incdir/$${filename_strip} ]; \
158 then ( \
159 install $(INSTALL_FLAGS) ./incdir/$${filename} $(dir $@);\
160 ); \
161 else \
162 echo Header file $< not exported; \
163 fi; \
164 $(RM) -rf /incdir;
165
166 $(INSTALL_MD_GEN_LCL_FILES): $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/% : %
167 @true echo Installing $< in $(dir $@); \
168 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
169 $(RM) $(RMFLAGS) $@; \
170 install $(INSTALL_FLAGS) $< $(dir $@);
171
172 setup_installhdrs_mi:
173 @echo "[ $(SOURCE) ] make setup_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
174
175 do_installhdrs_mi: $(INSTALL_MI_GEN_INC_FILES) $(INSTALL_MI_GEN_LCL_FILES)
176 @echo "[ $(SOURCE) ] make do_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
177 @if [ -n "$(strip $(INSTALL_MI_LIST))" ]; then \
178 if [ -d $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR) ]; then \
179 (cd $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR);$(RM) $(RMFLAGS) $(INSTALL_MI_LIST) ); \
180 else \
181 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
182 fi; \
183 $(MKDIR) ./incdir; \
184 for j in $(INSTALL_MI_LIST); \
185 do \
186 echo garbage > ./incdir/$$j.strip; \
187 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
188 $(SOURCE)/$$j > ./incdir/$$j || \
189 $(DECOMMENT) ./incdir/$$j r > \
190 ./incdir/$$j.strip; \
191 if [ -s ./incdir/$$j.strip ]; \
192 then ( \
193 install $(INSTALL_FLAGS) ./incdir/$$j $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
194 ); \
195 else \
196 echo Header file $$j not exported; \
197 fi; \
198 done; \
199 $(RM) -rf ./incdir; \
200 fi
201 @if [ -n "$(strip $(INSTALL_MI_LCL_LIST))" ]; then \
202 if [ -d $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR) ]; then \
203 (cd $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR);$(RM) $(RMFLAGS) $(INSTALL_MI_LCL_LIST) ); \
204 else \
205 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
206 fi; \
207 install $(INSTALL_FLAGS) $(INSTALL_MI_LCL_FILES) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
208 fi
209
210 setup_installhdrs_md:
211 @echo "[ $(SOURCE) ] make setup_installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
212
213 do_installhdrs_md: $(INSTALL_MD_GEN_INC_FILES) $(INSTALL_MD_GEN_LCL_FILES)
214 @echo "[ $(SOURCE) ] make do_installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
215 @if [ -n "$(strip $(INSTALL_MD_LIST))" ]; then \
216 if [ -d $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR) ]; then \
217 (cd $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR);$(RM) $(RMFLAGS) $(INSTALL_MD_LIST) ); \
218 else \
219 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
220 fi; \
221 $(MKDIR) ./incdir; \
222 for j in $(INSTALL_MD_LIST); \
223 do \
224 echo garbage > ./incdir/$$j.strip; \
225 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
226 $(SOURCE)/$$j > ./incdir/$$j || \
227 $(DECOMMENT) ./incdir/$$j r > \
228 ./incdir/$$j.strip; \
229 if [ -s ./incdir/$$j.strip ]; \
230 then ( \
231 install $(INSTALL_FLAGS) ./incdir/$$j $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
232 ); \
233 else \
234 echo Header file $$j not exported; \
235 fi; \
236 done; \
237 $(RM) -rf ./incdir; \
238 fi
239 @if [ -n "$(strip $(INSTALL_MD_LCL_LIST))" ]; then \
240 if [ -d $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR) ]; then \
241 (cd $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR);$(RM) $(RMFLAGS) $(INSTALL_MD_LCL_LIST) ); \
242 else \
243 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
244 fi; \
245 install $(INSTALL_FLAGS) $(INSTALL_MD_LCL_FILES) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
246 fi
247
248
249 endif
250
251 #
252 # Generic Export rules
253 #
254 ifeq ($(INCR_EXPORTHDRS), TRUE)
255
256 EXPORT_MI_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/, $(EXPORT_MI_LIST))
257 EXPORT_MI_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/, $(EXPORT_MI_GEN_LIST))
258
259 $(EXPORT_MI_INC_FILES) $(EXPORT_MI_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/% : %
260 @true echo Exporting $< in $(dir $@); \
261 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR); \
262 ${CP} -p $< $(dir $@); \
263
264
265 EXPORT_MD_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/, $(EXPORT_MD_LIST))
266 EXPORT_MD_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/, $(EXPORT_MD_GEN_LIST))
267
268 $(EXPORT_MD_INC_FILES) $(EXPORT_MD_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/% : %
269 @true echo Exporting $< in $(dir $@); \
270 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR); \
271 ${CP} -p $< $(dir $@); \
272
273 setup_exporthdrs_mi:
274 @echo "[ $(SOURCE) ] make setup_exporthdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
275
276 do_exporthdrs_mi: $(EXPORT_MI_INC_FILES) $(EXPORT_MI_GEN_INC_FILES)
277 @echo "[ $(SOURCE) ] make do_exporthdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
278
279 setup_exporthdrs_md:
280 @echo "[ $(SOURCE) ] make setup_exporthdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
281
282 do_exporthdrs_md: $(EXPORT_MD_INC_FILES) $(EXPORT_MD_GEN_INC_FILES)
283 @echo "[ $(SOURCE) ] make do_exporthdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
284
285 else
286
287 EXPORT_MI_INC_FILES = $(addprefix $(SOURCE), $(EXPORT_MI_LIST))
288 EXPORT_MI_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/, $(EXPORT_MI_GEN_LIST))
289
290 $(EXPORT_MI_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/% : %
291 @true echo Exporting $< in $(dir $@); \
292 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR); \
293 ${CP} -p $< $(dir $@); \
294
295
296 EXPORT_MD_INC_FILES = $(addprefix $(SOURCE), $(EXPORT_MD_LIST))
297 EXPORT_MD_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/, $(EXPORT_MD_GEN_LIST))
298
299 $(EXPORT_MD_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/% : %
300 @true echo Exporting $< in $(dir $@); \
301 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR); \
302 ${CP} -p $< $(dir $@); \
303
304 setup_exporthdrs_mi:
305 @echo "[ $(SOURCE) ] make setup_exporthdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
306
307 do_exporthdrs_mi: $(EXPORT_MI_GEN_INC_FILES)
308 @echo "[ $(SOURCE) ] make do_exporthdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
309 @if [ -n "$(strip $(EXPORT_MI_LIST))" ]; then \
310 if [ -d $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR) ]; then \
311 (cd $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR);$(RM) $(RMFLAGS) $(EXPORT_MI_LIST) ); \
312 else \
313 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR); \
314 fi; \
315 ${CP} -p $(EXPORT_MI_INC_FILES) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR); \
316 fi
317
318 setup_exporthdrs_md:
319 @echo "[ $(SOURCE) ] make setup_exporthdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
320
321 do_exporthdrs_md: $(EXPORT_MD_GEN_INC_FILES)
322 @echo "[ $(SOURCE) ] make do_exporthdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
323 @if [ -n "$(strip $(EXPORT_MD_LIST))" ]; then \
324 if [ -d $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR) ]; then \
325 (cd $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR);$(RM) $(RMFLAGS) $(EXPORT_MD_LIST) ); \
326 else \
327 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR); \
328 fi; \
329 ${CP} -p $(EXPORT_MD_INC_FILES) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR); \
330 fi
331
332
333 #
334 endif
335 #
336 # Generic Compilation rules
337 #
338
339 #
340 # Compilation rules to generate .o from .s
341 #
342 COMP_SOBJ_FILES = $(addprefix $(TARGET)$(COMP_OBJ_DIR), $(COMP_SOBJ_LIST))
343
344 $(COMP_SOBJ_FILES): $(TARGET)$(COMP_OBJ_DIR)%.o : %.s
345 ${S_KCC} -E -MD ${SFLAGS} -DASSEMBLER $(INCFLAGS) $< > $(patsubst %.o, %.pp, ${@});
346 sed '/^\#/d' $(patsubst %.o, %.pp, ${@}) > $(patsubst %.o, %.s, ${@});
347 ${S_KCC} ${SFLAGS} -m${ARCH_CONFIG_LC} ${_HOST_AS_FLAGS} -c $(patsubst %.o, %.s, ${@});
348 ${RM} ${_RMFLAGS_} $(patsubst %.o, %.pp, ${@}) $(patsubst %.o,%.s,${@});
349
350 S_RULE_1A=@ls /
351 S_RULE_1B= ${patsubst %.o,%.s,${@}} > /dev/null
352 S_RULE_2= ${S_KCC} -E -MD ${SFLAGS} -DASSEMBLER $(INCFLAGS) $< \
353 > $(patsubst %.o, %.pp, ${@}); \
354 sed '/^\#/d' $(patsubst %.o, %.pp, ${@}) > $(patsubst %.o, %.s, ${@});
355 S_RULE_3= ${S_KCC} ${SFLAGS} -m${ARCH_CONFIG_LC} ${_HOST_AS_FLAGS} -c $(patsubst %.o, %.s, ${@});\
356 ${RM} ${_RMFLAGS_} $(patsubst %.o, %.pp, ${@}) $(patsubst %.o,%.s,${@})
357
358 #
359 # Compilation rules to generate .o from .c
360 #
361 COMP_COBJ_FILES = $(addprefix $(TARGET)$(COMP_OBJ_DIR), $(COMP_COBJ_LIST))
362
363 $(COMP_COBJ_FILES): $(TARGET)$(COMP_OBJ_DIR)%.o : %.c
364 ${KCC} -c ${CFLAGS} -MD ${${join $@,_CFLAGS}} ${INCFLAGS} ${${join $@,_INCFLAGS}} $<
365
366 #
367 # Compilation rules to generate .o from .c for normal files
368 #
369 C_RULE_1A=${KCC} -c ${CFLAGS} -MD ${${join $@,_CFLAGS}} ${INCFLAGS} ${${join $@,_INCFLAGS}}
370 C_RULE_1B=$*.c
371 C_RULE_2=
372 C_RULE_3=
373 C_RULE_4=
374
375 #
376 # Compilation rules to generate .o from .c for driver files
377 #
378 C_RULE_1A_D=${C_RULE_1A}
379 C_RULE_1B_D=${C_RULE_1B}
380 C_RULE_2_D=${C_RULE_2}
381 C_RULE_3_D=${C_RULE_3}
382 C_RULE_4_D=${C_RULE_4}
383
384 #
385 # Compilation rules to generate .o from .m
386 #
387 M_RULE_1A=${KCC} -c ${CFLAGS} -MD ${${join $@,_CFLAGS}} ${INCFLAGS} ${${join $@,_INCFLAGS}}
388 M_RULE_1B=$*.m
389 M_RULE_2=
390 M_RULE_3=
391 M_RULE_4=
392
393 #
394 # Compilation rules to generate .co from .cp or .cpo from .cpp
395 # The config tool slickly changes the last source filename char to 'o'
396 # for the object filename.
397 #
398 P_RULE_1A=${KCC} -o $@ -c ${CPPFLAGS} ${CFLAGS} -MD ${${join $@,_CFLAGS}} ${INCFLAGS} ${${join $@,_INCFLAGS}}
399 P_RULE_1B=$(<F)
400 P_RULE_2=@sed 's/.o: /.cpo: /' $(@:.cpo=.d) > $(@:.cpo=.d~) && mv $(@:.cpo=.d~) $(@:.cpo=.d)
401 P_RULE_3=
402 P_RULE_4=
403
404 #
405 # Linker rule to generate a component
406 #
407 LD_COMPONENT_OBJ_FILES = $(addprefix $(TARGET)$(COMP_OBJ_DIR), $(LD_COMPONENT_OBJ_LIST))
408
409 COMPONENT_IMAGE_FILE = $(addprefix $(TARGET), $(COMPONENT_IMAGE))
410
411 $(COMPONENT_IMAGE_FILE): $(LD_COMPONENT_OBJ_FILES)
412 @echo "[ creating $(COMPONENT_IMAGE) ]"
413 $(LD) $(LDFLAGS_COMPONENT) -o $(COMPONENT_IMAGE_FILE) ${LD_COMPONENT_OBJ_FILES};
414 (cd $(TARGET)$(COMP_OBJ_DIR); ${MD} -u Makedep -f -d `ls *.d`);
415
416 setup_build_all:
417 @echo "[ $(SOURCE) ] make setup_build_all $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
418
419 do_build_all: $(COMP_FILES) $(COMP_COBJ_FILES) $(COMP_SOBJ_FILES) $(COMPONENT_IMAGE_FILE)
420 @echo "[ $(SOURCE) ] make do_build_all $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
421
422 ifeq ($(COMPONENT), .)
423 do_build_all: do_build_mach_kernel
424 endif
425
426 #
427 # mach_kernel building rules
428 #
429 do_build_mach_kernel:
430 @echo "[ building mach_kernel ]";
431 $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/kernel_newvers \
432 "`${CAT} $(SRCROOT)/osfmk/conf/kernelversion.major`" \
433 "`${CAT} $(SRCROOT)/osfmk/conf/kernelversion.minor`" \
434 "`${CAT} $(SRCROOT)/osfmk/conf/kernelversion.variant`"; \
435 ${KCC} $(CFLAGS) $(INCLUDES) -c kernel_vers.c; \
436 $(LD) $(LDFLAGS_KERNEL) $(addprefix $(TARGET)/,$(foreach component,$(COMPONENT_LIST), $(addprefix $(component)/$(firstword $($(addsuffix _KERNEL_CONFIG, $(component))) $(KERNEL_CONFIG))/, $(addsuffix .o, $(component))))) kernel_vers.o -o $(TARGET)/mach_kernel.sys $(LD_KERNEL_LIBS); \
437 $(STRIP) $(STRIP_FLAGS) $(TARGET)/mach_kernel.sys -o $(TARGET)/mach_kernel;
438 #
439 # Generic Install rules
440 #
441 INSTALL_FILE_FILES = $(addprefix $(DSTROOT)$(INSTALL_FILE_DIR), $(INSTALL_FILE_LIST))
442
443 force_file_install:
444
445 $(INSTALL_FILE_FILES): $(DSTROOT)$(INSTALL_FILE_DIR)% : $(TARGET)/% force_file_install
446 @echo Installing $< in $@;
447 @$(MKDIR) $(DSTROOT)$(INSTALL_FILE_DIR); \
448 if [ "`echo $(INSTALL_ARCHS_LC) | wc -w`" -eq 1 ]; then \
449 $(RM) $(RMFLAGS) $@; \
450 install $(INSTALL_FLAGS) $< $(dir $@); \
451 else \
452 if [ ! -e $@ ]; then \
453 echo >empty_file; \
454 lipo_arg="$(subst _empty_file, empty_file,$(foreach lipo_arch,$(INSTALL_ARCHS_LC), $(addprefix -arch , $(addsuffix _empty_file, $(lipo_arch)))))"; \
455 $(LIPO) $${lipo_arg} -create -output $@; \
456 $(RM) $(RMFLAGS) empty_file; \
457 fi; \
458 $(LIPO) $@ -replace $(ARCH_CONFIG_LC) $< -o $@; \
459 fi
460
461 INSTALL_FILESYS_FILES = $(addprefix $(SYMROOT)$(INSTALL_FILE_DIR), $(INSTALL_FILE_LIST))
462
463 force_filesys_install:
464
465 $(INSTALL_FILESYS_FILES): $(SYMROOT)$(INSTALL_FILE_DIR)% : $(TARGET)/%.sys force_filesys_install
466 @echo Installing $< in $@;
467 @$(MKDIR) $(SYMROOT)$(INSTALL_FILE_DIR); \
468 if [ "`echo $(INSTALL_ARCHS_LC) | wc -w`" -eq 1 ]; then \
469 $(RM) $(RMFLAGS) $@; \
470 install $(INSTALL_FLAGS) $< $(dir $@); \
471 else \
472 if [ ! -e $@ ]; then \
473 echo >empty_file; \
474 lipo_arg="$(subst _empty_file, empty_file,$(foreach lipo_arch,$(INSTALL_ARCHS_LC), $(addprefix -arch , $(addsuffix _empty_file, $(lipo_arch)))))"; \
475 $(LIPO) $${lipo_arg} -create -output $@; \
476 $(RM) $(RMFLAGS) empty_file; \
477 fi; \
478 $(LIPO) $@ -replace $(ARCH_CONFIG_LC) $< -o $@; \
479 fi
480
481 setup_build_install:
482 @echo "[ $(SOURCE) ] make setup_build_install $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
483
484 do_build_install: $(INSTALL_FILESYS_FILES) $(INSTALL_FILE_FILES)
485 @echo "[ $(SOURCE) ] make do_build_install $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
486
487 ifeq ($(INCL_MAKEDEP), TRUE)
488 -include Makedep
489 endif
490