consider virtual dependencies (generated by using PROVIDES:=) when generating the...
[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-2006 Felix Fietkau <nbd@openwrt.org>
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 PKG_NAME:=gcc
24 PKG_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))#"))
25
26 PATCH_DIR=./patches/$(PKG_VERSION)
27 PKG_SOURCE_URL:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(PKG_VERSION) \
28 http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(PKG_VERSION) \
29 ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(PKG_VERSION)
30 PKG_SOURCE:=gcc-$(PKG_VERSION).tar.bz2
31 STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
32 BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
33
34 include $(INCLUDE_DIR)/host-build.mk
35
36 STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed
37 BUILD_DIR1:=$(BUILD_DIR_HOST)/gcc-$(PKG_VERSION)-initial
38 BUILD_DIR2:=$(BUILD_DIR_HOST)/gcc-$(PKG_VERSION)-final
39
40 SEP:=,
41 TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)"
42
43 EXTRA_TARGET=$(if $(CONFIG_EXTRA_TARGET_ARCH),--enable-biarch --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-uclibc)
44
45 define Stage1/Configure
46 $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
47 $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
48 mkdir -p $(BUILD_DIR1)
49 (cd $(BUILD_DIR1); rm -f config.cache; \
50 SHELL="$(BASH)" \
51 $(PKG_BUILD_DIR)/configure \
52 --prefix=$(TOOLCHAIN_DIR) \
53 --build=$(GNU_HOST_NAME) \
54 --host=$(GNU_HOST_NAME) \
55 --target=$(REAL_GNU_TARGET_NAME) \
56 --enable-languages=c \
57 --disable-shared \
58 --with-sysroot=$(BUILD_DIR_HOST)/uClibc_dev/ \
59 --disable-__cxa_atexit \
60 --enable-target-optspace \
61 --with-gnu-ld \
62 --disable-nls \
63 --disable-libmudflap \
64 --disable-multilib \
65 $(EXTRA_TARGET) \
66 $(SOFT_FLOAT_CONFIG_OPTION) \
67 $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
68 );
69 endef
70 define Stage1/Compile
71 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) all-gcc
72 endef
73 define Stage1/Install
74 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) install-gcc
75 endef
76
77 define Stage2/Configure
78 mkdir -p $(BUILD_DIR2) $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)
79 # Important! Required for limits.h to be fixed.
80 rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
81 ln -sf ../include $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
82 rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
83 ln -sf ../lib $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
84 (cd $(BUILD_DIR2); rm -f config.cache; \
85 SHELL="$(BASH)" \
86 $(PKG_BUILD_DIR)/configure \
87 --prefix=$(TOOLCHAIN_DIR) \
88 --build=$(GNU_HOST_NAME) \
89 --host=$(GNU_HOST_NAME) \
90 --target=$(REAL_GNU_TARGET_NAME) \
91 --enable-languages=$(TARGET_LANGUAGES) \
92 --enable-shared \
93 --disable-__cxa_atexit \
94 --enable-target-optspace \
95 --with-gnu-ld \
96 --disable-nls \
97 --disable-libmudflap \
98 --disable-multilib \
99 $(EXTRA_TARGET) \
100 $(SOFT_FLOAT_CONFIG_OPTION) \
101 $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
102 );
103 endef
104
105 define Stage2/Compile
106 export SHELL="\$(BASH)"; \$(MAKE) -C \$(BUILD_DIR2) all
107 endef
108
109 define SetupExtraArch
110 for app in $(TOOLCHAIN_DIR)/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
111 [ -e $$$$app ] || continue; \
112 old_base=$$$$(basename $$$$app); \
113 new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
114 sed -e "s/@CC_BASE@/$$$$old_base/" \
115 -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
116 ./files/alternate-arch-cc.in > \
117 $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
118 chmod a+x $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
119 done
120 endef
121
122 define Stage2/Install
123 $(MAKE) -C $(BUILD_DIR2) \
124 SHELL="$(BASH)" \
125 install
126 # Set up the symlinks to enable lying about target name.
127 set -e; \
128 (cd $(TOOLCHAIN_DIR); \
129 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
130 cd bin; \
131 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
132 ln -sf $$$${app} \
133 $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
134 done; \
135 );
136 $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
137 endef
138
139 define Build/Prepare
140 $(call Build/Prepare/Default)
141 $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(PKG_BUILD_DIR)/gcc/version.c
142 $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(PKG_BUILD_DIR)/gcc/version.c
143 (cd $(PKG_BUILD_DIR)/libstdc++-v3; autoconf;);
144 $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(PKG_BUILD_DIR)/libstdc++-v3/configure
145 endef
146
147 define Build/Configure
148 $(call Stage1/Configure)
149 endef
150
151 define Build/Compile
152 $(call Stage1/Compile)
153 $(if $(wildcard $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-gcc),,$(call Stage1/Install))
154 endef
155
156 define Build/Install
157 $(call Stage2/Configure)
158 $(call Stage2/Compile)
159 $(call Stage2/Install)
160 endef
161
162 define Build/Clean
163 rm -rf \
164 $(PKG_BUILD_DIR) \
165 $(BUILD_DIR1) \
166 $(BUILD_DIR2) \
167 $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
168 $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
169 $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
170 endef
171
172 $(eval $(call HostBuild))
This page took 0.04699 seconds and 5 git commands to generate.