2016-08-22 20:52:34 +01:00
|
|
|
# This file is part of MXE. See LICENSE.md for licensing information.
|
2008-11-08 08:42:47 +00:00
|
|
|
|
2009-04-05 13:00:17 +01:00
|
|
|
PKG := gcc
|
2017-03-04 10:33:47 +00:00
|
|
|
$(PKG)_WEBSITE := https://gcc.gnu.org/
|
2016-12-18 05:43:56 +00:00
|
|
|
$(PKG)_DESCR := GCC
|
2018-04-06 05:40:20 +01:00
|
|
|
$(PKG)_IGNORE :=
|
|
|
|
$(PKG)_VERSION := 5.5.0
|
|
|
|
$(PKG)_CHECKSUM := 530cea139d82fe542b358961130c69cfde8b3d14556370b65823d2f91f0ced87
|
2009-10-27 13:33:05 +00:00
|
|
|
$(PKG)_SUBDIR := gcc-$($(PKG)_VERSION)
|
2018-04-06 05:40:20 +01:00
|
|
|
$(PKG)_FILE := gcc-$($(PKG)_VERSION).tar.xz
|
2017-03-04 10:33:47 +00:00
|
|
|
$(PKG)_URL := https://ftp.gnu.org/gnu/gcc/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
|
|
|
|
$(PKG)_URL_2 := https://www.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
|
2017-11-25 10:48:27 +00:00
|
|
|
$(PKG)_DEPS := binutils mingw-w64 $(addprefix $(BUILD)~,gmp isl mpc mpfr)
|
2008-11-08 08:42:47 +00:00
|
|
|
|
|
|
|
define $(PKG)_UPDATE
|
2017-03-04 10:33:47 +00:00
|
|
|
$(WGET) -q -O- 'https://ftp.gnu.org/gnu/gcc/?C=M;O=D' | \
|
2018-04-06 05:40:20 +01:00
|
|
|
grep -v 'gcc-6\|gcc-7' | \
|
2009-12-20 15:36:28 +00:00
|
|
|
$(SED) -n 's,.*<a href="gcc-\([0-9][^"]*\)/".*,\1,p' | \
|
2013-05-22 10:33:04 +01:00
|
|
|
$(SORT) -V | \
|
|
|
|
tail -1
|
2008-11-08 08:42:47 +00:00
|
|
|
endef
|
|
|
|
|
2013-05-23 15:35:29 +01:00
|
|
|
define $(PKG)_CONFIGURE
|
2013-10-19 07:11:43 +01:00
|
|
|
# configure gcc
|
2017-02-03 09:25:56 +00:00
|
|
|
cd '$(BUILD_DIR)' && '$(SOURCE_DIR)/configure' \
|
2017-07-23 16:45:09 +01:00
|
|
|
$(MXE_DISABLE_DOC_OPTS) \
|
2009-09-19 03:46:12 +01:00
|
|
|
--target='$(TARGET)' \
|
2014-02-02 07:00:10 +00:00
|
|
|
--build='$(BUILD)' \
|
2009-09-19 03:46:12 +01:00
|
|
|
--prefix='$(PREFIX)' \
|
2011-08-19 12:54:26 +01:00
|
|
|
--libdir='$(PREFIX)/lib' \
|
2018-04-06 05:40:20 +01:00
|
|
|
--with-sysroot='$(PREFIX)/$(TARGET)' \
|
2009-09-19 03:46:12 +01:00
|
|
|
--enable-languages='c,c++,objc,fortran' \
|
|
|
|
--enable-version-specific-runtime-libs \
|
|
|
|
--with-gcc \
|
|
|
|
--with-gnu-ld \
|
|
|
|
--with-gnu-as \
|
|
|
|
--disable-nls \
|
2014-02-17 03:25:48 +00:00
|
|
|
$(if $(BUILD_STATIC),--disable-shared) \
|
2013-05-23 15:35:29 +01:00
|
|
|
--disable-multilib \
|
2009-09-19 03:46:12 +01:00
|
|
|
--without-x \
|
|
|
|
--disable-win32-registry \
|
2015-10-27 03:14:43 +00:00
|
|
|
--enable-threads=$(MXE_GCC_THREADS) \
|
2017-02-04 10:33:53 +00:00
|
|
|
$(MXE_GCC_EXCEPTION_OPTS) \
|
2020-06-05 05:02:36 +01:00
|
|
|
--enable-default-ssp \
|
2015-10-27 02:58:22 +00:00
|
|
|
--enable-libgomp \
|
2015-10-13 13:48:10 +01:00
|
|
|
--with-gmp='$(PREFIX)/$(BUILD)' \
|
|
|
|
--with-isl='$(PREFIX)/$(BUILD)' \
|
|
|
|
--with-mpc='$(PREFIX)/$(BUILD)' \
|
|
|
|
--with-mpfr='$(PREFIX)/$(BUILD)' \
|
2014-02-11 01:53:30 +00:00
|
|
|
--with-as='$(PREFIX)/bin/$(TARGET)-as' \
|
|
|
|
--with-ld='$(PREFIX)/bin/$(TARGET)-ld' \
|
|
|
|
--with-nm='$(PREFIX)/bin/$(TARGET)-nm' \
|
2017-02-04 10:33:53 +00:00
|
|
|
$(shell [ `uname -s` == Darwin ] && echo "LDFLAGS='-Wl,-no_pie'") \
|
2020-06-09 15:44:17 +01:00
|
|
|
$(PKG_CONFIGURE_OPTS)
|
2013-05-23 15:35:29 +01:00
|
|
|
endef
|
2010-02-07 09:00:58 +00:00
|
|
|
|
2013-05-23 15:35:29 +01:00
|
|
|
define $(PKG)_BUILD_mingw-w64
|
2020-06-19 13:54:45 +01:00
|
|
|
# `configure`'s libdl detection:
|
|
|
|
# - bypasses the gcc/mingw use of `LoadLibrary`
|
|
|
|
# - adds unnecessary dependency
|
|
|
|
# - causes unexpected linking errors
|
|
|
|
# - can't be reliably disabled in all subdirs
|
|
|
|
# safe option is `make clean`, but we don't want to enforce that
|
|
|
|
-rm -v '$(PREFIX)/$(TARGET)'/{lib,bin}/libdl.*
|
2020-06-20 02:49:03 +01:00
|
|
|
-rm -v '$(PREFIX)/$(TARGET)/include/dlfcn.h'
|
2020-06-19 13:54:45 +01:00
|
|
|
|
2015-10-27 02:58:22 +00:00
|
|
|
# install mingw-w64 headers
|
2017-02-03 09:25:56 +00:00
|
|
|
$(call PREPARE_PKG_SOURCE,mingw-w64,$(BUILD_DIR))
|
|
|
|
mkdir '$(BUILD_DIR).headers'
|
|
|
|
cd '$(BUILD_DIR).headers' && '$(BUILD_DIR)/$(mingw-w64_SUBDIR)/mingw-w64-headers/configure' \
|
2015-10-27 02:58:22 +00:00
|
|
|
--host='$(TARGET)' \
|
|
|
|
--prefix='$(PREFIX)/$(TARGET)' \
|
2020-04-16 12:15:36 +01:00
|
|
|
--with-default-msvcrt=msvcrt \
|
2015-10-27 02:58:22 +00:00
|
|
|
--enable-sdk=all \
|
2016-06-08 20:02:49 +01:00
|
|
|
--enable-idl \
|
2017-01-29 02:23:21 +00:00
|
|
|
--enable-secure-api \
|
2020-06-05 05:02:36 +01:00
|
|
|
--with-default-msvcrt=msvcrt \
|
2016-06-08 20:02:49 +01:00
|
|
|
$(mingw-w64-headers_CONFIGURE_OPTS)
|
2017-02-03 09:25:56 +00:00
|
|
|
$(MAKE) -C '$(BUILD_DIR).headers' install
|
2015-10-27 02:58:22 +00:00
|
|
|
|
2013-05-23 15:35:29 +01:00
|
|
|
# build standalone gcc
|
|
|
|
$($(PKG)_CONFIGURE)
|
2017-02-03 09:25:56 +00:00
|
|
|
$(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' all-gcc
|
|
|
|
$(MAKE) -C '$(BUILD_DIR)' -j 1 $(INSTALL_STRIP_TOOLCHAIN)-gcc
|
2013-05-23 15:35:29 +01:00
|
|
|
|
|
|
|
# build mingw-w64-crt
|
2017-02-03 09:25:56 +00:00
|
|
|
mkdir '$(BUILD_DIR).crt'
|
|
|
|
cd '$(BUILD_DIR).crt' && '$(BUILD_DIR)/$(mingw-w64_SUBDIR)/mingw-w64-crt/configure' \
|
2013-05-23 15:35:29 +01:00
|
|
|
--host='$(TARGET)' \
|
|
|
|
--prefix='$(PREFIX)/$(TARGET)' \
|
2018-11-13 15:56:06 +00:00
|
|
|
--with-default-msvcrt=msvcrt \
|
2020-06-05 05:02:36 +01:00
|
|
|
@gcc-crt-config-opts@ \
|
|
|
|
$(mingw-w64-crt_CONFIGURE_OPTS)
|
2017-02-03 09:25:56 +00:00
|
|
|
$(MAKE) -C '$(BUILD_DIR).crt' -j '$(JOBS)' || $(MAKE) -C '$(BUILD_DIR).crt' -j '$(JOBS)'
|
|
|
|
$(MAKE) -C '$(BUILD_DIR).crt' -j 1 $(INSTALL_STRIP_TOOLCHAIN)
|
2013-05-23 15:35:29 +01:00
|
|
|
|
2015-10-27 02:58:22 +00:00
|
|
|
# build posix threads
|
2017-02-03 09:25:56 +00:00
|
|
|
mkdir '$(BUILD_DIR).pthreads'
|
|
|
|
cd '$(BUILD_DIR).pthreads' && '$(BUILD_DIR)/$(mingw-w64_SUBDIR)/mingw-w64-libraries/winpthreads/configure' \
|
2015-10-27 02:58:22 +00:00
|
|
|
$(MXE_CONFIGURE_OPTS)
|
2017-02-03 09:25:56 +00:00
|
|
|
$(MAKE) -C '$(BUILD_DIR).pthreads' -j '$(JOBS)' || $(MAKE) -C '$(BUILD_DIR).pthreads' -j '$(JOBS)'
|
|
|
|
$(MAKE) -C '$(BUILD_DIR).pthreads' -j 1 $(INSTALL_STRIP_TOOLCHAIN)
|
2015-10-27 02:58:22 +00:00
|
|
|
|
2013-05-23 15:35:29 +01:00
|
|
|
# build rest of gcc
|
2017-09-29 14:10:50 +01:00
|
|
|
# `all-target-libstdc++-v3` sometimes has parallel failure
|
2017-10-06 12:49:31 +01:00
|
|
|
$(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' all-target-libstdc++-v3 || $(MAKE) -C '$(BUILD_DIR)' -j 1 all-target-libstdc++-v3
|
2017-02-03 09:25:56 +00:00
|
|
|
$(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
|
|
|
|
$(MAKE) -C '$(BUILD_DIR)' -j 1 $(INSTALL_STRIP_TOOLCHAIN)
|
2014-02-11 01:53:30 +00:00
|
|
|
|
2017-02-03 09:39:14 +00:00
|
|
|
$($(PKG)_POST_BUILD)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define $(PKG)_POST_BUILD
|
|
|
|
# - no non-trivial way to configure installation of *.dlls
|
|
|
|
# each sudbir has it's own variations of variables like:
|
|
|
|
# `toolexeclibdir` `install-toolexeclibLTLIBRARIES` etc.
|
|
|
|
# and maintaining those would be cumbersome
|
|
|
|
# - shared libgcc isn't installed to version-specific locations
|
|
|
|
# - need to keep `--enable-version-specific-runtime-libs` otherwise
|
|
|
|
# libraries go directly into $(PREFIX)/$(TARGET)/lib and are
|
|
|
|
# harder to cleanup
|
|
|
|
# - ignore rm failure as parallel build may have cleaned up, but
|
|
|
|
# don't wildcard all libs so future additions will be detected
|
2015-11-12 06:40:24 +00:00
|
|
|
$(and $(BUILD_SHARED),
|
2017-02-03 09:25:56 +00:00
|
|
|
$(MAKE) -C '$(BUILD_DIR)/$(TARGET)/libgcc' -j 1 \
|
2015-12-03 07:52:27 +00:00
|
|
|
toolexecdir='$(PREFIX)/$(TARGET)/bin' \
|
2015-11-12 06:40:24 +00:00
|
|
|
SHLIB_SLIBDIR_QUAL= \
|
2017-02-03 09:39:14 +00:00
|
|
|
install-shared
|
|
|
|
mv -v '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/'*.dll '$(PREFIX)/$(TARGET)/bin/'
|
|
|
|
-rm -v '$(PREFIX)/lib/gcc/$(TARGET)/'libgcc_s*.dll
|
|
|
|
-rm -v '$(PREFIX)/lib/gcc/$(TARGET)/lib/'libgcc_s*.a
|
|
|
|
-rmdir '$(PREFIX)/lib/gcc/$(TARGET)/lib/')
|
2015-11-12 06:40:24 +00:00
|
|
|
|
2017-02-03 09:39:14 +00:00
|
|
|
# cc1libdir isn't passed to subdirs so install correctly and rm
|
|
|
|
$(MAKE) -C '$(BUILD_DIR)/libcc1' -j 1 install cc1libdir='$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)'
|
|
|
|
-rm -f '$(PREFIX)/lib/'libcc1*
|
2018-04-06 05:40:20 +01:00
|
|
|
|
2020-06-05 05:02:36 +01:00
|
|
|
# overwrite default specs to mimic stack protector handling of glibc
|
|
|
|
# ./configure above doesn't do this
|
|
|
|
'$(TARGET)-gcc' -dumpspecs > '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/specs'
|
|
|
|
$(SED) -i 's,-lmingwex,-lmingwex -lssp_nonshared -lssp,' '$(PREFIX)/lib/gcc/$(TARGET)/$($(PKG)_VERSION)/specs'
|
|
|
|
|
2018-04-06 05:40:20 +01:00
|
|
|
# compile test
|
|
|
|
cd '$(PREFIX)/$(TARGET)/bin' && '$(TARGET)-gcc' \
|
|
|
|
-W -Wall -Werror -ansi -pedantic \
|
2020-06-05 05:02:36 +01:00
|
|
|
-D_FORTIFY_SOURCE=2 \
|
2018-04-06 05:40:20 +01:00
|
|
|
--coverage -fprofile-dir=. -v \
|
|
|
|
'$(TEST_FILE)' -o '$(PREFIX)/$(TARGET)/bin/test-$(PKG).exe'
|
2013-05-23 15:35:29 +01:00
|
|
|
endef
|
|
|
|
|
2014-02-18 03:04:23 +00:00
|
|
|
$(PKG)_BUILD_x86_64-w64-mingw32 = $(subst @gcc-crt-config-opts@,--disable-lib32,$($(PKG)_BUILD_mingw-w64))
|
|
|
|
$(PKG)_BUILD_i686-w64-mingw32 = $(subst @gcc-crt-config-opts@,--disable-lib64,$($(PKG)_BUILD_mingw-w64))
|