]>
Commit | Line | Data |
---|---|---|
cd1a2927 | 1 | ############################################################################### |
cd1a2927 | 2 | # # |
70df8302 | 3 | # IPFire.org - A linux based firewall # |
3f8c9dc5 | 4 | # Copyright (C) 2007-2011 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 | ||
25 | include Config | |
26 | ||
8675b78a | 27 | VER = 4.9.3 |
82b312a9 MT |
28 | |
29 | GMP_VER = 5.0.5 | |
30 | MPFR_VER = 2.4.2 | |
8675b78a | 31 | MPC_VER = 1.0.3 |
cd1a2927 MT |
32 | |
33 | THISAPP = gcc-$(VER) | |
8675b78a | 34 | DL_FILE = $(THISAPP).tar.gz |
dd714b8a | 35 | DL_FROM = $(URL_IPFIRE) |
cd1a2927 | 36 | DIR_APP = $(DIR_SRC)/$(THISAPP) |
cd1a2927 | 37 | |
ed635824 MT |
38 | CFLAGS := $(patsubst -march=%,,$(CFLAGS)) |
39 | CFLAGS := $(patsubst -mtune=%,,$(CFLAGS)) | |
62a430f9 | 40 | CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS)) |
8675b78a MT |
41 | CFLAGS := $(filter-out -fexceptions,$(CFLAGS)) |
42 | CXXFLAGS := $(CFLAGS) | |
ff1d5f3a | 43 | |
cd1a2927 MT |
44 | # Normal build or /tools build. |
45 | # | |
46 | ifeq "$(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 | 60 | else |
15679d9f | 61 | ifeq "$(PASS)" "1" |
cd1a2927 | 62 | TARGET = $(DIR_INFO)/$(THISAPP)-tools1 |
82b312a9 MT |
63 | EXTRA_CONFIG = \ |
64 | --target=$(CROSSTARGET) \ | |
65 | --prefix=/tools \ | |
66 | --disable-nls \ | |
67 | --disable-shared \ | |
68 | --disable-decimal-float \ | |
69 | --disable-threads \ | |
70 | --disable-libmudflap \ | |
71 | --disable-libssp \ | |
72 | --disable-libgomp \ | |
73 | --disable-libquadmath \ | |
74 | --with-newlib \ | |
75 | --without-headers \ | |
76 | --without-ppl \ | |
77 | --without-cloog \ | |
b469c8c2 | 78 | --enable-languages=c |
575ea031 | 79 | EXTRA_MAKE = |
cd1a2927 MT |
80 | EXTRA_INSTALL = |
81 | else | |
82 | TARGET = $(DIR_INFO)/$(THISAPP)-tools2 | |
82b312a9 MT |
83 | EXTRA_ENV = \ |
84 | CC="$(CROSSTARGET)-gcc -B/tools/lib/" \ | |
85 | AR="$(CROSSTARGET)-ar" \ | |
86 | RANLIB="$(CROSSTARGET)-ranlib" | |
87 | EXTRA_CONFIG = \ | |
88 | --host=$(BUILDTARGET) \ | |
89 | --build=$(BUILDTARGET) \ | |
90 | --target=$(BUILDTARGET) \ | |
91 | --prefix=/tools \ | |
92 | --with-local-prefix=/tools \ | |
93 | --enable-clocale=gnu \ | |
94 | --enable-shared \ | |
95 | --enable-threads=posix \ | |
96 | --enable-__cxa_atexit \ | |
97 | --enable-languages=c,c++ \ | |
98 | --disable-libstdcxx-pch \ | |
99 | --disable-bootstrap | |
cd1a2927 MT |
100 | EXTRA_MAKE = |
101 | EXTRA_INSTALL = | |
102 | endif | |
3a317084 AF |
103 | |
104 | # Disable stack protection in toolchain. | |
105 | CFLAGS += -fno-stack-protector | |
cd1a2927 MT |
106 | endif |
107 | ||
cc72d5cb | 108 | ifeq "$(MACHINE_TYPE)" "arm" |
51f9e7ac | 109 | EXTRA_CONFIG += \ |
afbd9856 MT |
110 | --with-float=soft \ |
111 | --disable-sjlj-exceptions | |
51f9e7ac MT |
112 | endif |
113 | ||
ed635824 MT |
114 | ifeq "$(MACHINE)" "i586" |
115 | EXTRA_CONFIG += \ | |
116 | --with-arch=i586 \ | |
117 | --with-tune=generic | |
118 | endif | |
119 | ||
81aa9714 MT |
120 | ifeq "$(MACHINE)" "x86_64" |
121 | EXTRA_CONFIG += \ | |
122 | --disable-multilib | |
123 | endif | |
124 | ||
ed635824 MT |
125 | EXTRA_CONFIG += \ |
126 | --with-bugurl=http://bugtracker.ipfire.org \ | |
127 | --disable-libunwind-exceptions \ | |
128 | --enable-gnu-unique-object | |
129 | ||
51f9e7ac MT |
130 | export XCFLAGS = $(CFLAGS) |
131 | export TCFLAGS = $(CFLAGS) | |
132 | ||
cd1a2927 MT |
133 | ############################################################################### |
134 | # Top-level Rules | |
135 | ############################################################################### | |
82b312a9 MT |
136 | |
137 | objects = $(DL_FILE) \ | |
138 | gmp-$(GMP_VER).tar.bz2 \ | |
8675b78a MT |
139 | mpfr-$(MPFR_VER).tar.bz2 \ |
140 | mpc-$(MPC_VER).tar.gz | |
cd1a2927 | 141 | |
41921bd9 | 142 | $(DL_FILE) = $(DL_FROM)/$(DL_FILE) |
82b312a9 MT |
143 | gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2 |
144 | mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2 | |
8675b78a | 145 | mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz |
cd1a2927 | 146 | |
8675b78a | 147 | $(DL_FILE)_MD5 = 648bfba342bb41a4b5350fb685f85bc5 |
82b312a9 MT |
148 | gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe |
149 | mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0 | |
8675b78a | 150 | mpc-$(MPC_VER).tar.gz_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26 |
cd1a2927 MT |
151 | |
152 | install : $(TARGET) | |
153 | ||
154 | check : $(patsubst %,$(DIR_CHK)/%,$(objects)) | |
155 | ||
156 | download :$(patsubst %,$(DIR_DL)/%,$(objects)) | |
157 | ||
158 | md5 : $(subst %,%_MD5,$(objects)) | |
159 | ||
160 | ############################################################################### | |
161 | # Downloading, checking, md5sum | |
162 | ############################################################################### | |
163 | ||
164 | $(patsubst %,$(DIR_CHK)/%,$(objects)) : | |
165 | @$(CHECK) | |
166 | ||
167 | $(patsubst %,$(DIR_DL)/%,$(objects)) : | |
168 | @$(LOAD) | |
169 | ||
170 | $(subst %,%_MD5,$(objects)) : | |
171 | @$(MD5) | |
172 | ||
173 | ############################################################################### | |
174 | # Installation Details | |
175 | ############################################################################### | |
176 | ||
177 | $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) | |
178 | @$(PREBUILD) | |
8675b78a | 179 | @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) |
dd714b8a | 180 | @mkdir $(DIR_SRC)/gcc-build |
51f9e7ac | 181 | |
ed635824 | 182 | # Apply patches. |
8675b78a MT |
183 | cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-i386-libgomp.patch |
184 | cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-libtool-no-rpath.patch | |
185 | cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-no-add-needed.patch | |
186 | cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-pr38757.patch | |
187 | cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-pr64336.patch | |
188 | cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc/gcc-fix-inlining-issues.patch | |
defd8d00 | 189 | |
82b312a9 MT |
190 | ifneq "$(ROOT)" "" |
191 | # Build gmp and mpfr internally in toolchain. | |
192 | cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2 | |
193 | cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp | |
194 | cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2 | |
195 | cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr | |
8675b78a MT |
196 | cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz |
197 | cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc | |
82b312a9 MT |
198 | |
199 | ifeq "$(PASS)" "1" | |
200 | # GCC does not detect stack protection correctly, which causes problems | |
201 | # for the build of libresolv_pic.a. | |
202 | cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure | |
203 | endif | |
51f9e7ac | 204 | |
82b312a9 MT |
205 | ifeq "$(PASS)" "2" |
206 | cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.4.3-startfiles_fix-1.patch | |
207 | ||
82b312a9 MT |
208 | for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \ |
209 | -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \ | |
210 | echo "Processing $${file}..."; \ | |
211 | sed -i $${file} \ | |
212 | -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \ | |
213 | -e 's@/usr@/tools@g'; \ | |
214 | echo '#undef STANDARD_INCLUDE_DIR' >> $${file}; \ | |
215 | echo '#define STANDARD_INCLUDE_DIR 0' >> $${file}; \ | |
216 | echo '#define STANDARD_STARTFILE_PREFIX_1 ""' >> $${file}; \ | |
217 | echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \ | |
218 | done | |
219 | endif | |
220 | endif | |
dd714b8a | 221 | |
afbd9856 MT |
222 | cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in |
223 | cd $(DIR_APP) && sed -i gcc/Makefile.in \ | |
224 | -e 's@\./fixinc\.sh@-c true@' \ | |
225 | -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/' | |
226 | ||
82b312a9 MT |
227 | # The actual build. |
228 | cd $(DIR_SRC)/gcc-build && \ | |
229 | $(EXTRA_ENV) \ | |
230 | $(DIR_APP)/configure \ | |
231 | $(EXTRA_CONFIG) | |
f97be0a6 MT |
232 | cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE) |
233 | cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install | |
82b312a9 | 234 | |
afbd9856 MT |
235 | ifeq "$(ROOT)" "" |
236 | ln -svf ../usr/bin/cpp /lib | |
6753fbe0 | 237 | ln -svf gcc /usr/bin/cc |
afbd9856 | 238 | else |
82b312a9 MT |
239 | ifeq "$(PASS)" "1" |
240 | ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/') | |
cd1a2927 | 241 | else |
82b312a9 | 242 | ln -svf gcc /tools/bin/cc |
cd1a2927 | 243 | endif |
cd1a2927 MT |
244 | endif |
245 | @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build | |
246 | @$(POSTBUILD) |