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