868428c6207223b9f57286fac8648076358fde27
[people/teissler/ipfire-2.x.git] / lfs / gcc
1 ###############################################################################
2 # This file is part of the IPCop Firewall. #
3 # #
4 # IPCop is free software; you can redistribute it and/or modify #
5 # it under the terms of the GNU General Public License as published by #
6 # the Free Software Foundation; either version 2 of the License, or #
7 # (at your option) any later version. #
8 # #
9 # IPCop is distributed in the hope that it will be useful, #
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
12 # GNU General Public License for more details. #
13 # #
14 # You should have received a copy of the GNU General Public License #
15 # along with IPCop; if not, write to the Free Software #
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
17 # #
18 # Makefiles are based on LFSMake, which is #
19 # Copyright (C) 2002 Rod Roard <rod@sunsetsystems.com> #
20 # #
21 ###############################################################################
22
23 ###############################################################################
24 # Definitions
25 ###############################################################################
26
27 include Config
28
29 VER = 4.0.3
30
31 THISAPP = gcc-$(VER)
32 DL_FILE = $(THISAPP).tar.bz2
33 DL_FROM = $(URL_IPFIRE)
34 DIR_APP = $(DIR_SRC)/$(THISAPP)
35 CFLAGS =
36 CXXFLAGS =
37
38 # Normal build or /tools build.
39 #
40 ifeq "$(ROOT)" ""
41 ifeq "$(INST)" "1"
42 TARGET = $(DIR_INFO)/$(THISAPP)-install1
43 EXTRA_CONFIG = --target=$(MACHINE)-linux-uclibc --prefix=/opt/$(MACHINE)-uClibc \
44 --with-local-prefix=/opt/$(MACHINE)-uClibc/$(MACHINE)-linux-uclibc --with-newlib \
45 --with-sysroot=/opt/$(MACHINE)-uClibc --disable-nls \
46 --enable-threads=no --enable-symvers=gnu \
47 --disable-__cxa_atexit --enable-languages=c \
48 --disable-shared --with-gnu-as --with-gnu-ld \
49 --without-headers
50 else
51 ifeq "$(INST)" "2"
52 TARGET = $(DIR_INFO)/$(THISAPP)-install2
53 EXTRA_CONFIG = --target=$(MACHINE)-linux-uclibc --prefix=/opt/$(MACHINE)-uClibc \
54 --with-local-prefix=/opt/$(MACHINE)-uClibc/$(MACHINE)-linux-uclibc \
55 --with-sysroot=/opt/$(MACHINE)-uClibc \
56 --disable-nls \
57 --enable-threads=posix --enable-symvers=gnu \
58 --disable-__cxa_atexit --enable-languages=c,c++ \
59 --enable-c99 --enable-long-long --with-gnu-as \
60 --with-gnu-ld --enable-shared --enable-clocale \
61 --enable-target-optspace
62 else
63 TARGET = $(DIR_INFO)/$(THISAPP)
64 EXTRA_CONFIG = --prefix=/usr \
65 --libexecdir=/usr/lib --enable-shared \
66 --enable-threads=posix --enable-__cxa_atexit \
67 --enable-clocale=gnu --enable-languages=c,c++ \
68 --disable-nls
69 EXTRA_MAKE =
70 EXTRA_INSTALL =
71 endif
72 endif
73 else
74 ifeq "$(PASS)" "1"
75 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
76 EXTRA_CONFIG = --prefix=/tools \
77 --with-local-prefix=/tools --disable-nls --enable-shared \
78 --enable-languages=c
79 EXTRA_MAKE = bootstrap BOOT_LDFLAGS="-static"
80 EXTRA_INSTALL =
81 else
82 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
83 EXTRA_CONFIG = --prefix=/tools \
84 --with-local-prefix=/tools --enable-clocale=gnu \
85 --enable-shared --enable-threads=posix \
86 --enable-__cxa_atexit --enable-languages=c,c++ \
87 --disable-libstdcxx-pch
88 EXTRA_MAKE =
89 EXTRA_INSTALL =
90 endif
91 endif
92
93 ###############################################################################
94 # Top-level Rules
95 ###############################################################################
96 objects = $(DL_FILE)
97
98 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
99
100 $(DL_FILE)_MD5 = 6ff1af12c53cbb3f79b27f2d6a9a3d50
101
102 install : $(TARGET)
103
104 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
105
106 download :$(patsubst %,$(DIR_DL)/%,$(objects))
107
108 md5 : $(subst %,%_MD5,$(objects))
109
110 ###############################################################################
111 # Downloading, checking, md5sum
112 ###############################################################################
113
114 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
115 @$(CHECK)
116
117 $(patsubst %,$(DIR_DL)/%,$(objects)) :
118 @$(LOAD)
119
120 $(subst %,%_MD5,$(objects)) :
121 @$(MD5)
122
123 ###############################################################################
124 # Installation Details
125 ###############################################################################
126
127 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
128 @$(PREBUILD)
129 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
130 @mkdir $(DIR_SRC)/gcc-build
131 ifeq "$(ROOT)" ""
132 ifeq "$(INST)" "1"
133 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc-uclibc-conf.patch
134 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
135 override PATH = /opt/$(MACHINE)-uClibc/bin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin
136 cd $(DIR_SRC)/gcc-build && make all-gcc install-gcc
137 else
138 ifeq "$(INST)" "2"
139 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc-uclibc-conf.patch
140 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc-uclibc-locale.patch
141 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc-libstdc++-pic.patch
142 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc-sdk-libstdc++-includes.patch
143 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
144 cd $(DIR_SRC)/gcc-build && make all install
145 cp -f /opt/$(MACHINE)-uClibc/lib/libgcc_s.so /lib
146 cd /lib && ln -sf libgcc_s.so libgcc_s.so.1
147 else
148 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
149 cd $(DIR_APP) && sed -i 's/^XCFLAGS =$$/& -fomit-frame-pointer/' gcc/Makefile.in
150 cd $(DIR_APP) && sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
151 cd $(DIR_APP) && sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in
152
153 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
154 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
155 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
156 ln -sfv ../usr/bin/cpp /lib
157 ln -sfv gcc /usr/bin/cc
158 endif
159 endif
160 else
161 ifeq "$(PASS)" "1"
162 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
163 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
164 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
165 ln -sfv gcc /tools/bin/cc
166 else
167 cd $(DIR_APP) && cp -v gcc/Makefile.in{,.orig}
168 cd $(DIR_APP) && sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in
169 cd $(DIR_APP) && cp -v gcc/Makefile.in{,.tmp}
170 cd $(DIR_APP) && sed 's/^XCFLAGS =$\/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \
171 > gcc/Makefile.in
172 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/$(THISAPP)-specs-1.patch
173 cd $(DIR_SRC)/gcc-build && $(DIR_APP)/configure $(EXTRA_CONFIG)
174 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
175 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
176 endif
177 endif
178 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
179 @$(POSTBUILD)