]> git.ipfire.org Git - ipfire-3.x.git/blob - lfs/gcc
Rootfile update.
[ipfire-3.x.git] / lfs / gcc
1 ###############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007, 2008, 2009 Michael Tremer & Christian Schmidt #
5 # #
6 # This program is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation, either version 3 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
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 #
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
18 # #
19 ###############################################################################
20
21 ###############################################################################
22 # Definitions
23 ###############################################################################
24
25 include Config
26
27 PKG_NAME = gcc
28 VER = 4.3.3
29 PKG_VER = 0
30
31 THISAPP = $(PKG_NAME)-$(VER)
32 DL_FILE = $(THISAPP).tar.bz2
33 DIR_APP = $(DIR_SRC)/$(THISAPP)
34
35 ifeq "$(STAGE)" "base"
36 OBJECT = $(DIR_INFO)/$(STAGE_ORDER)_$(STAGE)/$(THISAPP)
37 else
38 OBJECT = $(DIR_INFO)/$(STAGE_ORDER)_$(STAGE)/$(THISAPP)-pass$(PASS)
39 endif
40
41 MAINTAINER =
42 GROUP = Development/Compilers
43 EXTRA = no
44 DEBUG = no
45 DEPS =
46
47 URL = http://gcc.gnu.org/
48 LICENSE = GPLv3+ and GPLv2+ with exceptions
49 SHORT_DESC = Various compilers (C, C++, Objective-C, Java, ...).
50
51 define LONG_DESC
52 The gcc package contains the GNU Compiler Collection. \
53 You'll need this package in order to compile C code.
54 endef
55
56 CFLAGS = -pipe
57 CXXFLAGS =
58
59 GMP = $(shell grep ^VER $(DIR_LFS)/gmp | awk '{ print $$3 }')
60 MPFR = $(shell grep ^VER $(DIR_LFS)/mpfr | awk '{ print $$3 }')
61
62 ifeq "$(MACHINE)" "i586"
63 CONFIGURE_ARGS = --disable-decimal-float
64 endif
65
66 ###############################################################################
67 # Top-level Rules
68 ###############################################################################
69
70 objects = $(DL_FILE) \
71 gmp-$(GMP).tar.bz2 mpfr-$(MPFR).tar.bz2 \
72 $(THISAPP)-fstack_protector-1.patch \
73 $(THISAPP)-fortify_source-2.patch \
74 $(THISAPP)-fpie-1.patch \
75 $(THISAPP)-branch-startfiles-1.patch \
76 $(THISAPP)-asprintf_fix.patch
77
78 download: $(objects)
79
80 info:
81 $(DO_PKG_INFO)
82
83 install: $(OBJECT)
84
85 package:
86 @$(DO_PACKAGE)
87
88 $(objects):
89 @$(LOAD)
90
91 ###############################################################################
92 # Installation Details
93 ###############################################################################
94
95 $(OBJECT): $(objects)
96 @$(PREBUILD)
97 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && $(EXTRACTOR) $(DIR_DL)/$(DL_FILE)
98 -mkdir -v $(DIR_SRC)/gcc-build
99
100 # First, unpack gmp and mpfr.
101 # We use the build-"magic" of the gcc build system that we compile libgmp and
102 # libmpfr right (with -fPIC and so on).
103 cd $(DIR_APP) && $(EXTRACTOR) $(DIR_DL)/gmp-$(GMP).tar.bz2
104 cd $(DIR_APP) && ln -svf gmp-* gmp
105 cd $(DIR_APP) && $(EXTRACTOR) $(DIR_DL)/mpfr-$(MPFR).tar.bz2
106 cd $(DIR_APP) && ln -svf mpfr-* mpfr
107
108 ifeq "$(STAGE)" "toolchain"
109 ifeq "$(PASS)" "1"
110 ## Enable -fPIC by default
111 cd $(DIR_APP) && sed 's/^\(#define CC1_SPEC.*\)\("\)$$/\1 %{fno-pic|fpic|fPIC:;:-fPIC}\2/' \
112 -i gcc/config/i386/linux.h
113
114 # libssp has no use with new versions of Glibc. Glibc completely replaces all
115 # functions in libssp, linking to libssp will cause conflicts with libc, so
116 # libssp is a waste of space... so --disable-libssp.
117
118 cd $(DIR_SRC)/gcc-build && \
119 CC="gcc -B/usr/bin/" \
120 ../$(THISAPP)/configure \
121 $(CONFIGURE_ARCH) \
122 --target=$(IFS_TARGET) \
123 --with-cpu=$(MACHINE) \
124 --with-arch=$(MACHINE) \
125 --prefix=$(TOOLS_DIR) \
126 --with-local-prefix=$(TOOLS_DIR) \
127 --libexecdir=$(TOOLS_DIR)/lib \
128 --enable-languages=c \
129 --enable-shared \
130 --disable-nls \
131 --disable-libssp \
132 --disable-werror \
133 $(CONFIGURE_ARGS)
134
135 cd $(DIR_SRC)/gcc-build && make $(PARALLELISMFLAGS)
136 cd $(DIR_SRC)/gcc-build && make install
137
138 ln -fvs gcc $(TOOLS_DIR)/bin/cc
139 endif
140
141 ifeq "$(PASS)" "2"
142 # Enable hardening by default:
143 cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fortify_source-2.patch
144 cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fstack_protector-1.patch
145
146 # This fpie patch also warns about DT_TEXTREL in shared objects (libraries and
147 # PIE's), and makes linker warnings fatal. Disable --fatal-warnings with
148 # -Wl,--no-fatal-warnings.
149 cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fpie-1.patch
150 cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-branch-startfiles-1.patch
151
152 # This patch fixes a conflict between libiberty's asprintf() and Glibc's, when
153 # -D_FORTIFY_SOURCE=2 is used:
154 cd $(DIR_APP) && patch -Np0 -i $(DIR_PATCHES)/$(THISAPP)-asprintf_fix.patch
155
156 cd $(DIR_APP) && sed 's@\./fixinc\.sh@-c true@' -i gcc/Makefile.in
157 cd $(DIR_APP) && sed 's/^XCFLAGS =$$/& -fomit-frame-pointer/' -i gcc/Makefile.in
158 cd $(DIR_APP) && \
159 for file in $$(find gcc/config -name linux64.h -o -name linux.h); do \
160 cp -uv $$file{,.orig}; \
161 sed -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \
162 -e 's@/usr@$(TOOLS_DIR)@g' $$file.orig > $$file; \
163 echo -e "\n#undef STANDARD_INCLUDE_DIR\n#define STANDARD_INCLUDE_DIR 0" >> $$file; \
164 touch $$file.orig; \
165 done
166
167 # Libgomp uses -Werror regardless of --disable-werror, and this will cause a
168 # build failure when -D_FORTIFY_SOURCE=2 causes build time warnings:
169 cd $(DIR_APP) && sed -e "s/-Werror//" -i libgomp/configure
170
171 # We need to do another bootstrap, so that everything in $(TOOLS_DIR) is hardened.
172 cd $(DIR_SRC)/gcc-build && \
173 ../$(THISAPP)/configure \
174 $(CONFIGURE_ARCH) \
175 --target=$(IFS_TARGET) \
176 --with-cpu=$(MACHINE) \
177 --with-arch=$(MACHINE) \
178 --prefix=$(TOOLS_DIR) \
179 --with-local-prefix=$(TOOLS_DIR) \
180 --libexecdir=$(TOOLS_DIR)/lib \
181 --enable-clocale=gnu \
182 --enable-shared \
183 --enable-threads=posix \
184 --enable-__cxa_atexit \
185 --enable-languages=c,c++ \
186 --disable-libstdcxx-pch \
187 --disable-bootstrap \
188 --disable-werror \
189 --disable-libssp \
190 --disable-nls \
191 $(CONFIGURE_ARGS)
192 cd $(DIR_SRC)/gcc-build && make $(PARALLELISMFLAGS)
193 cd $(DIR_SRC)/gcc-build && make install
194 endif
195 endif
196
197 ifeq "$(STAGE)" "base"
198 cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fortify_source-2.patch
199 cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fstack_protector-1.patch
200 cd $(DIR_APP) && patch -Np1 -i $(DIR_PATCHES)/$(THISAPP)-fpie-1.patch
201 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
202 cd $(DIR_APP) && sed -i 's/^XCFLAGS =$$/& -fomit-frame-pointer/' gcc/Makefile.in
203 cd $(DIR_APP) && sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
204
205 # Libgomp uses -Werror regardless of --disable-werror, and this will cause a
206 # build failure when -D_FORTIFY_SOURCE=2 causes build time warnings:
207 cd $(DIR_APP) && sed -e "s/-Werror//" -i libgomp/configure
208
209 cd $(DIR_SRC)/gcc-build && \
210 ../$(THISAPP)/configure \
211 $(CONFIGURE_ARCH) \
212 --target=$(IFS_TARGET) \
213 --with-cpu=$(MACHINE) \
214 --with-arch=$(MACHINE) \
215 --prefix=/usr \
216 --libexecdir=/usr/lib \
217 --enable-shared \
218 --enable-threads=posix \
219 --enable-__cxa_atexit \
220 --enable-clocale=gnu \
221 --enable-languages=c,c++ \
222 --disable-bootstrap \
223 --disable-werror \
224 --disable-libssp
225
226 cd $(DIR_SRC)/gcc-build && make $(PARALLELISMFLAGS)
227 cd $(DIR_SRC)/gcc-build && make install
228
229 ln -sfv ../usr/bin/cpp /lib
230 ln -sfv gcc /usr/bin/cc
231 endif
232
233 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
234 @$(POSTBUILD)