nginx: bump to 1.26.1 release
[feed/packages.git] / devel / gcc / Makefile
1 #
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
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 GCC_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
25 PKG_VERSION:=$(firstword $(subst +, ,$(GCC_VERSION)))
26 GCC_MAJOR_VERSION:=$(word 1,$(subst ., ,$(PKG_VERSION)))
27 PKG_RELEASE:=6
28 GCC_DIR:=$(PKG_NAME)-$(PKG_VERSION)
29
30 PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
31 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
32 PKG_INSTALL:=1
33 PKG_FIXUP:=libtool
34 PKG_BUILD_PARALLEL:=1
35
36 PKG_CPE_ID:=cpe:/a:gnu:gcc
37
38 ifeq ($(PKG_VERSION),8.4.0)
39 PKG_HASH:=e30a6e52d10e1f27ed55104ad233c30bd1e99cfb5ff98ab022dc941edd1b2dd4
40 endif
41
42 ifeq ($(PKG_VERSION),10.3.0)
43 PKG_HASH:=64f404c1a650f27fc33da242e1f2df54952e3963a49e06e73f6940f3223ac344
44 endif
45
46 ifeq ($(PKG_VERSION),11.3.0)
47 PKG_HASH:=b47cf2818691f5b1e21df2bb38c795fac2cfbd640ede2d0a5e1c89e338a3ac39
48 endif
49
50 ifeq ($(PKG_VERSION),12.3.0)
51 PKG_HASH:=949a5d4f99e786421a93b532b22ffab5578de7321369975b91aec97adfda8c3b
52 endif
53
54 ifeq ($(PKG_VERSION),13.3.0)
55 PKG_HASH:=0845e9621c9543a13f484e94584a49ffc0129970e9914624235fc1d061a0c083
56 endif
57
58 PATCH_DIR:=patches-$(GCC_MAJOR_VERSION).x
59
60 include $(INCLUDE_DIR)/package.mk
61
62 define Package/gcc
63 SECTION:=devel
64 CATEGORY:=Development
65 TITLE:=gcc
66 MAINTAINER:=W. Michael Petullo <mike@flyn.org>
67 DEPENDS:= +binutils +libstdcpp +libzstd @!arc
68 MENU:=1
69 endef
70
71 define Package/gcc/config
72 source "$(SOURCE)/Config.in"
73 endef
74
75 ifeq ($(CONFIG_INCLUDE_STATIC_LIBC),y)
76 COPY_STATIC_LIBC=cp -a $(TOOLCHAIN_ROOT_DIR)/lib/libc.a $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
77 endif
78
79 ifeq ($(CONFIG_INCLUDE_STATIC_LIBPTHREAD),y)
80 COPY_STATIC_LIBPTHREAD=cp -a $(TOOLCHAIN_ROOT_DIR)/lib/libpthread.a $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
81 endif
82
83 ifeq ($(CONFIG_INCLUDE_STATIC_LIBSTDC),y)
84 COPY_STATIC_LIBSTDC=cp -a $(TOOLCHAIN_ROOT_DIR)/lib/libstdc++.a $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
85 endif
86
87 ifeq ($(CONFIG_INCLUDE_STATIC_LINK_SPEC),y)
88 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
89 REMOVE_STATIC_SPEC=rm /usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)/specs
90 endif
91
92 TARGET_LANGUAGES:="c,c++"
93 BUGURL=https://dev.openwrt.org/
94 PKGVERSION=OpenWrt GCC $(PKG_VERSION)
95 TARGET_CPPFLAGS += -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS
96
97 # not using sstrip here as this messes up the .so's somehow
98 STRIP:=$(firstword $(TOOLCHAIN_BIN_DIRS))/$(TARGET_CROSS)strip
99 RSTRIP:= \
100 NM="$(firstword $(TOOLCHAIN_BIN_DIRS))/$(TARGET_CROSS)nm" \
101 STRIP="$(STRIP)" \
102 STRIP_KMOD="$(STRIP) --strip-debug" \
103 $(SCRIPT_DIR)/rstrip.sh
104
105 ifneq ($(CONFIG_SOFT_FLOAT),y)
106 ifeq ($(CONFIG_arm),y)
107 ARM_FLOAT_OPTION:= --with-float=hard
108 endif
109 endif
110
111 GMPSRC=gmp-6.1.0
112
113 define Download/gmp
114 URL:=ftp://gcc.gnu.org/pub/gcc/infrastructure/
115 FILE:=$(GMPSRC).tar.bz2
116 HASH:=498449a994efeba527885c10405993427995d3f86b8768d8cdf8d9dd7c6b73e8
117 endef
118 $(eval $(call Download,gmp))
119
120 MPCSRC=mpc-1.0.3
121
122 define Download/mpc
123 URL:=ftp://gcc.gnu.org/pub/gcc/infrastructure/
124 FILE:=$(MPCSRC).tar.gz
125 HASH:=617decc6ea09889fb08ede330917a00b16809b8db88c29c31bfbb49cbf88ecc3
126 endef
127 $(eval $(call Download,mpc))
128
129 MPFRSRC=mpfr-3.1.4
130
131 define Download/mpfr
132 URL:=ftp://gcc.gnu.org/pub/gcc/infrastructure/
133 FILE:=$(MPFRSRC).tar.bz2
134 HASH:=d3103a80cdad2407ed581f3618c4bed04e0c92d1cf771a65ead662cc397f7775
135 endef
136 $(eval $(call Download,mpfr))
137
138 define Build/Prepare
139 $(PKG_UNPACK)
140 # we have to download and unpack additional stuff before patching
141 tar -C $(PKG_BUILD_DIR) -xvjf $(DL_DIR)/$(GMPSRC).tar.bz2
142 ln -sf $(PKG_BUILD_DIR)/$(GMPSRC) $(PKG_BUILD_DIR)/gmp
143 tar -C $(PKG_BUILD_DIR) -xvzf $(DL_DIR)/$(MPCSRC).tar.gz
144 ln -sf $(PKG_BUILD_DIR)/$(MPCSRC) $(PKG_BUILD_DIR)/mpc
145 tar -C $(PKG_BUILD_DIR) -xvjf $(DL_DIR)/$(MPFRSRC).tar.bz2
146 ln -sf $(PKG_BUILD_DIR)/$(MPFRSRC) $(PKG_BUILD_DIR)/mpfr
147 $(Build/Patch)
148 # poor man's fix for `none-openwrt-linux' not recognized when building with musl
149 cp $(PKG_BUILD_DIR)/config.sub $(PKG_BUILD_DIR)/mpfr/
150 cp $(PKG_BUILD_DIR)/config.sub $(PKG_BUILD_DIR)/gmp/
151 chmod u+w $(PKG_BUILD_DIR)/mpc/config.sub
152 cp $(PKG_BUILD_DIR)/config.sub $(PKG_BUILD_DIR)/mpc/
153 endef
154
155 CONFIGURE_ARGS += CXXFLAGS_FOR_TARGET="-g -O2 -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS"
156
157 define Build/Configure
158 (cd $(PKG_BUILD_DIR); rm -f config.cache; \
159 SHELL="$(BASH)" \
160 $(TARGET_CONFIGURE_OPTS) \
161 $(PKG_BUILD_DIR)/configure \
162 $(CONFIGURE_ARGS) \
163 --build=$(GNU_HOST_NAME) \
164 --host=$(REAL_GNU_TARGET_NAME) \
165 --target=$(REAL_GNU_TARGET_NAME) \
166 --enable-languages=$(TARGET_LANGUAGES) \
167 --with-bugurl=$(BUGURL) \
168 --with-pkgversion="$(PKGVERSION)" \
169 --enable-shared \
170 $(if $(CONFIG_LIBC_USE_GLIBC),--enable,--disable)-__cxa_atexit \
171 --with-default-libstdcxx-abi=gcc4-compatible \
172 --enable-target-optspace \
173 --with-gnu-ld \
174 --disable-nls \
175 --disable-libsanitizer \
176 --disable-libvtv \
177 --disable-libcilkrts \
178 --disable-libmudflap \
179 --disable-libmpx \
180 --disable-multilib \
181 --disable-libgomp \
182 --disable-libquadmath \
183 --disable-libssp \
184 --disable-decimal-float \
185 --disable-libstdcxx-pch \
186 --with-host-libstdcxx=-lstdc++ \
187 --prefix=/usr \
188 --libexecdir=/usr/lib \
189 --with-local-prefix=/usr \
190 --with-stage1-ldflags=-lstdc++ \
191 $(ARM_FLOAT_OPTION) \
192 $(SOFT_FLOAT_CONFIG_OPTION) \
193 $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
194 );
195 endef
196
197 define Build/Compile
198 export SHELL="$(BASH)"; $(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
199 DESTDIR="$(PKG_INSTALL_DIR)" $(MAKE_ARGS) all
200 export SHELL="$(BASH)"; $(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
201 DESTDIR="$(PKG_INSTALL_DIR)" $(MAKE_ARGS) install
202 endef
203
204 ENVCFLAGS:="$(TARGET_OPTIMIZATION) $(EXTRA_OPTIMIZATION)
205 ifeq ($(CONFIG_SOFT_FLOAT),y)
206 ifeq ($(CONFIG_arm),y)
207 ENVCFLAGS+= -mfloat-abi=soft
208 else
209 ENVCFLAGS+= -msoft-float
210 endif
211 endif
212 ENVCFLAGS+="
213
214 ENVLDFLAGS:="-Wl,-rpath=/usr/lib -Wl,--dynamic-linker=/usr/lib/$(DYNLINKER) -L/usr/lib, -lstdc++"
215
216 define Package/gcc/install
217 $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
218 cp -ar $(PKG_INSTALL_DIR)/usr/include $(1)/usr
219 cp -a $(PKG_INSTALL_DIR)/usr/bin/{$(REAL_GNU_TARGET_NAME)-{g++,gcc},cpp,gcov} $(1)/usr/bin
220 ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/c++
221 ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/g++
222 ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/$(REAL_GNU_TARGET_NAME)-c++
223 ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/gcc
224 ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/cc
225 ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc-$(PKG_VERSION)
226 cp -ar $(PKG_INSTALL_DIR)/usr/lib/gcc $(1)/usr/lib
227 cp -ar $(TOOLCHAIN_ROOT_DIR)/include $(1)/usr
228 cp -a $(TOOLCHAIN_ROOT_DIR)/lib/*.{o,so*} $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
229 cp -a $(TOOLCHAIN_ROOT_DIR)/lib/*nonshared*.a $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
230 cp -a $(TOOLCHAIN_ROOT_DIR)/lib/libm.a $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
231 $(COPY_STATIC_LIBC)
232 $(COPY_STATIC_LIBPTHREAD)
233 $(COPY_STATIC_LIBSTDC)
234 rm -f $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)/libgo*
235 rm -f $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)/libcc1*
236 echo '#!/bin/sh' > $(1)/usr/bin/gcc_env.sh
237 echo 'export LDFLAGS=$(ENVLDFLAGS)' >> $(1)/usr/bin/gcc_env.sh
238 echo 'export CFLAGS=$(ENVCFLAGS)' >> $(1)/usr/bin/gcc_env.sh
239 chmod +x $(1)/usr/bin/gcc_env.sh
240 endef
241
242 ifeq ($(CONFIG_INCLUDE_STATIC_LINK_SPEC),y)
243 define Package/gcc/postinst
244 #!/bin/sh
245
246 $(INSTALL_STATIC_SPEC)
247 endef
248
249 define Package/gcc/postrm
250 #!/bin/sh
251
252 $(REMOVE_STATIC_SPEC)
253 endef
254 endif
255
256 $(eval $(call BuildPackage,gcc))