mount /proc earlier in /sbin/mount_root
[openwrt.git] / 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 $(subst ",, $(CONFIG_GCC_VERSION)))#"))
24
25 #GCC_SITE:=ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(GCC_VERSION)
26 GCC_SITE:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(GCC_VERSION) \
27 http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(GCC_VERSION)
28
29 GCC_SOURCE:=gcc-$(GCC_VERSION).tar.bz2
30 GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)
31 GCC_CAT:=bzcat
32
33 #############################################################
34 #
35 # Setup some initial stuff
36 #
37 #############################################################
38
39 ifeq ($(CONFIG_INSTALL_LIBGCJ),y)
40 TARGET_LANGUAGES:=c,c++,java
41 else
42 ifeq ($(CONFIG_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 $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(GCC_DIR)/gcc/version.c
74 $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(GCC_DIR)/gcc/version.c
75 touch $(GCC_DIR)/.patched
76
77 # The --without-headers option stopped working with gcc 3.0 and has never been
78 # # fixed, so we need to actually have working C library header files prior to
79 # # the step or libgcc will not build...
80
81 $(GCC_BUILD_DIR1)/.configured: $(GCC_DIR)/.patched
82 mkdir -p $(GCC_BUILD_DIR1)
83 (cd $(GCC_BUILD_DIR1); rm -f config.cache; PATH=$(TARGET_PATH) \
84 $(GCC_DIR)/configure \
85 --prefix=$(STAGING_DIR) \
86 --build=$(GNU_HOST_NAME) \
87 --host=$(GNU_HOST_NAME) \
88 --target=$(REAL_GNU_TARGET_NAME) \
89 --enable-languages=c \
90 --disable-shared \
91 --with-sysroot=$(TOOL_BUILD_DIR)/uClibc_dev/ \
92 --disable-__cxa_atexit \
93 --enable-target-optspace \
94 --with-gnu-ld \
95 $(DISABLE_NLS) \
96 $(MULTILIB) \
97 );
98 touch $(GCC_BUILD_DIR1)/.configured
99
100 $(GCC_BUILD_DIR1)/.compiled: $(GCC_BUILD_DIR1)/.configured
101 PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) all-gcc
102 touch $(GCC_BUILD_DIR1)/.compiled
103
104 $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc: $(GCC_BUILD_DIR1)/.compiled
105 PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR1) install-gcc
106
107 #############################################################
108 #
109 # second pass compiler build. Build the compiler targeting
110 # the newly built shared uClibc library.
111 #
112 #############################################################
113 #
114 # Sigh... I had to rework things because using --with-gxx-include-dir
115 # causes issues with include dir search order for g++. This seems to
116 # have something to do with "path translations" and possibly doesn't
117 # affect gcc-target. However, I haven't tested gcc-target yet so no
118 # guarantees. mjn3
119
120 GCC_BUILD_DIR2:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)-final
121 $(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched $(STAGING_DIR)/lib/libc.a
122 mkdir -p $(GCC_BUILD_DIR2)
123 # Important! Required for limits.h to be fixed.
124 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
125 ln -sf ../include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
126 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
127 ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
128 (cd $(GCC_BUILD_DIR2); rm -f config.cache; PATH=$(TARGET_PATH) \
129 $(GCC_DIR)/configure \
130 --prefix=$(STAGING_DIR) \
131 --build=$(GNU_HOST_NAME) \
132 --host=$(GNU_HOST_NAME) \
133 --target=$(REAL_GNU_TARGET_NAME) \
134 --enable-languages=$(TARGET_LANGUAGES) \
135 --enable-shared \
136 --disable-__cxa_atexit \
137 --enable-target-optspace \
138 --with-gnu-ld \
139 $(DISABLE_NLS) \
140 $(MULTILIB) \
141 );
142 touch $(GCC_BUILD_DIR2)/.configured
143
144 $(GCC_BUILD_DIR2)/.compiled: $(GCC_BUILD_DIR2)/.configured
145 PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR2) all
146 touch $(GCC_BUILD_DIR2)/.compiled
147
148 gcc-install: $(GCC_BUILD_DIR2)/.compiled FORCE
149 PATH=$(TARGET_PATH) $(MAKE) -C $(GCC_BUILD_DIR2) install
150 echo $(GCC_VERSION) > $(STAGING_DIR)/gcc_version
151 # Set up the symlinks to enable lying about target name.
152 set -e; \
153 (cd $(STAGING_DIR); \
154 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
155 cd bin; \
156 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
157 ln -sf $${app} \
158 $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
159 done; \
160 );
161
162 source: $(DL_DIR)/$(GCC_SOURCE)
163 prepare: $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc
164 compile: gcc-install
165 install:
166 clean: gcc-clean
167 rm -rf $(GCC_DIR)
168 rm -rf $(GCC_BUILD_DIR1)
169 rm -rf $(GCC_BUILD_DIR2)
170 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc*
171 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
This page took 0.057214 seconds and 5 git commands to generate.