more cleanup in toolchain/
[openwrt.git] / openwrt / toolchain / gcc / Makefile
1 # Makefile for to build a gcc/uClibc toolchain
2 #
3 # Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
4 # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
5 # Copyright (C) 2005 Felix Fietkau <openwrt@nbd.name>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 include $(TOPDIR)/rules.mk
22
23 GCC_VERSION:=$(strip $(GCC_VERSION))
24
25 #GCC_SITE:=ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(GCC_VERSION)
26 GCC_SITE:=http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(GCC_VERSION)
27
28 GCC_SOURCE:=gcc-$(GCC_VERSION).tar.bz2
29 GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)
30 GCC_CAT:=bzcat
31 GCC_STRIP_HOST_BINARIES:=true
32
33 #############################################################
34 #
35 # Setup some initial stuff
36 #
37 #############################################################
38
39 ifeq ($(BR2_INSTALL_LIBGCJ),y)
40 TARGET_LANGUAGES:=c,c++,java
41 else
42 ifeq ($(BR2_INSTALL_LIBSTDCPP),y)
43 TARGET_LANGUAGES:=c,c++
44 else
45 TARGET_LANGUAGES:=c
46 endif
47 endif
48
49 #############################################################
50 #
51 # build the first pass gcc compiler
52 #
53 #############################################################
54
55 GCC_BUILD_DIR1:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)-initial
56
57 $(DL_DIR)/$(GCC_SOURCE):
58 mkdir -p $(DL_DIR)
59 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(GCC_SOURCE) x $(GCC_SITE)
60
61 $(GCC_DIR)/.unpacked: $(DL_DIR)/$(GCC_SOURCE)
62 mkdir -p $(TOOL_BUILD_DIR)
63 $(GCC_CAT) $(DL_DIR)/$(GCC_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
64 touch $(GCC_DIR)/.unpacked
65
66 $(GCC_DIR)/.patched: $(GCC_DIR)/.unpacked
67 # Apply any files named gcc-*.patch from the source directory to gcc
68 $(SCRIPT_DIR)/patch-kernel.sh $(GCC_DIR) ./$(GCC_VERSION) \*.patch
69 # Note: The soft float situation has improved considerably with gcc 3.4.x.
70 # We can dispense with the custom spec files, as well as libfloat for the arm case.
71 # However, we still need a patch for arm. There's a similar patch for gcc 3.3.x
72 # which needs to be integrated so we can kill of libfloat for good.
73 ifeq ($(BR2_SOFT_FLOAT),y)
74 ifeq ("$(strip $(ARCH))","arm")
75 $(SCRIPT_DIR)/patch-kernel.sh $(GCC_DIR) ./$(GCC_VERSION) arm-softfloat.patch.conditional
76 endif
77 ifeq ("$(strip $(ARCH))","armeb")
78 $(SCRIPT_DIR)/patch-kernel.sh $(GCC_DIR) ./$(GCC_VERSION) arm-softfloat.patch.conditional
79 endif
80 endif
81 touch $(GCC_DIR)/.patched
82
83 # The --without-headers option stopped working with gcc 3.0 and has never been
84 # # fixed, so we need to actually have working C library header files prior to
85 # # the step or libgcc will not build...
86
87 $(GCC_BUILD_DIR1)/.configured: $(GCC_DIR)/.patched
88 mkdir -p $(GCC_BUILD_DIR1)
89 (cd $(GCC_BUILD_DIR1); PATH=$(TARGET_PATH) \
90 $(GCC_DIR)/configure \
91 --prefix=$(STAGING_DIR) \
92 --build=$(GNU_HOST_NAME) \
93 --host=$(GNU_HOST_NAME) \
94 --target=$(REAL_GNU_TARGET_NAME) \
95 --enable-languages=c \
96 --disable-shared \
97 --with-sysroot=$(TOOL_BUILD_DIR)/uClibc_dev/ \
98 --disable-__cxa_atexit \
99 --enable-target-optspace \
100 --with-gnu-ld \
101 $(DISABLE_NLS) \
102 $(MULTILIB) \
103 $(SOFT_FLOAT_CONFIG_OPTION) \
104 $(GCC_WITH_CPU) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
105 $(EXTRA_GCC_CONFIG_OPTIONS));
106 touch $(GCC_BUILD_DIR1)/.configured
107
108 $(GCC_BUILD_DIR1)/.compiled: $(GCC_BUILD_DIR1)/.configured
109 PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) all-gcc
110 touch $(GCC_BUILD_DIR1)/.compiled
111
112 $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc: $(GCC_BUILD_DIR1)/.compiled
113 PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) install-gcc
114
115 #############################################################
116 #
117 # second pass compiler build. Build the compiler targeting
118 # the newly built shared uClibc library.
119 #
120 #############################################################
121 #
122 # Sigh... I had to rework things because using --with-gxx-include-dir
123 # causes issues with include dir search order for g++. This seems to
124 # have something to do with "path translations" and possibly doesn't
125 # affect gcc-target. However, I haven't tested gcc-target yet so no
126 # guarantees. mjn3
127
128 GCC_BUILD_DIR2:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)-final
129 $(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched $(STAGING_DIR)/lib/libc.a
130 mkdir -p $(GCC_BUILD_DIR2)
131 # Important! Required for limits.h to be fixed.
132 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
133 ln -sf ../include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
134 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
135 ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
136 (cd $(GCC_BUILD_DIR2); PATH=$(TARGET_PATH) \
137 $(GCC_DIR)/configure \
138 --prefix=$(STAGING_DIR) \
139 --build=$(GNU_HOST_NAME) \
140 --host=$(GNU_HOST_NAME) \
141 --target=$(REAL_GNU_TARGET_NAME) \
142 --enable-languages=$(TARGET_LANGUAGES) \
143 --enable-shared \
144 --disable-__cxa_atexit \
145 --enable-target-optspace \
146 --with-gnu-ld \
147 $(DISABLE_NLS) \
148 $(MULTILIB) \
149 $(SOFT_FLOAT_CONFIG_OPTION) \
150 $(GCC_WITH_CPU) $(GCC_WITH_ARCH) $(GCC_WITH_TUNE) \
151 $(GCC_USE_SJLJ_EXCEPTIONS) \
152 $(EXTRA_GCC_CONFIG_OPTIONS));
153 touch $(GCC_BUILD_DIR2)/.configured
154
155 $(GCC_BUILD_DIR2)/.compiled: $(GCC_BUILD_DIR2)/.configured
156 PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR2) all
157 touch $(GCC_BUILD_DIR2)/.compiled
158
159 gcc-install: $(GCC_BUILD_DIR2)/.compiled
160 PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR2) install
161 echo $(GCC_VERSION) > $(STAGING_DIR)/gcc_version
162 # Set up the symlinks to enable lying about target name.
163 set -e; \
164 (cd $(STAGING_DIR); \
165 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
166 cd bin; \
167 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
168 ln -sf $${app} \
169 $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
170 done; \
171 );
172 #
173 # Now for the ugly 3.3.x soft float hack...
174 #
175 ifeq ($(BR2_SOFT_FLOAT),y)
176 ifeq ($(findstring 3.3.,$(GCC_VERSION)),3.3.)
177 # Make sure we have a soft float specs file for this arch
178 if [ ! -f ./$(GCC_VERSION)/specs-$(ARCH)-soft-float ] ; then \
179 echo soft float configured but no specs file for this arch ; \
180 /bin/false ; \
181 fi;
182 # Replace specs file with one that defaults to soft float mode.
183 if [ ! -f $(STAGING_DIR)/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs ] ; then \
184 echo staging dir specs file is missing ; \
185 /bin/false ; \
186 fi;
187 cp ./$(GCC_VERSION)/specs-$(ARCH)-soft-float $(STAGING_DIR)/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
188 endif
189 endif
190
191 source: $(DL_DIR)/$(GCC_SOURCE)
192 prepare: $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc
193 compile: gcc-install
194 install:
195 clean: gcc-clean
196 rm -rf $(GCC_DIR)
197 rm -rf $(GCC_BUILD_DIR1)
198 rm -rf $(GCC_BUILD_DIR2)
199 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc*
200 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
This page took 0.064159 seconds and 5 git commands to generate.