make.sh: Drop option to generate a source ISO
[ipfire-2.x.git] / lfs / gcc
CommitLineData
cd1a2927 1###############################################################################
cd1a2927 2# #
70df8302 3# IPFire.org - A linux based firewall #
f3c01b39 4# Copyright (C) 2007-2017 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
cfd39a32 27VER = 6.3.0
82b312a9
MT
28
29GMP_VER = 5.0.5
30MPFR_VER = 2.4.2
8675b78a 31MPC_VER = 1.0.3
cd1a2927
MT
32
33THISAPP = gcc-$(VER)
cfd39a32 34DL_FILE = $(THISAPP).tar.gz
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
MT
42CFLAGS := $(filter-out -fexceptions,$(CFLAGS))
43CXXFLAGS := $(CFLAGS)
ff1d5f3a 44
b45e371f
MT
45ifeq "$(BUILD_ARCH)" "armv7hl"
46 FULL_BOOTSTRAP = 1
47endif
48
49ifeq "$(BUILD_ARCH)" "armv5tel"
50 FULL_BOOTSTRAP = 1
51endif
52
cd1a2927
MT
53# Normal build or /tools build.
54#
55ifeq "$(ROOT)" ""
56 TARGET = $(DIR_INFO)/$(THISAPP)
afbd9856
MT
57 EXTRA_CONFIG = \
58 --prefix=/usr \
59 --libexecdir=/usr/lib \
60 --enable-shared \
61 --enable-threads=posix \
62 --enable-__cxa_atexit \
63 --enable-clocale=gnu \
64 --enable-languages=c,c++ \
65 --disable-bootstrap \
66 --disable-nls
857d9bf2
MT
67 EXTRA_MAKE =
68 EXTRA_INSTALL =
cd1a2927 69else
15679d9f 70ifeq "$(PASS)" "1"
cd1a2927 71 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
82b312a9
MT
72 EXTRA_CONFIG = \
73 --target=$(CROSSTARGET) \
74 --prefix=/tools \
764a3f1f 75 --with-sysroot=$(ROOT) \
cfd39a32
MT
76 --with-local-prefix=/tools \
77 --with-native-system-header-dir=/tools/include \
82b312a9
MT
78 --disable-nls \
79 --disable-shared \
80 --disable-decimal-float \
81 --disable-threads \
764a3f1f 82 --disable-libatomic \
82b312a9
MT
83 --disable-libmudflap \
84 --disable-libssp \
8bc5ded2 85 --disable-libmpx \
82b312a9
MT
86 --disable-libgomp \
87 --disable-libquadmath \
764a3f1f
AF
88 --disable-libstdc++-v3 \
89 --disable-libvtv \
90 --disable-libcilkrts \
91 --disable-libitm \
92 --disable-libsanitizer \
82b312a9
MT
93 --with-newlib \
94 --without-headers \
95 --without-ppl \
96 --without-cloog \
764a3f1f 97 --enable-languages=c,c++
575ea031 98 EXTRA_MAKE =
cd1a2927
MT
99 EXTRA_INSTALL =
100else
764a3f1f 101ifeq "$(PASS)" "2"
cd1a2927 102 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
82b312a9 103 EXTRA_ENV = \
6f8f4522 104 CC="$(CROSSTARGET)-gcc" \
764a3f1f 105 CXX="$(CROSSTARGET)-g++" \
82b312a9
MT
106 AR="$(CROSSTARGET)-ar" \
107 RANLIB="$(CROSSTARGET)-ranlib"
108 EXTRA_CONFIG = \
82b312a9 109 --build=$(BUILDTARGET) \
82b312a9
MT
110 --prefix=/tools \
111 --with-local-prefix=/tools \
764a3f1f 112 --with-native-system-header-dir=/tools/include \
82b312a9
MT
113 --enable-languages=c,c++ \
114 --disable-libstdcxx-pch \
b45e371f 115 --disable-libgomp
cd1a2927
MT
116 EXTRA_MAKE =
117 EXTRA_INSTALL =
b45e371f
MT
118
119 ifeq "$(FULL_BOOTSTRAP)" "1"
120 EXTRA_CONFIG += --enable-bootstrap
121 else
122 EXTRA_CONFIG += --disable-bootstrap
123 endif
764a3f1f
AF
124else
125 # PASS=L # libstdc++-v3
126 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
127 EXTRA_ENV = \
6f8f4522 128 CC="$(CROSSTARGET)-gcc" \
764a3f1f
AF
129 AR="$(CROSSTARGET)-ar" \
130 RANLIB="$(CROSSTARGET)-ranlib"
131 EXTRA_CONFIG = \
132 --host=$(CROSSTARGET) \
133 --prefix=/tools \
134 --with-sysroot=$(ROOT) \
135 --disable-shared \
136 --disable-nls \
137 --disable-libstdcxx-threads \
138 --disable-libstdcxx-pch \
139 --with-gxx-include-dir=/tools/$(CROSSTARGET)/include/c++/$(VER)
140 EXTRA_MAKE =
141 EXTRA_INSTALL =
142endif
cd1a2927
MT
143endif
144endif
145
dc7d6b20 146ifeq "$(BUILD_ARCH)" "armv7hl"
0c24d56d
MT
147 EXTRA_CONFIG += \
148 --with-float=hard
149endif
150
dc7d6b20 151ifeq "$(BUILD_ARCH)" "armv5tel"
51f9e7ac 152 EXTRA_CONFIG += \
afbd9856
MT
153 --with-float=soft \
154 --disable-sjlj-exceptions
51f9e7ac
MT
155endif
156
dc7d6b20 157ifeq "$(BUILD_ARCH)" "i586"
ed635824
MT
158 EXTRA_CONFIG += \
159 --with-arch=i586 \
160 --with-tune=generic
161endif
162
163EXTRA_CONFIG += \
51777e5d 164 --disable-multilib \
ed635824
MT
165 --with-bugurl=http://bugtracker.ipfire.org \
166 --disable-libunwind-exceptions \
167 --enable-gnu-unique-object
168
51f9e7ac
MT
169export XCFLAGS = $(CFLAGS)
170export TCFLAGS = $(CFLAGS)
171
cd1a2927
MT
172###############################################################################
173# Top-level Rules
174###############################################################################
82b312a9
MT
175
176objects = $(DL_FILE) \
177 gmp-$(GMP_VER).tar.bz2 \
8675b78a
MT
178 mpfr-$(MPFR_VER).tar.bz2 \
179 mpc-$(MPC_VER).tar.gz
cd1a2927 180
41921bd9 181$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
82b312a9
MT
182gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
183mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
8675b78a 184mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
cd1a2927 185
cfd39a32 186$(DL_FILE)_MD5 = 6e5ea04789678f1250c1b30c4d9ec417
82b312a9
MT
187gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
188mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
8675b78a 189mpc-$(MPC_VER).tar.gz_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26
cd1a2927
MT
190
191install : $(TARGET)
192
193check : $(patsubst %,$(DIR_CHK)/%,$(objects))
194
195download :$(patsubst %,$(DIR_DL)/%,$(objects))
196
197md5 : $(subst %,%_MD5,$(objects))
198
199###############################################################################
200# Downloading, checking, md5sum
201###############################################################################
202
203$(patsubst %,$(DIR_CHK)/%,$(objects)) :
204 @$(CHECK)
205
206$(patsubst %,$(DIR_DL)/%,$(objects)) :
207 @$(LOAD)
208
209$(subst %,%_MD5,$(objects)) :
210 @$(MD5)
211
212###############################################################################
213# Installation Details
214###############################################################################
215
216$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
217 @$(PREBUILD)
8675b78a 218 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
dd714b8a 219 @mkdir $(DIR_SRC)/gcc-build
51f9e7ac 220
991d11d7
MT
221 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
222 cd $(DIR_APP) && sed -i gcc/Makefile.in \
223 -e 's@\./fixinc\.sh@-c true@' \
224 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
225
226ifeq "$(TOOLCHAIN)" "1"
82b312a9
MT
227 # Build gmp and mpfr internally in toolchain.
228 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
229 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
230 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
231 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
8675b78a
MT
232 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
233 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
82b312a9 234
991d11d7 235ifeq "$(PASS)" "2"
764a3f1f
AF
236 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
237 `dirname $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
991d11d7
MT
238endif
239
82b312a9 240 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
cfd39a32 241 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
82b312a9
MT
242 echo "Processing $${file}..."; \
243 sed -i $${file} \
244 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
245 -e 's@/usr@/tools@g'; \
764a3f1f
AF
246 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
247 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
248 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
82b312a9
MT
249 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
250 done
82b312a9 251endif
dd714b8a 252
991d11d7 253ifeq "$(PASS)" "L"
764a3f1f
AF
254 # libstdc++ pass
255 cd $(DIR_SRC)/gcc-build && \
256 $(EXTRA_ENV) \
257 $(DIR_APP)/libstdc++-v3/configure \
258 $(EXTRA_CONFIG)
6323c4d0 259 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
764a3f1f 260 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
cfd39a32 261
764a3f1f 262else
82b312a9
MT
263 # The actual build.
264 cd $(DIR_SRC)/gcc-build && \
265 $(EXTRA_ENV) \
266 $(DIR_APP)/configure \
267 $(EXTRA_CONFIG)
6323c4d0 268 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
f97be0a6 269 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
764a3f1f 270endif
82b312a9 271
991d11d7
MT
272ifeq "$(TOOLCHAIN)" "1"
273 ifeq "$(PASS)" "1"
82b312a9 274 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
991d11d7
MT
275 endif
276
277 ifeq "$(PASS)" "2"
82b312a9 278 ln -svf gcc /tools/bin/cc
8f2ac12a
AF
279 # remove gdb python files from libdir
280 rm -rf /tools/lib/*-gdb.py
991d11d7
MT
281 endif
282
283 ifeq "$(PASS)" "L"
284 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
285 sed -e "s/^#include_next/#include/" -i /tools/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
286 endif
287
288else # NON-TOOLCHAIN
289 ln -svf ../usr/bin/cpp /lib
290 ln -svf gcc /usr/bin/cc
291 # remove gdb python files from libdir
292 rm -rf /usr/lib/*-gdb.py
cd1a2927 293endif
991d11d7 294
cd1a2927
MT
295 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
296 @$(POSTBUILD)