import shutil class Recipe(recipe.Recipe): name = 'gcc' version = '8.2.0' licenses = [License.GPLv3Plus] stype = SourceType.CUSTOM make = 'make all' make_install = 'make install-strip' add_host_build_target = False override_libtool = False deps = ['gcc-sources', 'mingw-w64-crt', 'winpthreads', 'gmp', 'mpc', 'mpfr', 'isl'] configure_options = '--with-host-libstdcxx=\'-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm\' ' \ '--disable-maintainer-mode' \ '--disable-shared ' \ '--disable-libgomp ' \ '--disable-libquadmath ' \ '--disable-libquadmath-support ' \ '--disable-libmudflap ' \ '--disable-libmpx ' \ '--disable-libssp ' \ '--disable-nls ' \ '--enable-threads=posix ' \ '--enable-__cxa_atexit ' \ '--enable-lto ' \ '--enable-plugin ' \ '--enable-multiarch ' \ '--enable-languages=c,c++ ' \ '--enable-long-long ' \ '' def prepare(self): if self.config.target_arch == Architecture.X86: raise InvalidRecipeError(self) # The configure checks are failing on this function # which ends in a double definition, so let's override it. self.set_env ('ac_cv_func_powf', 'yes') self.set_env ('CPP') self._target = 'x86_64-w64-mingw32' sysroot = os.path.join(self.config.prefix, self._target, 'sysroot') self.configure_options += ' --with-sysroot=%s ' % sysroot self.configure_options += ' --with-local-prefix=%s ' % sysroot self.configure_options += ' --target=%s' % self._target if self.config.target_platform == Platform.WINDOWS: self.configure_options += ' --host=%s' % self._target self.build_dir = os.path.join(self.config.sources, 'gcc-%s' % self.version) self.make_dir = os.path.join(self.build_dir, 'gcc_build_final') self.config_sh = '../configure' async def configure(self): try: os.mkdir(self.make_dir) except: pass await super(Recipe, self).configure() def post_install(self): if self.config.target_platform == Platform.WINDOWS: bindir = os.path.join(self.config.prefix, 'bin') libdir = os.path.join(self.config.prefix, 'lib') lib32dir = os.path.join(self.config.prefix, 'lib32') # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89044 os.remove(os.path.join(bindir, 'libstdc++-6.dll')) stdc64 = 'x86_64-w64-mingw32/libstdc++-v3/src/.libs/libstdc++-6.dll' stdc32 = 'x86_64-w64-mingw32/32/libstdc++-v3/src/.libs/libstdc++-6.dll' shutil.copy(os.path.join(self.make_dir, stdc64), libdir) shutil.copy(os.path.join(self.make_dir, stdc32), lib32dir) super().post_install()