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