summaryrefslogtreecommitdiff
path: root/mk/gcc.mk
blob: a9c9b997f460c27400cb1b71690e5fd1d947e003 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#########################################################################################
# GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
# Copyright(C) 2009 GAYE Abdoulaye Walsimou. All rights reserved.
#
# This program is free software; you can distribute it and/or modify it
# under the terms of the GNU General Public License
# (Version 2 or later) published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
#########################################################################################
#
# \file         gcc.mk
# \brief	gcc.mk of Embtoolkit
# \author       GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
# \date         May 2009
#########################################################################################

GCC_VERSION := $(subst ",,$(strip $(CONFIG_EMBTK_GCC_VERSION_STRING)))
GCC_SITE := ftp://ftp.lip6.fr/pub/gcc/releases/gcc-$(GCC_VERSION)
GCC_PACKAGE := gcc-$(GCC_VERSION).tar.bz2
GCC1_BUILD_DIR := $(TOOLS_BUILD)/gcc1
GCC2_BUILD_DIR := $(TOOLS_BUILD)/gcc2
GCC3_BUILD_DIR := $(TOOLS_BUILD)/gcc3

#Hard or soft floating point
ifeq ($(CONFIG_EMBTK_SOFTFLOAT),y)
GCC_FLOAT_TYPE := soft
else
GCC_FLOAT_TYPE := hard
endif

gcc1_install: $(GCC1_BUILD_DIR)/.built

gcc2_install: $(GCC2_BUILD_DIR)/.built

gcc3_install: $(GCC3_BUILD_DIR)/.installed

#Multilib or not?
ifeq ($(CONFIG_EMBTK_TOOLCHAIN_MULTILIB),y)
GCC_MULTILIB :=
else
GCC_MULTILIB := --disable-multilib
endif

#GCC first stage
$(GCC1_BUILD_DIR)/.built: download_gcc $(GCC1_BUILD_DIR)/.decompressed \
	$(GCC1_BUILD_DIR)/.configured
	PATH=$(PATH):$(TOOLS)/bin/ $(MAKE) -C $(GCC1_BUILD_DIR) && \
	PATH=$(PATH):$(TOOLS)/bin/ $(MAKE) -C $(GCC1_BUILD_DIR) install
	@touch $@
download_gcc:
	@test -e $(DOWNLOAD_DIR)/$(GCC_PACKAGE) || \
	wget -O $(DOWNLOAD_DIR)/$(GCC_PACKAGE) $(GCC_SITE)/$(GCC_PACKAGE)

$(GCC1_BUILD_DIR)/.decompressed:
	$(call DECOMPRESS_MESSAGE,$(GCC_PACKAGE))
	@tar -C $(TOOLS_BUILD) -xjf $(DOWNLOAD_DIR)/$(GCC_PACKAGE)
	@mkdir -p $(GCC1_BUILD_DIR)
	@touch $@

$(GCC1_BUILD_DIR)/.configured:
	$(call CONFIGURE_MESSAGE,gcc-$(GCC_VERSION))
	cd $(GCC1_BUILD_DIR); CC=$(HOSTCC_CACHED) CXX=$(HOSTCXX_CACHED) \
	$(TOOLS_BUILD)/gcc-$(GCC_VERSION)/configure \
	--prefix=$(TOOLS) --with-sysroot=$(SYSROOT) --target=$(STRICT_GNU_TARGET) \
	--with-arch=$(GNU_TARGET_ARCH) --with-float=$(GCC_FLOAT_TYPE) \
	--host=$(HOST_ARCH) --build=$(HOST_BUILD) \
	--without-headers --with-newlib --disable-shared --disable-threads \
	--disable-libssp --disable-libgomp --disable-libmudflap --disable-nls \
	--enable-languages=c --with-gmp=$(GMP_HOST_DIR) --with-mpfr=$(MPFR_HOST_DIR) \
	$(GCC_MULTILIB) $(GCC_WITH_ABI)
	@touch $@

#GCC second stage
$(GCC2_BUILD_DIR)/.built: $(GCC2_BUILD_DIR)/.configured
	PATH=$(PATH):$(TOOLS)/bin/ $(MAKE) -C $(GCC2_BUILD_DIR) && \
	PATH=$(PATH):$(TOOLS)/bin/ $(MAKE) -C $(GCC2_BUILD_DIR) install
	@touch $@

$(GCC2_BUILD_DIR)/.configured:
	$(call CONFIGURE_MESSAGE,gcc-$(GCC_VERSION))
	@mkdir -p $(GCC2_BUILD_DIR)
	cd $(GCC2_BUILD_DIR); CC=$(HOSTCC_CACHED) CXX=$(HOSTCXX_CACHED) \
	$(TOOLS_BUILD)/gcc-$(GCC_VERSION)/configure \
	--prefix=$(TOOLS) --with-sysroot=$(SYSROOT) --target=$(STRICT_GNU_TARGET) \
	--with-arch=$(GNU_TARGET_ARCH) --with-float=$(GCC_FLOAT_TYPE) \
	--host=$(HOST_ARCH) --build=$(HOST_BUILD) \
	--disable-libssp --disable-libgomp --disable-libmudflap \
	--enable-languages=c --with-gmp=$(GMP_HOST_DIR) \
	--with-mpfr=$(MPFR_HOST_DIR) \
	$(GCC_MULTILIB) $(GCC_WITH_ABI)
	@touch $@

#GCC last stage
$(GCC3_BUILD_DIR)/.installed: $(GCC3_BUILD_DIR)/.configured
	PATH=$(PATH):$(TOOLS)/bin/ $(MAKE) -C $(GCC3_BUILD_DIR) && \
	PATH=$(PATH):$(TOOLS)/bin/ $(MAKE) -C $(GCC3_BUILD_DIR) install
ifeq ($(EMBTK_TARGET_ARCH),64)
	cp -d $(TOOLS)/$(STRICT_GNU_TARGET)/lib64/libgcc_s.so* $(SYSROOT)/lib64
	cp -d $(TOOLS)/$(STRICT_GNU_TARGET)/lib64/libstdc++.so* $(SYSROOT)/lib64
else
	cp -d $(TOOLS)/$(STRICT_GNU_TARGET)/lib/libgcc_s.so* $(SYSROOT)/lib
	cp -d $(TOOLS)/$(STRICT_GNU_TARGET)/lib/libstdc++.so* $(SYSROOT)/lib
	@touch $@
endif

$(GCC3_BUILD_DIR)/.configured:
	$(call CONFIGURE_MESSAGE,gcc-$(GCC_VERSION))
	@mkdir -p $(GCC3_BUILD_DIR)
	cd $(GCC3_BUILD_DIR); CC=$(HOSTCC_CACHED) CXX=$(HOSTCXX_CACHED) \
	$(TOOLS_BUILD)/gcc-$(GCC_VERSION)/configure \
	--prefix=$(TOOLS) --with-sysroot=$(SYSROOT) --target=$(STRICT_GNU_TARGET) \
	--with-arch=$(GNU_TARGET_ARCH) --with-float=$(GCC_FLOAT_TYPE) \
	--host=$(HOST_ARCH) --build=$(HOST_BUILD) --enable-__cxa_atexit \
	--disable-libssp --disable-libgomp --disable-libmudflap \
	--enable-threads --enable-shared --enable-languages=c,c++ \
	--with-gmp=$(GMP_HOST_DIR) --with-mpfr=$(MPFR_HOST_DIR) \
	$(GCC_MULTILIB) $(GCC_WITH_ABI)
	@touch $@