]> git.saurik.com Git - apple/xnu.git/blob - makedefs/MakeInc.rule
xnu-344.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} -m${ARCH_CONFIG_LC} ${_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} -m${ARCH_CONFIG_LC} ${_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 ${CFLAGS} -MD ${${join $@,_CFLAGS}} ${INCFLAGS} ${${join $@,_INCFLAGS}} $<
442
443 #
444 # Compilation rules to generate .o from .c for normal files
445 #
446 C_RULE_1A=${KCC} -c ${CFLAGS} -MD ${${join $@,_CFLAGS}} ${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 ${CFLAGS} -MD ${${join $@,_CFLAGS}} ${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 ${CPPFLAGS} ${CFLAGS} -MD ${${join $@,_CFLAGS}} ${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:
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, $(component))) $(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 # Generic Install rules
517 #
518 INSTALL_FILE_FILES = $(addprefix $(DSTROOT)$(INSTALL_FILE_DIR), $(INSTALL_FILE_LIST))
519
520 force_file_install:
521
522 $(INSTALL_FILE_FILES): $(DSTROOT)$(INSTALL_FILE_DIR)% : $(TARGET)/% force_file_install
523 @echo Installing $< in $@;
524 @$(MKDIR) $(DSTROOT)$(INSTALL_FILE_DIR); \
525 if [ "`echo $(INSTALL_ARCHS_LC) | wc -w`" -eq 1 ]; then \
526 $(RM) $(RMFLAGS) $@; \
527 install $(INSTALL_FLAGS) $< $(dir $@); \
528 else \
529 if [ ! -e $@ ]; then \
530 echo >empty_file; \
531 lipo_arg="$(subst _empty_file, empty_file,$(foreach lipo_arch,$(INSTALL_ARCHS_LC), $(addprefix -arch , $(addsuffix _empty_file, $(lipo_arch)))))"; \
532 $(LIPO) $${lipo_arg} -create -output $@; \
533 $(RM) $(RMFLAGS) empty_file; \
534 fi; \
535 $(LIPO) $@ -replace $(ARCH_CONFIG_LC) $< -o $@; \
536 fi
537
538 INSTALL_FILESYS_FILES = $(addprefix $(SYMROOT)$(INSTALL_FILE_DIR), $(INSTALL_FILE_LIST))
539
540 force_filesys_install:
541
542 $(INSTALL_FILESYS_FILES): $(SYMROOT)$(INSTALL_FILE_DIR)% : $(TARGET)/%.sys force_filesys_install
543 @echo Installing $< in $@;
544 @$(MKDIR) $(SYMROOT)$(INSTALL_FILE_DIR); \
545 if [ "`echo $(INSTALL_ARCHS_LC) | wc -w`" -eq 1 ]; then \
546 $(RM) $(RMFLAGS) $@; \
547 install $(INSTALL_FLAGS) $< $(dir $@); \
548 else \
549 if [ ! -e $@ ]; then \
550 echo >empty_file; \
551 lipo_arg="$(subst _empty_file, empty_file,$(foreach lipo_arch,$(INSTALL_ARCHS_LC), $(addprefix -arch , $(addsuffix _empty_file, $(lipo_arch)))))"; \
552 $(LIPO) $${lipo_arg} -create -output $@; \
553 $(RM) $(RMFLAGS) empty_file; \
554 fi; \
555 $(LIPO) $@ -replace $(ARCH_CONFIG_LC) $< -o $@; \
556 fi
557
558 setup_build_install:
559 @echo "[ $(SOURCE) ] make setup_build_install $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
560
561 do_build_install: $(INSTALL_FILESYS_FILES) $(INSTALL_FILE_FILES)
562 @echo "[ $(SOURCE) ] make do_build_install $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
563
564 INSTALL_MAN_FILES = $(addprefix $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR)/, $(INSTALL_MAN_LIST))
565
566 do_installman: $(INSTALL_MAN_FILES)
567 @echo "[ $(SOURCE) ] make do_installman"
568 @if [ -n "$(strip $(INSTALL_MAN_LIST))" ]; then \
569 man_dir=$(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR); \
570 if [ -d $$man_dir ]; then \
571 cur_dir=`pwd`; \
572 cd $$man_dir; \
573 $(RM) $(RMFLAGS) $(INSTALL_MAN_LIST); \
574 cd $$cur_dir; \
575 else \
576 $(MKDIR) $$man_dir; \
577 fi; \
578 echo Installing $(INSTALL_MAN_LIST) in $$man_dir; \
579 install $(INSTALL_FLAGS) $(INSTALL_MAN_LIST) $$man_dir; \
580 fi
581
582 $(INSTALL_MAN_FILES): $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR)/% : %
583 @true echo Installing $< in $(dir $@); \
584 $(MKDIR) $(DSTROOT)/$(MANDIR)/$(INSTALL_MAN_DIR); \
585 $(RM) $(RMFLAGS) $@; \
586 install $(INSTALL_FLAGS) $< $(dir $@);
587
588 ifeq ($(INCL_MAKEDEP), TRUE)
589 -include Makedep
590 endif
591