]> git.saurik.com Git - apple/libsystem.git/blob - libsys/Makefile
Libsystem-111.1.1.tar.gz
[apple/libsystem.git] / libsys / Makefile
1 .ifndef DSTROOT
2 DSTROOT != x=`pwd`/DSTROOT && mkdir -p $$x && echo $$x
3 .endif
4 .ifndef OBJROOT
5 OBJROOT != x=`pwd`/OBJROOT && mkdir -p $$x && echo $$x
6 .endif
7 .ifndef SRCROOT
8 SRCROOT != dirname `pwd`
9 .endif
10 .ifndef SYMROOT
11 SYMROOT != x=`pwd`/SYMROOT && mkdir -p $$x && echo $$x
12 .endif
13 ARCH != arch
14 .ifndef RC_ARCHS
15 RC_ARCHS = $(ARCH)
16 RC_$(RC_ARCHS) = 1
17 .endif
18 NARCHS != echo $(RC_ARCHS) | wc -w
19 .ifdef ALTUSRLOCALLIBSYSTEM
20 LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
21 .else
22 LIBSYS = $(NEXT_ROOT)/usr/local/lib/system
23 .endif
24 NJOBS != perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)'
25 BSDMAKE = bsdmake -f Makefile
26 BSDMAKEJ = $(BSDMAKE) -j $(NJOBS)
27
28 # This variables are to guarantee that the left-hand side of an expression is
29 # always a variable
30 dynamic = dynamic
31
32 # Remove the arch stuff, since we know better here.
33 LOCAL_CFLAGS != echo $(RC_CFLAGS) | sed 's/ *-arch [^ ][^ ]*//g'
34
35 FORMS := debug dynamic profile
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 F in $(FORMS)
53 .if $(dynamic) == $(F)
54 SUFFIX$(F) =
55 .else
56 SUFFIX$(F) = _$(F)
57 .endif
58 LIPOARGS$(F) != perl -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/$$_/$(F)/libc$(SUFFIX$(F)).a\"), qw($(RC_ARCHS))))'
59
60 .for A in $(RC_ARCHS)
61 build-$(F): build-$(A)-$(F)
62 .endfor # RC_ARCHS
63 build-$(F):
64 .if $(NARCHS) == 1
65 cp -p "$(OBJROOT)/$(RC_ARCHS)/$(F)/libc$(SUFFIX$(F)).a" "$(SYMROOT)"
66 .else
67 lipo -create $(LIPOARGS$(F)) -output "$(SYMROOT)/libc$(SUFFIX$(F)).a"
68 .endif
69 ranlib "$(SYMROOT)/libc$(SUFFIX$(F)).a"
70
71 .for A in $(RC_ARCHS)
72 build-$(A)-$(F): $(OBJROOT)/$(A)/libsystem.o
73 mkdir -p '$(OBJROOT)/$(A)/$(F)'
74 @set -x && \
75 cd '$(OBJROOT)/$(A)/$(F)' && \
76 ditto -arch $(A) '$(LIBSYS)/libc-partial$(SUFFIX$(F)).a' . && \
77 ar x 'libc-partial$(SUFFIX$(F)).a' && \
78 ditto -arch $(A) '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' . && \
79 ar x 'libsyscall$(SUFFIX$(F)).a' && \
80 '$(SRCROOT)/libsys/build-libc.pl' '$(LIBSYS)' '$(OBJROOT)/$(A)/$(F)' && \
81 ln -s ../libsystem.o && \
82 $(BSDMAKEJ)
83 .endfor # RC_ARCHS
84 .endfor # FORMS
85
86 .for A in $(RC_ARCHS)
87 $(OBJROOT)/$(A)/libsystem.o: $(OBJROOT)/libsystem.c
88 mkdir -p '$(OBJROOT)/$(A)'
89 cc -c -o '$(.TARGET)' -arch $(A) '$(.ALLSRC)'
90 .endfor # RC_ARCHS
91
92 $(OBJROOT)/libsystem.c:
93 /Developer/Makefiles/bin/version.pl Libsystem > $(.TARGET)
94
95 installhdrs:
96
97 .for F in $(FORMS)
98 BI-install-$(F): build-$(F)
99 mkdir -p "$(DSTROOT)/usr/local/lib/system"
100 @echo "Installing libc$(SUFFIX$(F)).a"
101 install "$(SYMROOT)/libc$(SUFFIX$(F)).a" "$(DSTROOT)/usr/local/lib/system"
102 ranlib "$(DSTROOT)/usr/local/lib/system/libc$(SUFFIX$(F)).a"
103 chmod 0444 "$(DSTROOT)/usr/local/lib/system/libc$(SUFFIX$(F)).a"
104 .endfor # FORMS
105
106 install-all: build
107 .for F in $(FORMS)
108 install-all: BI-install-$(F)
109 .endfor # FORMS
110
111 clean:
112 .for A in $(RC_ARCHS)
113 rm -rf $(OBJROOT)/$(A)
114 .endfor # RC_ARCHS