]> git.saurik.com Git - apple/libc.git/blob - BSDmakefile
Libc-391.5.18.tar.gz
[apple/libc.git] / BSDmakefile
1 .ifndef OBJROOT
2 OBJROOT != pwd
3 .endif
4 .ifndef SYMROOT
5 SYMROOT != pwd
6 .endif
7 ARCH != arch
8 .ifndef RC_ARCHS
9 RC_ARCHS = $(ARCH)
10 RC_$(RC_ARCHS) = 1
11 .endif
12 NARCHS != echo $(RC_ARCHS) | wc -w
13 .ifdef ALTUSRLOCALLIBSYSTEM
14 LIBSYS = $(ALTUSRLOCALLIBSYSTEM)
15 .else
16 LIBSYS = $(NEXT_ROOT)/usr/local/lib/system
17 .endif
18 NJOBS != perl -e '$$n = `/usr/sbin/sysctl -n hw.ncpu`; printf "%d\n", $$n < 2 ? 2 : ($$n * 1.5)'
19 BSDMAKE = bsdmake -f Makefile
20 #BSDMAKEJ = $(BSDMAKE) -j $(NJOBS)
21 BSDMAKEJ = $(BSDMAKE) -j $(NJOBS) -P
22
23 # This variables are to guarantee that the left-hand side of an expression is
24 # always a variable
25 dynamic = dynamic
26 static = static
27
28 # Remove the arch stuff, since we know better here.
29 LOCAL_CFLAGS != echo $(RC_CFLAGS) | sed 's/ *-arch [^ ][^ ]*//g'
30
31 FORMS := dynamic debug profile static
32
33 all: build
34
35 # These are the non B&I defaults
36 .ifndef RC_ProjectName
37 installhdrs: installhdrs-real
38 build: build-static build-profile build-debug build-dynamic
39 install: installhdrs install-all
40
41 .else # RC_ProjectName
42
43 # And these are to deal with B&I building libc differently
44 # based on RC_ProjectName.
45 .if $(RC_ProjectName) == Libc
46 installhdrs:
47 build: build-dynamic
48 install: BI-install-dynamic
49 .endif
50 .if $(RC_ProjectName) == Libc_headers
51 installhdrs: installhdrs-real
52 build:
53 install: installhdrs-real
54 .endif
55 .if $(RC_ProjectName) == Libc_man
56 installhdrs:
57 build:
58 install: install-man
59 .endif
60 .if $(RC_ProjectName) == Libc_static
61 installhdrs:
62 build: build-static
63 install: BI-install-static
64 .endif
65 .if $(RC_ProjectName) == Libc_debug
66 installhdrs:
67 build: build-debug
68 install: BI-install-debug
69 .endif
70 .if $(RC_ProjectName) == Libc_profile
71 installhdrs:
72 build: build-profile
73 install: BI-install-profile
74 .endif
75 .endif # RC_ProjectName
76
77 # Because of 3780028, there are random failures on HFS because the
78 # CC_PRINT_OPTIONS_FILE can't be created. So we touch it first.
79 .if !empty $(CC_PRINT_OPTIONS_FILE)
80 $(CC_PRINT_OPTIONS_FILE):
81 touch $(CC_PRINT_OPTIONS_FILE)
82 .endif # CC_PRINT_OPTIONS_FILE
83
84 .for F in $(FORMS)
85 .if $(dynamic) == $(F)
86 SUFFIX$(F) =
87 .else
88 SUFFIX$(F) = _$(F)
89 .endif
90 LIPOARGS$(F) != perl -e 'printf "%s\n", join(" ", map(qq(-arch $$_ \"$(OBJROOT)/obj.$$_/libc$(SUFFIX$(F)).a\"), qw($(RC_ARCHS))))'
91
92 build-$(F): autopatch $(CC_PRINT_OPTIONS_FILE)
93 .for A in $(RC_ARCHS)
94 build-$(F): build-$(A)-$(F)
95 .endfor # RC_ARCHS
96 build-$(F):
97 .if $(NARCHS) == 1
98 cp -p "$(OBJROOT)/obj.$(RC_ARCHS)/libc$(SUFFIX$(F)).a" "$(SYMROOT)"
99 .else
100 lipo -create $(LIPOARGS$(F)) -output $(SYMROOT)/libc$(SUFFIX$(F)).a
101 .endif
102
103 .for A in $(RC_ARCHS)
104 build-$(A)-$(F):
105 mkdir -p $(OBJROOT)/obj.$(A) && \
106 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \
107 MAKEFLAGS="" CFLAGS="-arch $(A) $(LOCAL_CFLAGS)" $(BSDMAKEJ) libc$(SUFFIX$(F)).a
108 .endfor # RC_ARCHS
109 .endfor # FORMS
110
111 # We have to separately call bsdmake to patch the FreeBSD files, because of
112 # the way its cache works, it would otherwise pick A file in ${SYMROOT}, even
113 # over A .s file.
114 autopatch:
115 .for A in $(RC_ARCHS)
116 MACHINE_ARCH="$(A)" $(BSDMAKEJ) autopatch
117 .endfor # RC_ARCHS
118
119 installsrc:
120 pax -rw . "$(SRCROOT)"
121
122 installhdrs-real: $(CC_PRINT_OPTIONS_FILE)
123 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \
124 $(BSDMAKEJ) installhdrs
125 .for A in $(RC_ARCHS)
126 mkdir -p "$(OBJROOT)/obj.$(A)" && \
127 MAKEOBJDIR="$(OBJROOT)/obj.$(A)" MACHINE_ARCH="$(A)" \
128 MAKEFLAGS="" $(BSDMAKEJ) installhdrs-md
129 .endfor # RC_ARCHS
130
131 .for F in $(FORMS)
132 BI-install-$(F): build-$(F)
133 mkdir -p $(DSTROOT)/usr/local/lib/system
134 if [ -f "$(SYMROOT)/libc$(SUFFIX$(F)).a" ]; then \
135 echo "Installing libc$(SUFFIX$(F)).a" && \
136 install -c -m 444 "$(SYMROOT)/libc$(SUFFIX$(F)).a" \
137 $(DSTROOT)/usr/local/lib/system && \
138 ranlib "$(DSTROOT)/usr/local/lib/system/libc$(SUFFIX$(F)).a"; \
139 fi
140 .if !empty $(RC_ppc) && ($(static) != $(F))
141 if [ -f "$(OBJROOT)/obj.ppc/libc-ldbl128$(SUFFIX$(F)).a" ]; then \
142 echo "Installing libldbl128$(SUFFIX$(F)).a" ; \
143 $(SRCROOT)/make_libldbl128 "$(OBJROOT)/obj.ppc/libc-ldbl128$(SUFFIX$(F)).a" \
144 "$(SUFFIX$(F))" "$(DSTROOT)/usr/local/lib/system" $(LIBSYS) ; \
145 fi
146 .endif # RC_ppc && !static
147 .endfor # FORMS
148
149 # Don't use -j here; it may try to make links before the files are copied
150 install-man:
151 mkdir -p $(DSTROOT)/usr/share/man/man2
152 mkdir -p $(DSTROOT)/usr/share/man/man3
153 mkdir -p $(DSTROOT)/usr/share/man/man4
154 mkdir -p $(DSTROOT)/usr/share/man/man5
155 mkdir -p $(DSTROOT)/usr/share/man/man7
156 MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" NOMANCOMPRESS=1 \
157 MACHINE_ARCH="$(ARCH)" MAKEFLAGS="" $(BSDMAKE) autopatchman maninstall
158
159 install-all: build install-man
160 .for F in $(FORMS)
161 install-all: BI-install-$(F)
162 .endfor # FORMS
163
164 clean:
165 .for F in $(FORMS)
166 rm -f $(OBJROOT)/libc$(SUFFIX$(F)).a
167 .endfor # FORMS
168 .for A in $(RC_ARCHS)
169 rm -rf $(OBJROOT)/obj.$(A)
170 .endfor # RC_ARCHS