AppleBI.mk revision f7e6f383d9c661ccbcd986fc1478336f57f4ce7c
1
2#
3# Make rules to build compiler_rt in Apple B&I infrastructure
4#
5
6# set ProjSrcRoot appropriately
7ProjSrcRoot := $(SRCROOT)
8# set ProjObjRoot appropriately
9ifdef OBJROOT
10  ProjObjRoot := $(OBJROOT)
11else
12  ProjObjRoot := $(ProjSrcRoot)
13endif
14
15ifeq (,$(RC_PURPLE))
16	INSTALL_TARGET = install-MacOSX
17else
18  ifeq (,$(RC_INDIGO))
19    INSTALL_TARGET = install-iOS
20  else
21    INSTALL_TARGET = install-iOS-Simulator
22  endif
23endif
24
25
26
27# Log full compile lines in B&I logs and omit summary lines.
28Verb :=
29Summary := @true
30
31# List of functions needed for each architecture.
32
33# Copies any public headers to DSTROOT.
34installhdrs:
35
36
37# Copies source code to SRCROOT.
38installsrc:
39	cp -r . $(SRCROOT)
40
41
42install:  $(INSTALL_TARGET)
43
44# Copy results to DSTROOT.
45install-MacOSX : $(SYMROOT)/libcompiler_rt.dylib \
46                 $(SYMROOT)/libcompiler_rt-dyld.a 
47	mkdir -p $(DSTROOT)/usr/local/lib/dyld
48	cp $(SYMROOT)/libcompiler_rt-dyld.a  \
49				    $(DSTROOT)/usr/local/lib/dyld/libcompiler_rt.a
50	mkdir -p $(DSTROOT)/usr/lib/system
51	$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
52	    -o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
53	cd $(DSTROOT)/usr/lib/system; \
54	    ln -s libcompiler_rt.dylib libcompiler_rt_profile.dylib; \
55	    ln -s libcompiler_rt.dylib libcompiler_rt_debug.dylib
56
57# Rule to make each dylib slice
58$(OBJROOT)/libcompiler_rt-%.dylib : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
59	echo "const char vers[] = \"@(#) $(RC_ProjectName)-$(RC_ProjectSourceVersion)\"; " > $(OBJROOT)/version.c
60	$(call GetCNAVar,CC,Platform.darwin_bni,Release,$*) \
61	   $(OBJROOT)/version.c -arch $* -dynamiclib \
62	   -install_name /usr/lib/system/libcompiler_rt.dylib \
63	   -compatibility_version 1 -current_version $(RC_ProjectSourceVersion) \
64	   -nodefaultlibs -umbrella System -dead_strip \
65	   -Wl,-upward-lunwind \
66	   -Wl,-upward-lsystem_m \
67	   -Wl,-upward-lsystem_c \
68	   -Wl,-upward-lsystem_kernel \
69	   -Wl,-upward-lsystem_platform \
70	   -Wl,-ldyld \
71	   -L$(SDKROOT)/usr/lib/system \
72	   $(DYLIB_FLAGS) -Wl,-force_load,$^ -o $@ 
73
74# Rule to make fat dylib
75$(SYMROOT)/libcompiler_rt.dylib: $(foreach arch,$(filter-out armv4t,$(RC_ARCHS)), \
76                                        $(OBJROOT)/libcompiler_rt-$(arch).dylib)
77	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
78	$(call GetCNAVar,DSYMUTIL,Platform.darwin_bni,Release,) $@
79
80
81# Copy results to DSTROOT.
82install-iOS: $(SYMROOT)/libcompiler_rt-static.a \
83             $(SYMROOT)/libcompiler_rt-dyld.a \
84             $(SYMROOT)/libcompiler_rt.dylib
85	mkdir -p $(DSTROOT)/usr/local/lib
86	cp $(SYMROOT)/libcompiler_rt-static.a  \
87				    $(DSTROOT)/usr/local/lib/libcompiler_rt-static.a
88	mkdir -p $(DSTROOT)/usr/local/lib/dyld
89	cp $(SYMROOT)/libcompiler_rt-dyld.a  \
90				    $(DSTROOT)/usr/local/lib/dyld/libcompiler_rt.a
91	mkdir -p $(DSTROOT)/usr/lib/system
92	$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
93	    -o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
94
95# Rule to make fat archive
96$(SYMROOT)/libcompiler_rt-static.a : $(foreach arch,$(RC_ARCHS), \
97                         $(OBJROOT)/darwin_bni/Static/$(arch)/libcompiler_rt.a)
98	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
99
100# rule to make each archive slice for dyld (which removes a few archive members)
101$(OBJROOT)/libcompiler_rt-dyld-%.a : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
102	cp $^ $@
103	DEL_LIST=`$(AR)  -t $@ | egrep 'apple_versioning|gcc_personality_v0|eprintf' | xargs echo` ; \
104	if [ -n "$${DEL_LIST}" ] ; \
105	then  \
106		$(call GetCNAVar,AR,Platform.darwin_bni,Release,) -d $@ $${DEL_LIST}; \
107		$(call GetCNAVar,RANLIB,Platform.darwin_bni,Release,) $@ ; \
108	fi
109
110# rule to make make archive for dyld
111$(SYMROOT)/libcompiler_rt-dyld.a : $(foreach arch,$(RC_ARCHS), \
112                         $(OBJROOT)/libcompiler_rt-dyld-$(arch).a)
113	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
114
115
116
117# Copy results to DSTROOT.
118install-iOS-Simulator: $(SYMROOT)/libcompiler_rt_sim.dylib \
119                       $(SYMROOT)/libcompiler_rt-dyld.a
120	mkdir -p $(DSTROOT)/$(SDKROOT)/usr/lib/system
121	$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt_sim.dylib \
122	    -o $(DSTROOT)/$(SDKROOT)/usr/lib/system/libcompiler_rt_sim.dylib
123	mkdir -p $(DSTROOT)/$(SDKROOT)/usr/local/lib/dyld
124	cp $(SYMROOT)/libcompiler_rt-dyld.a  \
125				    $(DSTROOT)/$(SDKROOT)/usr/local/lib/dyld/libcompiler_rt.a
126  
127# Rule to make fat dylib
128$(SYMROOT)/libcompiler_rt_sim.dylib: $(foreach arch,$(RC_ARCHS), \
129                                        $(OBJROOT)/libcompiler_rt_sim-$(arch).dylib)
130	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
131	$(call GetCNAVar,DSYMUTIL,Platform.darwin_bni,Release,) $@
132
133# Rule to make each dylib slice
134$(OBJROOT)/libcompiler_rt_sim-%.dylib : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
135	echo "const char vers[] = \"@(#) $(RC_ProjectName)-$(RC_ProjectSourceVersion)\"; " > $(OBJROOT)/version.c
136	$(call GetCNAVar,CC,Platform.darwin_bni,Release,$*) \
137	   $(OBJROOT)/version.c -arch $* -dynamiclib \
138	   -install_name /usr/lib/system/libcompiler_rt_sim.dylib \
139	   -compatibility_version 1 -current_version $(RC_ProjectSourceVersion) \
140     -Wl,-unexported_symbol,___enable_execute_stack \
141	   -nostdlib \
142	   -Wl,-upward-lunwind_sim \
143	   -Wl,-upward-lsystem_sim_m \
144	   -Wl,-upward-lsystem_sim_c \
145	   -ldyld_sim \
146	   -Wl,-upward-lSystem \
147	   -umbrella System -Wl,-no_implicit_dylibs -L$(SDKROOT)/usr/lib/system -dead_strip \
148	   $(DYLIB_FLAGS) -Wl,-force_load,$^ -o $@ 
149
150