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