]> git.ipfire.org Git - ipfire-2.x.git/blob - lfs/gcc
toolchain: build toolchain on armv6l and armv7l.
[ipfire-2.x.git] / lfs / gcc
1 ###############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2011 IPFire Team <info@ipfire.org> #
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 VER = 4.1.2
28
29 THISAPP = gcc-$(VER)
30 DL_FILE = $(THISAPP).tar.bz2
31 DL_FROM = $(URL_IPFIRE)
32 DIR_APP = $(DIR_SRC)/$(THISAPP)
33
34 # Normal build or /tools build.
35 #
36 ifeq "$(ROOT)" ""
37 TARGET = $(DIR_INFO)/$(THISAPP)
38 EXTRA_CONFIG = --prefix=/usr \
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
46 EXTRA_MAKE =
47 EXTRA_INSTALL =
48 else
49 ifeq "$(PASS)" "1"
50 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
51 EXTRA_CONFIG = --prefix=/tools \
52 --with-local-prefix=/tools \
53 --disable-nls \
54 --enable-shared \
55 --enable-languages=c \
56 --enable-bootstrap
57 EXTRA_MAKE =
58 EXTRA_INSTALL =
59 else
60 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
61 EXTRA_CONFIG = --prefix=/tools \
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
69 EXTRA_MAKE =
70 EXTRA_INSTALL =
71 endif
72 endif
73
74 ifeq "$(MACHINE_TYPE)" "arm"
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
88 else
89 EXTRA_CONFIG += --build=$(BUILDTARGET) --host=$(BUILDTARGET) \
90 --target=$(BUILDTARGET)
91 endif
92
93 export XCFLAGS = $(CFLAGS)
94 export TCFLAGS = $(CFLAGS)
95
96 ifeq "$(PASS)" "1"
97 CFLAGS =
98 endif
99
100 ###############################################################################
101 # Top-level Rules
102 ###############################################################################
103 objects = $(DL_FILE)
104
105 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
106
107 $(DL_FILE)_MD5 = a4a3eb15c96030906d8494959eeda23c
108
109 install : $(TARGET)
110
111 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
112
113 download :$(patsubst %,$(DIR_DL)/%,$(objects))
114
115 md5 : $(subst %,%_MD5,$(objects))
116
117 ###############################################################################
118 # Downloading, checking, md5sum
119 ###############################################################################
120
121 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
122 @$(CHECK)
123
124 $(patsubst %,$(DIR_DL)/%,$(objects)) :
125 @$(LOAD)
126
127 $(subst %,%_MD5,$(objects)) :
128 @$(MD5)
129
130 ###############################################################################
131 # Installation Details
132 ###############################################################################
133
134 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
135 @$(PREBUILD)
136 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
137 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-fix_linker_version_detection.patch
138 @mkdir $(DIR_SRC)/gcc-build
139
140 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.1.2-gcc_eh.patch
141 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.1.2-arm-linux-soft-float.patch
142
143 ifeq "$(ROOT)" ""
144 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
145 cd $(DIR_APP) && sed -i 's/^XCFLAGS =$$/& -fomit-frame-pointer/' gcc/Makefile.in
146 cd $(DIR_APP) && sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
147 cd $(DIR_APP) && sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in
148
149 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
150 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
151 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
152 ln -sfv ../usr/bin/cpp /lib
153 ln -sfv gcc /usr/bin/cc
154 else
155 ifeq "$(PASS)" "1"
156 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
157 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
158 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
159 ln -sfv gcc /tools/bin/cc
160 ln -sf ccache $(ROOT)/usr/local/bin/$(BUILDTARGET)-gcc
161 ln -sf ccache $(ROOT)/usr/local/bin/$(BUILDTARGET)-g++
162 ln -sf ccache $(ROOT)/usr/local/bin/$(BUILDTARGET)-cc
163 else
164 cd $(DIR_APP) && cp -v gcc/Makefile.in{,.orig}
165 cd $(DIR_APP) && sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in
166 cd $(DIR_APP) && cp -v gcc/Makefile.in{,.tmp}
167 cd $(DIR_APP) && sed 's/^XCFLAGS =$\/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \
168 > gcc/Makefile.in
169 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-specs-1.patch
170 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
171 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
172 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
173 endif
174 endif
175 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
176 @$(POSTBUILD)