-
Notifications
You must be signed in to change notification settings - Fork 48
/
Makefile.gcc
161 lines (143 loc) · 4.28 KB
/
Makefile.gcc
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
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# Copyright 2020 Joyent, Inc.
#
# Shared makefile for building GCC versions. For the most part, the build is the
# same, but with different component versions.
#
#
# The gcc build system expects that the build is done from a separate objdir
# instead of in-place in the source.
#
SEPARATE_BUILD = yes
CFLAGS = -g -O2
CFLAGS.64 = -g -O2
#
# Note this presumes only one of 32/64 bit builds.
#
ifeq ($(BUILD64),yes)
CFLAGS += -m64
TRIPLET = x86_64-pc-solaris2.11
SUFFIX = 64
GCC.64 = $(GCC.host.64)
GXX.64 = $(GXX.host.64)
else
TRIPLET = i386-pc-solaris2.11
SUFFIX = 32
GCC.32 = $(GCC.host.32)
GXX.32 = $(GXX.host.32)
endif
#
# We set --enable-bootstrap to allow the build to mismatch the host
#
AUTOCONF_OPTS += \
--enable-bootstrap \
--build=$(TRIPLET) \
--host=$(TRIPLET) \
--with-ld=/usr/bin/ld \
--without-gnu-ld \
--with-gnu-as \
--with-as=$(DESTDIR)/usr/gnu/bin/gas \
--enable-languages="c,c++" \
--enable-shared \
--disable-nls
AUTOCONF_PREFIX = /usr/gcc/$(GCC_VER)
AUTOCONF_CPPFLAGS =
AUTOCONF_LIBS =
AUTOCONF_LIBS.64 =
AUTOCONF_LDFLAGS =
AUTOCONF_LDFLAGS.64 =
GENLDFLAGS =
AUTOCONF_ENV += \
DESTDIR=$(DESTDIR) \
MAKE=$(MAKE)
PATCHES = Patches/*
ALL_TGT = bootstrap
include ../Makefile.targ
include ../Makefile.targ.autoconf
MPFR_TARBALL ?= $(MPFR_VER).tar.bz2
GMP_TARBALL ?= $(GMP_VER).tar.bz2
MPC_TARBALL ?= $(MPC_VER).tar.gz
#
# To reduce repository size, the source files are stored in Manta and
# need to be downloaded (excluding gcc4).
#
$(TARBALL) $(MPFR_TARBALL) $(GMP_TARBALL) $(MPC_TARBALL):
if [[ ! -f [email protected] ]]; then \
echo "Missing required digest file!"; \
exit 1; \
fi; \
curl -o [email protected] $(FETCH_BASE)/$@
digest -a sha1 [email protected] > [email protected]
rm -f [email protected]
mv [email protected] $@
#
# We could use the support libraries from the build system (since the compiler
# will be run here), but there's no good way to make gcc build itself correctly
# if we do. There are two main problems:
#
# 1. Stage2 and later cc1 and company don't honour any combination of LDFLAGS,
# LDFLAGS_FOR_TARGET, BOOT_LDFLAGS, STAGE2_LDFLAGS, etc. The only ways to
# get these things built with -R/opt/local/lib are to use LD_OPTIONS, which will
# yield the wrong results for libraries, or to hack configure.
#
# 2. Even if we could get -R/opt/local/lib into these programs without building
# the libraries incorrectly, it would still be wrong. The pkgsrc lib directory
# on many systems contains libgcc_s.so.1; however, cc1 was built by the stage2
# compiler and should find the libgcc that matches that compiler. That happens
# to be the one we just built, not the pkgsrc one.
#
# Instead we build these libraries directly ourselves.
#
ifeq ($(GCC_VER),4)
$(AUTOCONF_OUT.$(SUFFIX)): | $(VER.$(SUFFIX))/mpfr $(VER.$(SUFFIX))/gmp
else
$(AUTOCONF_OUT.$(SUFFIX)): | $(VER.$(SUFFIX))/mpfr $(VER.$(SUFFIX))/gmp $(VER.$(SUFFIX))/mpc
endif
$(VER.$(SUFFIX))/mpfr: $(MPFR_TARBALL) | $(VER.$(SUFFIX))
-rm -rf $@
mkdir -p .unpack
gtar x -C .unpack --no-same-owner -f $(MPFR_TARBALL)
mv -f .unpack/$(MPFR_VER) ./$@
-rmdir .unpack
chmod 755 $@/configure
touch $@/configure
$(VER.$(SUFFIX))/gmp: $(GMP_TARBALL) | $(VER.$(SUFFIX))
-rm -rf $@
mkdir -p .unpack
gtar x -C .unpack --no-same-owner -f $(GMP_TARBALL)
mv -f .unpack/$(GMP_VER) ./$@
-rmdir .unpack
chmod 755 $@/configure
touch $@/configure
$(VER.$(SUFFIX))/mpc: $(MPC_TARBALL) | $(VER.$(SUFFIX))
-rm -rf $@
mkdir -p .unpack
gtar x -C .unpack --no-same-owner -f $(MPC_TARBALL)
mv -f .unpack/$(MPC_VER) ./$@
-rmdir .unpack
chmod 755 $@/configure
touch $@/configure
ifeq ($(STRAP),strap)
.PHONY: strapfix
strapfix:
$(BASE)/../tools/gcc-strapfix -d $(DESTDIR) -v $(GCC_VER) \
-p $(PRIMARY_COMPILER)
else
#
# A non-strap build: do not install anything other than our runtime libraries
# saved by gcc-strapfix. This should only happen for the primary compiler.
#
.PHONY: fixup
fixup:
cd $(DESTDIR)/usr/lib && gtar xvf $(STRAPPROTO)/gcclibs.tar.gz
endif