]> git.ipfire.org Git - ipfire-2.x.git/blob - lfs/gcc
MONSTER-REVISION!
[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 # Modifications by: #
22 # ??-12-2003 Mark Wormgoor < mark@wormgoor.com> #
23 # - Modified Makefile for IPCop build #
24 # #
25 # $Id: gcc,v 1.18.2.9 2006/01/22 21:58:23 franck78 Exp $
26 # #
27 ###############################################################################
28
29 ###############################################################################
30 # Definitions
31 ###############################################################################
32
33 include Config
34
35 VER = 3.3.3
36
37 THISAPP = gcc-$(VER)
38 DL_FILE = gcc-core-$(VER).tar.bz2
39 DL_FROM = $(URL_GNU)/gcc/releases/gcc-$(VER)
40 DIR_APP = $(DIR_SRC)/$(THISAPP)
41 CFLAGS =
42 CXXFLAGS =
43
44 # Normal build or /tools build.
45 #
46 ifeq "$(ROOT)" ""
47 TARGET = $(DIR_INFO)/$(THISAPP)
48 EXTRA_CONFIG = --prefix=/usr \
49 --enable-shared --enable-threads=posix \
50 --enable-__cxa_atexit --enable-clocale=gnu \
51 --enable-languages=c,c++ --disable-nls
52 EXTRA_MAKE =
53 EXTRA_INSTALL =
54 else
55 ifeq "$(LFS_PASS)" "1"
56 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
57 EXTRA_CONFIG = --prefix=/tools --with-local-prefix=/tools \
58 --disable-nls --enable-shared --enable-languages=c
59 EXTRA_MAKE = BOOT_LDFLAGS="-static" bootstrap
60 EXTRA_INSTALL =
61 else
62 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
63 EXTRA_CONFIG = --prefix=/tools --with-local-prefix=/tools \
64 --enable-clocale=gnu --enable-shared \
65 --enable-threads=posix --enable-__cxa_atexit \
66 --enable-languages=c,c++ --disable-nls
67 EXTRA_MAKE =
68 EXTRA_INSTALL =
69 endif
70 endif
71
72 ###############################################################################
73 # Top-level Rules
74 ###############################################################################
75 objects = $(DL_FILE) \
76 gcc-g++-$(VER).tar.bz2 \
77 $(THISAPP)-specs-1.patch \
78 $(THISAPP)-no_fixincludes-1.patch \
79 gcc-3.3-ssp-4.patch
80
81 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
82 gcc-g++-$(VER).tar.bz2 = $(URL_GNU)/gcc/releases/gcc-$(VER)/gcc-g++-$(VER).tar.bz2
83 $(THISAPP)-specs-1.patch = $(URL_LFS)/gcc/$(THISAPP)-specs-1.patch
84 $(THISAPP)-no_fixincludes-1.patch = $(URL_LFS)/gcc/$(THISAPP)-no_fixincludes-1.patch
85 gcc-3.3-ssp-4.patch = $(URL_LFS)/gcc/gcc-3.3-ssp-4.patch
86
87 $(DL_FILE)_MD5 = f878a455b14b3830aaf2da0a17f003c0
88 gcc-g++-$(VER).tar.bz2_MD5 = 29830b52f2c112fc660d662427660641
89 $(THISAPP)-specs-1.patch_MD5 = 74cb9822f21774ae1c9a8ef1fa133f49
90 $(THISAPP)-no_fixincludes-1.patch_MD5 = 5f764c74b3e9c36252fe4f9a14598ee4
91 gcc-3.3-ssp-4.patch_MD5 = d31cccd0afbaaeeb95264164360ea135
92
93 install : $(TARGET)
94
95 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
96
97 download :$(patsubst %,$(DIR_DL)/%,$(objects))
98
99 md5 : $(subst %,%_MD5,$(objects))
100
101 ###############################################################################
102 # Downloading, checking, md5sum
103 ###############################################################################
104
105 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
106 @$(CHECK)
107
108 $(patsubst %,$(DIR_DL)/%,$(objects)) :
109 @$(LOAD)
110
111 $(subst %,%_MD5,$(objects)) :
112 @$(MD5)
113
114 ###############################################################################
115 # Installation Details
116 ###############################################################################
117
118 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
119 @$(PREBUILD)
120 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
121 cd $(DIR_SRC) && tar jxf $(DIR_DL)/gcc-g++-$(VER).tar.bz2
122 # fix a macro in gcc3.3.3 hurting gcc4.x !
123 cd $(DIR_APP) && sed -i "s/\*((void \*\*)__o.*;/*((void **)__o->next_free) = ((void *)datum); __o->next_free += sizeof(void *);/" include/obstack.h
124 cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/gcc-3.3-ssp-4.patch
125 cd $(DIR_APP) && sed -i -e 's|^\(LIBGCC2_CFLAGS.*\)$$|\1 -D_LIBC_PROVIDES_SSP_|' gcc/Makefile.in
126 ifeq "$(ROOT)" ""
127 cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-no_fixincludes-1.patch
128 else
129 ifeq "$(LFS_PASS)" "2"
130 cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-no_fixincludes-1.patch
131 cd $(DIR_APP) && patch -Np1 < $(DIR_DL)/$(THISAPP)-specs-1.patch
132 endif
133 endif
134 @mkdir $(DIR_SRC)/gcc-build
135 cd $(DIR_SRC)/gcc-build && /bin/bash $(DIR_APP)/configure $(EXTRA_CONFIG)
136 cd $(DIR_SRC)/gcc-build && make -j 3 $(EXTRA_MAKE)
137 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
138 ifeq "$(ROOT)" ""
139 GCC_SPECS_DIR="`/usr/bin/gcc --print-libgcc-file-name`"; \
140 GCC_SPECS="`dirname $$GCC_SPECS_DIR`/specs"; \
141 if [ "$(MACHINE)" = "i386" ]; then \
142 SSP_PROT_ALL_STRING="%(cc1_cpu) %{!fno-stack-protector: %{!fno-stack-protector-all: %{!D__KERNEL__: -fstack-protector %{!nostartfiles: %{!nodefaultlibs: %{!nostdlib: %{!nostdinc: -fstack-protector-all} } } } } } } %{profile:-p}"; \
143 elif [ "$(MACHINE)" = "alpha" ]; then \
144 SSP_PROT_ALL_STRING="%{G*} %{!fno-stack-protector: %{!fno-stack-protector-all: %{!D__KERNEL__: -fstack-protector %{!nostartfiles: %{!nodefaultlibs: %{!nostdlib: %{!nostdinc: -fstack-protector-all} } } } } } }"; \
145 fi; \
146 mv -f $${GCC_SPECS} $${GCC_SPECS}.noprot; \
147 sed "/cc1:/{n;d}" $${GCC_SPECS}.noprot > $${GCC_SPECS}.tmp; \
148 sed "s/cc1:/cc1:\n$${SSP_PROT_ALL_STRING}/" $${GCC_SPECS}.tmp > $${GCC_SPECS}.prot; \
149 rm -f $${GCC_SPECS}.tmp; \
150 cp -f $${GCC_SPECS}.prot $${GCC_SPECS}
151 else
152 ifeq "$(LFS_PASS)" "2"
153 GCC_SPECS_DIR="`/tools/bin/gcc --print-libgcc-file-name`"; \
154 GCC_SPECS="`dirname $$GCC_SPECS_DIR`/specs"; \
155 if [ "$(MACHINE)" = "i386" ]; then \
156 SSP_PROT_ALL_STRING="%(cc1_cpu) %{!fno-stack-protector: %{!fno-stack-protector-all: %{!D__KERNEL__: -fstack-protector %{!nostartfiles: %{!nodefaultlibs: %{!nostdlib: %{!nostdinc: -fstack-protector-all} } } } } } } %{profile:-p}"; \
157 elif [ "$(MACHINE)" = "alpha" ]; then \
158 SSP_PROT_ALL_STRING="%{G*} %{!fno-stack-protector: %{!fno-stack-protector-all: %{!D__KERNEL__: -fstack-protector %{!nostartfiles: %{!nodefaultlibs: %{!nostdlib: %{!nostdinc: -fstack-protector-all} } } } } } }"; \
159 fi; \
160 mv -f $${GCC_SPECS} $${GCC_SPECS}.noprot; \
161 sed "/cc1:/{n;d}" $${GCC_SPECS}.noprot > $${GCC_SPECS}.tmp; \
162 sed "s/cc1:/cc1:\n$${SSP_PROT_ALL_STRING}/" $${GCC_SPECS}.tmp > $${GCC_SPECS}.prot; \
163 rm -f $${GCC_SPECS}.tmp; \
164 cp -f $${GCC_SPECS}.prot $${GCC_SPECS}
165 endif
166 endif
167 ifeq "$(ROOT)" ""
168 ln -sf ../usr/bin/cpp /lib
169 ln -sf gcc /usr/bin/cc
170 else
171 ln -sf gcc /tools/bin/cc
172 endif
173 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
174 @$(POSTBUILD)