Home | History | Annotate | Download | only in make
      1 
      2 #
      3 # Make rules to build compiler_rt in Apple B&I infrastructure
      4 #
      5 
      6 # set ProjSrcRoot appropriately
      7 ProjSrcRoot := $(SRCROOT)
      8 # set ProjObjRoot appropriately
      9 ifdef OBJROOT
     10   ProjObjRoot := $(OBJROOT)
     11 else
     12   ProjObjRoot := $(ProjSrcRoot)
     13 endif
     14 
     15 ifeq (,$(SDKROOT))
     16 	INSTALL_TARGET = install-MacOSX
     17 else
     18 	INSTALL_TARGET = install-iOS
     19 endif
     20 
     21 
     22 
     23 # Log full compile lines in B&I logs and omit summary lines.
     24 Verb :=
     25 Summary := @true
     26 
     27 # List of functions needed for each architecture.
     28 
     29 # Copies any public headers to DSTROOT.
     30 installhdrs:
     31 
     32 
     33 # Copies source code to SRCROOT.
     34 installsrc:
     35 	cp -r . $(SRCROOT)
     36 
     37 
     38 install:  $(INSTALL_TARGET)
     39 
     40 # Copy results to DSTROOT.
     41 install-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
     46 	mkdir -p $(DSTROOT)/usr/lib/system
     47 	$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
     48 	    -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
     52 
     53 # 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
     56 	$(call GetCNAVar,CC,Platform.darwin_bni,Release,$*) \
     57 	   $(OBJROOT)/version.c -arch $* -dynamiclib \
     58 	   -install_name /usr/lib/system/libcompiler_rt.dylib \
     59 	   -compatibility_version 1 -current_version $(RC_ProjectSourceVersion) \
     60 	   -nodefaultlibs -umbrella System -dead_strip \
     61 	   -Wl,-upward-lunwind \
     62 	   -Wl,-upward-lsystem_m \
     63 	   -Wl,-upward-lsystem_c \
     64 	   -Wl,-upward-lsystem_platform \
     65 	   -Wl,-ldyld \
     66 	   -Wl,-lsystem_kernel \
     67 	   -L$(SDKROOT)/usr/lib/system \
     68 	   $(DYLIB_FLAGS) -Wl,-force_load,$^ -o $@ 
     69 
     70 # Rule to make fat dylib
     71 $(SYMROOT)/libcompiler_rt.dylib: $(foreach arch,$(filter-out armv4t,$(RC_ARCHS)), \
     72                                         $(OBJROOT)/libcompiler_rt-$(arch).dylib)
     73 	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
     74 	$(call GetCNAVar,DSYMUTIL,Platform.darwin_bni,Release,) $@
     75 
     76 
     77 # Copy results to DSTROOT.
     78 install-iOS: $(SYMROOT)/libcompiler_rt-static.a \
     79              $(SYMROOT)/libcompiler_rt-dyld.a \
     80              $(SYMROOT)/libcompiler_rt.dylib
     81 	mkdir -p $(DSTROOT)/usr/local/lib
     82 	cp $(SYMROOT)/libcompiler_rt-static.a  \
     83 				    $(DSTROOT)/usr/local/lib/libcompiler_rt-static.a
     84 	mkdir -p $(DSTROOT)/usr/local/lib/dyld
     85 	cp $(SYMROOT)/libcompiler_rt-dyld.a  \
     86 				    $(DSTROOT)/usr/local/lib/dyld/libcompiler_rt.a
     87 	mkdir -p $(DSTROOT)/usr/lib/system
     88 	$(call GetCNAVar,STRIP,Platform.darwin_bni,Release,) -S $(SYMROOT)/libcompiler_rt.dylib \
     89 	    -o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
     90 
     91 	
     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)
     95 	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
     96 
     97 # rule to make each archive slice for dyld (which removes a few archive members)
     98 $(OBJROOT)/libcompiler_rt-dyld-%.a : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
     99 	cp $^ $@
    100 	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
    106 
    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)
    110 	$(call GetCNAVar,LIPO,Platform.darwin_bni,Release,) -create $^ -o  $@
    111 
    112