]>
Commit | Line | Data |
---|---|---|
c9e8bbd6 A |
1 | NAME = libc |
2 | ||
7a301563 A |
3 | NARCHS != echo $(RC_ARCHS) | wc -w |
4 | .ifdef ALTUSRLOCALLIBSYSTEM | |
5 | LIBSYS = $(ALTUSRLOCALLIBSYSTEM) | |
6 | .else | |
c9e8bbd6 | 7 | LIBSYS = $(SDKROOT)/usr/local/lib/system |
7a301563 A |
8 | .endif |
9 | NJOBS != perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)' | |
10 | BSDMAKE = bsdmake -f Makefile | |
11 | BSDMAKEJ = $(BSDMAKE) -j $(NJOBS) | |
12 | ||
c9e8bbd6 | 13 | # These variables are to guarantee that the left-hand side of an expression is |
7a301563 A |
14 | # always a variable |
15 | dynamic = dynamic | |
16 | ||
7a301563 A |
17 | FORMS := debug dynamic profile |
18 | ||
19 | all: build | |
20 | ||
21 | build: build-debug build-dynamic build-profile | |
22 | ||
23 | # These are the non B&I defaults | |
24 | .ifndef RC_ProjectName | |
25 | install: installhdrs install-all | |
26 | ||
27 | .else # RC_ProjectName | |
28 | ||
29 | .for F in $(FORMS) | |
30 | install: BI-install-$(F) | |
31 | .endfor # FORMS | |
32 | .endif # RC_ProjectName | |
33 | ||
34 | .for F in $(FORMS) | |
35 | .if $(dynamic) == $(F) | |
36 | SUFFIX$(F) = | |
37 | .else | |
38 | SUFFIX$(F) = _$(F) | |
39 | .endif | |
c9e8bbd6 | 40 | LIPOARGS$(F) != perl -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/$$_/$(F)/$(NAME)$(SUFFIX$(F)).a\"), qw($(RC_ARCHS))))' |
7a301563 A |
41 | |
42 | .for A in $(RC_ARCHS) | |
43 | build-$(F): build-$(A)-$(F) | |
44 | .endfor # RC_ARCHS | |
45 | build-$(F): | |
46 | .if $(NARCHS) == 1 | |
c9e8bbd6 | 47 | cp -p "$(OBJROOT)/$(RC_ARCHS)/$(F)/$(NAME)$(SUFFIX$(F)).a" "$(SYMROOT)" |
7a301563 | 48 | .else |
c9e8bbd6 | 49 | lipo -create $(LIPOARGS$(F)) -output "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).a" |
7a301563 | 50 | .endif |
c9e8bbd6 | 51 | ranlib "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).a" |
7a301563 A |
52 | |
53 | .for A in $(RC_ARCHS) | |
54 | build-$(A)-$(F): $(OBJROOT)/$(A)/libsystem.o | |
55 | mkdir -p '$(OBJROOT)/$(A)/$(F)' | |
56 | @set -x && \ | |
57 | cd '$(OBJROOT)/$(A)/$(F)' && \ | |
c9e8bbd6 A |
58 | if lipo -info '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' | grep -q '^Non-'; then \ |
59 | cp -p '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' .; \ | |
60 | else \ | |
61 | arch=`lipo -detailed_info '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' | sed -E -n 's/.*architecture:? //p' | sort | grep '^$(A)' | head -n 1` && \ | |
62 | lipo -thin $$arch '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' -output '$(NAME)-partial$(SUFFIX$(F)).a'; \ | |
63 | fi && \ | |
64 | ar x '$(NAME)-partial$(SUFFIX$(F)).a' && \ | |
65 | if lipo -info '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' | grep -q '^Non-'; then \ | |
66 | cp -p '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' .; \ | |
67 | else \ | |
68 | arch=`lipo -detailed_info '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' | sed -E -n 's/.*architecture:? //p' | sort | grep '^$(A)' | head -n 1` && \ | |
69 | lipo -thin $$arch '$(LIBSYS)/libsyscall$(SUFFIX$(F)).a' -output 'libsyscall$(SUFFIX$(F)).a'; \ | |
70 | fi && \ | |
7a301563 A |
71 | ar x 'libsyscall$(SUFFIX$(F)).a' && \ |
72 | '$(SRCROOT)/libsys/build-libc.pl' '$(LIBSYS)' '$(OBJROOT)/$(A)/$(F)' && \ | |
73 | ln -s ../libsystem.o && \ | |
74 | $(BSDMAKEJ) | |
75 | .endfor # RC_ARCHS | |
76 | .endfor # FORMS | |
77 | ||
78 | .for A in $(RC_ARCHS) | |
79 | $(OBJROOT)/$(A)/libsystem.o: $(OBJROOT)/libsystem.c | |
80 | mkdir -p '$(OBJROOT)/$(A)' | |
81 | cc -c -o '$(.TARGET)' -arch $(A) '$(.ALLSRC)' | |
82 | .endfor # RC_ARCHS | |
83 | ||
84 | $(OBJROOT)/libsystem.c: | |
c9e8bbd6 | 85 | $(SDKROOT)/Developer/Makefiles/bin/version.pl Libsystem > $(.TARGET) |
7a301563 A |
86 | |
87 | installhdrs: | |
88 | ||
89 | .for F in $(FORMS) | |
90 | BI-install-$(F): build-$(F) | |
91 | mkdir -p "$(DSTROOT)/usr/local/lib/system" | |
c9e8bbd6 A |
92 | @echo "===== Installing $(NAME)$(SUFFIX$(F)).a =====" |
93 | install "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).a" "$(DSTROOT)/usr/local/lib/system" | |
94 | ranlib "$(DSTROOT)/usr/local/lib/system/$(NAME)$(SUFFIX$(F)).a" | |
95 | chmod 0444 "$(DSTROOT)/usr/local/lib/system/$(NAME)$(SUFFIX$(F)).a" | |
7a301563 A |
96 | .endfor # FORMS |
97 | ||
98 | install-all: build | |
99 | .for F in $(FORMS) | |
100 | install-all: BI-install-$(F) | |
101 | .endfor # FORMS | |
102 | ||
103 | clean: | |
104 | .for A in $(RC_ARCHS) | |
105 | rm -rf $(OBJROOT)/$(A) | |
106 | .endfor # RC_ARCHS |