]>
Commit | Line | Data |
---|---|---|
5b2abdfb A |
1 | ifndef $(OBJROOT) |
2 | OBJROOT = . | |
3 | endif | |
4 | ifndef $(SYMROOT) | |
5 | SYMROOT = . | |
6 | endif | |
7 | ARCH = $(shell arch) | |
8 | ifndef RC_ppc | |
9 | ifndef RC_i386 | |
10 | RC_ppc = 1 | |
11 | endif | |
12 | endif | |
9385eb3d | 13 | BSDMAKE = bsdmake -j 2 |
5b2abdfb A |
14 | |
15 | # Remove the arch stuff, since we know better here. | |
16 | LOCAL_CFLAGS = $(filter-out -arch ppc -arch i386,$(RC_CFLAGS)) | |
17 | ||
18 | all: build | |
19 | # These are the non B&I defaults | |
20 | ifndef RC_ProjectName | |
21 | installhdrs: installhdrs-real | |
22 | build: build-static build-profile build-debug build-dynamic | |
23 | install: installhdrs install-all | |
24 | endif | |
25 | ||
26 | # And these are to deal with B&I building libc differently | |
27 | # based on RC_ProjectName. | |
28 | ifeq ($(RC_ProjectName),Libc) | |
29 | installhdrs: installhdrs-real | |
30 | build: build-man build-dynamic | |
31 | install: installhdrs-real BI-install-dynamic install-man | |
32 | endif | |
33 | ifeq ($(RC_ProjectName),Libc_static) | |
34 | installhdrs: | |
35 | build: build-static | |
36 | install: BI-install-static | |
37 | endif | |
38 | ifeq ($(RC_ProjectName),Libc_debug) | |
39 | installhdrs: | |
40 | build: build-debug | |
41 | install: BI-install-debug | |
42 | endif | |
43 | ifeq ($(RC_ProjectName),Libc_profile) | |
44 | installhdrs: | |
45 | build: build-profile | |
46 | install: BI-install-profile | |
47 | endif | |
48 | ||
49 | build-man: | |
50 | MAKEOBJDIR="$(OBJROOT)" MACHINE_ARCH="$(shell arch)" \ | |
9385eb3d | 51 | MAKEFLAGS="" $(BSDMAKE) buildman |
5b2abdfb A |
52 | build-static: build-ppc-static build-i386-static |
53 | @echo "Checking for libc_static.a" | |
54 | @if [ -f "$(OBJROOT)/obj.ppc/libc_static.a" -a -f "$(OBJROOT)/obj.i386/libc_static.a" ]; then\ | |
55 | lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_static.a" \ | |
56 | -arch i386 "$(OBJROOT)/obj.i386/libc_static.a" \ | |
57 | -output $(SYMROOT)/libc_static.a;\ | |
58 | elif [ -f "$(OBJROOT)/obj.ppc/libc_static.a" ]; then \ | |
59 | cp -p "$(OBJROOT)/obj.ppc/libc_static.a" "$(SYMROOT)"; \ | |
60 | elif [ -f "$(OBJROOT)/obj.i386/libc_static.a" ]; then \ | |
61 | cp -p "$(OBJROOT)/obj.i386/libc_static.a" "$(SYMROOT)"; \ | |
62 | fi | |
63 | build-profile: build-ppc-profile build-i386-profile | |
64 | @echo "Checking for libc_profile.a" | |
65 | @if [ -f "$(OBJROOT)/obj.ppc/libc_profile.a" -a -f "$(OBJROOT)/obj.i386/libc_profile.a" ]; then\ | |
66 | lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_profile.a" \ | |
67 | -arch i386 "$(OBJROOT)/obj.i386/libc_profile.a" \ | |
68 | -output $(SYMROOT)/libc_profile.a;\ | |
69 | elif [ -f "$(OBJROOT)/obj.ppc/libc_profile.a" ]; then \ | |
70 | cp -p "$(OBJROOT)/obj.ppc/libc_profile.a" "$(SYMROOT)"; \ | |
71 | elif [ -f "$(OBJROOT)/obj.i386/libc_profile.a" ]; then \ | |
72 | cp -p "$(OBJROOT)/obj.i386/libc_profile.a" "$(SYMROOT)"; \ | |
73 | fi | |
74 | build-debug: build-ppc-debug build-i386-debug | |
75 | @echo "Checking for libc_debug.a" | |
76 | @if [ -f "$(OBJROOT)/obj.ppc/libc_debug.a" -a -f "$(OBJROOT)/obj.i386/libc_debug.a" ]; then\ | |
77 | lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc_debug.a" \ | |
78 | -arch i386 "$(OBJROOT)/obj.i386/libc_debug.a" \ | |
79 | -output $(SYMROOT)/libc_debug.a;\ | |
80 | elif [ -f "$(OBJROOT)/obj.ppc/libc_debug.a" ]; then \ | |
81 | cp -p "$(OBJROOT)/obj.ppc/libc_debug.a" "$(SYMROOT)"; \ | |
82 | elif [ -f "$(OBJROOT)/obj.i386/libc_debug.a" ]; then \ | |
83 | cp -p "$(OBJROOT)/obj.i386/libc_debug.a" "$(SYMROOT)"; \ | |
84 | fi | |
85 | build-dynamic: build-ppc-dynamic build-i386-dynamic | |
86 | @echo "Checking for libc.a" | |
87 | @if [ -f "$(OBJROOT)/obj.ppc/libc.a" -a -f "$(OBJROOT)/obj.i386/libc.a" ]; then\ | |
88 | echo "Creating FAT libc.a"; \ | |
89 | lipo -create -arch ppc "$(OBJROOT)/obj.ppc/libc.a" -arch i386 \ | |
90 | "$(OBJROOT)/obj.i386/libc.a" -output $(SYMROOT)/libc.a;\ | |
91 | elif [ -f "$(OBJROOT)/obj.ppc/libc.a" ]; then \ | |
92 | echo "Using thin PPC libc.a" ;\ | |
93 | cp -p "$(OBJROOT)/obj.ppc/libc.a" "$(SYMROOT)"; \ | |
94 | elif [ -f "$(OBJROOT)/obj.i386/libc.a" ]; then \ | |
95 | echo "Using thin i386 libc.a" ;\ | |
96 | cp -p "$(OBJROOT)/obj.i386/libc.a" "$(SYMROOT)"; \ | |
97 | fi | |
98 | build-ppc-static: | |
99 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
100 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
101 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
9385eb3d | 102 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\ |
5b2abdfb A |
103 | fi |
104 | build-i386-static: | |
105 | @if [ ! -z "$(RC_i386)" ]; then \ | |
106 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
107 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
9385eb3d | 108 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_static.a;\ |
5b2abdfb A |
109 | fi |
110 | build-ppc-profile: | |
111 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
112 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
113 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
9385eb3d | 114 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\ |
5b2abdfb A |
115 | fi |
116 | build-i386-profile: | |
117 | @if [ ! -z "$(RC_i386)" ]; then \ | |
118 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
119 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
9385eb3d | 120 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_profile.a;\ |
5b2abdfb A |
121 | fi |
122 | build-ppc-debug: | |
123 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
124 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
125 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
9385eb3d | 126 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\ |
5b2abdfb A |
127 | fi |
128 | build-i386-debug: | |
129 | @if [ ! -z "$(RC_i386)" ]; then \ | |
130 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
131 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
9385eb3d | 132 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc_debug.a;\ |
5b2abdfb A |
133 | fi |
134 | build-ppc-dynamic: | |
135 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
136 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
137 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
9385eb3d | 138 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\ |
5b2abdfb A |
139 | fi |
140 | build-i386-dynamic: | |
141 | @if [ ! -z "$(RC_i386)" ]; then \ | |
142 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
143 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
9385eb3d | 144 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) libc.a;\ |
5b2abdfb A |
145 | fi |
146 | ||
147 | build-ppc: | |
148 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
149 | mkdir -p $(OBJROOT)/obj.ppc ; \ | |
150 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
9385eb3d | 151 | MAKEFLAGS="" CFLAGS="-arch ppc $(LOCAL_CFLAGS)" $(BSDMAKE) build;\ |
5b2abdfb A |
152 | fi |
153 | build-i386: | |
154 | @if [ ! -z "$(RC_i386)" ]; then \ | |
155 | mkdir -p $(OBJROOT)/obj.i386 ; \ | |
156 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
9385eb3d | 157 | MAKEFLAGS="" CFLAGS="-arch i386 $(LOCAL_CFLAGS)" $(BSDMAKE) build;\ |
5b2abdfb A |
158 | fi |
159 | installsrc: | |
160 | $(_v) pax -rw . "$(SRCROOT)" | |
9385eb3d | 161 | |
5b2abdfb | 162 | installhdrs-real: |
9385eb3d A |
163 | MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" MAKEFLAGS="" \ |
164 | $(BSDMAKE) installhdrs | |
165 | @if [ ! -z "$(RC_i386)" ]; then \ | |
166 | mkdir -p "$(OBJROOT)/obj.i386" ; \ | |
167 | MAKEOBJDIR="$(OBJROOT)/obj.i386" MACHINE_ARCH="i386" \ | |
168 | MAKEFLAGS="" $(BSDMAKE) installhdrs-md ; \ | |
169 | fi | |
170 | @if [ ! -z "$(RC_ppc)" ]; then \ | |
171 | mkdir -p "$(OBJROOT)/obj.ppc" ; \ | |
172 | MAKEOBJDIR="$(OBJROOT)/obj.ppc" MACHINE_ARCH="ppc" \ | |
173 | MAKEFLAGS="" $(BSDMAKE) installhdrs-md ; \ | |
174 | fi | |
5b2abdfb A |
175 | |
176 | BI-install-static: build-static | |
177 | mkdir -p $(DSTROOT)/usr/local/lib/system | |
178 | if [ -f "$(SYMROOT)/libc_static.a" ]; then \ | |
179 | echo "Installing libc_static.a" ; \ | |
180 | install -c -m 444 "$(SYMROOT)/libc_static.a" \ | |
181 | $(DSTROOT)/usr/local/lib/system; \ | |
182 | ranlib "$(DSTROOT)/usr/local/lib/system/libc_static.a"; \ | |
183 | fi | |
184 | BI-install-profile: build-profile | |
185 | mkdir -p $(DSTROOT)/usr/local/lib/system | |
186 | if [ -f "$(SYMROOT)/libc_profile.a" ]; then \ | |
187 | echo "Installing libc_profile.a" ; \ | |
188 | install -c -m 444 "$(SYMROOT)/libc_profile.a" \ | |
189 | $(DSTROOT)/usr/local/lib/system; \ | |
190 | ranlib "$(DSTROOT)/usr/local/lib/system/libc_profile.a"; \ | |
191 | fi | |
192 | BI-install-debug: build-debug | |
193 | mkdir -p $(DSTROOT)/usr/local/lib/system | |
194 | if [ -f "$(SYMROOT)/libc_debug.a" ]; then \ | |
195 | echo "Installing libc_debug.a" ; \ | |
196 | install -c -m 444 "$(SYMROOT)/libc_debug.a" \ | |
197 | $(DSTROOT)/usr/local/lib/system; \ | |
198 | ranlib "$(DSTROOT)/usr/local/lib/system/libc_debug.a"; \ | |
199 | fi | |
200 | BI-install-dynamic: build-dynamic | |
201 | mkdir -p $(DSTROOT)/usr/local/lib/system | |
202 | if [ -f "$(SYMROOT)/libc.a" ]; then \ | |
203 | echo "Installing libc.a" ; \ | |
204 | install -c -m 444 "$(SYMROOT)/libc.a" \ | |
205 | $(DSTROOT)/usr/local/lib/system; \ | |
206 | ranlib "$(DSTROOT)/usr/local/lib/system/libc.a"; \ | |
207 | fi | |
208 | ||
9385eb3d | 209 | # Don't use -j here; it may try to make links before the files are copied |
5b2abdfb A |
210 | install-man: |
211 | mkdir -p $(DSTROOT)/usr/share/man/man2 | |
212 | mkdir -p $(DSTROOT)/usr/share/man/man3 | |
213 | mkdir -p $(DSTROOT)/usr/share/man/man4 | |
214 | mkdir -p $(DSTROOT)/usr/share/man/man5 | |
215 | mkdir -p $(DSTROOT)/usr/share/man/man7 | |
216 | MAKEOBJDIR="$(OBJROOT)" DESTDIR="$(DSTROOT)" NOMANCOMPRESS=1 \ | |
9385eb3d | 217 | MACHINE_ARCH="$(shell arch)" MAKEFLAGS="" bsdmake fbsdman maninstall |
5b2abdfb A |
218 | |
219 | install-all: build install-man BI-install-dynamic BI-install-static BI-install-profile | |
220 | ||
221 | clean: | |
222 | rm -rf $(OBJROOT)/obj.ppc $(OBJROOT)/obj.i386 $(OBJROOT)/libc.a \ | |
223 | $(OBJROOT)/libc_static.a $(OBJROOT)/libc_debug.a \ | |
224 | $(OBJROOT)/libc_profile.a |