]> git.saurik.com Git - apple/libsystem.git/blame - Makefile
Libsystem-123.tar.gz
[apple/libsystem.git] / Makefile
CommitLineData
c9e8bbd6
A
1NAME0 = libSystem
2NAME = $(NAME0).$(VersionLetter)
3
699e5813
A
4.include <CoreOS/Standard/Commands.mk>
5.include <CoreOS/Standard/Variables.mk>
6
c9e8bbd6 7# for now, use the default compiler
699e5813
A
8MYCC := $(CC)
9MYCCLIBS = -lgcc
10RTLIBS = -lcompiler_rt
11NARCHS != $(ECHO) $(RC_ARCHS) | $(WC) -w
c9e8bbd6
A
12.ifdef ALTUSRLOCALLIBSYSTEM
13LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
14.else
15LIBSYS = $(SDKROOT)/usr/local/lib/system
16.endif
17SLFS_F_PH = $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
18.ifdef SDKROOT
19SDKROOTCFLAGS = -isysroot '$(SDKROOT)'
699e5813 20SDKROOTLDFLAGS = -Wl,-syslibroot,'$(SDKROOT)'
c9e8bbd6 21.endif
699e5813 22ORDERFILES = -Wl,-order_file,$(SRCROOT)/SystemInit.order -Wl,-order_file,$(PLATFORM_ORDER_FILE)
7a301563
A
23LIBS = -lc -lcommonCrypto -ldyldapis\
24 -linfo -ldns_sd -lm -lmacho\
c9e8bbd6 25 -lnotify -lkeymgr -llaunch \
699e5813
A
26 -lcopyfile -lremovefile
27CONDITIONALLIBS = unc sandbox quarantine closure cache dispatch unwind \
28 dnsinfo
29LIBSCONDITIONAL != for L in $(CONDITIONALLIBS); do tconf -q --test usr_local_lib_system_Archive:lib$$L && $(ECHO) -l$$L; done
435227b9 30
c9e8bbd6
A
31# These variables are to guarantee that the left-hand side of an expression is
32# always a variable
33dynamic = dynamic
34
35all: build
36
37build: build-debug build-dynamic build-profile
38
39# These are the non B&I defaults
40.ifndef RC_ProjectName
41install: installhdrs install-all
42
43.else # RC_ProjectName
44
45.for F in $(FORMS)
46install: BI-install-$(F)
47.endfor # FORMS
48.endif # RC_ProjectName
49
50.for A in $(RC_ARCHS)
51OBJS-$(A) = $(OBJROOT)/$(A)/SystemMath.o $(OBJROOT)/$(A)/System_vers.o
52.endfor # RC_ARCHS
53
54.for F in $(FORMS)
55.if $(dynamic) == $(F)
56SUFFIX$(F) =
57.else
58SUFFIX$(F) = _$(F)
59.endif
60.if !empty(FEATURE_LIBMATHCOMMON)
61LIBMATHCOMMON$(F) = -L/usr/lib/system -sub_library libmathCommon$(SUFFIX$(F)) -lmathCommon$(SUFFIX$(F))
62.endif
699e5813 63LIPOARGS$(F) != $(PERL) -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/$$_/$(F)/$(NAME)$(SUFFIX$(F)).dylib\"), qw($(RC_ARCHS))))'
c9e8bbd6
A
64
65.for A in $(RC_ARCHS)
66build-$(F): build-$(A)-$(F)
67.endfor # RC_ARCHS
68build-$(F):
69.if $(NARCHS) == 1
699e5813 70 $(CP) "$(OBJROOT)/$(RC_ARCHS)/$(F)/$(NAME)$(SUFFIX$(F)).dylib" "$(SYMROOT)"
c9e8bbd6 71.else
699e5813 72 $(LIPO) -create $(LIPOARGS$(F)) -output "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib"
c9e8bbd6 73.endif
699e5813 74 $(DSYMUTIL) "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib"
c9e8bbd6
A
75
76.for A in $(RC_ARCHS)
699e5813
A
77LINKDYLIB-$(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))/)
86
c9e8bbd6 87build-$(A)-$(F): $(OBJROOT)/$(A)/$(F) $(OBJROOT)/$(A)/CommPageSymbols.o $(OBJS-$(A))
699e5813
A
88 @$(ECHO) $(LINKDYLIB-$(F)-$(A)) $(RTLIBS) && \
89 if $(LINKDYLIB-$(F)-$(A)) $(RTLIBS); then \
90 $(ECHO) -n; \
91 else \
92 $(ECHO) '*** Failed. Retrying with -lgcc ***' && \
93 $(ECHO) $(LINKDYLIB-$(F)-$(A)) $(MYCCLIBS) && \
94 $(LINKDYLIB-$(F)-$(A)) $(MYCCLIBS); \
95 fi
c9e8bbd6
A
96
97$(OBJROOT)/$(A)/$(F):
699e5813 98 $(MKDIR) '$(.TARGET)'
c9e8bbd6
A
99
100.endfor # RC_ARCHS
101.endfor # FORMS
102
103SEG1ADDR_i386 = 0xffff0000
104SEG1ADDR_ppc = 0xffff8000
105SEG1ADDR_ppc64 = 0xffffffffffff8000
106SEG1ADDR_x86_64 = 0x00007fffffe00000
107SEG1ADDR_arm = 0xffff8000
108
109CFLAGS = -g -Os -Wall -Werror -I'$(SLFS_F_PH)' -fno-common $(SDKROOTCFLAGS)
110
111$(OBJROOT)/System_vers.c:
699e5813
A
112 $(VERS_STRING) -c System | \
113 $(SED) -e 's/SGS_VERS/SYSTEM_VERS_STRING/' -e 's/VERS_NUM/SYSTEM_VERS_NUM/' > $(.TARGET)
435227b9 114
c9e8bbd6
A
115.for A in $(RC_ARCHS)
116$(OBJROOT)/$(A)/CommPageSymbols.o: $(SRCROOT)/CommPageSymbols.st
699e5813
A
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)'
435227b9 119
c9e8bbd6 120$(OBJROOT)/$(A)/SystemMath.o: $(SRCROOT)/SystemMath.s
699e5813 121 $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
435227b9 122
c9e8bbd6 123$(OBJROOT)/$(A)/System_vers.o: $(OBJROOT)/System_vers.c
699e5813 124 $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
435227b9 125
c9e8bbd6 126.endfor # RC_ARCHS
435227b9 127
c9e8bbd6 128installhdrs:
435227b9 129
c9e8bbd6
A
130.for F in $(FORMS)
131BI-install-$(F): build-$(F)
699e5813
A
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"
c9e8bbd6 138.endfor # FORMS
435227b9 139
c9e8bbd6
A
140install-all: build
141.for F in $(FORMS)
142install-all: BI-install-$(F)
143.endfor # FORMS
435227b9 144
c9e8bbd6
A
145clean:
146.for A in $(RC_ARCHS)
699e5813 147 $(RMDIR) $(OBJROOT)/$(A)
c9e8bbd6 148.endfor # RC_ARCHS