mpfr: Update to 4.1.0
[ipfire-2.x.git] / lfs / gcc
CommitLineData
cd1a2927 1###############################################################################
cd1a2927 2# #
70df8302 3# IPFire.org - A linux based firewall #
11b5e5cb 4# Copyright (C) 2007-2018 IPFire Team <info@ipfire.org> #
70df8302
MT
5# #
6# This program is free software: you can redistribute it and/or modify #
cd1a2927 7# it under the terms of the GNU General Public License as published by #
70df8302 8# the Free Software Foundation, either version 3 of the License, or #
cd1a2927
MT
9# (at your option) any later version. #
10# #
70df8302 11# This program is distributed in the hope that it will be useful, #
cd1a2927
MT
12# but WITHOUT ANY WARRANTY; without even the implied warranty of #
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14# GNU General Public License for more details. #
15# #
16# You should have received a copy of the GNU General Public License #
70df8302 17# along with this program. If not, see <http://www.gnu.org/licenses/>. #
cd1a2927 18# #
cd1a2927
MT
19###############################################################################
20
21###############################################################################
22# Definitions
23###############################################################################
24
25include Config
26
0c30619a 27VER = 10.2.0
82b312a9 28
11b5e5cb 29GMP_VER = 6.1.2
210b27e1
MT
30MPFR_VER = 4.0.2
31MPC_VER = 1.1.0
cd1a2927
MT
32
33THISAPP = gcc-$(VER)
11b5e5cb 34DL_FILE = $(THISAPP).tar.xz
dd714b8a 35DL_FROM = $(URL_IPFIRE)
cd1a2927 36DIR_APP = $(DIR_SRC)/$(THISAPP)
cd1a2927 37
ed635824 38CFLAGS := $(patsubst -march=%,,$(CFLAGS))
f3c01b39 39CFLAGS := $(patsubst -mfpu=%,,$(CFLAGS))
ed635824 40CFLAGS := $(patsubst -mtune=%,,$(CFLAGS))
62a430f9 41CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS))
8675b78a 42CFLAGS := $(filter-out -fexceptions,$(CFLAGS))
11b5e5cb
AF
43
44ifeq "$(PASS)" "1"
45CFLAGS := $(patsubst -mindirect-branch=%,,$(CFLAGS))
46CFLAGS := $(patsubst -mfunction-return=%,,$(CFLAGS))
47endif
48
8675b78a 49CXXFLAGS := $(CFLAGS)
ff1d5f3a 50
b45e371f
MT
51ifeq "$(BUILD_ARCH)" "armv7hl"
52 FULL_BOOTSTRAP = 1
53endif
54
55ifeq "$(BUILD_ARCH)" "armv5tel"
56 FULL_BOOTSTRAP = 1
57endif
58
6c4cc7ea 59# Normal build or $(TOOLS_DIR) build.
cd1a2927
MT
60#
61ifeq "$(ROOT)" ""
62 TARGET = $(DIR_INFO)/$(THISAPP)
afbd9856
MT
63 EXTRA_CONFIG = \
64 --prefix=/usr \
65 --libexecdir=/usr/lib \
66 --enable-shared \
67 --enable-threads=posix \
68 --enable-__cxa_atexit \
69 --enable-clocale=gnu \
eed179ac 70 --enable-languages=c,c++ \
afbd9856
MT
71 --disable-bootstrap \
72 --disable-nls
857d9bf2
MT
73 EXTRA_MAKE =
74 EXTRA_INSTALL =
cd1a2927 75else
15679d9f 76ifeq "$(PASS)" "1"
cd1a2927 77 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
82b312a9
MT
78 EXTRA_CONFIG = \
79 --target=$(CROSSTARGET) \
6c4cc7ea 80 --prefix=$(TOOLS_DIR) \
764a3f1f 81 --with-sysroot=$(ROOT) \
6c4cc7ea
MT
82 --with-local-prefix=$(TOOLS_DIR) \
83 --with-native-system-header-dir=$(TOOLS_DIR)/include \
82b312a9
MT
84 --disable-nls \
85 --disable-shared \
86 --disable-decimal-float \
87 --disable-threads \
764a3f1f 88 --disable-libatomic \
82b312a9
MT
89 --disable-libmudflap \
90 --disable-libssp \
8bc5ded2 91 --disable-libmpx \
82b312a9
MT
92 --disable-libgomp \
93 --disable-libquadmath \
764a3f1f
AF
94 --disable-libstdc++-v3 \
95 --disable-libvtv \
96 --disable-libcilkrts \
97 --disable-libitm \
98 --disable-libsanitizer \
82b312a9
MT
99 --with-newlib \
100 --without-headers \
101 --without-ppl \
102 --without-cloog \
764a3f1f 103 --enable-languages=c,c++
575ea031 104 EXTRA_MAKE =
cd1a2927
MT
105 EXTRA_INSTALL =
106else
764a3f1f 107ifeq "$(PASS)" "2"
cd1a2927 108 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
82b312a9 109 EXTRA_ENV = \
6f8f4522 110 CC="$(CROSSTARGET)-gcc" \
764a3f1f 111 CXX="$(CROSSTARGET)-g++" \
82b312a9
MT
112 AR="$(CROSSTARGET)-ar" \
113 RANLIB="$(CROSSTARGET)-ranlib"
114 EXTRA_CONFIG = \
82b312a9 115 --build=$(BUILDTARGET) \
6c4cc7ea
MT
116 --prefix=$(TOOLS_DIR) \
117 --with-local-prefix=$(TOOLS_DIR) \
118 --with-native-system-header-dir=$(TOOLS_DIR)/include \
82b312a9
MT
119 --enable-languages=c,c++ \
120 --disable-libstdcxx-pch \
b45e371f 121 --disable-libgomp
cd1a2927
MT
122 EXTRA_MAKE =
123 EXTRA_INSTALL =
b45e371f
MT
124
125 ifeq "$(FULL_BOOTSTRAP)" "1"
126 EXTRA_CONFIG += --enable-bootstrap
127 else
128 EXTRA_CONFIG += --disable-bootstrap
129 endif
764a3f1f
AF
130else
131 # PASS=L # libstdc++-v3
132 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
133 EXTRA_ENV = \
6f8f4522 134 CC="$(CROSSTARGET)-gcc" \
764a3f1f
AF
135 AR="$(CROSSTARGET)-ar" \
136 RANLIB="$(CROSSTARGET)-ranlib"
137 EXTRA_CONFIG = \
138 --host=$(CROSSTARGET) \
6c4cc7ea 139 --prefix=$(TOOLS_DIR) \
764a3f1f
AF
140 --with-sysroot=$(ROOT) \
141 --disable-shared \
142 --disable-nls \
143 --disable-libstdcxx-threads \
144 --disable-libstdcxx-pch \
6c4cc7ea 145 --with-gxx-include-dir=$(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)
764a3f1f
AF
146 EXTRA_MAKE =
147 EXTRA_INSTALL =
148endif
cd1a2927
MT
149endif
150endif
151
0c30619a
MT
152ifeq "$(BUILD_ARCH)" "aarch64"
153 EXTRA_CONFIG += \
154 --enable-standard-branch-protection
155endif
156
dc7d6b20 157ifeq "$(BUILD_ARCH)" "armv7hl"
0c24d56d
MT
158 EXTRA_CONFIG += \
159 --with-float=hard
160endif
161
dc7d6b20 162ifeq "$(BUILD_ARCH)" "armv5tel"
51f9e7ac 163 EXTRA_CONFIG += \
afbd9856
MT
164 --with-float=soft \
165 --disable-sjlj-exceptions
51f9e7ac
MT
166endif
167
dc7d6b20 168ifeq "$(BUILD_ARCH)" "i586"
ed635824
MT
169 EXTRA_CONFIG += \
170 --with-arch=i586 \
171 --with-tune=generic
172endif
173
174EXTRA_CONFIG += \
51777e5d 175 --disable-multilib \
ed635824
MT
176 --with-bugurl=http://bugtracker.ipfire.org \
177 --disable-libunwind-exceptions \
178 --enable-gnu-unique-object
179
51f9e7ac
MT
180export XCFLAGS = $(CFLAGS)
181export TCFLAGS = $(CFLAGS)
182
cd1a2927
MT
183###############################################################################
184# Top-level Rules
185###############################################################################
82b312a9
MT
186
187objects = $(DL_FILE) \
11b5e5cb
AF
188 gmp-$(GMP_VER).tar.xz \
189 mpfr-$(MPFR_VER).tar.xz \
8675b78a 190 mpc-$(MPC_VER).tar.gz
cd1a2927 191
41921bd9 192$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
176b1cc6 193gmp-$(GMP_VER).tar.xz = $(DL_FROM)/gmp-$(GMP_VER).tar.xz
11b5e5cb 194mpfr-$(MPFR_VER).tar.xz = $(DL_FROM)/mpfr-$(MPFR_VER).tar.xz
8675b78a 195mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
cd1a2927 196
0c30619a 197$(DL_FILE)_MD5 = e9fd9b1789155ad09bcf3ae747596b50
11b5e5cb 198gmp-$(GMP_VER).tar.xz_MD5 = f58fa8001d60c4c77595fbbb62b63c1d
210b27e1
MT
199mpfr-$(MPFR_VER).tar.xz_MD5 = 320fbc4463d4c8cb1e566929d8adc4f8
200mpc-$(MPC_VER).tar.gz_MD5 = 4125404e41e482ec68282a2e687f6c73
cd1a2927
MT
201
202install : $(TARGET)
203
204check : $(patsubst %,$(DIR_CHK)/%,$(objects))
205
206download :$(patsubst %,$(DIR_DL)/%,$(objects))
207
208md5 : $(subst %,%_MD5,$(objects))
209
210###############################################################################
211# Downloading, checking, md5sum
212###############################################################################
213
214$(patsubst %,$(DIR_CHK)/%,$(objects)) :
215 @$(CHECK)
216
217$(patsubst %,$(DIR_DL)/%,$(objects)) :
218 @$(LOAD)
219
220$(subst %,%_MD5,$(objects)) :
221 @$(MD5)
222
223###############################################################################
224# Installation Details
225###############################################################################
226
227$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
228 @$(PREBUILD)
8675b78a 229 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
dd714b8a 230 @mkdir $(DIR_SRC)/gcc-build
51f9e7ac 231
991d11d7
MT
232 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
233 cd $(DIR_APP) && sed -i gcc/Makefile.in \
234 -e 's@\./fixinc\.sh@-c true@' \
235 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
236
237ifeq "$(TOOLCHAIN)" "1"
82b312a9 238 # Build gmp and mpfr internally in toolchain.
11b5e5cb 239 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.xz
82b312a9 240 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
11b5e5cb 241 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.xz
82b312a9 242 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
8675b78a
MT
243 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
244 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
82b312a9 245
991d11d7 246ifeq "$(PASS)" "2"
764a3f1f 247 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
6c4cc7ea 248 `dirname $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
991d11d7
MT
249endif
250
82b312a9 251 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
cfd39a32 252 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
82b312a9
MT
253 echo "Processing $${file}..."; \
254 sed -i $${file} \
6c4cc7ea
MT
255 -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \
256 -e 's@/usr@$(TOOLS_DIR)@g'; \
764a3f1f
AF
257 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
258 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
6c4cc7ea 259 echo '#define STANDARD_STARTFILE_PREFIX_1 "$(TOOLS_DIR)/lib/"' >> $${file}; \
82b312a9
MT
260 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
261 done
82b312a9 262endif
dd714b8a 263
991d11d7 264ifeq "$(PASS)" "L"
764a3f1f
AF
265 # libstdc++ pass
266 cd $(DIR_SRC)/gcc-build && \
267 $(EXTRA_ENV) \
268 $(DIR_APP)/libstdc++-v3/configure \
269 $(EXTRA_CONFIG)
79ccd55d 270 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
764a3f1f 271 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
cfd39a32 272
764a3f1f 273else
82b312a9
MT
274 # The actual build.
275 cd $(DIR_SRC)/gcc-build && \
276 $(EXTRA_ENV) \
277 $(DIR_APP)/configure \
278 $(EXTRA_CONFIG)
79ccd55d 279 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
f97be0a6 280 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
764a3f1f 281endif
82b312a9 282
991d11d7
MT
283ifeq "$(TOOLCHAIN)" "1"
284 ifeq "$(PASS)" "1"
6c4cc7ea 285 ln -svf libgcc.a $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
991d11d7
MT
286 endif
287
288 ifeq "$(PASS)" "2"
6c4cc7ea 289 ln -svf gcc $(TOOLS_DIR)/bin/cc
8f2ac12a 290 # remove gdb python files from libdir
6c4cc7ea 291 rm -rf $(TOOLS_DIR)/lib/*-gdb.py
991d11d7
MT
292 endif
293
294 ifeq "$(PASS)" "L"
295 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
6c4cc7ea 296 sed -e "s/^#include_next/#include/" -i $(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
991d11d7
MT
297 endif
298
299else # NON-TOOLCHAIN
300 ln -svf ../usr/bin/cpp /lib
301 ln -svf gcc /usr/bin/cc
302 # remove gdb python files from libdir
303 rm -rf /usr/lib/*-gdb.py
cd1a2927 304endif
991d11d7 305
cd1a2927
MT
306 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
307 @$(POSTBUILD)