toolchain: Cross build binutils.
[ipfire-2.x.git] / lfs / gcc
CommitLineData
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
25include Config
26
3f8c9dc5 27VER = 4.1.2
cd1a2927
MT
28
29THISAPP = gcc-$(VER)
dd714b8a
MT
30DL_FILE = $(THISAPP).tar.bz2
31DL_FROM = $(URL_IPFIRE)
cd1a2927 32DIR_APP = $(DIR_SRC)/$(THISAPP)
cd1a2927
MT
33
34# Normal build or /tools build.
35#
36ifeq "$(ROOT)" ""
37 TARGET = $(DIR_INFO)/$(THISAPP)
38 EXTRA_CONFIG = --prefix=/usr \
a50d04ab
MT
39 --libexecdir=/usr/lib \
40 --enable-shared \
41 --enable-threads=posix \
42 --enable-__cxa_atexit \
43 --enable-clocale=gnu \
44 --enable-languages=c,c++ \
45 --disable-nls
857d9bf2
MT
46 EXTRA_MAKE =
47 EXTRA_INSTALL =
cd1a2927 48else
15679d9f 49ifeq "$(PASS)" "1"
cd1a2927 50 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
dd714b8a 51 EXTRA_CONFIG = --prefix=/tools \
a50d04ab
MT
52 --with-local-prefix=/tools \
53 --disable-nls \
54 --enable-shared \
51f9e7ac
MT
55 --enable-languages=c \
56 --disable-bootstrap
575ea031 57 EXTRA_MAKE =
cd1a2927
MT
58 EXTRA_INSTALL =
59else
60 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
dd714b8a 61 EXTRA_CONFIG = --prefix=/tools \
a50d04ab
MT
62 --with-local-prefix=/tools \
63 --enable-clocale=gnu \
64 --enable-shared \
65 --enable-threads=posix \
66 --enable-__cxa_atexit \
67 --enable-languages=c,c++ \
68 --disable-libstdcxx-pch
cd1a2927
MT
69 EXTRA_MAKE =
70 EXTRA_INSTALL =
71endif
72endif
73
cc72d5cb 74ifeq "$(MACHINE_TYPE)" "arm"
51f9e7ac
MT
75 EXTRA_CONFIG += \
76 --build=$(BUILDTARGET) \
77 --host=$(BUILDTARGET) \
78 --target=$(BUILDTARGET) \
79 --with-float=soft \
80 --disable-libmudflap \
81 --disable-libssp \
82 --disable-libgomp \
83 --enable-threads=posix \
84 --enable-long-long \
85 --enable-c99 \
86 --enable-__cxa_atexit \
87 --disable-multilib
7b321c2c
MT
88else
89 EXTRA_CONFIG += --build=$(BUILDTARGET) --host=$(BUILDTARGET) \
90 --target=$(BUILDTARGET)
51f9e7ac
MT
91endif
92
93export XCFLAGS = $(CFLAGS)
94export TCFLAGS = $(CFLAGS)
95
cd1a2927
MT
96###############################################################################
97# Top-level Rules
98###############################################################################
dd714b8a 99objects = $(DL_FILE)
cd1a2927 100
41921bd9 101$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
cd1a2927 102
3f8c9dc5 103$(DL_FILE)_MD5 = a4a3eb15c96030906d8494959eeda23c
cd1a2927
MT
104
105install : $(TARGET)
106
107check : $(patsubst %,$(DIR_CHK)/%,$(objects))
108
109download :$(patsubst %,$(DIR_DL)/%,$(objects))
110
111md5 : $(subst %,%_MD5,$(objects))
112
113###############################################################################
114# Downloading, checking, md5sum
115###############################################################################
116
117$(patsubst %,$(DIR_CHK)/%,$(objects)) :
118 @$(CHECK)
119
120$(patsubst %,$(DIR_DL)/%,$(objects)) :
121 @$(LOAD)
122
123$(subst %,%_MD5,$(objects)) :
124 @$(MD5)
125
126###############################################################################
127# Installation Details
128###############################################################################
129
130$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
131 @$(PREBUILD)
132 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
2b56ee99 133 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-fix_linker_version_detection.patch
dd714b8a 134 @mkdir $(DIR_SRC)/gcc-build
51f9e7ac
MT
135
136 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.1.2-gcc_eh.patch
137 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.1.2-arm-linux-soft-float.patch
138
cd1a2927 139ifeq "$(ROOT)" ""
f97be0a6
MT
140 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
141 cd $(DIR_APP) && sed -i 's/^XCFLAGS =$$/& -fomit-frame-pointer/' gcc/Makefile.in
9b0ff0a0
MT
142 cd $(DIR_APP) && sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
143 cd $(DIR_APP) && sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in
dd714b8a 144
f97be0a6
MT
145 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
146 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
147 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
9b0ff0a0
MT
148 ln -sfv ../usr/bin/cpp /lib
149 ln -sfv gcc /usr/bin/cc
cd1a2927 150else
15679d9f 151ifeq "$(PASS)" "1"
f97be0a6 152 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
dd714b8a 153 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
cd1a2927 154 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
9b0ff0a0 155 ln -sfv gcc /tools/bin/cc
51f9e7ac
MT
156 ln -sf ccache $(ROOT)/usr/local/bin/$(BUILDTARGET)-gcc
157 ln -sf ccache $(ROOT)/usr/local/bin/$(BUILDTARGET)-g++
158 ln -sf ccache $(ROOT)/usr/local/bin/$(BUILDTARGET)-cc
cd1a2927 159else
dd714b8a
MT
160 cd $(DIR_APP) && cp -v gcc/Makefile.in{,.orig}
161 cd $(DIR_APP) && sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in
162 cd $(DIR_APP) && cp -v gcc/Makefile.in{,.tmp}
90d372c4
MT
163 cd $(DIR_APP) && sed 's/^XCFLAGS =$\/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \
164 > gcc/Makefile.in
9b0ff0a0 165 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-specs-1.patch
f97be0a6 166 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
dd714b8a
MT
167 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
168 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
cd1a2927 169endif
cd1a2927
MT
170endif
171 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
172 @$(POSTBUILD)