]> git.saurik.com Git - apple/xnu.git/blob - Makefile
xnu-2422.90.20.tar.gz
[apple/xnu.git] / Makefile
1 #
2 # Copyright (C) 1999-2010 Apple Inc. All rights reserved.
3 #
4
5 ifndef VERSDIR
6 export VERSDIR := $(shell /bin/pwd)
7 endif
8
9 ifndef SRCROOT
10 export SRCROOT := $(shell /bin/pwd)
11 endif
12 ifndef OBJROOT
13 export OBJROOT = $(SRCROOT)/BUILD/obj
14 endif
15 ifndef DSTROOT
16 export DSTROOT = $(SRCROOT)/BUILD/dst
17 endif
18 ifndef SYMROOT
19 export SYMROOT = $(SRCROOT)/BUILD/sym
20 endif
21
22 export MakeInc_top=${VERSDIR}/makedefs/MakeInc.top
23 export MakeInc_kernel=${VERSDIR}/makedefs/MakeInc.kernel
24 export MakeInc_cmd=${VERSDIR}/makedefs/MakeInc.cmd
25 export MakeInc_def=${VERSDIR}/makedefs/MakeInc.def
26 export MakeInc_rule=${VERSDIR}/makedefs/MakeInc.rule
27 export MakeInc_dir=${VERSDIR}/makedefs/MakeInc.dir
28
29 #
30 # Dispatch non-xnu build aliases to their own build
31 # systems. All xnu variants start with MakeInc_top.
32 #
33
34 ifeq ($(findstring Libsyscall,$(RC_ProjectName)),Libsyscall)
35
36 ifeq ($(RC_ProjectName),Libsyscall_headers_Sim)
37 TARGET=-target Libsyscall_headers_Sim
38 endif
39
40 default: install
41
42 installhdrs install:
43 cd libsyscall ; \
44 xcodebuild $@ $(TARGET) \
45 "SRCROOT=$(SRCROOT)/libsyscall" \
46 "OBJROOT=$(OBJROOT)" \
47 "SYMROOT=$(SYMROOT)" \
48 "DSTROOT=$(DSTROOT)" \
49 "SDKROOT=$(SDKROOT)"
50
51 clean:
52
53 installsrc:
54 pax -rw . $(SRCROOT)
55
56 else ifeq ($(RC_ProjectName),libkxld)
57
58 default: install
59
60 installhdrs install clean:
61 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all
62
63 installsrc:
64 pax -rw . $(SRCROOT)
65
66 else ifeq ($(RC_ProjectName),libkxld_host)
67
68 default: install
69
70 installhdrs install clean:
71 $(MAKE) -C libkern/kxld $@ USE_APPLE_PB_SUPPORT=all PRODUCT_TYPE=ARCHIVE
72
73 installsrc:
74 pax -rw . $(SRCROOT)
75
76 else ifeq ($(RC_ProjectName),libkmod)
77
78 default: install
79
80 installhdrs install:
81 cd libkern/kmod ; \
82 xcodebuild $@ \
83 "SRCROOT=$(SRCROOT)/libkern/kmod" \
84 "OBJROOT=$(OBJROOT)" \
85 "SYMROOT=$(SYMROOT)" \
86 "DSTROOT=$(DSTROOT)" \
87 "SDKROOT=$(SDKROOT)"
88
89 clean:
90
91 installsrc:
92 pax -rw . $(SRCROOT)
93
94 else ifeq ($(RC_ProjectName),xnu_quick_test)
95
96 default: install
97
98 installhdrs:
99
100 install: xnu_quick_test
101
102 clean:
103
104 installsrc:
105 pax -rw . $(SRCROOT)
106
107 else # all other RC_ProjectName
108
109 ifndef CURRENT_BUILD_CONFIG
110
111 # avoid having to include MakeInc.cmd
112 ifeq ($(RC_XBS),YES)
113 _v =
114 else ifeq ($(VERBOSE),YES)
115 _v =
116 else
117 _v = @
118 endif
119
120 #
121 # Setup for parallel sub-makes based on 2 times number of logical CPUs.
122 # If MAKEJOBS or -jN is passed on the make line, that takes precedence.
123 #
124 MAKEJOBS := --jobs=$(shell expr `/usr/sbin/sysctl -n hw.physicalcpu` \* 2)
125
126 TOP_TARGETS = clean installsrc installhdrs installhdrs_embedded installman exporthdrs setup build all all_embedded install install_embedded installopensource cscope tags help print_exports print_exports_first_build_config
127
128 .PHONY: $(TOP_TARGETS)
129
130 default: all
131
132 ifneq ($(REMOTEBUILD),)
133 $(TOP_TARGETS):
134 $(_v)$(VERSDIR)/tools/remote_build.sh _REMOTEBUILD_TARGET=$@ _REMOTEBUILD_MAKE=$(MAKE) $(MAKEFLAGS)
135 else
136 $(TOP_TARGETS):
137 $(_v)$(MAKE) -r $(if $(filter -j,$(MAKEFLAGS)),,$(MAKEJOBS)) -f $(MakeInc_top) $@
138 endif
139
140 else # CURRENT_BUILD_CONFIG
141
142 include $(MakeInc_cmd)
143 include $(MakeInc_def)
144
145 ALL_SUBDIRS = \
146 bsd \
147 iokit \
148 osfmk \
149 pexpert \
150 libkern \
151 libsa \
152 security \
153 config
154
155 CONFIG_SUBDIRS = config tools
156
157 INSTINC_SUBDIRS = $(ALL_SUBDIRS) EXTERNAL_HEADERS
158 INSTINC_SUBDIRS_X86_64 = $(INSTINC_SUBDIRS)
159 INSTINC_SUBDIRS_ARM = $(INSTINC_SUBDIRS)
160
161 EXPINC_SUBDIRS = $(ALL_SUBDIRS)
162 EXPINC_SUBDIRS_X86_64 = $(EXPINC_SUBDIRS)
163 EXPINC_SUBDIRS_ARM = $(EXPINC_SUBDIRS)
164
165 SETUP_SUBDIRS = SETUP
166
167 COMP_SUBDIRS_X86_64 = $(ALL_SUBDIRS)
168 COMP_SUBDIRS_ARM = $(ALL_SUBDIRS)
169
170 INST_SUBDIRS = \
171 bsd \
172 config
173
174 INSTMAN_SUBDIRS = \
175 bsd
176
177 include $(MakeInc_kernel)
178 include $(MakeInc_rule)
179 include $(MakeInc_dir)
180
181 endif # CURRENT_BUILD_CONFIG
182
183 endif # all other RC_ProjectName
184
185 # "xnu_quick_test" and "testbots" are targets that can be invoked via a standalone
186 # "make xnu_quick_test" or via buildit/XBS with the RC_ProjectName=xnu_quick_test.
187 # Define the target here in the outermost scope of the initial Makefile
188
189 xnu_quick_test:
190 $(MAKE) -C $(SRCROOT)/tools/tests \
191 SRCROOT=$(SRCROOT)/tools/tests
192
193 # This target is defined to compile and run xnu_quick_test under testbots
194 testbots:
195 $(MAKE) -C $(SRCROOT)/tools/tests/xnu_quick_test \
196 SRCROOT=$(SRCROOT)/tools/tests/xnu_quick_test \
197 MORECFLAGS="-DRUN_UNDER_TESTBOTS=1" \
198 MAKE=$(MAKE) \
199 testbots