]> git.saurik.com Git - apple/libsystem.git/blob - Makefile
Libsystem-111.1.3.tar.gz
[apple/libsystem.git] / Makefile
1 NAME0 = libSystem
2 NAME = $(NAME0).$(VersionLetter)
3
4 # for now, use the default compiler
5 GCC := $(CC)
6 GCCLIBS = -lgcc -lgcc_eh
7 NARCHS != echo $(RC_ARCHS) | wc -w
8 .ifdef ALTUSRLOCALLIBSYSTEM
9 LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
10 .else
11 LIBSYS = $(SDKROOT)/usr/local/lib/system
12 .endif
13 SLFS_F_PH = $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
14 .ifdef SDKROOT
15 SDKROOTCFLAGS = -isysroot '$(SDKROOT)'
16 SDKROOTLDFLAGS = -syslibroot '$(SDKROOT)'
17 .endif
18 .if !empty(FEATURE_ORDER_FILE)
19 ORDERFILES = -Wl,-order_file,$(SRCROOT)/SystemInit.order -Wl,-order_file,$(SRCROOT)/System.order
20 .endif
21 LIBS = -lc -lcommonCrypto -ldyldapis\
22 -linfo -ldns_sd -lm -lmacho\
23 -lnotify -lkeymgr -llaunch \
24 -lcopyfile -lsandbox -lremovefile
25 CONDITIONALLIBS = unc quarantine
26 .for L in $(CONDITIONALLIBS)
27 # the following should be replaced with tconf when 5784037 is complete
28 .if exists($(LIBSYS)/lib$(L).a)
29 LIBS += -l$(L)
30 .endif
31 .endfor # CONDITIONALLIBS
32
33 # These variables are to guarantee that the left-hand side of an expression is
34 # always a variable
35 dynamic = dynamic
36
37 all: build
38
39 build: build-debug build-dynamic build-profile
40
41 # These are the non B&I defaults
42 .ifndef RC_ProjectName
43 install: installhdrs install-all
44
45 .else # RC_ProjectName
46
47 .for F in $(FORMS)
48 install: BI-install-$(F)
49 .endfor # FORMS
50 .endif # RC_ProjectName
51
52 .for A in $(RC_ARCHS)
53 OBJS-$(A) = $(OBJROOT)/$(A)/SystemMath.o $(OBJROOT)/$(A)/System_vers.o
54 .endfor # RC_ARCHS
55
56 .for F in $(FORMS)
57 .if $(dynamic) == $(F)
58 SUFFIX$(F) =
59 .else
60 SUFFIX$(F) = _$(F)
61 .endif
62 .if !empty(FEATURE_LIBMATHCOMMON)
63 LIBMATHCOMMON$(F) = -L/usr/lib/system -sub_library libmathCommon$(SUFFIX$(F)) -lmathCommon$(SUFFIX$(F))
64 .endif
65 LIPOARGS$(F) != perl -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/$$_/$(F)/$(NAME)$(SUFFIX$(F)).dylib\"), qw($(RC_ARCHS))))'
66
67 .for A in $(RC_ARCHS)
68 build-$(F): build-$(A)-$(F)
69 .endfor # RC_ARCHS
70 build-$(F):
71 .if $(NARCHS) == 1
72 cp -p "$(OBJROOT)/$(RC_ARCHS)/$(F)/$(NAME)$(SUFFIX$(F)).dylib" "$(SYMROOT)"
73 .else
74 lipo -create $(LIPOARGS$(F)) -output "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib"
75 .endif
76 dsymutil "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib"
77
78 .for A in $(RC_ARCHS)
79 build-$(A)-$(F): $(OBJROOT)/$(A)/$(F) $(OBJROOT)/$(A)/CommPageSymbols.o $(OBJS-$(A))
80 $(GCC) -dynamiclib -arch $(A) -pipe \
81 -o '$(OBJROOT)/$(A)/$(F)/$(NAME)$(SUFFIX$(F)).dylib' \
82 -compatibility_version 1 -current_version $(Version) \
83 -install_name /usr/lib/$(NAME)$(SUFFIX$(F)).dylib \
84 -nodefaultlibs -all_load -multi_module -Wl,-search_paths_first \
85 -segcreate __DATA __commpage $(OBJROOT)/$(A)/CommPageSymbols.o \
86 $(ORDERFILES) $(SKDROOTLDFLAGS) $(OBJS-$(A)) \
87 -L$(DSTROOT)/usr/local/lib/system -L$(LIBSYS) $(LIBMATHCOMMON$(F)) \
88 $(LIBS:C/$/$(SUFFIX$(F))/) $(GCCLIBS)
89
90 $(OBJROOT)/$(A)/$(F):
91 mkdir -p '$(.TARGET)'
92
93 .endfor # RC_ARCHS
94 .endfor # FORMS
95
96 SEG1ADDR_i386 = 0xffff0000
97 SEG1ADDR_ppc = 0xffff8000
98 SEG1ADDR_ppc64 = 0xffffffffffff8000
99 SEG1ADDR_x86_64 = 0x00007fffffe00000
100 SEG1ADDR_arm = 0xffff8000
101
102 CFLAGS = -g -Os -Wall -Werror -I'$(SLFS_F_PH)' -fno-common $(SDKROOTCFLAGS)
103
104 $(OBJROOT)/System_vers.c:
105 vers_string -c System | \
106 sed -e 's/SGS_VERS/SYSTEM_VERS_STRING/' -e 's/VERS_NUM/SYSTEM_VERS_NUM/' > $(.TARGET)
107
108 .for A in $(RC_ARCHS)
109 $(OBJROOT)/$(A)/CommPageSymbols.o: $(SRCROOT)/CommPageSymbols.st
110 $(GCC) -c -o '$(.TARGET:R)_intermediate.$(.TARGET:E)' -arch $(A) -x assembler-with-cpp $(CFLAGS) '$(.ALLSRC)'
111 ld -arch $(A) -r -seg1addr $(SEG1ADDR_$(A:C/^armv.*$/arm/)) '$(.TARGET:R)_intermediate.$(.TARGET:E)' -o '$(.TARGET)'
112
113 $(OBJROOT)/$(A)/SystemMath.o: $(SRCROOT)/SystemMath.s
114 $(GCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
115
116 $(OBJROOT)/$(A)/System_vers.o: $(OBJROOT)/System_vers.c
117 $(GCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
118
119 .endfor # RC_ARCHS
120
121 installhdrs:
122
123 .for F in $(FORMS)
124 BI-install-$(F): build-$(F)
125 mkdir -p "$(DSTROOT)/usr/lib"
126 @echo "===== Installing $(NAME)$(SUFFIX$(F)).dylib ====="
127 install "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib" "$(DSTROOT)/usr/lib"
128 strip -S "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib"
129 chmod a-w "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib"
130 ln -sf "$(NAME)$(SUFFIX$(F)).dylib" "$(DSTROOT)/usr/lib/$(NAME0)$(SUFFIX$(F)).dylib"
131 .endfor # FORMS
132
133 install-all: build
134 .for F in $(FORMS)
135 install-all: BI-install-$(F)
136 .endfor # FORMS
137
138 clean:
139 .for A in $(RC_ARCHS)
140 rm -rf $(OBJROOT)/$(A)
141 .endfor # RC_ARCHS