3 # Set default rule before anything else.
8 # If SRCROOT is defined, assume we are doing an Apple style build. We should be
9 # able to use RC_XBS for this but that is unused during "make installsrc".
11 include make
/AppleBI.mk
14 # Make sure we don't build with a missing ProjObjRoot.
15 ifeq ($(ProjObjRoot
),)
16 $(error Refusing to build with empty ProjObjRoot variable
)
27 # FIXME: Document the available subtargets.
29 @echo
"usage: make [{VARIABLE=VALUE}*] target"
31 @echo
"User variables:"
32 @echo
" VERBOSE=1: Use to show all commands [default=0]"
34 @echo
"Available targets:"
35 @echo
" <platform name>: build the libraries for 'platform'"
36 @echo
" clean: clean all configurations"
37 @echo
" test: run unit tests"
39 @echo
" info-platforms: list available platforms"
40 @echo
" help-devel: print additional help for developers"
44 @echo
"Development targets:"
45 @echo
" <platform name>-<config name>:"
46 @echo
" build the libraries for a single platform config"
47 @echo
" <platform name>-<config name>-<arch name>:"
48 @echo
" build the libraries for a single config and arch"
49 @echo
" info-functions: list available compiler-rt functions"
50 @echo
" help-hidden: print help for Makefile debugging"
53 help-hidden
: help-devel
54 @echo
"Debugging variables:"
55 @echo
" DEBUGMAKE=1: enable some Makefile logging [default=]"
56 @echo
" =2: enable more Makefile logging"
58 @echo
"Debugging targets:"
59 @echo
" make-print-FOO: print information on the variable 'FOO'"
63 @echo
"compiler-rt Available Functions"
65 @echo
"All Functions: $(AvailableFunctions)"
66 @
$(foreach fn
,$(AvailableFunctions
),\
67 printf
" %-20s - available in (%s)\n" $(fn
)\
68 "$(foreach key,$(AvailableIn.$(fn)),$($(key).Dir))";)
71 @echo
"compiler-rt Available Platforms"
74 @
$(foreach key
,$(PlatformKeys
),\
75 printf
" %s - from '%s'\n" $($(key
).Name
) $($(key
).Path
);\
76 printf
" %s\n" "$($(key).Description)";\
77 printf
" Configurations: %s\n\n" "$($(key).Configs)";)
79 # Provide default clean target which is extended by other templates.
86 cd
test/Unit
&& .
/test
89 # Directory handling magic.
91 # Create directories as needed, and timestamp their creation.
93 $(Summary
) " MKDIR: $*"
94 $(Verb
) $(MKDIR
) $* > /dev
/null
102 # Include child makefile fragments
105 include make
/subdir.mk
106 include make
/lib_info.mk
107 include make
/lib_util.mk
108 include make
/lib_platforms.mk
111 # Define Platform Rules
113 define PerPlatform_template
114 $(call Set
,Tmp.Key
,$(1))
115 $(call Set
,Tmp.Name
,$($(Tmp.Key
).Name
))
116 $(call Set
,Tmp.Configs
,$($(Tmp.Key
).Configs
))
117 $(call Set
,Tmp.ObjPath
,$(ProjObjRoot
)/$(Tmp.Name
))
119 # Top-Level Platform Target
120 $(Tmp.Name
):: $(Tmp.Configs
:%=$(Tmp.ObjPath
)/%/libcompiler_rt.a
)
124 $(Verb
) rm -rf
$(Tmp.ObjPath
)
126 # Per-Config Libraries
127 $(foreach config
,$(Tmp.Configs
),\
128 $(call PerPlatformConfig_template
,$(config
)))
131 define PerPlatformConfig_template
132 $(call Set
,Tmp.Config
,$(1))
133 $(call Set
,Tmp.ObjPath
,$(ProjObjRoot
)/$(Tmp.Name
)/$(Tmp.Config
))
135 # Compute the archs to build, depending on whether this is a universal build or
137 $(call Set
,Tmp.ArchsToBuild
,\
138 $(if
$(call IsDefined
,$(Tmp.Key
).UniversalArchs
),\
140 $(or
$($(Tmp.Key
).UniversalArchs.
$(Tmp.Config
)),\
141 $($(Tmp.Key
).UniversalArchs
))),\
142 $(call VarOrDefault
,$(Tmp.Key
).Arch.
$(Tmp.Config
),$($(Tmp.Key
).Arch
))))
144 # Copy or lipo to create the per-config library.
145 $(call Set
,Tmp.Inputs
,$(Tmp.ArchsToBuild
:%=$(Tmp.ObjPath
)/%/libcompiler_rt.a
))
146 $(Tmp.ObjPath
)/libcompiler_rt.a
: $(Tmp.Inputs
) $(Tmp.ObjPath
)/.
dir
147 $(Summary
) " FINAL-ARCHIVE: $(Tmp.Name)/$(Tmp.Config): $$@"
149 $(if
$(call streq
,1,$(words $(Tmp.ArchsToBuild
))), \
150 $(Verb
) $(CP
) $(Tmp.Inputs
) $$@
, \
151 $(Verb
) $(LIPO
) -create
-output
$$@
$(Tmp.Inputs
))
152 .PRECIOUS
: $(Tmp.ObjPath
)/.
dir
155 $(Tmp.Name
)-$(Tmp.Config
):: $(Tmp.ObjPath
)/libcompiler_rt.a
156 .PHONY
: $(Tmp.Name
)-$(Tmp.Config
)
158 # Per-Config-Arch Libraries
159 $(foreach arch
,$(Tmp.ArchsToBuild
),\
160 $(call PerPlatformConfigArch_template
,$(arch
)))
163 define PerPlatformConfigArch_template
164 $(call Set
,Tmp.Arch
,$(1))
165 $(call Set
,Tmp.ObjPath
,$(ProjObjRoot
)/$(Tmp.Name
)/$(Tmp.Config
)/$(Tmp.Arch
))
166 $(call Set
,Tmp.Functions
,$(strip \
167 $(AlwaysRequiredModules
) \
168 $(call GetCNAVar
,FUNCTIONS
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
169 $(call Set
,Tmp.Optimized
,$(strip \
170 $(call GetCNAVar
,OPTIMIZED
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
171 $(call Set
,Tmp.AR
,$(strip \
172 $(call GetCNAVar
,AR
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
173 $(call Set
,Tmp.ARFLAGS
,$(strip \
174 $(call GetCNAVar
,ARFLAGS
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
175 $(call Set
,Tmp.RANLIB
,$(strip \
176 $(call GetCNAVar
,RANLIB
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
177 $(call Set
,Tmp.RANLIBFLAGS
,$(strip \
178 $(call GetCNAVar
,RANLIBFLAGS
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
180 # Compute the object inputs for this library.
181 $(call Set
,Tmp.Inputs
,\
182 $(foreach fn
,$(sort $(Tmp.Functions
)),\
183 $(call Set
,Tmp.FnDir
,\
184 $(call SelectFunctionDir
,$(Tmp.Config
),$(Tmp.Arch
),$(fn
),$(Tmp.Optimized
)))\
185 $(Tmp.ObjPath
)/$(Tmp.FnDir
)/$(fn
).o
))
186 $(Tmp.ObjPath
)/libcompiler_rt.a
: $(Tmp.Inputs
) $(Tmp.ObjPath
)/.
dir
187 $(Summary
) " ARCHIVE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$@"
189 $(Verb
) $(Tmp.AR
) $(Tmp.ARFLAGS
) $$@
$(Tmp.Inputs
)
190 $(Verb
) $(Tmp.RANLIB
) $(Tmp.RANLIBFLAGS
) $$@
191 .PRECIOUS
: $(Tmp.ObjPath
)/.
dir
193 # Per-Config-Arch Targets
194 $(Tmp.Name
)-$(Tmp.Config
)-$(Tmp.Arch
):: $(Tmp.ObjPath
)/libcompiler_rt.a
195 .PHONY
: $(Tmp.Name
)-$(Tmp.Config
)-$(Tmp.Arch
)
197 # Per-Config-Arch-SubDir Objects
198 $(foreach key
,$(SubDirKeys
),\
199 $(call PerPlatformConfigArchSubDir_template
,$(key
)))
202 define PerPlatformConfigArchSubDir_template
203 $(call Set
,Tmp.SubDirKey
,$(1))
204 $(call Set
,Tmp.SubDir
,$($(Tmp.SubDirKey
).Dir
))
205 $(call Set
,Tmp.SrcPath
,$(ProjSrcRoot
)/$(Tmp.SubDir
))
206 $(call Set
,Tmp.ObjPath
,$(ProjObjRoot
)/$(Tmp.Name
)/$(Tmp.Config
)/$(Tmp.Arch
)/$(Tmp.SubDirKey
))
207 $(call Set
,Tmp.Dependencies
,$($(Tmp.SubDirKey
).Dependencies
))
208 $(call Set
,Tmp.CC
,$(strip \
209 $(call GetCNAVar
,CC
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
210 $(call Set
,Tmp.KERNEL_USE
,$(strip \
211 $(call GetCNAVar
,KERNEL_USE
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
212 $(call Set
,Tmp.VISIBILITY_HIDDEN
,$(strip \
213 $(call GetCNAVar
,VISIBILITY_HIDDEN
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
214 $(call Set
,Tmp.CFLAGS
,$(strip \
215 $(if
$(call IsDefined
,$(Tmp.Key
).UniversalArchs
),-arch
$(Tmp.Arch
),)\
216 $(if
$(call streq
,$(Tmp.VISIBILITY_HIDDEN
),1),\
217 -fvisibility
=hidden
-DVISIBILITY_HIDDEN
,)\
218 $(if
$(call streq
,$(Tmp.KERNEL_USE
),1),\
219 -mkernel
-DKERNEL_USE
,)\
220 $(call GetCNAVar
,CFLAGS
,$(Tmp.Key
),$(Tmp.Config
),$(Tmp.Arch
))))
222 $(Tmp.ObjPath
)/%.o
: $(Tmp.SrcPath
)/%.s
$(Tmp.Dependencies
) $(Tmp.ObjPath
)/.
dir
223 $(Summary
) " ASSEMBLE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<"
224 $(Verb
) $(Tmp.CC
) $(Tmp.CFLAGS
) -c
-o
$$@
$$<
225 $(Tmp.ObjPath
)/%.o
: $(Tmp.SrcPath
)/%.S
$(Tmp.Dependencies
) $(Tmp.ObjPath
)/.
dir
226 $(Summary
) " ASSEMBLE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<"
227 $(Verb
) $(Tmp.CC
) $(Tmp.CFLAGS
) -c
-o
$$@
$$<
228 $(Tmp.ObjPath
)/%.o
: $(Tmp.SrcPath
)/%.c
$(Tmp.Dependencies
) $(Tmp.ObjPath
)/.
dir
229 $(Summary
) " COMPILE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<"
230 $(Verb
) $(Tmp.CC
) $(Tmp.CFLAGS
) -c
$(COMMON_CFLAGS
) -o
$$@
$$<
231 $(Tmp.ObjPath
)/%.o
: $(Tmp.SrcPath
)/%.
cc $(Tmp.Dependencies
) $(Tmp.ObjPath
)/.
dir
232 $(Summary
) " COMPILE: $(Tmp.Name)/$(Tmp.Config)/$(Tmp.Arch): $$<"
233 $(Verb
) $(Tmp.CC
) $(Tmp.CFLAGS
) -c
$(COMMON_CXXFLAGS
) -o
$$@
$$<
234 .PRECIOUS
: $(Tmp.ObjPath
)/.
dir
239 $(foreach key
,$(PlatformKeys
),\
240 $(eval
$(call PerPlatform_template
,$(key
))))
244 ifneq ($(DEBUGMAKE
),)
245 $(info MAKE
: Done processing Makefile
)