blob: d3d4771309c444ad73f6cc7e887d528fa90b07d7 [file] [log] [blame]
Daniel Dunbarb3a69012009-06-26 16:47:03 +00001
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
Nick Kledzikafb7b6e2010-04-21 22:46:53 +000015ifeq (,$(SDKROOT))
16 INSTALL_TARGET = install-MacOSX
17else
Nick Kledzikdc0b5592010-07-04 18:29:23 +000018 INSTALL_TARGET = install-iOS
Nick Kledzikafb7b6e2010-04-21 22:46:53 +000019endif
20
21
Nick Kledzik9435c402011-06-21 00:07:55 +000022
Daniel Dunbar557a6ea2010-01-13 16:13:01 +000023# Log full compile lines in B&I logs and omit summary lines.
24Verb :=
Daniel Dunbarb3a69012009-06-26 16:47:03 +000025Summary := @true
26
Daniel Dunbar557a6ea2010-01-13 16:13:01 +000027# List of functions needed for each architecture.
Daniel Dunbarb3a69012009-06-26 16:47:03 +000028
Daniel Dunbar557a6ea2010-01-13 16:13:01 +000029# Copies any public headers to DSTROOT.
Daniel Dunbarb3a69012009-06-26 16:47:03 +000030installhdrs:
31
32
Daniel Dunbar557a6ea2010-01-13 16:13:01 +000033# Copies source code to SRCROOT.
Daniel Dunbarb3a69012009-06-26 16:47:03 +000034installsrc:
Daniel Dunbar3c2a7762010-01-18 06:49:42 +000035 cp -r . $(SRCROOT)
Daniel Dunbarb3a69012009-06-26 16:47:03 +000036
37
Nick Kledzikafb7b6e2010-04-21 22:46:53 +000038install: $(INSTALL_TARGET)
39
Daniel Dunbar557a6ea2010-01-13 16:13:01 +000040# Copy results to DSTROOT.
Nick Kledzik7956ca92011-04-14 00:45:01 +000041install-MacOSX : $(SYMROOT)/libcompiler_rt.dylib \
42 $(SYMROOT)/libcompiler_rt-dyld.a
43 mkdir -p $(DSTROOT)/usr/local/lib/dyld
44 cp $(SYMROOT)/libcompiler_rt-dyld.a \
45 $(DSTROOT)/usr/local/lib/dyld/libcompiler_rt.a
Nick Kledzik1f7ee1d2010-03-31 20:38:57 +000046 mkdir -p $(DSTROOT)/usr/lib/system
Nick Kledzik9435c402011-06-21 00:07:55 +000047 $(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
Nick Kledzik1f7ee1d2010-03-31 20:38:57 +000048 -o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
49 cd $(DSTROOT)/usr/lib/system; \
50 ln -s libcompiler_rt.dylib libcompiler_rt_profile.dylib; \
51 ln -s libcompiler_rt.dylib libcompiler_rt_debug.dylib
Daniel Dunbarb3a69012009-06-26 16:47:03 +000052
Nick Kledzik1f7ee1d2010-03-31 20:38:57 +000053# Rule to make each dylib slice
54$(OBJROOT)/libcompiler_rt-%.dylib : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
55 echo "const char vers[] = \"@(#) $(RC_ProjectName)-$(RC_ProjectSourceVersion)\"; " > $(OBJROOT)/version.c
Nick Kledzik9435c402011-06-21 00:07:55 +000056 $(call GetCNAVar,CC,Platform.darwin_bni,Release,$*) \
57 $(OBJROOT)/version.c -arch $* -dynamiclib \
Nick Kledzik1f7ee1d2010-03-31 20:38:57 +000058 -install_name /usr/lib/system/libcompiler_rt.dylib \
59 -compatibility_version 1 -current_version $(RC_ProjectSourceVersion) \
Nick Kledzikef3667a2013-03-05 00:16:52 +000060 -nodefaultlibs -umbrella System -dead_strip \
61 -Wl,-upward-lunwind \
62 -Wl,-upward-lsystem_m \
63 -Wl,-upward-lsystem_c \
Nick Kledzike04a1fd2013-05-21 23:02:04 +000064 -Wl,-upward-lsystem_platform \
Nick Kledzikef3667a2013-03-05 00:16:52 +000065 -Wl,-ldyld \
66 -Wl,-lsystem_kernel \
67 -L$(SDKROOT)/usr/lib/system \
Nick Kledzik9435c402011-06-21 00:07:55 +000068 $(DYLIB_FLAGS) -Wl,-force_load,$^ -o $@
Daniel Dunbarb3a69012009-06-26 16:47:03 +000069
Nick Kledzik1f7ee1d2010-03-31 20:38:57 +000070# Rule to make fat dylib
Nick Kledzika11b52f2011-09-27 20:05:27 +000071$(SYMROOT)/libcompiler_rt.dylib: $(foreach arch,$(filter-out armv4t,$(RC_ARCHS)), \
Nick Kledzikafb7b6e2010-04-21 22:46:53 +000072 $(OBJROOT)/libcompiler_rt-$(arch).dylib)
Nick Kledzik9435c402011-06-21 00:07:55 +000073 $(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o $@
Nick Kledzikc0973d62012-11-26 22:48:51 +000074 $(call GetCNAVar,DSYMUTIL,Platform.darwin_bni,Release,) $@
Nick Kledzikafb7b6e2010-04-21 22:46:53 +000075
76
77# Copy results to DSTROOT.
Nick Kledzik3d407402011-03-05 02:15:16 +000078install-iOS: $(SYMROOT)/libcompiler_rt-static.a \
Nick Kledzik7956ca92011-04-14 00:45:01 +000079 $(SYMROOT)/libcompiler_rt-dyld.a \
Nick Kledzik3d407402011-03-05 02:15:16 +000080 $(SYMROOT)/libcompiler_rt.dylib
81 mkdir -p $(DSTROOT)/usr/local/lib
Nick Kledzikafb7b6e2010-04-21 22:46:53 +000082 cp $(SYMROOT)/libcompiler_rt-static.a \
Nick Kledzikdc0b5592010-07-04 18:29:23 +000083 $(DSTROOT)/usr/local/lib/libcompiler_rt-static.a
Nick Kledzik7956ca92011-04-14 00:45:01 +000084 mkdir -p $(DSTROOT)/usr/local/lib/dyld
85 cp $(SYMROOT)/libcompiler_rt-dyld.a \
86 $(DSTROOT)/usr/local/lib/dyld/libcompiler_rt.a
Nick Kledzik3d407402011-03-05 02:15:16 +000087 mkdir -p $(DSTROOT)/usr/lib/system
Nick Kledzik9435c402011-06-21 00:07:55 +000088 $(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
Nick Kledzik3d407402011-03-05 02:15:16 +000089 -o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
Nick Kledzikafb7b6e2010-04-21 22:46:53 +000090
Nick Kledzikafb7b6e2010-04-21 22:46:53 +000091
92# Rule to make fat archive
93$(SYMROOT)/libcompiler_rt-static.a : $(foreach arch,$(RC_ARCHS), \
94 $(OBJROOT)/darwin_bni/Static/$(arch)/libcompiler_rt.a)
Nick Kledzik9435c402011-06-21 00:07:55 +000095 $(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o $@
Daniel Dunbarb3a69012009-06-26 16:47:03 +000096
Nick Kledzik9435c402011-06-21 00:07:55 +000097# rule to make each archive slice for dyld (which removes a few archive members)
Nick Kledzik7956ca92011-04-14 00:45:01 +000098$(OBJROOT)/libcompiler_rt-dyld-%.a : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
99 cp $^ $@
Nick Kledzik9435c402011-06-21 00:07:55 +0000100 DEL_LIST=`$(AR) -t $@ | egrep 'apple_versioning|gcc_personality_v0|eprintf' | xargs echo` ; \
101 if [ -n "$${DEL_LIST}" ] ; \
102 then \
103 $(call GetCNAVar,AR,Platform.darwin_bni,Release,) -d $@ $${DEL_LIST}; \
104 $(call GetCNAVar,RANLIB,Platform.darwin_bni,Release,) $@ ; \
105 fi
Nick Kledzik7956ca92011-04-14 00:45:01 +0000106
107# rule to make make archive for dyld
108$(SYMROOT)/libcompiler_rt-dyld.a : $(foreach arch,$(RC_ARCHS), \
109 $(OBJROOT)/libcompiler_rt-dyld-$(arch).a)
Nick Kledzik9435c402011-06-21 00:07:55 +0000110 $(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o $@
Nick Kledzik7956ca92011-04-14 00:45:01 +0000111