]> git.saurik.com Git - apple/libsystem.git/blob - GNUmakefile
Libsystem-111.tar.gz
[apple/libsystem.git] / GNUmakefile
1 ##---------------------------------------------------------------------
2 # Makefile for Libsystem
3 # Call Makefile to do the work, but for the install case, we need to
4 # call Makefile for each arch separately, and create fat dylibs at the
5 # end. This is because the comm page symbols are added as a special segment,
6 # which the linker will not thin, so we have to build thin and combine.
7 ##---------------------------------------------------------------------
8 PROJECT = Libsystem
9
10 no_target:
11 @$(MAKE) -f Makefile
12
13 ##---------------------------------------------------------------------
14 # For each arch, we setup the independent OBJROOT and DSTROOT, and adjust
15 # the other flags. After all the archs are built, we copy over one on
16 # time (for the non-dylib files), and then call lipo to create fat files
17 # for the three dylibs.
18 ##---------------------------------------------------------------------
19 ALLARCHS = hppa i386 m68k ppc ppc64 sparc x86_64
20 NARCHS = $(words $(RC_ARCHS))
21 USRLIB = /usr/lib
22 ifdef ALTUSRLOCALLIBSYSTEM
23 LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
24 else
25 LIBSYS = $(NEXT_ROOT)/usr/local/lib/system
26 endif
27
28 install: fake $(DSTROOT)/usr/local/lib/system/libc.a $(RC_ARCHS)
29 ifneq "$(NARCHS)" "1"
30 rsync -aH $(OBJROOT)/$(word 1,$(RC_ARCHS))/dstroot/ $(DSTROOT)
31 rsync -aH $(OBJROOT)/$(word 1,$(RC_ARCHS))/symroot/ $(SYMROOT)
32 @set -x && \
33 for i in libSystem.B.dylib libSystem.B_debug.dylib libSystem.B_profile.dylib; do \
34 rm -f $(DSTROOT)$(USRLIB)/$$i && \
35 lipo -create -o $(DSTROOT)$(USRLIB)/$$i $(foreach ARCH,$(RC_ARCHS),$(OBJROOT)/$(ARCH)/dstroot$(USRLIB)/$$i) && \
36 rm -f $(SYMROOT)/$$i && \
37 lipo -create -o $(SYMROOT)/$$i $(foreach ARCH,$(RC_ARCHS),$(OBJROOT)/$(ARCH)/symroot/$$i) || exit 1; \
38 done
39 endif
40 @set -x && \
41 for i in libSystem.B.dylib libSystem.B_debug.dylib libSystem.B_profile.dylib; do \
42 dsymutil $(SYMROOT)/$$i || exit 1; \
43 done
44
45 # 4993197: force dependency generation for libsyscall.a
46 fake:
47 @set -x && \
48 cd $(OBJROOT) && \
49 echo 'main() { __getpid(); return 0; }' > fake.c && \
50 cc -c fake.c && \
51 ld -r -o fake fake.o -lsyscall -L$(LIBSYS)
52
53 $(DSTROOT)/usr/local/lib/system/libc.a:
54 bsdmake -C libsys install
55
56 $(ALLARCHS):
57 ifneq "$(NARCHS)" "1"
58 mkdir -p $(OBJROOT)/$@/objroot $(OBJROOT)/$@/dstroot $(OBJROOT)/$@/symroot
59 $(MAKE) -f Makefile install \
60 OBJROOT='$(OBJROOT)/$@/objroot' \
61 TOPOBJROOT='$(OBJROOT)' \
62 DSTROOT='$(OBJROOT)/$@/dstroot' \
63 SYMROOT='$(OBJROOT)/$@/symroot' \
64 DESTDIR='$(DSTROOT)' \
65 RC_CFLAGS='-arch $@ $(RC_NONARCH_CFLAGS)' \
66 RC_ARCHS='$@' \
67 RC_$@=YES $(foreach ARCH,$(filter-out $@,$(ALLARCHS)),RC_$(ARCH)=)
68 else # NARCHS == 1
69 $(MAKE) -f Makefile install TOPOBJROOT='$(OBJROOT)' DESTDIR='$(DSTROOT)'
70 endif # NARCHS != 1
71
72 .DEFAULT:
73 @$(MAKE) -f Makefile $@