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