]> git.saurik.com Git - apple/libsystem.git/blame - Makefile
Libsystem-159.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 8MYCC := $(CC)
ec8f0a04 9.if $(RC_TARGET_CONFIG) == iPhone
699e5813 10MYCCLIBS = -lgcc
c9e8bbd6 11.endif
ec8f0a04
A
12RTLIBS =
13NARCHS != $(ECHO) $(RC_ARCHS) | $(WC) -w
c9e8bbd6 14SLFS_F_PH = $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
ec8f0a04 15CODESIGN != xcrun -find codesign
c9e8bbd6
A
16.ifdef SDKROOT
17SDKROOTCFLAGS = -isysroot '$(SDKROOT)'
699e5813 18SDKROOTLDFLAGS = -Wl,-syslibroot,'$(SDKROOT)'
c9e8bbd6 19.endif
699e5813 20ORDERFILES = -Wl,-order_file,$(SRCROOT)/SystemInit.order -Wl,-order_file,$(PLATFORM_ORDER_FILE)
ec8f0a04
A
21
22.ifdef ALTUSRLOCALLIBSYSTEM
23LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
24.else
25LIBSYS = $(SDKROOT)/usr/local/lib/system
26.endif
27.ifdef ALTUSRLIBSYSTEM
28LSYS = $(ALTUSRLIBSYSTEM)
29.else
30LSYS = $(SDKROOT)/usr/lib/system
31.endif
32
33ACTUALLIBS = $(SYMROOT)/actuallibs
34ALLLIBS = $(SYMROOT)/alllibs
35FROMUSRLIBSYSTEM = $(SYMROOT)/fromusrlibsystem
36FROMUSRLOCALLIBSYSTEM = $(SYMROOT)/fromusrlocallibsystem
37INUSRLIBSYSTEM = $(SYMROOT)/inusrlibsystem
38INUSRLOCALLIBSYSTEM = $(SYMROOT)/inusrlocallibsystem
39MISSINGLIBS = $(SYMROOT)/missinglibs
40OPTIONALLIBS = $(SRCROOT)/optionallibs
41POSSIBLEUSRLOCALLIBSYSTEM = $(SYMROOT)/possibleusrlocallibsystem
42REQUIREDLIBS = $(SRCROOT)/requiredlibs
43
44$(MISSINGLIBS):
45 cat $(REQUIREDLIBS) $(OPTIONALLIBS) | sort > $(ALLLIBS)
46 cd $(LSYS) && ls lib*.dylib | sed -E -e 's/^lib//' -e 's/\..*$$//' -e 's/_(debug|profile|static)$$//' | sort -u > $(INUSRLIBSYSTEM)
47 cd $(LIBSYS) && ls lib*.a | sed -E -e 's/^lib//' -e 's/\..*$$//' -e 's/_(debug|profile|static)$$//' | sort -u > $(INUSRLOCALLIBSYSTEM)
48 comm -12 $(ALLLIBS) $(INUSRLIBSYSTEM) > $(FROMUSRLIBSYSTEM)
49 comm -12 $(ALLLIBS) $(INUSRLOCALLIBSYSTEM) > $(POSSIBLEUSRLOCALLIBSYSTEM)
50 comm -13 $(FROMUSRLIBSYSTEM) $(POSSIBLEUSRLOCALLIBSYSTEM) > $(FROMUSRLOCALLIBSYSTEM)
51 cat $(FROMUSRLIBSYSTEM) $(FROMUSRLOCALLIBSYSTEM) | sort > $(ACTUALLIBS)
52 comm -23 $(REQUIREDLIBS) $(ACTUALLIBS) > $(MISSINGLIBS)
53 @if [ -s $(MISSINGLIBS) ]; then \
54 echo '*** missing required libs ***' && \
55 cat $(MISSINGLIBS) && \
56 exit 1; \
57 fi ;
435227b9 58
c9e8bbd6
A
59# These variables are to guarantee that the left-hand side of an expression is
60# always a variable
61dynamic = dynamic
62
63all: build
64
65build: build-debug build-dynamic build-profile
66
67# These are the non B&I defaults
68.ifndef RC_ProjectName
69install: installhdrs install-all
70
71.else # RC_ProjectName
72
73.for F in $(FORMS)
74install: BI-install-$(F)
75.endfor # FORMS
76.endif # RC_ProjectName
77
78.for A in $(RC_ARCHS)
ec8f0a04 79OBJS-$(A) = $(OBJROOT)/$(A)/SystemMath.o $(OBJROOT)/$(A)/CompatibilityHacks.o $(OBJROOT)/$(A)/System_vers.o $(OBJROOT)/$(A)/init.o
c9e8bbd6
A
80.endfor # RC_ARCHS
81
82.for F in $(FORMS)
83.if $(dynamic) == $(F)
84SUFFIX$(F) =
85.else
86SUFFIX$(F) = _$(F)
87.endif
699e5813 88LIPOARGS$(F) != $(PERL) -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/$$_/$(F)/$(NAME)$(SUFFIX$(F)).dylib\"), qw($(RC_ARCHS))))'
c9e8bbd6
A
89
90.for A in $(RC_ARCHS)
91build-$(F): build-$(A)-$(F)
92.endfor # RC_ARCHS
93build-$(F):
94.if $(NARCHS) == 1
699e5813 95 $(CP) "$(OBJROOT)/$(RC_ARCHS)/$(F)/$(NAME)$(SUFFIX$(F)).dylib" "$(SYMROOT)"
c9e8bbd6 96.else
699e5813 97 $(LIPO) -create $(LIPOARGS$(F)) -output "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib"
c9e8bbd6 98.endif
699e5813 99 $(DSYMUTIL) "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib"
c9e8bbd6
A
100
101.for A in $(RC_ARCHS)
ec8f0a04
A
102# Hardcode libc.a for now. This will have to be changed when libc becomes
103# its own dylib.
699e5813
A
104LINKDYLIB-$(F)-$(A) = $(MYCC) -dynamiclib -arch $(A) -pipe $(SDKROOTLDFLAGS) \
105 -o '$(OBJROOT)/$(A)/$(F)/$(NAME)$(SUFFIX$(F)).dylib' \
106 -compatibility_version 1 -current_version $(Version) \
107 -install_name /usr/lib/$(NAME)$(SUFFIX$(F)).dylib \
ec8f0a04 108 -nodefaultlibs -Wl,-search_paths_first \
699e5813 109 $(ORDERFILES) $(SKDROOTLDFLAGS) $(OBJS-$(A)) \
ec8f0a04
A
110 -L$(LSYS) -L$(LIBSYS) $(LIBMATHCOMMON$(F)) \
111 `sed 's/.*/-Wl,-reexport-l&/' $(FROMUSRLIBSYSTEM)` \
112 `sed -e '/^c$$/d' -e 's|.*|-Wl,-force_load,$(LIBSYS)/lib&$(SUFFIX$(F)).a|' $(FROMUSRLOCALLIBSYSTEM)`
113
114build-$(A)-$(F): $(OBJROOT)/$(A)/$(F) $(OBJS-$(A)) $(MISSINGLIBS)
115 @$(ECHO) '========================================='
116 @$(ECHO) $(LINKDYLIB-$(F)-$(A)) $(RTLIBS) $(MYCCLIBS)
117 @$(LINKDYLIB-$(F)-$(A)) $(RTLIBS) $(MYCCLIBS)
c9e8bbd6
A
118
119$(OBJROOT)/$(A)/$(F):
699e5813 120 $(MKDIR) '$(.TARGET)'
c9e8bbd6
A
121
122.endfor # RC_ARCHS
123.endfor # FORMS
124
125SEG1ADDR_i386 = 0xffff0000
126SEG1ADDR_ppc = 0xffff8000
127SEG1ADDR_ppc64 = 0xffffffffffff8000
128SEG1ADDR_x86_64 = 0x00007fffffe00000
129SEG1ADDR_arm = 0xffff8000
130
131CFLAGS = -g -Os -Wall -Werror -I'$(SLFS_F_PH)' -fno-common $(SDKROOTCFLAGS)
132
133$(OBJROOT)/System_vers.c:
699e5813
A
134 $(VERS_STRING) -c System | \
135 $(SED) -e 's/SGS_VERS/SYSTEM_VERS_STRING/' -e 's/VERS_NUM/SYSTEM_VERS_NUM/' > $(.TARGET)
435227b9 136
c9e8bbd6 137.for A in $(RC_ARCHS)
c9e8bbd6 138$(OBJROOT)/$(A)/SystemMath.o: $(SRCROOT)/SystemMath.s
699e5813 139 $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
435227b9 140
ec8f0a04
A
141$(OBJROOT)/$(A)/CompatibilityHacks.o: $(SRCROOT)/CompatibilityHacks.c
142 $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
143
c9e8bbd6 144$(OBJROOT)/$(A)/System_vers.o: $(OBJROOT)/System_vers.c
699e5813 145 $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
435227b9 146
ec8f0a04
A
147$(OBJROOT)/$(A)/init.o: $(SRCROOT)/init.c
148 $(MYCC) -c -o '$(.TARGET)' -arch $(A) $(CFLAGS) '$(.ALLSRC)'
149
c9e8bbd6 150.endfor # RC_ARCHS
435227b9 151
c9e8bbd6 152installhdrs:
435227b9 153
c9e8bbd6
A
154.for F in $(FORMS)
155BI-install-$(F): build-$(F)
699e5813
A
156 $(MKDIR) "$(DSTROOT)/usr/lib"
157 @$(ECHO) "===== Installing $(NAME)$(SUFFIX$(F)).dylib ====="
158 $(INSTALL) "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).dylib" "$(DSTROOT)/usr/lib"
159 $(STRIP) -S "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib"
160 $(CHMOD) a-w "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib"
161 $(LN) -sf "$(NAME)$(SUFFIX$(F)).dylib" "$(DSTROOT)/usr/lib/$(NAME0)$(SUFFIX$(F)).dylib"
ec8f0a04 162 $(CODESIGN) -s - "$(DSTROOT)/usr/lib/$(NAME)$(SUFFIX$(F)).dylib"
c9e8bbd6 163.endfor # FORMS
435227b9 164
c9e8bbd6
A
165install-all: build
166.for F in $(FORMS)
167install-all: BI-install-$(F)
168.endfor # FORMS
435227b9 169
c9e8bbd6
A
170clean:
171.for A in $(RC_ARCHS)
699e5813 172 $(RMDIR) $(OBJROOT)/$(A)
c9e8bbd6 173.endfor # RC_ARCHS