2 # Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
3 # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
4 # Copyright (C) 2005-2006 Felix Fietkau <nbd@nbd.name>
5 # Copyright (C) 2006-2014 OpenWrt.org
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.
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.
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
21 include $(TOPDIR
)/rules.mk
24 GCC_VERSION
:=$(call qstrip
,$(CONFIG_GCC_VERSION
))
25 PKG_VERSION
:=$(firstword $(subst +, ,$(GCC_VERSION
)))
27 GCC_DIR
:=$(PKG_NAME
)-$(PKG_VERSION
)
29 PKG_SOURCE_URL
:=@GNU
/gcc
/gcc-
$(PKG_VERSION
)
30 PKG_SOURCE
:=$(PKG_NAME
)-$(PKG_VERSION
).
tar.xz
35 PKG_CPE_ID
:=cpe
:/a
:gnu
:gcc
37 ifeq ($(PKG_VERSION
),8.4.0)
38 PKG_HASH
:=e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4
41 ifeq ($(PKG_VERSION
),10.3.0)
42 PKG_HASH
:=64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344
45 ifeq ($(PKG_VERSION
),11.3.0)
46 PKG_HASH
:=b47cf2818691f5b1e21df2bb38c795fac2cfbd640ede2d0a5e1c89e338a3ac39
49 ifeq ($(PKG_VERSION
),12.3.0)
50 PKG_HASH
:=949a5d4f99e786421a93b532b22ffab5578de7321369975b91aec97adfda8c3b
53 PATCH_DIR
=.
/patches
/$(GCC_VERSION
)
55 include $(INCLUDE_DIR
)/package.mk
61 MAINTAINER
:=W. Michael Petullo
<mike@flyn.org
>
62 DEPENDS
:= +binutils
+libstdcpp
+libzstd @
!arc
66 define Package
/gcc
/config
67 source
"$(SOURCE)/Config.in"
70 ifeq ($(CONFIG_INCLUDE_STATIC_LIBC
),y
)
71 COPY_STATIC_LIBC
=cp
-a
$(TOOLCHAIN_DIR
)/lib
/libc.a
$(1)/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)
74 ifeq ($(CONFIG_INCLUDE_STATIC_LIBPTHREAD
),y
)
75 COPY_STATIC_LIBPTHREAD
=cp
-a
$(TOOLCHAIN_DIR
)/lib
/libpthread.a
$(1)/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)
78 ifeq ($(CONFIG_INCLUDE_STATIC_LIBSTDC
),y
)
79 COPY_STATIC_LIBSTDC
=cp
-a
$(TOOLCHAIN_DIR
)/lib
/libstdc
++.a
$(1)/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)
82 ifeq ($(CONFIG_INCLUDE_STATIC_LINK_SPEC
),y
)
83 INSTALL_STATIC_SPEC
=g
++ -dumpspecs |sed s
/--start-group
}\
%G\
%L\
/--start-group
}\
%G\
%L\
-lstdc
++\
-lgcc_pic\
/ >/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)/specs
84 REMOVE_STATIC_SPEC
=rm /usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)/specs
87 TARGET_LANGUAGES
:="c,c++"
88 BUGURL
=https
://dev.openwrt.org
/
89 PKGVERSION
=OpenWrt GCC
$(PKG_VERSION
)
90 TARGET_CPPFLAGS
+= -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS
92 # not using sstrip here as this messes up the .so's somehow
93 STRIP
:=$(TOOLCHAIN_DIR
)/bin
/$(TARGET_CROSS
)strip
95 NM
="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)nm" \
97 STRIP_KMOD
="$(STRIP) --strip-debug" \
98 $(SCRIPT_DIR
)/rstrip.sh
100 ifneq ($(CONFIG_SOFT_FLOAT
),y
)
101 ifeq ($(CONFIG_arm
),y
)
102 ARM_FLOAT_OPTION
:= --with-float
=hard
109 URL
:=ftp
://gcc.gnu.org
/pub
/gcc
/infrastructure
/
110 FILE
:=$(GMPSRC
).
tar.bz2
111 HASH
:=498449a994efeba527885c10405993427995d3f86b8768d8cdf8d9dd7c6b73e8
113 $(eval
$(call Download
,gmp
))
118 URL
:=ftp
://gcc.gnu.org
/pub
/gcc
/infrastructure
/
119 FILE
:=$(MPCSRC
).
tar.gz
120 HASH
:=617decc6ea09889fb08ede330917a00b16809b8db88c29c31bfbb49cbf88ecc3
122 $(eval
$(call Download
,mpc
))
127 URL
:=ftp
://gcc.gnu.org
/pub
/gcc
/infrastructure
/
128 FILE
:=$(MPFRSRC
).
tar.bz2
129 HASH
:=d3103a80cdad2407ed581f3618c4bed04e0c92d1cf771a65ead662cc397f7775
131 $(eval
$(call Download
,mpfr
))
135 # we have to download and unpack additional stuff before patching
136 tar -C
$(PKG_BUILD_DIR
) -xvjf
$(DL_DIR
)/$(GMPSRC
).
tar.bz2
137 ln
-sf
$(PKG_BUILD_DIR
)/$(GMPSRC
) $(PKG_BUILD_DIR
)/gmp
138 tar -C
$(PKG_BUILD_DIR
) -xvzf
$(DL_DIR
)/$(MPCSRC
).
tar.gz
139 ln
-sf
$(PKG_BUILD_DIR
)/$(MPCSRC
) $(PKG_BUILD_DIR
)/mpc
140 tar -C
$(PKG_BUILD_DIR
) -xvjf
$(DL_DIR
)/$(MPFRSRC
).
tar.bz2
141 ln
-sf
$(PKG_BUILD_DIR
)/$(MPFRSRC
) $(PKG_BUILD_DIR
)/mpfr
143 # poor man's fix for `none-openwrt-linux' not recognized when building with musl
144 cp
$(PKG_BUILD_DIR
)/config.sub
$(PKG_BUILD_DIR
)/mpfr
/
145 cp
$(PKG_BUILD_DIR
)/config.sub
$(PKG_BUILD_DIR
)/gmp
/
146 chmod u
+w
$(PKG_BUILD_DIR
)/mpc
/config.sub
147 cp
$(PKG_BUILD_DIR
)/config.sub
$(PKG_BUILD_DIR
)/mpc
/
150 CONFIGURE_ARGS
+= CXXFLAGS_FOR_TARGET
="-g -O2 -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS"
152 define Build
/Configure
153 (cd
$(PKG_BUILD_DIR
); rm -f config.cache
; \
155 $(TARGET_CONFIGURE_OPTS
) \
156 $(PKG_BUILD_DIR
)/configure \
158 --build
=$(GNU_HOST_NAME
) \
159 --host
=$(REAL_GNU_TARGET_NAME
) \
160 --target
=$(REAL_GNU_TARGET_NAME
) \
161 --enable-languages
=$(TARGET_LANGUAGES
) \
162 --with-bugurl
=$(BUGURL
) \
163 --with-pkgversion
="$(PKGVERSION)" \
165 $(if
$(CONFIG_LIBC_USE_GLIBC
),--enable
,--disable
)-__cxa_atexit \
166 --with-default-libstdcxx-abi
=gcc4-compatible \
167 --enable-target-optspace \
170 --disable-libsanitizer \
172 --disable-libcilkrts \
173 --disable-libmudflap \
177 --disable-libquadmath \
179 --disable-decimal-float \
180 --disable-libstdcxx-pch \
181 --with-host-libstdcxx
=-lstdc
++ \
183 --libexecdir
=/usr
/lib \
184 --with-local-prefix
=/usr \
185 --with-stage1-ldflags
=-lstdc
++ \
186 $(ARM_FLOAT_OPTION
) \
187 $(SOFT_FLOAT_CONFIG_OPTION
) \
188 $(call qstrip
,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS
)) \
193 export SHELL
="$(BASH)"; $(MAKE_VARS
) $(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
) \
194 DESTDIR
="$(PKG_INSTALL_DIR)" $(MAKE_ARGS
) all
195 export SHELL
="$(BASH)"; $(MAKE_VARS
) $(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
) \
196 DESTDIR
="$(PKG_INSTALL_DIR)" $(MAKE_ARGS
) install
199 ENVCFLAGS
:="$(TARGET_OPTIMIZATION) $(EXTRA_OPTIMIZATION)
200 ifeq ($(CONFIG_SOFT_FLOAT),y)
201 ifeq ($(CONFIG_arm),y)
202 ENVCFLAGS+= -mfloat-abi=soft
204 ENVCFLAGS+= -msoft-float
209 ENVLDFLAGS
:="-Wl,-rpath=/usr/lib -Wl,--dynamic-linker=/usr/lib/$(DYNLINKER) -L/usr/lib, -lstdc++"
211 define Package
/gcc
/install
212 $(INSTALL_DIR
) $(1)/usr
/bin
$(1)/usr
/lib
$(1)/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)
213 cp
-ar $(PKG_INSTALL_DIR
)/usr
/include $(1)/usr
214 cp
-a
$(PKG_INSTALL_DIR
)/usr
/bin
/{$(REAL_GNU_TARGET_NAME
)-{g
++,gcc
},cpp,gcov
} $(1)/usr
/bin
215 ln
-s
$(REAL_GNU_TARGET_NAME
)-g
++ $(1)/usr
/bin
/c
++
216 ln
-s
$(REAL_GNU_TARGET_NAME
)-g
++ $(1)/usr
/bin
/g
++
217 ln
-s
$(REAL_GNU_TARGET_NAME
)-g
++ $(1)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-c
++
218 ln
-s
$(REAL_GNU_TARGET_NAME
)-gcc
$(1)/usr
/bin
/gcc
219 ln
-s
$(REAL_GNU_TARGET_NAME
)-gcc
$(1)/usr
/bin
/cc
220 ln
-s
$(REAL_GNU_TARGET_NAME
)-gcc
$(1)/usr
/bin
/$(REAL_GNU_TARGET_NAME
)-gcc-
$(PKG_VERSION
)
221 cp
-ar $(PKG_INSTALL_DIR
)/usr
/lib
/gcc
$(1)/usr
/lib
222 cp
-ar $(TOOLCHAIN_DIR
)/include $(1)/usr
223 cp
-a
$(TOOLCHAIN_DIR
)/lib
/*.
{o
,so
*} $(1)/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)
224 cp
-a
$(TOOLCHAIN_DIR
)/lib
/*nonshared
*.a
$(1)/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)
225 cp
-a
$(TOOLCHAIN_DIR
)/lib
/libm.a
$(1)/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)
227 $(COPY_STATIC_LIBPTHREAD
)
228 $(COPY_STATIC_LIBSTDC
)
229 rm -f
$(1)/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)/libgo
*
230 rm -f
$(1)/usr
/lib
/$(PKG_NAME
)/$(REAL_GNU_TARGET_NAME
)/$(PKG_VERSION
)/libcc1
*
231 echo
'#!/bin/sh' > $(1)/usr
/bin
/gcc_env.sh
232 echo
'export LDFLAGS=$(ENVLDFLAGS)' >> $(1)/usr
/bin
/gcc_env.sh
233 echo
'export CFLAGS=$(ENVCFLAGS)' >> $(1)/usr
/bin
/gcc_env.sh
234 chmod
+x
$(1)/usr
/bin
/gcc_env.sh
237 ifeq ($(CONFIG_INCLUDE_STATIC_LINK_SPEC
),y
)
238 define Package
/gcc
/postinst
241 $(INSTALL_STATIC_SPEC
)
244 define Package
/gcc
/postrm
247 $(REMOVE_STATIC_SPEC
)
251 $(eval
$(call BuildPackage
,gcc
))