2 NAME = $(NAME0).$(VersionLetter)
4 .include <CoreOS/Standard/Commands.mk>
5 .include <CoreOS/Standard/Variables.mk>
7 # for now, use the default compiler
10 RTLIBS = -lcompiler_rt
11 NARCHS != $(ECHO) $(RC_ARCHS) | $(WC) -w
12 .ifdef ALTUSRLOCALLIBSYSTEM
13 LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
15 LIBSYS = $(SDKROOT)/usr/local/lib/system
17 SLFS_F_PH = $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
19 SDKROOTCFLAGS = -isysroot '$(SDKROOT)'
20 SDKROOTLDFLAGS = -Wl,-syslibroot,'$(SDKROOT)'
22 ORDERFILES = -Wl,-order_file,$(SRCROOT)/SystemInit.order -Wl,-order_file,$(PLATFORM_ORDER_FILE)
23 LIBS = -lc -lcommonCrypto -ldyldapis\
24 -linfo -ldns_sd -lm -lmacho\
25 -lnotify -lkeymgr -llaunch \
26 -lcopyfile -lremovefile
27 CONDITIONALLIBS = unc sandbox quarantine closure cache dispatch unwind \
29 LIBSCONDITIONAL != for L in $(CONDITIONALLIBS); do tconf -q --test usr_local_lib_system_Archive:lib$$L && $(ECHO) -l$$L; done
31 # These variables are to guarantee that the left-hand side of an expression is
37 build: build-debug build-dynamic build-profile
39 # These are the non B&I defaults
40 .ifndef RC_ProjectName
41 install: installhdrs install-all
43 .else # RC_ProjectName
46 install: BI-install-$(F)
48 .endif # RC_ProjectName
51 OBJS-$(A) = $(OBJROOT)/$(A)/SystemMath.o $(OBJROOT)/$(A)/System_vers.o
55 .if $(dynamic) == $(F)
60 .if !empty(FEATURE_LIBMATHCOMMON)
61 LIBMATHCOMMON$(F) = -L/usr/lib/system -sub_library libmathCommon$(SUFFIX$(F)) -lmathCommon$(SUFFIX$(F))
63 LIPOARGS$(F) != $(PERL) -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/$$_/$(F)/$(NAME)$(SUFFIX$(F)).dylib\"), qw($(RC_ARCHS))))'
66 build-$(F): build-$(A)-$(F)
70 $(CP) "$(OBJROOT)/$(RC_ARCHS)/$(F)/$(NAME)$(SUFFIX$(F)).dylib" "$(SYMROOT)"
72 $(LIPO) -create $(LIPOARGS$(F)) -output "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib"
74 $(DSYMUTIL) "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib"
77 LINKDYLIB-$(F)-$(A) = $(MYCC) -dynamiclib -arch $(A) -pipe $(SDKROOTLDFLAGS) \
78 -o '$(OBJROOT)/$(A)/$(F)/$(NAME)$(SUFFIX$(F)).dylib' \
79 -compatibility_version 1 -current_version $(Version) \
80 -install_name /usr/lib/$(NAME)$(SUFFIX$(F)).dylib \
81 -nodefaultlibs -all_load -multi_module -Wl,-search_paths_first \
82 -segcreate __DATA __commpage $(OBJROOT)/$(A)/CommPageSymbols.o \
83 $(ORDERFILES) $(SKDROOTLDFLAGS) $(OBJS-$(A)) \
84 -L$(DSTROOT)/usr/local/lib/system -L$(LIBSYS) $(LIBMATHCOMMON$(F)) \
85 $(LIBS:C/$/$(SUFFIX$(F))/) $(LIBSCONDITIONAL:C/$/$(SUFFIX$(F))/)
87 build-$(A)-$(F): $(OBJROOT)/$(A)/$(F) $(OBJROOT)/$(A)/CommPageSymbols.o $(OBJS-$(A))
88 @$(ECHO) $(LINKDYLIB-$(F)-$(A)) $(RTLIBS) && \
89 if $(LINKDYLIB-$(F)-$(A)) $(RTLIBS); then \
92 $(ECHO) '*** Failed. Retrying with -lgcc ***' && \
93 $(ECHO) $(LINKDYLIB-$(F)-$(A)) $(MYCCLIBS) && \
94 $(LINKDYLIB-$(F)-$(A)) $(MYCCLIBS); \
103 SEG1ADDR_i386 = 0xffff0000
104 SEG1ADDR_ppc = 0xffff8000
105 SEG1ADDR_ppc64 = 0xffffffffffff8000
106 SEG1ADDR_x86_64 = 0x00007fffffe00000
107 SEG1ADDR_arm = 0xffff8000
109 CFLAGS = -g -Os -Wall -Werror -I'$(SLFS_F_PH)' -fno-common $(SDKROOTCFLAGS)
111 $(OBJROOT)/System_vers.c:
112 $(VERS_STRING) -c System | \
113 $(SED) -e 's/SGS_VERS/SYSTEM_VERS_STRING/' -e 's/VERS_NUM/SYSTEM_VERS_NUM/' > $(.TARGET)
115 .for A in $(RC_ARCHS)
116 $(OBJROOT)/$(A)/CommPageSymbols.o: $(SRCROOT)/CommPageSymbols.st
117 $(MYCC) -c -o '$(.TARGET:R)_intermediate.$(.TARGET:E)' -arch $(A) -x assembler-with-cpp $(CFLAGS) '$(.ALLSRC)'
118 $(LD) -arch $(A) -r -seg1addr $(SEG1ADDR_$(A:C/^armv.*$/arm/)) '$(.TARGET:R)_intermediate.$(.TARGET:E)' -o '$(.TARGET)'
120 $(OBJROOT)/$(A)/SystemMath.o: $(SRCROOT)/SystemMath.s
121 $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
123 $(OBJROOT)/$(A)/System_vers.o: $(OBJROOT)/System_vers.c
124 $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
131 BI-install-$(F): build-$(F)
132 $(MKDIR) "$(DSTROOT)/usr/lib"
133 @$(ECHO) "===== Installing $(NAME)$(SUFFIX$(F)).dylib ====="
134 $(INSTALL) "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib" "$(DSTROOT)/usr/lib"
135 $(STRIP) -S "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib"
136 $(CHMOD) a-w "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib"
137 $(LN) -sf "$(NAME)$(SUFFIX$(F)).dylib" "$(DSTROOT)/usr/lib/$(NAME0)$(SUFFIX$(F)).dylib"
142 install-all: BI-install-$(F)
146 .for A in $(RC_ARCHS)
147 $(RMDIR) $(OBJROOT)/$(A)