]> git.saurik.com Git - apple/xnu.git/blob - makedefs/MakeInc.rule
xnu-517.7.21.tar.gz
[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 #
28 # These are the machine independent headers that end up in /usr/include
29 # Eventually they're copied to System framework's headers directory
30 #
31 INSTALL_MI_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LIST))
32 INSTALL_MI_GEN_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_GEN_LIST))
33
34 $(INSTALL_MI_INC_FILES) $(INSTALL_MI_GEN_INC_FILES): $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/% : %
35 @true echo Installing $< in $(dir $@); \
36 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
37 filename=`$(BASENAME) $<`; \
38 filename_strip=$(addsuffix .strip,$${filename}); \
39 $(RM) $(RMFLAGS) $@; \
40 $(MKDIR) ./incdir; \
41 echo garbage > ./incdir/$${filename_strip}; \
42 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
43 $< > ./incdir/$${filename} || \
44 $(DECOMMENT) ./incdir/$${filename} r > \
45 ./incdir/$${filename_strip}; \
46 if [ -s ./incdir/$${filename_strip} ]; \
47 then ( \
48 install $(INSTALL_FLAGS) ./incdir/$${filename} $(dir $@);\
49 ); \
50 else \
51 echo Header file $< not exported; \
52 fi; \
53 $(RM) -rf ./incdir;
54
55 #
56 # These are usually machine independent System framework private headers
57 # Unless LCLDIR is specified as something else
58 #
59 INSTALL_MI_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_LIST))
60 INSTALL_MI_GEN_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_GEN_LIST))
61
62 $(INSTALL_MI_LCL_FILES) $(INSTALL_MI_GEN_LCL_FILES): $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/% : %
63 @true echo Installing $< in $(dir $@); \
64 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
65 $(RM) $(RMFLAGS) $@; \
66 install $(INSTALL_FLAGS) $< $(dir $@);
67
68 #
69 # These are the Kernel framework's machine independent private headers
70 # They should be specified in INSTALL_MI_LCL_KERN_LIST and INSTALL_MI_LCL_GEN_KERN_LIST
71 #
72 INSTALL_MI_LCL_KERN_FILES = $(addprefix $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_KERN_LIST))
73 INSTALL_MI_GEN_LCL_KERN_FILES = $(addprefix $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_GEN_KERN_LIST))
74
75 $(INSTALL_MI_LCL_KERN_FILES) $(INSTALL_MI_GEN_LCL_KERN_FILES): $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR)/% : %
76 @true echo Installing $< in $(dir $@); \
77 $(MKDIR) $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR); \
78 $(RM) $(RMFLAGS) $@; \
79 install $(INSTALL_FLAGS) $< $(dir $@);
80
81 #
82 # These are the machine dependent headers that end up in /usr/include
83 # Eventually they're copied to System framework's headers directory
84 #
85 INSTALL_MD_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LIST))
86 INSTALL_MD_GEN_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_GEN_LIST))
87
88 $(INSTALL_MD_INC_FILES) $(INSTALL_MD_GEN_INC_FILES): $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/% : %
89 @true echo Installing $< in $(dir $@); \
90 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
91 filename=`$(BASENAME) $<`; \
92 filename_strip=$(addsuffix .strip,$${filename}); \
93 $(RM) $(RMFLAGS) $@; \
94 $(MKDIR) ./incdir; \
95 echo garbage > ./incdir/$${filename_strip}; \
96 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
97 $< > ./incdir/$${filename} || \
98 $(DECOMMENT) ./incdir/$${filename} r > \
99 ./incdir/$${filename_strip}; \
100 if [ -s ./incdir/$${filename_strip} ]; \
101 then ( \
102 install $(INSTALL_FLAGS) ./incdir/$${filename} $(dir $@);\
103 ); \
104 else \
105 echo Header file $< not exported; \
106 fi; \
107 $(RM) -rf ./incdir;
108
109 #
110 # These are usually machine dependent System framework private headers
111 # Unless LCLDIR is specified as something else
112 #
113 INSTALL_MD_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_LIST))
114 INSTALL_MD_GEN_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_GEN_LIST))
115
116 $(INSTALL_MD_LCL_FILES) $(INSTALL_MD_GEN_LCL_FILES): $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/% : %
117 @true echo Installing $< in $(dir $@); \
118 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
119 $(RM) $(RMFLAGS) $@; \
120 install $(INSTALL_FLAGS) $< $(dir $@);
121
122 #
123 # These are the Kernel framework's machine dependent private headers
124 # They should be specified in INSTALL_MD_LCL_KERN_LIST and INSTALL_MD_LCL_GEN_KERN_LIST
125 #
126 INSTALL_MD_LCL_KERN_FILES = $(addprefix $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_KERN_LIST))
127 INSTALL_MD_GEN_LCL_KERN_FILES = $(addprefix $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_GEN_KERN_LIST))
128
129 $(INSTALL_MD_LCL_KERN_FILES) $(INSTALL_MD_GEN_LCL_KERN_FILES): $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR)/% : %
130 @true echo Installing $< in $(dir $@); \
131 $(MKDIR) $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR); \
132 $(RM) $(RMFLAGS) $@; \
133 install $(INSTALL_FLAGS) $< $(dir $@);
134
135 setup_installhdrs_mi:
136 @echo "[ $(SOURCE) ] make setup_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
137
138 do_installhdrs_mi: $(INSTALL_MI_INC_FILES) $(INSTALL_MI_GEN_INC_FILES) $(INSTALL_MI_LCL_FILES) $(INSTALL_MI_GEN_LCL_FILES) $(INSTALL_MI_LCL_KERN_FILES) $(INSTALL_MI_GEN_LCL_KERN_FILES)
139 @true echo "[ $(SOURCE) ] make do_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
140
141 setup_installhdrs_md:
142 @echo "[ $(SOURCE) ] make setup_installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
143
144 do_installhdrs_md: $(INSTALL_MD_INC_FILES) $(INSTALL_MD_GEN_INC_FILES) $(INSTALL_MD_LCL_FILES) $(INSTALL_MD_GEN_LCL_FILES) $(INSTALL_MD_LCL_KERN_FILES) $(INSTALL_MD_GEN_LCL_KERN_FILES)
145 @true echo "[ $(SOURCE) ] make do_installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
146
147 else
148
149 INSTALL_MI_INC_FILES = $(addprefix $(SOURCE), $(INSTALL_MI_LIST))
150 INSTALL_MI_GEN_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_GEN_LIST))
151
152 $(INSTALL_MI_GEN_INC_FILES): $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR)/% : %
153 @true echo Installing $< in $(dir $@); \
154 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
155 filename=`$(BASENAME) $<`; \
156 filename_strip=$(addsuffix .strip,$${filename}); \
157 $(RM) $(RMFLAGS) $@; \
158 $(MKDIR) ./incdir; \
159 echo garbage > ./incdir/$${filename_strip}; \
160 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
161 $< > ./incdir/$${filename} || \
162 $(DECOMMENT) ./incdir/$${filename} r > \
163 ./incdir/$${filename_strip}; \
164 if [ -s ./incdir/$${filename_strip} ]; \
165 then ( \
166 install $(INSTALL_FLAGS) ./incdir/$${filename} $(dir $@);\
167 ); \
168 else \
169 echo Header file $< not exported; \
170 fi; \
171 $(RM) -rf ./incdir;
172
173 INSTALL_MI_LCL_FILES = $(addprefix $(SOURCE), $(INSTALL_MI_LCL_LIST))
174 INSTALL_MI_GEN_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_GEN_LIST))
175
176 $(INSTALL_MI_GEN_LCL_FILES): $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR)/% : %
177 @true echo Installing $< in $(dir $@); \
178 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
179 $(RM) $(RMFLAGS) $@; \
180 install $(INSTALL_FLAGS) $< $(dir $@);
181
182 INSTALL_MI_LCL_KERN_FILES = $(addprefix $(SOURCE), $(INSTALL_MI_LCL_KERN_LIST))
183 INSTALL_MI_GEN_LCL_KERN_FILES = $(addprefix $(KPINCDIR)/$(LCLDIR)/$(INSTALL_MI_DIR)/, $(INSTALL_MI_LCL_KERN_GEN_LIST))
184
185 $(INSTALL_MI_GEN_LCL_KERN_FILES): $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR)/% : %
186 @true echo Installing $< in $(dir $@); \
187 $(MKDIR) $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR); \
188 $(RM) $(RMFLAGS) $@; \
189 install $(INSTALL_FLAGS) $< $(dir $@);
190
191 INSTALL_MD_INC_FILES = $(addprefix $(SOURCE), $(INSTALL_MD_LIST))
192 INSTALL_MD_GEN_INC_FILES = $(addprefix $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_GEN_LIST))
193
194 $(INSTALL_MD_GEN_INC_FILES): $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR)/% : %
195 @true echo Installing $< in $(dir $@); \
196 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
197 filename=`$(BASENAME) $<`; \
198 filename_strip=$(addsuffix .strip,$${filename}); \
199 $(RM) $(RMFLAGS) $@; \
200 $(MKDIR) ./incdir; \
201 echo garbage > ./incdir/$${filename_strip}; \
202 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
203 $< > ./incdir/$${filename} || \
204 $(DECOMMENT) ./incdir/$${filename} r > \
205 ./incdir/$${filename_strip}; \
206 if [ -s ./incdir/$${filename_strip} ]; \
207 then ( \
208 install $(INSTALL_FLAGS) ./incdir/$${filename} $(dir $@);\
209 ); \
210 else \
211 echo Header file $< not exported; \
212 fi; \
213 $(RM) -rf /incdir;
214
215 INSTALL_MD_LCL_FILES = $(addprefix $(SOURCE), $(INSTALL_MD_LCL_LIST))
216 INSTALL_MD_GEN_LCL_FILES = $(addprefix $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_GEN_LIST))
217
218 $(INSTALL_MD_GEN_LCL_FILES): $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR)/% : %
219 @true echo Installing $< in $(dir $@); \
220 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
221 $(RM) $(RMFLAGS) $@; \
222 install $(INSTALL_FLAGS) $< $(dir $@);
223
224 INSTALL_MD_LCL_KERN_FILES = $(addprefix $(SOURCE), $(INSTALL_MD_LCL_KERN_LIST))
225 INSTALL_MD_GEN_LCL_KERN_FILES = $(addprefix $(KPINCDIR)/$(LCLDIR)/$(INSTALL_MD_DIR)/, $(INSTALL_MD_LCL_KERN_GEN_LIST))
226
227 $(INSTALL_MD_GEN_LCL_KERN_FILES): $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR)/% : %
228 @true echo Installing $< in $(dir $@); \
229 $(MKDIR) $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR); \
230 $(RM) $(RMFLAGS) $@; \
231 install $(INSTALL_FLAGS) $< $(dir $@);
232
233 setup_installhdrs_mi:
234 @echo "[ $(SOURCE) ] make setup_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
235
236 do_installhdrs_mi: $(INSTALL_MI_GEN_INC_FILES) $(INSTALL_MI_GEN_LCL_FILES) $(INSTALL_MI_GEN_LCL_KERN_FILES)
237 @true echo "[ $(SOURCE) ] make do_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
238 @if [ -n "$(strip $(INSTALL_MI_LIST))" ]; then \
239 if [ -d $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR) ]; then \
240 (cd $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR);$(RM) $(RMFLAGS) $(INSTALL_MI_LIST) ); \
241 else \
242 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
243 fi; \
244 $(MKDIR) ./incdir; \
245 for j in $(INSTALL_MI_LIST); \
246 do \
247 echo garbage > ./incdir/$$j.strip; \
248 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
249 $(SOURCE)/$$j > ./incdir/$$j || \
250 $(DECOMMENT) ./incdir/$$j r > \
251 ./incdir/$$j.strip; \
252 if [ -s ./incdir/$$j.strip ]; \
253 then ( \
254 install $(INSTALL_FLAGS) ./incdir/$$j $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
255 ); \
256 else \
257 echo Header file $$j not exported; \
258 fi; \
259 done; \
260 $(RM) -rf ./incdir; \
261 fi
262 @if [ -n "$(strip $(INSTALL_MI_LCL_LIST))" ]; then \
263 if [ -d $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR) ]; then \
264 (cd $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR);$(RM) $(RMFLAGS) $(INSTALL_MI_LCL_LIST) ); \
265 else \
266 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
267 fi; \
268 install $(INSTALL_FLAGS) $(INSTALL_MI_LCL_FILES) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
269 fi
270 @if [ -n "$(strip $(INSTALL_MI_LCL_KERN_LIST))" ]; then \
271 if [ -d $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR) ]; then \
272 (cd $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR);$(RM) $(RMFLAGS) $(INSTALL_MI_LCL_KERN_LIST) ); \
273 else \
274 $(MKDIR) $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR); \
275 fi; \
276 install $(INSTALL_FLAGS) $(INSTALL_MI_LCL_KERN_FILES) $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MI_DIR); \
277 fi
278
279 setup_installhdrs_md:
280 @echo "[ $(SOURCE) ] make setup_installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
281
282 do_installhdrs_md: $(INSTALL_MD_GEN_INC_FILES) $(INSTALL_MD_GEN_LCL_FILES) $(INSTALL_MI_GEN_LCL_KERN_FILES)
283 @true echo "[ $(SOURCE) ] make do_installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
284 @if [ -n "$(strip $(INSTALL_MD_LIST))" ]; then \
285 if [ -d $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR) ]; then \
286 (cd $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR);$(RM) $(RMFLAGS) $(INSTALL_MD_LIST) ); \
287 else \
288 $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
289 fi; \
290 $(MKDIR) ./incdir; \
291 for j in $(INSTALL_MD_LIST); \
292 do \
293 echo garbage > ./incdir/$$j.strip; \
294 $(UNIFDEF) -UKERNEL_PRIVATE -UDRIVER_PRIVATE \
295 $(SOURCE)/$$j > ./incdir/$$j || \
296 $(DECOMMENT) ./incdir/$$j r > \
297 ./incdir/$$j.strip; \
298 if [ -s ./incdir/$$j.strip ]; \
299 then ( \
300 install $(INSTALL_FLAGS) ./incdir/$$j $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
301 ); \
302 else \
303 echo Header file $$j not exported; \
304 fi; \
305 done; \
306 $(RM) -rf ./incdir; \
307 fi
308 @if [ -n "$(strip $(INSTALL_MD_LCL_LIST))" ]; then \
309 if [ -d $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR) ]; then \
310 (cd $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR);$(RM) $(RMFLAGS) $(INSTALL_MD_LCL_LIST) ); \
311 else \
312 $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
313 fi; \
314 install $(INSTALL_FLAGS) $(INSTALL_MD_LCL_FILES) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
315 fi
316 @if [ -n "$(strip $(INSTALL_MD_LCL_KERN_LIST))" ]; then \
317 if [ -d $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR) ]; then \
318 (cd $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR);$(RM) $(RMFLAGS) $(INSTALL_MD_LCL_KERN_LIST) ); \
319 else \
320 $(MKDIR) $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR); \
321 fi; \
322 install $(INSTALL_FLAGS) $(INSTALL_MD_LCL_KERN_FILES) $(DSTROOT)/$(KPINCDIR)/$(INSTALL_MD_DIR); \
323 fi
324
325
326 endif
327
328 #
329 # Generic Export rules
330 #
331 ifeq ($(INCR_EXPORTHDRS), TRUE)
332
333 EXPORT_MI_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/, $(EXPORT_MI_LIST))
334 EXPORT_MI_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/, $(EXPORT_MI_GEN_LIST))
335
336 $(EXPORT_MI_INC_FILES) $(EXPORT_MI_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/% : %
337 @true echo Exporting $< in $(dir $@); \
338 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR); \
339 ${CP} -p $< $(dir $@); \
340
341
342 EXPORT_MD_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/, $(EXPORT_MD_LIST))
343 EXPORT_MD_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/, $(EXPORT_MD_GEN_LIST))
344
345 $(EXPORT_MD_INC_FILES) $(EXPORT_MD_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/% : %
346 @true echo Exporting $< in $(dir $@); \
347 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR); \
348 ${CP} -p $< $(dir $@); \
349
350 setup_exporthdrs_mi:
351 @echo "[ $(SOURCE) ] make setup_exporthdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
352
353 do_exporthdrs_mi: $(EXPORT_MI_INC_FILES) $(EXPORT_MI_GEN_INC_FILES)
354 @true echo "[ $(SOURCE) ] make do_exporthdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
355
356 setup_exporthdrs_md:
357 @echo "[ $(SOURCE) ] make setup_exporthdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
358
359 do_exporthdrs_md: $(EXPORT_MD_INC_FILES) $(EXPORT_MD_GEN_INC_FILES)
360 @true echo "[ $(SOURCE) ] make do_exporthdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
361
362 else
363
364 EXPORT_MI_INC_FILES = $(addprefix $(SOURCE), $(EXPORT_MI_LIST))
365 EXPORT_MI_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/, $(EXPORT_MI_GEN_LIST))
366
367 $(EXPORT_MI_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR)/% : %
368 @true echo Exporting $< in $(dir $@); \
369 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR); \
370 ${CP} -p $< $(dir $@); \
371
372
373 EXPORT_MD_INC_FILES = $(addprefix $(SOURCE), $(EXPORT_MD_LIST))
374 EXPORT_MD_GEN_INC_FILES = $(addprefix $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/, $(EXPORT_MD_GEN_LIST))
375
376 $(EXPORT_MD_GEN_INC_FILES): $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR)/% : %
377 @true echo Exporting $< in $(dir $@); \
378 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR); \
379 ${CP} -p $< $(dir $@); \
380
381 setup_exporthdrs_mi:
382 @echo "[ $(SOURCE) ] make setup_exporthdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
383
384 do_exporthdrs_mi: $(EXPORT_MI_GEN_INC_FILES)
385 @true echo "[ $(SOURCE) ] make do_exporthdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
386 @if [ -n "$(strip $(EXPORT_MI_LIST))" ]; then \
387 if [ -d $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR) ]; then \
388 (cd $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR);$(RM) $(RMFLAGS) $(EXPORT_MI_LIST) ); \
389 else \
390 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR); \
391 fi; \
392 ${CP} -p $(EXPORT_MI_INC_FILES) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MI_DIR); \
393 fi
394
395 setup_exporthdrs_md:
396 @echo "[ $(SOURCE) ] make setup_exporthdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
397
398 do_exporthdrs_md: $(EXPORT_MD_GEN_INC_FILES)
399 @true echo "[ $(SOURCE) ] make do_exporthdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
400 @if [ -n "$(strip $(EXPORT_MD_LIST))" ]; then \
401 if [ -d $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR) ]; then \
402 (cd $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR);$(RM) $(RMFLAGS) $(EXPORT_MD_LIST) ); \
403 else \
404 $(MKDIR) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR); \
405 fi; \
406 ${CP} -p $(EXPORT_MD_INC_FILES) $(OBJROOT)/$(EXPDIR)/$(EXPORT_MD_DIR); \
407 fi
408
409
410 #
411 endif
412 #
413 # Generic Compilation rules
414 #
415
416 #
417 # Compilation rules to generate .o from .s
418 #
419 COMP_SOBJ_FILES = $(addprefix $(TARGET)$(COMP_OBJ_DIR), $(COMP_SOBJ_LIST))
420
421 $(COMP_SOBJ_FILES): $(TARGET)$(COMP_OBJ_DIR)%.o : %.s
422 ${S_KCC} -E -MD ${SFLAGS} -DASSEMBLER $(INCFLAGS) $< > $(patsubst %.o, %.pp, ${@});
423 sed '/^\#/d' $(patsubst %.o, %.pp, ${@}) > $(patsubst %.o, %.s, ${@});
424 ${S_KCC} ${SFLAGS} ${_HOST_AS_FLAGS} -c $(patsubst %.o, %.s, ${@});
425 ${RM} ${_RMFLAGS_} $(patsubst %.o, %.pp, ${@}) $(patsubst %.o,%.s,${@});
426
427 S_RULE_1A=@ls /
428 S_RULE_1B= ${patsubst %.o,%.s,${@}} > /dev/null
429 S_RULE_2= ${S_KCC} -E -MD ${SFLAGS} -DASSEMBLER $(INCFLAGS) $< \
430 > $(patsubst %.o, %.pp, ${@}); \
431 sed '/^\#/d' $(patsubst %.o, %.pp, ${@}) > $(patsubst %.o, %.s, ${@});
432 S_RULE_3= ${S_KCC} ${SFLAGS} ${_HOST_AS_FLAGS} -c $(patsubst %.o, %.s, ${@});\
433 ${RM} ${_RMFLAGS_} $(patsubst %.o, %.pp, ${@}) $(patsubst %.o,%.s,${@})
434
435 #
436 # Compilation rules to generate .o from .c
437 #
438 COMP_COBJ_FILES = $(addprefix $(TARGET)$(COMP_OBJ_DIR), $(COMP_COBJ_LIST))
439
440 $(COMP_COBJ_FILES): $(TARGET)$(COMP_OBJ_DIR)%.o : %.c
441 ${KCC} -c ${filter-out ${${join $@,_CFLAGS_RM}}, ${CFLAGS}} -MD ${${join $@,_CFLAGS_ADD}} ${INCFLAGS} ${${join $@,_INCFLAGS}} $<
442
443 #
444 # Compilation rules to generate .o from .c for normal files
445 #
446 C_RULE_1A=${KCC} -c ${filter-out ${${join $@,_CFLAGS_RM}}, ${CFLAGS}} -MD ${${join $@,_CFLAGS_ADD}} ${INCFLAGS} ${${join $@,_INCFLAGS}}
447 C_RULE_1B=$*.c
448 C_RULE_2=
449 C_RULE_3=
450 C_RULE_4=
451
452 #
453 # Compilation rules to generate .o from .c for driver files
454 #
455 C_RULE_1A_D=${C_RULE_1A}
456 C_RULE_1B_D=${C_RULE_1B}
457 C_RULE_2_D=${C_RULE_2}
458 C_RULE_3_D=${C_RULE_3}
459 C_RULE_4_D=${C_RULE_4}
460
461 #
462 # Compilation rules to generate .o from .m
463 #
464 M_RULE_1A=${KCC} -c ${filter-out ${${join $@,_CFLAGS_RM}}, ${CFLAGS}} -MD ${${join $@,_CFLAGS_ADD}} ${INCFLAGS} ${${join $@,_INCFLAGS}}
465 M_RULE_1B=$*.m
466 M_RULE_2=
467 M_RULE_3=
468 M_RULE_4=
469
470 #
471 # Compilation rules to generate .co from .cp or .cpo from .cpp
472 # The config tool slickly changes the last source filename char to 'o'
473 # for the object filename.
474 #
475 P_RULE_1A=${KC++} -o $@ -c ${CXXFLAGS} ${filter-out ${${join $@,_CFLAGS_RM}}, ${CFLAGS}} -MD ${${join $@,_CFLAGS_ADD}} ${INCFLAGS} ${${join $@,_INCFLAGS}}
476 P_RULE_1B=$(<F)
477 P_RULE_2=@sed 's/.c.o: /.cpo: /' $(@:.cpo=.d) > $(@:.cpo=.d~) && mv $(@:.cpo=.d~) $(@:.cpo=.d)
478 P_RULE_3=
479 P_RULE_4=
480
481 #
482 # Linker rule to generate a component
483 #
484 LD_COMPONENT_OBJ_FILES = $(addprefix $(TARGET)$(COMP_OBJ_DIR), $(LD_COMPONENT_OBJ_LIST))
485
486 COMPONENT_IMAGE_FILE = $(addprefix $(TARGET), $(COMPONENT_IMAGE))
487
488 $(COMPONENT_IMAGE_FILE): $(LD_COMPONENT_OBJ_FILES)
489 @echo "[ creating $(COMPONENT_IMAGE) ]"
490 $(LD) $(LDFLAGS_COMPONENT) -o $(COMPONENT_IMAGE_FILE) ${LD_COMPONENT_OBJ_FILES};
491 (cd $(TARGET)$(COMP_OBJ_DIR); ${MD} -u Makedep -f -d `ls *.d`);
492
493 setup_build_all:
494 @echo "[ $(SOURCE) ] make setup_build_all $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
495
496 do_build_all: $(COMP_FILES) $(COMP_COBJ_FILES) $(COMP_SOBJ_FILES) $(COMPONENT_IMAGE_FILE)
497 @true echo "[ $(SOURCE) ] make do_build_all $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
498
499 ifeq ($(COMPONENT), .)
500 do_build_all: do_build_mach_kernel
501 endif
502
503 #
504 # mach_kernel building rules
505 #
506 do_build_mach_kernel: $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/kgmacros
507 @echo "[ building mach_kernel ]";
508 $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/kernel_newvers \
509 "`${CAT} $(SRCROOT)/osfmk/conf/kernelversion.major`" \
510 "`${CAT} $(SRCROOT)/osfmk/conf/kernelversion.minor`" \
511 "`${CAT} $(SRCROOT)/osfmk/conf/kernelversion.variant`"; \
512 ${KCC} $(CFLAGS) $(INCLUDES) -c kernel_vers.c; \
513 $(LD) $(LDFLAGS_KERNEL) $(addprefix $(TARGET)/,$(foreach component,$(COMPONENT_LIST), $(addprefix $(component)/$(firstword $($(addsuffix _KERNEL_CONFIG, $(shell echo -n $(component) | tr a-z A-Z))) $(KERNEL_CONFIG))/, $(addsuffix .o, $(component))))) kernel_vers.o -o $(TARGET)/mach_kernel.sys $(LD_KERNEL_LIBS); \
514 $(STRIP) $(STRIP_FLAGS) $(TARGET)/mach_kernel.sys -o $(TARGET)/mach_kernel;
515
516 $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/kgmacros: $(SRCROOT)/kgmacros
517 cp $? $@
518
519 #
520 # Generic Install rules
521 #
522 INSTALL_FILE_FILES = $(addprefix $(DSTROOT)$(INSTALL_FILE_DIR), $(INSTALL_FILE_LIST))
523
524 force_file_install:
525
526 $(INSTALL_FILE_FILES): $(DSTROOT)$(INSTALL_FILE_DIR)% : $(TARGET)/% force_file_install
527 @echo Installing $< in $@;
528 @if [ ! -e $(DSTROOT)$(INSTALL_FILE_DIR) ]; then \
529 $(MKDIR) $(DSTROOT)$(INSTALL_FILE_DIR); \
530 fi; \
531 if [ "`echo $(INSTALL_ARCHS_LC) | wc -w`" -eq 1 ]; then \
532 $(RM) $(RMFLAGS) $@; \
533 install $(FILE_INSTALL_FLAGS) $< $(dir $@); \
534 else \
535 if [ ! -e $@ ]; then \
536 echo >empty_file_$(notdir $@); \
537 lipo_arg="$(subst _empty_file, empty_file_$(notdir $@),$(foreach lipo_arch,$(INSTALL_ARCHS_LC), $(addprefix -arch , $(addsuffix _empty_file, $(lipo_arch)))))"; \
538 $(LIPO) $${lipo_arg} -create -output $@; \
539 $(RM) $(RMFLAGS) empty_file_$(notdir $@); \
540 fi; \
541 $(LIPO) $@ -replace $(ARCH_CONFIG_LC) $< -o $@; \
542 fi
543
544 INSTALL_FILESYS_FILES = $(addprefix $(SYMROOT)$(INSTALL_FILE_DIR), $(INSTALL_FILE_LIST))
545
546 force_filesys_install:
547
548 $(INSTALL_FILESYS_FILES): $(SYMROOT)$(INSTALL_FILE_DIR)% : $(TARGET)/%.sys force_filesys_install
549 @echo Installing $< in $@;
550 @if [ ! -e $(SYMROOT)$(INSTALL_FILE_DIR) ]; then \
551 $(MKDIR) $(SYMROOT)$(INSTALL_FILE_DIR); \
552 fi; \
553 if [ "`echo $(INSTALL_ARCHS_LC) | wc -w`" -eq 1 ]; then \
554 $(RM) $(RMFLAGS) $@; \
555 install $(INSTALL_FLAGS) $< $(dir $@); \
556 else \
557 if [ ! -e $@ ]; then \
558 echo >empty_filesys_$(notdir $@); \
559 lipo_arg="$(subst _empty_file, empty_filesys_$(notdir $@),$(foreach lipo_arch,$(INSTALL_ARCHS_LC), $(addprefix -arch , $(addsuffix _empty_file, $(lipo_arch)))))"; \
560 $(LIPO) $${lipo_arg} -create -output $@; \
561 $(RM) $(RMFLAGS) empty_filesys_$(notdir $@); \
562 fi; \
563 $(LIPO) $@ -replace $(ARCH_CONFIG_LC) $< -o $@; \
564 fi
565 cp $(SOURCE)kgmacros $(SYMROOT)$(INSTALL_FILE_DIR)
566
567 INSTALL_DATA_FILES = $(addprefix $(DSTROOT)$(INSTALL_DATA_DIR), $(INSTALL_DATA_LIST))
568
569 $(INSTALL_DATA_FILES): $(DSTROOT)$(INSTALL_DATA_DIR)% : $(SOURCE)/%
570 @echo Installing $< in $@;
571 @$(MKDIR) $(dir $@); \
572 $(RM) $(RMFLAGS) $@; \
573 install $(DATA_INSTALL_FLAGS) $< $(dir $@);
574
575 setup_build_install:
576 @echo "[ $(SOURCE) ] make setup_build_install $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
577
578 do_build_install: $(INSTALL_FILESYS_FILES) $(INSTALL_FILE_FILES) $(INSTALL_DATA_FILES)
579 @echo "[ $(SOURCE) ] make do_build_install $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
580
581 INSTALL_MAN_FILES = $(addprefix $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR)/, $(INSTALL_MAN_LIST))
582
583 do_installman: $(INSTALL_MAN_FILES)
584 @echo "[ $(SOURCE) ] make do_installman"
585 @if [ -n "$(strip $(INSTALL_MAN_LIST))" ]; then \
586 man_dir=$(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR); \
587 if [ -d $$man_dir ]; then \
588 cur_dir=`pwd`; \
589 cd $$man_dir; \
590 $(RM) $(RMFLAGS) $(INSTALL_MAN_LIST); \
591 cd $$cur_dir; \
592 else \
593 $(MKDIR) $$man_dir; \
594 fi; \
595 echo Installing $(INSTALL_MAN_LIST) in $$man_dir; \
596 install $(INSTALL_FLAGS) $(INSTALL_MAN_LIST) $$man_dir; \
597 fi
598
599 $(INSTALL_MAN_FILES): $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR)/% : %
600 @true echo Installing $< in $(dir $@); \
601 $(MKDIR) $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR); \
602 $(RM) $(RMFLAGS) $@; \
603 install $(INSTALL_FLAGS) $< $(dir $@);
604
605 ifeq ($(INCL_MAKEDEP), TRUE)
606 -include Makedep
607 endif
608