BUILD_DIR -> KERNEL_BUILD_DIR
[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 PKG_SOURCE:=gcc-$(PKG_VERSION).tar.bz2
27 PKG_MD5SUM:=unknown
28 PKG_SOURCE_URL:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(PKG_VERSION) \
29 http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(PKG_VERSION) \
30 ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(PKG_VERSION)
31 PKG_CAT:=bzcat
32
33 PKG_BUILD_DIR:=$(TOOL_BUILD_DIR)/gcc-$(PKG_VERSION)
34
35 TARGET_LANGUAGES:=c
36 ifeq ($(CONFIG_INSTALL_LIBSTDCPP),y)
37 TARGET_LANGUAGES:=$(TARGET_LANGUAGES),c++
38 endif
39 ifeq ($(CONFIG_INSTALL_LIBGCJ),y)
40 TARGET_LANGUAGES:=$(TARGET_LANGUAGES),java
41 endif
42
43 include $(INCLUDE_DIR)/host-build.mk
44
45 BUILD_DIR1:=$(TOOL_BUILD_DIR)/gcc-$(PKG_VERSION)-initial
46 BUILD_DIR2:=$(TOOL_BUILD_DIR)/gcc-$(PKG_VERSION)-final
47
48
49 define Stage1/Configure
50 mkdir -p $(BUILD_DIR1)
51 (cd $(BUILD_DIR1); rm -f config.cache; PATH=$(TARGET_PATH) \
52 $(PKG_BUILD_DIR)/configure \
53 --prefix=$(STAGING_DIR) \
54 --build=$(GNU_HOST_NAME) \
55 --host=$(GNU_HOST_NAME) \
56 --target=$(REAL_GNU_TARGET_NAME) \
57 --enable-languages=c \
58 --disable-shared \
59 --with-sysroot=$(TOOL_BUILD_DIR)/uClibc_dev/ \
60 --disable-__cxa_atexit \
61 --enable-target-optspace \
62 --with-gnu-ld \
63 --disable-nls \
64 );
65 endef
66 define Stage1/Compile
67 PATH=$(TARGET_PATH) $(MAKE) -C $(BUILD_DIR1) all-gcc
68 endef
69 define Stage1/Install
70 PATH=$(TARGET_PATH) $(MAKE) -C $(BUILD_DIR1) install-gcc
71 endef
72
73 define Stage2/Configure
74 mkdir -p $(BUILD_DIR2)
75 # Important! Required for limits.h to be fixed.
76 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
77 ln -sf ../include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
78 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
79 ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
80 (cd $(BUILD_DIR2); rm -f config.cache; PATH=$(TARGET_PATH) \
81 $(PKG_BUILD_DIR)/configure \
82 --prefix=$(STAGING_DIR) \
83 --build=$(GNU_HOST_NAME) \
84 --host=$(GNU_HOST_NAME) \
85 --target=$(REAL_GNU_TARGET_NAME) \
86 --enable-languages=$(TARGET_LANGUAGES) \
87 --enable-shared \
88 --disable-__cxa_atexit \
89 --enable-target-optspace \
90 --with-gnu-ld \
91 --disable-nls \
92 );
93 endef
94 define Stage2/Compile
95 PATH=$(TARGET_PATH) $(MAKE) -C $(BUILD_DIR2) all
96 endef
97 define Stage2/Install
98 PATH=$(TARGET_PATH) $(MAKE) -C $(BUILD_DIR2) install
99 echo $(PKG_VERSION) > $(STAGING_DIR)/gcc_version
100 # Set up the symlinks to enable lying about target name.
101 set -e; \
102 (cd $(STAGING_DIR); \
103 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
104 cd bin; \
105 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
106 ln -sf $${app} \
107 $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
108 done; \
109 );
110 endef
111
112 define Build/Prepare
113 $(call Build/Prepare/Default)
114 $(SCRIPT_DIR)/patch-kernel.sh $(PKG_BUILD_DIR) ./patches/$(PKG_VERSION) \*.patch
115 $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(PKG_BUILD_DIR)/gcc/version.c
116 $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(PKG_BUILD_DIR)/gcc/version.c
117 endef
118
119 define Build/Configure
120 $(call Stage1/Configure)
121 endef
122
123 define Build/Compile
124 $(call Stage1/Compile)
125 $(call Stage1/Install)
126 endef
127
128 define Build/Install
129 $(call Stage2/Configure)
130 $(call Stage2/Compile)
131 $(call Stage2/Install)
132 endef
133
134 define Build/Clean
135 rm -rf $(PKG_BUILD_DIR)
136 rm -rf $(BUILD_DIR1)
137 rm -rf $(BUILD_DIR2)
138 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc*
139 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
140 endef
141
142 $(eval $(call HostBuild))
This page took 0.045477 seconds and 5 git commands to generate.