-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
440 lines (404 loc) · 15.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
##
## Apple C Compiler Makefile.
##
## Ask Kresten if you have any troubles / questions.
## (He probably won't be able to help, but ask him anyway!)
##
#
# ** MANUAL BUILDS **
#
# Use:
# setenv RC_ARCHS='i386 m68k ...'
# setenv RC_CFLAGS='-arch i386 -arch m68k ...'
# make debug TARGETS='i386 m68k ...' HOSTS='i386 ...'
#
# from this directory to do manual builds. The build compiler(s) will
# appear in ./obj/cc-<target>-on-<host>/ subdirectories of here. Use
# "./xgcc -B./" in there to run the specific compiler. You can also
# just cd to a specific ./obj subdirectory and type "make <foo>" to build
# a specific program, like "cpp" or "cc1objplus".
#
# ** AUTOMATIC BUILDS **
#
# Automatic builds strictly follow the RC makefile API standards.
#
# Enable NeXT extensions to (gnu)make.
USE_APPLE_PB_SUPPORT = all
HOSTS = `arch`
TARGET_OS = $(RC_OS)
targets = case "$(TARGET_OS)" in *win*) echo i386 ;; \
*) if [ "$(TARGET_OS)" = teflon -o "$(TARGET_OS)" = macos \
-o -f /usr/bin/uname ]; then \
echo $${TARGETS:-'ppc i386'}; \
elif [ "$(RC_RELEASE)" = Grail ]; then \
echo $${TARGETS:-'m68k i386 sparc ppc'}; \
else \
echo $${TARGETS:-'m68k i386 sparc'}; \
fi ;; esac
TARGETS := $(shell $(targets))
RC_ARCHS = $(HOSTS)
SRCROOT = .
SRC = `cd $(SRCROOT) && pwd | sed s,/private,,`
OBJROOT = $(SRC)/obj
SYMROOT = $(OBJROOT)/../sym
DSTROOT = $(OBJROOT)/../dst
BOOTSTRAP = --bootstrap
VERSION = 2.95.2
# DO_SYMLINKS set to 'yes' will all the full gcc2 installation which
# includes generating sym links in various places. These sym links
# are in the same places with the same names as those generated by
# gcc3. We may not want to clobber gcc3's sym links. Thus setting
# DO_SYMLINKS to 'no' will suppress them.
DO_SYMLINKS = no
# DO_HDR_SYMLINKS is similar to DO_SYMLINKS but only controls the
# generation of the sym links for the headers in /usr/include.
DO_HDR_SYMLINKS = no
# COEXIST_WITH_GCC3, when set to non-null modifies the original gcc2
# installation in the following ways:
#
# 1. libcc.a is installed in /usr/lib/gcc/darwin/default instead
# of /usr/lib and a sym link is placed in /usr/lib to the new
# location.
#
# 2. libcc_noc++.a is installed in /usr/lib/gcc/darwin/default instead
# of /usr/local/lib and a sym link is placed in /usr/local/lib
# to its new location.
#
# 3. /usr/bin/cc, /usr/bin/c++, and /usr/bin/c++filt become sym links
# to /usr/bin/gcc2, /usr/bin/g++2, and /usr/bin/c++filt2 respectively.
#
# 4. A /usr/bin/gcc and /usr/bin/cc are installed as a sym links to
# /usr/bin/gcc2.
#
# 5. A /usr/bin/g++ and /usr/bin/c++ are installed as sym links to
# /usr/bin/g++2.
#
# By making the sym links instead of having the actual files in
# those locations makes it easier to coexist with gcc3 (hence the
# name for the switch) and also makes it easier to switch between the
# two compilers.
COEXIST_WITH_GCC3=1
ARCH = `arch`
CHOWN = `if [ -f /usr/etc/chown ]; then echo /usr/etc/chown; \
elif [ -f /usr/sbin/chown ]; then echo /usr/sbin/chown; \
else echo chown; fi`
MKDIRS = `case "$(RC_OS)" in *win*) echo mkdirs ;; \
*) if [ -f /bin/mkdirs ]; then echo mkdirs; else echo mkdir -p; fi ;; \
esac`
RM = `case "$(RC_OS)" in *win*) echo rm ;; *) echo /bin/rm ;; esac`
install: installhdrs build install_no_src
if [ "$(RC_RELEASE)" = Flask -a "$(DO_SYMLINKS)" = yes ]; then \
cd $(DSTROOT)/usr/libexec && \
for dir in *; do \
cd $(DSTROOT)/usr/libexec/$$dir && \
ln -s */cpp .; \
done; \
fi
if [ "$(TARGET_OS)" = macos -a "$(DO_SYMLINKS)" = yes ]; then \
cd $(DSTROOT)/usr/libexec/gcc/darwin && \
for dir in *; do \
cd $(DSTROOT)/usr/libexec/gcc/darwin/$$dir && \
$(RM) -f default && \
ln -s $(VERSION) default; \
done; \
fi
if [ "$(TARGET_OS)" = nextstep -o "$(TARGET_OS)" = teflon \
-o "$(TARGET_OS)" = macos ]; then \
cd $(DSTROOT)/usr/lib/gcc/darwin && \
if [ "$(DO_SYMLINKS)" = yes ]; then \
$(RM) -f default && \
ln -s $(VERSION) default; \
fi && \
if [ "$$CHROOTED" ]; then \
echo "** cleaning unnessecary objects **"; \
$(RM) -Rf $(OBJROOT)/cc-*-on-*; \
fi; \
fi
installhdrs: DSTROOT cplusplus_hdrs
if [ "$(TARGET_OS)" = teflon -o "$(TARGET_OS)" = macos \
-o -f /usr/bin/uname ]; then \
std_include_dir=$(DSTROOT)/` \
if [ -f /usr/bin/uname -a "$(TARGET_OS)" = macos ]; then \
echo usr/include; \
else \
if [ -f /usr/bin/uname ]; then \
echo System/Library/Frameworks/System.framework/Versions/B/Headers/bsd; \
else echo NextLibrary/Frameworks/System.framework/Versions/B/Headers/bsd; \
fi; \
fi`; \
os_name=` \
if [ "$(TARGET_OS)" = macos -o -f /usr/bin/uname ]; then \
echo darwin; \
else echo openstep; \
fi`; \
hdr_dir=$$std_include_dir/gcc/$$os_name/$(VERSION); \
if [ "$(DO_HDR_SYMLINKS)" = yes ]; then \
$(MKDIRS) $$std_include_dir/machine; \
fi && \
$(MKDIRS) $$hdr_dir/machine && \
if [ "$(DO_HDR_SYMLINKS)" = yes ]; then \
ln -s $(VERSION) $$std_include_dir/gcc/$$os_name/default; \
fi && \
cd gcc && \
for file in assert ../float ../inttypes ../stdint ginclude/stdarg \
ginclude/stdbool ginclude/varargs ginclude/va-ppc; do \
install -c -m 444 $$file.h $$hdr_dir && \
if [ "$(DO_HDR_SYMLINKS)" = yes ]; then \
ln -s gcc/$$os_name/default/`echo $$file | sed 's;[-A-Za-z0-9_.]*/;;'`.h $$std_include_dir; \
fi \
done && \
$(RM) -f /tmp/limits.$$$$ && \
echo '#if !defined (_LIMITS_H___) && !defined (_MACH_MACHLIMITS_H_)' > /tmp/limits.$$$$ && \
echo '#if defined (__ppc__)' >>/tmp/limits.$$$$ && \
echo '#include <ppc/limits.h>' >>/tmp/limits.$$$$ && \
echo '#elif defined (__i386__)' >>/tmp/limits.$$$$ && \
echo '#include <i386/limits.h>' >>/tmp/limits.$$$$ && \
echo '#else' >>/tmp/limits.$$$$ && \
echo '#error architecture not supported' >>/tmp/limits.$$$$ && \
echo '#endif' >>/tmp/limits.$$$$ && \
echo '#undef MB_LEN_MAX' >>/tmp/limits.$$$$ && \
echo '#endif' >>/tmp/limits.$$$$ && \
cat glimits.h >>/tmp/limits.$$$$ && \
install -c -m 444 /tmp/limits.$$$$ $$hdr_dir/machine/limits.h && \
if [ "$(DO_HDR_SYMLINKS)" = yes ]; then \
ln -s ../gcc/$$os_name/default/machine/limits.h $$std_include_dir/machine; \
fi && \
$(RM) -f /tmp/limits.$$$$; \
fi
# OPENSTEP doesn't have machine/ansi.h, which is needed to build libcc.a,
# so create an empty one.
if [ "$(TARGET_OS)" = nextstep -a ! -f /usr/bin/uname ]; then \
$(MKDIRS) $(DSTROOT)/LocalDeveloper/Headers/machine && \
touch $(DSTROOT)/LocalDeveloper/Headers/machine/ansi.h && \
$(CHOWN) -f -R root.wheel $(DSTROOT)/LocalDeveloper && \
chmod -f -R a+r-w+X $(DSTROOT)/LocalDeveloper; \
fi
build: OBJROOT SYMROOT
APPLE_CC=`if echo $(SRCROOT) | grep '[0-9]$$' >/dev/null; then \
vers_string -f cc 2>/dev/null | sed -e 's/[-A-Za-z_]*//' \
| sed -e 's/\.[0-9.]*//'; \
elif [ -f /usr/bin/uname ]; then \
date +%Y%m%d%H%M%S; \
fi`; \
echo APPLE_CC=$$APPLE_CC; \
export APPLE_CC; \
./build_gcc --thins \
--srcroot=$(SRC) \
--dstroot=$(DSTROOT) \
--objroot=$(OBJROOT) \
--symroot=$(SYMROOT) \
--cflags="`if [ \( ! "$(TARGET_OS)" \
-o "$(TARGET_OS)" = nextstep \) \
-a ! -f /usr/bin/uname ]; then \
echo -DOPENSTEP; \
elif [ "$(TARGET_OS)" = macos ]; then \
echo -DMACOSX; \
fi` $(RC_CFLAGS) $(OTHER_CFLAGS) -g" \
--hosts="$(RC_ARCHS)" \
--targets="$(TARGETS)" \
--targetos="$(TARGET_OS)" \
--bison="$(BISON)" \
--symlinks=$(DO_SYMLINKS) \
--coexist_with_gcc3=$(COEXIST_WITH_GCC3) \
$(BOOTSTRAP)
# The following lines are for building a Mac-OS-X-Server-hosted
# cross compiler for Mac OS.
# cd $(OBJROOT) && \
# $(SRC)/gcc/configure --host=powerpc-apple-macosx_server \
# --target=powerpc-apple-macosx --srcdir=$(SRC)/gcc && \
# $(MAKE) LANGUAGES=c LIBGCC2_DEBUG_CFLAGS=-g0 AR_FOR_TARGET=ar \
# X_CPPFLAGS=-traditional-cpp LIBGCC2_INCLUDES=-I/usr/include \
# SYSTEM_HEADER_DIR=/usr/include TCFLAGS=-g0 \
# CFLAGS="-g `echo $(RC_CFLAGS) | sed 's/-arch [a-z0-9]*//g'` $(OTHER_CFLAGS)"
install_no_src:
if [ "$(TARGET_OS)" = nextstep -o "$(TARGET_OS)" = teflon \
-o "$(TARGET_OS)" = macos ]; then \
APPLE_CC=`if echo $(SRCROOT) | grep '[0-9]$$' >/dev/null; then \
vers_string -f cc 2>/dev/null | sed -e 's/[-A-Za-z_]*//' \
| sed -e 's/\.[0-9.]*//'; \
elif [ -f /usr/bin/uname ]; then \
date +%Y%m%d%H%M%S; \
fi`; \
echo APPLE_CC=$$APPLE_CC; \
export APPLE_CC; \
./build_gcc --fats \
--srcroot=$(SRC) \
--dstroot=$(DSTROOT) \
--objroot=$(OBJROOT) \
--symroot=$(SYMROOT) \
--cflags="`if [ \( ! "$(TARGET_OS)" \
-o "$(TARGET_OS)" = nextstep \) \
-a ! -f /usr/bin/uname ]; then \
echo -DOPENSTEP; \
elif [ "$(TARGET_OS)" = macos ]; then \
echo -DMACOSX; \
fi` $(RC_CFLAGS) $(OTHER_CFLAGS)" \
--hosts="$(RC_ARCHS)" \
--targets="$(TARGETS)" \
--targetos="$(TARGET_OS)" \
--symlinks=$(DO_SYMLINKS) \
--coexist_with_gcc3=$(COEXIST_WITH_GCC3) && \
if [ ! -f /usr/bin/uname ]; then \
install -m 555 cc++ $(DSTROOT)/bin && \
install -m 555 ld++ $(DSTROOT)/bin; \
fi; \
fi
installGNUsrc: installsrc
$(CHOWN) -f -R root.wheel $(SRCROOT)
chmod -f -R a+r-w+X $(SRCROOT)
find $(SRCROOT) -type d -exec chmod -f 755 {} \;
$(RM) -rf $(SRCROOT)/../egcs
mv $(SRCROOT)/gcc $(SRCROOT)/../egcs
$(RM) -rf $(SRCROOT)/../libstdc++
mv $(SRCROOT)/libstdc++ $(SRCROOT)/..
$(RM) -rf $(SRCROOT)
installsrc: SRCROOT
if [ $(SRCROOT) != . ]; then \
$(MKDIRS) $(SRCROOT); \
pax -r -w -v -s ',.*/tests.*/.*,,' -s ',^gcc/f/.*,,' \
-s ',^gcc/config/[^ria].*/.*,,' \
Makefile Makefile.libiberty build_gcc configure config.if \
config.sub config-ml.in include install-sh move-if-change gcc \
libiberty libio libstdc++ \
_G_config.h float.h inttypes.h stdint.h \
cc1*.order \
$(SRCROOT); \
fi
find -d "$(SRCROOT)" -type d -a -name CVS -exec $(RM) -rf {} \;
cd "$(SRCROOT)" && find -d . -type d -a \
\( -name f -o -name 'tests*' \) -exec $(RM) -rf {} \;
cd "$(SRCROOT)/gcc/config" && find -d . -type d -a \! -name . \
-a \! -name rs6000 -a \! -name i386 -a \! -name apple \
-exec $(RM) -rf {} \;
find "$(SRCROOT)" \
\( -name \*~ -o -name \*\# -o -name \*.rej -o -name \*.orig \
-o -name \*.old -o -name \*.new -o -name .dir\* -o -name .\#\* \
-o -name .nfs\* \) \
-exec $(RM) -f {} \;
#######################################################################
# C++-related targets
#
# Headers go into $$hdr_dir, set below, dependent upon
# TARGET_OS and uname:
#
# teflon or macos, or uname exists ==>
# /NextLibrary/Frameworks/System.framework/Versions/B/Headers/bsd/gcc/openstep/$(VERSION)/g++
# or /System/Library/Frameworks/System.framework/Versions/B/Headers/bsd/gcc/darwin/$(VERSION)/g++
# or /usr/include/gcc/darwin/$(VERSION)/g++
#
# For now, be explicit instead of theoretically "FSF-correct"
#
# Most of libstdc++
LIBSTDCPP_HDRS = cassert cctype cerrno cfloat ciso646 \
climits clocale cmath complex complex.h csetjmp \
csignal cstdarg cstddef cstdio cstdlib cstring ctime \
cwchar cwctype fstream iomanip iosfwd iostream \
stdexcept stl.h string strstream
LIBSTDCPP_STL_HDRS = algo.h algobase.h algorithm alloc.h bvector.h \
defalloc.h deque deque.h function.h functional hash_map hash_map.h \
hash_set hash_set.h hashtable.h heap.h iterator iterator.h list \
list.h map map.h memory multimap.h multiset.h numeric pair.h \
pthread_alloc pthread_alloc.h queue rope rope.h ropeimpl.h set \
set.h slist slist.h stack stack.h stl_algo.h stl_algobase.h \
stl_alloc.h stl_bvector.h stl_config.h stl_construct.h stl_deque.h \
stl_function.h stl_hash_fun.h stl_hash_map.h stl_hash_set.h \
stl_hashtable.h stl_heap.h stl_iterator.h stl_list.h stl_map.h \
stl_multimap.h stl_multiset.h stl_numeric.h stl_pair.h stl_queue.h \
stl_raw_storage_iter.h stl_relops.h stl_rope.h stl_set.h \
stl_slist.h stl_stack.h stl_tempbuf.h stl_tree.h \
stl_uninitialized.h stl_vector.h tempbuf.h tree.h type_traits.h \
utility vector vector.h
LIBSTDCPP_STD_HDRS = bastring.cc bastring.h complext.cc complext.h \
dcomplex.h fcomplex.h ldcomplex.h straits.h
# Some of the standard headers (e.g., <fstream>, <iomanip>)
# just #include these <*.h> versions from ./libio.
LIBIO_HDRS = fstream.h iomanip.h iostream.h \
libio.h streambuf.h strfile.h strstream.h
# DO WE NEED THE OTHERS? These are all of the *other* .h
# files in libio. I suspect we'll need to install some
# of them. Any that we find we need, just move from here
# into LIBIO_HDRS.
#
LIBIO_OTHER_H = PlotFile.h SFile.h builtinbuf.h editbuf.h \
floatio.h indstream.h iolibio.h iostdio.h iostreamP.h \
istream.h libioP.h ostream.h parsestream.h pfstream.h \
procbuf.h stdiostream.h stream.h
cplusplus_hdrs: DSTROOT
if [ "$(TARGET_OS)" = teflon -o "$(TARGET_OS)" = macos \
-o -f /usr/bin/uname ]; then \
hdr_dir=$(DSTROOT)/` \
if [ -f /usr/bin/uname -a "$(TARGET_OS)" = macos ]; then \
echo usr/include; \
else \
if [ -f /usr/bin/uname ]; then \
echo System/Library/Frameworks/System.framework/Versions/B/Headers/bsd; \
else echo NextLibrary/Frameworks/System.framework/Versions/B/Headers/bsd; \
fi; \
fi \
`/gcc/` \
if [ "$(TARGET_OS)" = macos -o -f /usr/bin/uname ]; then \
echo darwin; \
else echo openstep; \
fi \
`/$(VERSION)/g++; \
$(MKDIRS) $$hdr_dir && \
for file in exception new new.h typeinfo; do \
install -c -m 444 gcc/cp/inc/$$file $$hdr_dir; \
done; \
for file in $(LIBSTDCPP_HDRS); do \
install -c -m 444 libstdc++/$$file $$hdr_dir; \
done; \
for file in $(LIBSTDCPP_STL_HDRS); do \
install -c -m 444 libstdc++/stl/$$file $$hdr_dir; \
done; \
for file in $(LIBSTDCPP_STD_HDRS); do \
install -c -m 444 libstdc++/std/$$file $$hdr_dir; \
done; \
for file in $(LIBIO_HDRS); do \
install -c -m 444 libio/$$file $$hdr_dir; \
done; \
install -c -m 444 _G_config.h $$hdr_dir; \
cd $$hdr_dir ; \
if [ ! -h std ] ; then ln -s . std ; fi ; \
fi
########################################################################
lib_ofiles:
APPLE_CC=`if echo $(SRCROOT) | grep '[0-9]$$' >/dev/null; then \
vers_string -f cc 2>/dev/null | sed -e 's/[-A-Za-z_]*//' \
| sed -e 's/\.[0-9.]*//'; \
elif [ -f /usr/bin/uname ]; then \
date +%Y%m%d%H%M%S; \
fi`; \
echo APPLE_CC=$$APPLE_CC; \
export APPLE_CC; \
./build_gcc --lib_ofiles \
--srcroot=$(SRC) \
--dstroot=$(DSTROOT) \
--objroot=$(OBJROOT) \
--symroot=$(SYMROOT) \
--cflags="$(RC_CFLAGS)" \
--hosts="$(RC_ARCHS)" \
--targets="$(TARGETS)"
clean:
@if [ -d $(OBJROOT) -a "$(OBJROOT)" != / ]; then \
echo '*** DELETING ' $(OBJROOT); \
$(RM) -rf $(OBJROOT); \
fi
@if [ -d $(SYMROOT) -a "$(SYMROOT)" != / ]; then \
echo '*** DELETING ' $(SYMROOT); \
$(RM) -rf $(SYMROOT); \
fi
@if [ -d $(DSTROOT) -a "$(DSTROOT)" != / ]; then \
echo '*** DELETING ' $(DSTROOT); \
$(RM) -rf $(DSTROOT); \
fi
OBJROOT SYMROOT DSTROOT:
$(MKDIRS) $($@)
SRCROOT:
@if [ -n "$($@)" ]; \
then \
exit 0; \
else \
echo Must define $@; \
exit 1; \
fi