]>
Commit | Line | Data |
---|---|---|
1 | NAME = libc | |
2 | ||
3 | .include <CoreOS/Standard/Commands.mk> | |
4 | .include <CoreOS/Standard/Variables.mk> | |
5 | ||
6 | NARCHS != $(ECHO) $(RC_ARCHS) | $(WC) -w | |
7 | .ifdef ALTUSRLOCALLIBSYSTEM | |
8 | LIBSYS = $(ALTUSRLOCALLIBSYSTEM) | |
9 | .else | |
10 | LIBSYS = $(SDKROOT)/usr/local/lib/system | |
11 | .endif | |
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) | |
14 | ||
15 | # These variables are to guarantee that the left-hand side of an expression is | |
16 | # always a variable | |
17 | dynamic = dynamic | |
18 | ||
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 | |
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 | |
50 | LIPOARGS$(F) != $(PERL) -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/$$_/$(F)/$(NAME)$(SUFFIX$(F)).a\"), qw($(RC_ARCHS))))' | |
51 | ||
52 | .for A in $(RC_ARCHS) | |
53 | build-$(F): build-$(A)-$(F) | |
54 | .endfor # RC_ARCHS | |
55 | build-$(F): | |
56 | .if $(NARCHS) == 1 | |
57 | $(CP) "$(OBJROOT)/$(RC_ARCHS)/$(F)/$(NAME)$(SUFFIX$(F)).a" "$(SYMROOT)" | |
58 | .else | |
59 | $(LIPO) -create $(LIPOARGS$(F)) -output "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).a" | |
60 | .endif | |
61 | $(RANLIB) "$(SYMROOT)/$(NAME)$(SUFFIX$(F)).a" | |
62 | ||
63 | .for A in $(RC_ARCHS) | |
64 | build-$(A)-$(F): $(OBJROOT)/$(A)/libsystem.o | |
65 | $(MKDIR) '$(OBJROOT)/$(A)/$(F)' | |
66 | @set -x && \ | |
67 | cd '$(OBJROOT)/$(A)/$(F)' && \ | |
68 | if $(LIPO) -info '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' | $(GREP) -q '^Non-'; then \ | |
69 | $(CP) '$(LIBSYS)/$(NAME)-partial$(SUFFIX$(F)).a' .; \ | |
70 | else \ | |
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'; \ | |
73 | fi && \ | |
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' .; \ | |
77 | else \ | |
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'; \ | |
80 | fi && \ | |
81 | $(AR) x 'libsyscall$(SUFFIX$(F)).a' && \ | |
82 | NM=$(NM) '$(SRCROOT)/libsys/build-libc.pl' '$(LIBSYS)' '$(OBJROOT)/$(A)/$(F)' && \ | |
83 | $(LN) -s ../libsystem.o && \ | |
84 | $(BSDMAKEJ) | |
85 | .endfor # RC_ARCHS | |
86 | .endfor # FORMS | |
87 | ||
88 | .for A in $(RC_ARCHS) | |
89 | $(OBJROOT)/$(A)/libsystem.o: $(OBJROOT)/libsystem.c | |
90 | $(MKDIR) '$(OBJROOT)/$(A)' | |
91 | $(CC) -c -o '$(.TARGET)' -arch $(A) '$(.ALLSRC)' | |
92 | .endfor # RC_ARCHS | |
93 | ||
94 | $(OBJROOT)/libsystem.c: | |
95 | $(SDKROOT)/Developer/Makefiles/bin/version.pl Libsystem > $(.TARGET) | |
96 | ||
97 | installhdrs: | |
98 | ||
99 | .for F in $(FORMS) | |
100 | BI-install-$(F): build-$(F) | |
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" | |
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) | |
115 | $(RMDIR) $(OBJROOT)/$(A) | |
116 | .endfor # RC_ARCHS |