Unverified Commit b309b39f authored by boklm's avatar boklm
Browse files

Import components froms tor-messenger-build

Copy components from tor-messenger-build that will be useful for
building Tor Browser.

Copied from tor-messenger-build.git at commit f6411d2a66dae17e09e.
parent 9b4789ca
#!/bin/sh
set -e
distdir=/var/tmp/dist/binutils
tar xf [% project %]-[% c("version") %].tar.bz2
cd [% project %]-[% c("version") %]
[% IF c('var/windows') -%]
# XXX: This is needed due to bug 10102.
sed 's/= extern_rt_rel_d;/= extern_rt_rel_d;\n memset (extern_rt_rel_d, 0, PE_IDATA5_SIZE);/' -i ld/pe-dll.c
# Needed for the hardening...
patch -p1 < ../enable-reloc-section-ld.patch
# specify-timestamp patch from Stephen Kitt <steve@sk2.org>
# https://anonscm.debian.org/cgit/collab-maint/binutils-mingw-w64.git/
patch -p2 < ../specify-timestamp.patch
[% END -%]
./configure --prefix=$distdir [% c('var/configure_opt') %]
make -j4
make install
cd /var/tmp/dist
[% c('tar', {
tar_src => [ project ],
tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
}) %]
# vim: filetype=yaml sw=2
version: 2.25
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
remote_docker: 1
var:
deps:
- build-essential
- bison
configure_opt: '--disable-multilib --enable-gold --enable-deterministic-archives'
targets:
windows-i686:
var:
configure_opt: '--target=i686-w64-mingw32 --disable-multilib --enable-deterministic-archives'
input_files:
- URL: https://ftp.gnu.org/gnu/binutils/binutils-[% c("version") %].tar.bz2
sig_ext: sig
file_gpg_id: 1
gpg_keyring: binutils.gpg
- project: docker-image
- filename: enable-reloc-section-ld.patch
enable: '[% c("var/windows") %]'
# specify-timestamp patch from Stephen Kitt <steve@sk2.org>
# https://anonscm.debian.org/cgit/collab-maint/binutils-mingw-w64.git/
- filename: specify-timestamp.patch
enable: '[% c("var/windows") %]'
From 6ef8bae3d2a4f4704c4a32f786c9574db3e70f25 Mon Sep 17 00:00:00 2001
From: Erinn Clark <erinn@torproject.org>
Date: Fri, 8 Aug 2014 14:23:44 -0400
Subject: [PATCH] add relocation section so Windows bundles can have ASLR
Patch by skruffy.
---
ld/emultempl/pe.em | 6 +++++
ld/emultempl/pep.em | 8 ++++++-
ld/pe-dll.c | 63 ++++++++++++++++++++++++++++++-----------------------
ld/pe-dll.h | 1 +
4 files changed, 50 insertions(+), 28 deletions(-)
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index 979cc8b8e960..4a63863289c8 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -274,6 +274,7 @@ fragment <<EOF
#define OPTION_INSERT_TIMESTAMP (OPTION_TERMINAL_SERVER_AWARE + 1)
#define OPTION_NO_INSERT_TIMESTAMP (OPTION_INSERT_TIMESTAMP + 1)
#define OPTION_BUILD_ID (OPTION_NO_INSERT_TIMESTAMP + 1)
+#define OPTION_ENABLE_RELOC_SECTION (OPTION_BUILD_ID + 1)
static void
gld${EMULATION_NAME}_add_options
@@ -317,6 +318,7 @@ gld${EMULATION_NAME}_add_options
{"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL},
{"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMBOLS},
{"exclude-all-symbols", no_argument, NULL, OPTION_EXCLUDE_ALL_SYMBOLS},
+ {"enable-reloc-section", no_argument, NULL, OPTION_ENABLE_RELOC_SECTION},
{"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
{"exclude-modules-for-implib", required_argument, NULL, OPTION_EXCLUDE_MODULES_FOR_IMPLIB},
{"kill-at", no_argument, NULL, OPTION_KILL_ATS},
@@ -787,6 +789,9 @@ gld${EMULATION_NAME}_handle_option (int optc)
case OPTION_EXCLUDE_ALL_SYMBOLS:
pe_dll_exclude_all_symbols = 1;
break;
+ case OPTION_ENABLE_RELOC_SECTION:
+ pe_dll_enable_reloc_section = 1;
+ break;
case OPTION_EXCLUDE_LIBS:
pe_dll_add_excludes (optarg, EXCLUDELIBS);
break;
@@ -2059,6 +2064,7 @@ gld_${EMULATION_NAME}_finish (void)
if (link_info.shared
#if !defined(TARGET_IS_shpe)
|| (!link_info.relocatable && pe_def_file->num_exports != 0)
+ || (!link_info.relocatable && pe_dll_enable_reloc_section)
#endif
)
{
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
index b24a60820237..caf294663a80 100644
--- a/ld/emultempl/pep.em
+++ b/ld/emultempl/pep.em
@@ -248,7 +248,8 @@ enum options
OPTION_INSERT_TIMESTAMP,
OPTION_NO_INSERT_TIMESTAMP,
OPTION_TERMINAL_SERVER_AWARE,
- OPTION_BUILD_ID
+ OPTION_BUILD_ID,
+ OPTION_ENABLE_RELOC_SECTION
};
static void
@@ -290,6 +291,7 @@ gld${EMULATION_NAME}_add_options
{"export-all-symbols", no_argument, NULL, OPTION_EXPORT_ALL},
{"exclude-symbols", required_argument, NULL, OPTION_EXCLUDE_SYMBOLS},
{"exclude-all-symbols", no_argument, NULL, OPTION_EXCLUDE_ALL_SYMBOLS},
+ {"enable-reloc-section", no_argument, NULL, OPTION_ENABLE_RELOC_SECTION},
{"exclude-libs", required_argument, NULL, OPTION_EXCLUDE_LIBS},
{"exclude-modules-for-implib", required_argument, NULL, OPTION_EXCLUDE_MODULES_FOR_IMPLIB},
{"kill-at", no_argument, NULL, OPTION_KILL_ATS},
@@ -743,6 +745,9 @@ gld${EMULATION_NAME}_handle_option (int optc)
case OPTION_EXCLUDE_ALL_SYMBOLS:
pep_dll_exclude_all_symbols = 1;
break;
+ case OPTION_ENABLE_RELOC_SECTION:
+ pe_dll_enable_reloc_section = 1;
+ break;
case OPTION_EXCLUDE_LIBS:
pep_dll_add_excludes (optarg, EXCLUDELIBS);
break;
@@ -1838,6 +1843,7 @@ gld_${EMULATION_NAME}_finish (void)
#ifdef DLL_SUPPORT
if (link_info.shared
+ || (!link_info.relocatable && pe_dll_enable_reloc_section)
|| (!link_info.relocatable && pep_def_file->num_exports != 0))
{
pep_dll_fill_sections (link_info.output_bfd, &link_info);
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index 61d8fa5c7eea..24c0c72a6685 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -151,6 +151,7 @@ def_file * pe_def_file = 0;
int pe_dll_export_everything = 0;
int pe_dll_exclude_all_symbols = 0;
int pe_dll_do_default_excludes = 1;
+int pe_dll_enable_reloc_section = 0;
int pe_dll_kill_ats = 0;
int pe_dll_stdcall_aliases = 0;
int pe_dll_warn_dup_exports = 0;
@@ -3370,8 +3371,15 @@ pe_dll_build_sections (bfd *abfd, struct bfd_link_info *info)
process_def_file_and_drectve (abfd, info);
if (pe_def_file->num_exports == 0 && !info->shared)
- return;
-
+ {
+ if (pe_dll_enable_reloc_section)
+ {
+ build_filler_bfd (0);
+ pe_output_file_set_long_section_names (filler_bfd);
+ }
+ return;
+ }
+
generate_edata (abfd, info);
build_filler_bfd (1);
pe_output_file_set_long_section_names (filler_bfd);
@@ -3386,13 +3394,9 @@ pe_exe_build_sections (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED)
pe_output_file_set_long_section_names (filler_bfd);
}
-void
-pe_dll_fill_sections (bfd *abfd, struct bfd_link_info *info)
+static void
+pe_dll_create_reloc (bfd *abfd, struct bfd_link_info *info)
{
- pe_dll_id_target (bfd_get_target (abfd));
- pe_output_file_set_long_section_names (abfd);
- image_base = pe_data (abfd)->pe_opthdr.ImageBase;
-
generate_reloc (abfd, info);
if (reloc_sz > 0)
{
@@ -3409,38 +3413,43 @@ pe_dll_fill_sections (bfd *abfd, struct bfd_link_info *info)
lang_do_assignments (lang_final_phase_enum);
}
- fill_edata (abfd, info);
-
- if (info->shared && !info->pie)
- pe_data (abfd)->dll = 1;
-
- edata_s->contents = edata_d;
reloc_s->contents = reloc_d;
}
void
-pe_exe_fill_sections (bfd *abfd, struct bfd_link_info *info)
+pe_dll_fill_sections (bfd *abfd, struct bfd_link_info *info)
{
+ if (!reloc_s && !edata_s)
+ return;
pe_dll_id_target (bfd_get_target (abfd));
pe_output_file_set_long_section_names (abfd);
image_base = pe_data (abfd)->pe_opthdr.ImageBase;
- generate_reloc (abfd, info);
- if (reloc_sz > 0)
+ if (reloc_s)
+ pe_dll_create_reloc (abfd, info);
+
+ if (edata_s)
{
- bfd_set_section_size (filler_bfd, reloc_s, reloc_sz);
+ fill_edata (abfd, info);
+ edata_s->contents = edata_d;
+ }
- /* Resize the sections. */
- lang_reset_memory_regions ();
- lang_size_sections (NULL, TRUE);
+ if (info->shared && !info->pie)
+ pe_data (abfd)->dll = 1;
- /* Redo special stuff. */
- ldemul_after_allocation ();
- /* Do the assignments again. */
- lang_do_assignments (lang_final_phase_enum);
- }
- reloc_s->contents = reloc_d;
+}
+
+void
+pe_exe_fill_sections (bfd *abfd, struct bfd_link_info *info)
+{
+ if (!reloc_s)
+ return;
+ pe_dll_id_target (bfd_get_target (abfd));
+ pe_output_file_set_long_section_names (abfd);
+ image_base = pe_data (abfd)->pe_opthdr.ImageBase;
+
+ pe_dll_create_reloc (abfd, info);
}
bfd_boolean
diff --git a/ld/pe-dll.h b/ld/pe-dll.h
index 24ea30237aeb..6a0d6338646b 100644
--- a/ld/pe-dll.h
+++ b/ld/pe-dll.h
@@ -30,6 +30,7 @@ extern def_file *pe_def_file;
extern int pe_dll_export_everything;
extern int pe_dll_exclude_all_symbols;
extern int pe_dll_do_default_excludes;
+extern int pe_dll_enable_reloc_section;
extern int pe_dll_kill_ats;
extern int pe_dll_stdcall_aliases;
extern int pe_dll_warn_dup_exports;
--- a/upstream/bfd/peXXigen.c
+++ b/upstream/bfd/peXXigen.c
@@ -66,6 +66,9 @@
#include <wchar.h>
#endif
+#include <errno.h>
+#include <limits.h>
+
/* NOTE: it's strange to be including an architecture specific header
in what's supposed to be general (to PE/PEI) code. However, that's
where the definitions are, and they don't vary per architecture
@@ -873,8 +876,36 @@
H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
/* Only use a real timestamp if the option was chosen. */
- if ((pe_data (abfd)->insert_timestamp))
- H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
+ if (pe_data (abfd)->insert_timestamp) {
+ time_t now;
+ char *source_date_epoch;
+ unsigned long long epoch;
+ char *endptr;
+
+ now = time(NULL);
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch) {
+ errno = 0;
+ epoch = strtoull(source_date_epoch, &endptr, 10);
+ if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
+ || (errno != 0 && epoch == 0)) {
+ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n",
+ strerror(errno));
+ } else if (endptr == source_date_epoch) {
+ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n",
+ endptr);
+ } else if (*endptr != '\0') {
+ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n",
+ endptr);
+ } else if (epoch > ULONG_MAX) {
+ _bfd_error_handler("Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to: %lu but was found to be: %llu\n",
+ ULONG_MAX, epoch);
+ } else {
+ now = epoch;
+ }
+ }
+ H_PUT_32 (abfd, now, filehdr_out->f_timdat);
+ }
PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
filehdr_out->f_symptr);
--- a/upstream/ld/pe-dll.c
+++ b/upstream/ld/pe-dll.c
@@ -26,6 +26,8 @@
#include "filenames.h"
#include "safe-ctype.h"
+#include <errno.h>
+#include <limits.h>
#include <time.h>
#include "ld.h"
@@ -1185,8 +1187,36 @@
memset (edata_d, 0, edata_sz);
- if (pe_data (abfd)->insert_timestamp)
- H_PUT_32 (abfd, time (0), edata_d + 4);
+ if (pe_data (abfd)->insert_timestamp) {
+ time_t now;
+ char *source_date_epoch;
+ unsigned long long epoch;
+ char *endptr;
+
+ now = time(NULL);
+ source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+ if (source_date_epoch) {
+ errno = 0;
+ epoch = strtoull(source_date_epoch, &endptr, 10);
+ if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
+ || (errno != 0 && epoch == 0)) {
+ einfo("Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n",
+ strerror(errno));
+ } else if (endptr == source_date_epoch) {
+ einfo("Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n",
+ endptr);
+ } else if (*endptr != '\0') {
+ einfo("Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n",
+ endptr);
+ } else if (epoch > ULONG_MAX) {
+ einfo("Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to: %lu but was found to be: %llu\n",
+ ULONG_MAX, epoch);
+ } else {
+ now = epoch;
+ }
+ }
+ H_PUT_32 (abfd, now, edata_d + 4);
+ }
if (pe_def_file->version_major != -1)
{
--- a/upstream/ld/emultempl/pe.em
+++ b/upstream/ld/emultempl/pe.em
@@ -307,7 +307,7 @@
OPTION_USE_NUL_PREFIXED_IMPORT_TABLES},
{"no-leading-underscore", no_argument, NULL, OPTION_NO_LEADING_UNDERSCORE},
{"leading-underscore", no_argument, NULL, OPTION_LEADING_UNDERSCORE},
- {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP},
+ {"insert-timestamp", optional_argument, NULL, OPTION_INSERT_TIMESTAMP},
{"no-insert-timestamp", no_argument, NULL, OPTION_NO_INSERT_TIMESTAMP},
#ifdef DLL_SUPPORT
/* getopt allows abbreviations, so we do this to stop it
--- a/upstream/ld/emultempl/pep.em
+++ b/upstream/ld/emultempl/pep.em
@@ -324,7 +324,7 @@
{"no-bind", no_argument, NULL, OPTION_NO_BIND},
{"wdmdriver", no_argument, NULL, OPTION_WDM_DRIVER},
{"tsaware", no_argument, NULL, OPTION_TERMINAL_SERVER_AWARE},
- {"insert-timestamp", no_argument, NULL, OPTION_INSERT_TIMESTAMP},
+ {"insert-timestamp", optional_argument, NULL, OPTION_INSERT_TIMESTAMP},
{"no-insert-timestamp", no_argument, NULL, OPTION_NO_INSERT_TIMESTAMP},
{"build-id", optional_argument, NULL, OPTION_BUILD_ID},
{NULL, no_argument, NULL, 0}
#!/bin/sh
set -e
echo 1 > [% dest_dir %]/[% c('filename') %]
echo Creating [% dest_dir %]/[% c('filename') %]
# vim: filetype=yaml sw=2
filename: '[% sha256(c("pre")).substr(0, 12) %]'
remote_docker: 1
docker_image_prefix: 'tor-messenger_[% GET ENV.RBM_BUILDNAME ? ENV.RBM_BUILDNAME : ENV.USER ? ENV.USER : c("uid") %]'
docker_save_image: '[% c("docker_image_prefix") %]:[% c("filename") %]'
pkg_type: build
docker_image: '[% c("lsb_release/id").lower %]:[% c("lsb_release/release") %]'
lsb_release:
id: '[% pc(c("origin_project", { no_distro => 1 }), "lsb_release/id", { no_distro => 1 }) %]'
release: '[% pc(c("origin_project", { no_distro => 1 }), "lsb_release/release", { no_distro => 1 }) %]'
codename: '[% pc(c("origin_project", { no_distro => 1 }), "lsb_release/codename", { no_distro => 1 }) %]'
pre: |
#!/bin/sh
# [% c('docker_image') %]
set -e
[% IF c('lsb_release/release') == '14.10' -%]
sed -i 's/archive\.ubuntu\.com/old-releases.ubuntu.com/' /etc/apt/sources.list
[% END -%]
[% IF pc(c('origin_project'), 'var/pre_pkginst') -%]
[% pc(c('origin_project'), 'var/pre_pkginst') %]
[% END -%]
[% IF c('lsb_release/id') == 'Ubuntu' || c('lsb_release/id') == 'Debian' %]
apt-get update -y
apt-get upgrade -y
[% END %]
[%
deps = [];
IF pc(c('origin_project'), 'var/deps');
CALL deps.import(pc(c('origin_project'), 'var/deps').sort);
END;
IF pc(c('origin_project'), 'var/arch_deps');
CALL deps.import(pc(c('origin_project'), 'var/arch_deps').sort);
END;
IF deps.size;
FOREACH pkg IN deps;
SET p = tmpl(pkg);
IF p;
GET c('install_package', { pkg_name => p });
GET "\n";
END;
END;
END;
-%]
[% IF pc(c('origin_project'), 'var/post_pkginst') -%]
[% pc(c('origin_project'), 'var/post_pkginst') %]
[% END -%]
#!/bin/sh
set -e
distdir=/var/tmp/dist/[% project %]
mkdir /var/tmp/build
tar -C /var/tmp/build -xf [% project %]-[% c("version") %].tar.bz2
cd /var/tmp/build/[% project %]-[% c("version") %]
./configure --prefix=$distdir [% c("var/configure_opt") %]
make -j4
make install
cd /var/tmp/dist
[% c('tar', {
tar_src => [ project ],
tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
}) %]
# vim: filetype=yaml sw=2
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
version: 5.1.0
remote_docker: 1
var:
configure_opt: --enable-multilib --enable-languages=c,c++ --with-arch_32=i686
deps:
- build-essential
- libmpc-dev
- libc6-dev-i386
setup: |
mkdir -p /var/tmp/dist
tar -C /var/tmp/dist -xf [% c("compiler_tarfile") %]
export PATH="/var/tmp/dist/gcc/bin:$PATH"
[% IF c("var/osname") == "linux-i686" -%]
export LD_LIBRARY_PATH=/var/tmp/dist/gcc/lib32
[% ELSE -%]
export LD_LIBRARY_PATH=/var/tmp/dist/gcc/lib64
[% END -%]
targets:
osx-x86_64:
var:
configure_opt: --enable-multilib --enable-languages=c,c++
input_files:
- URL: 'https://ftp.gnu.org/gnu/gcc/gcc-[% c("version") %]/gcc-[% c("version") %].tar.bz2'
sha256sum: b7dafdf89cbb0e20333dbf5b5349319ae06e3d1a30bf3515b5488f7e89dca5ad
- project: docker-image
#!/bin/sh
set -e
distdir=$(pwd)/dist
mkdir -p $distdir/[% project %]
tar xf [% project %]-[% c('version') %].tar.gz
cd [% project %]-[% c('version') %]
patch -p1 < ../libdmg.patch
cmake -DCMAKE_INSTALL_PREFIX:PATH=$distdir/[% project %] CMakeLists.txt
cd dmg
make -j4
make install
cd $distdir
[% c('tar', {
tar_src => [ project ],
tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'),
}) %]
# vim: filetype=yaml sw=2
version: '[% c("abbrev") %]'
git_url: https://github.com/vasi/libdmg-hfsplus
git_hash: dfd5e5cc3dc1191e37d3c3a6118975afdd1d7014
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
remote_docker: 1
var:
deps:
- build-essential
- cmake
- zlib1g-dev
- libbz2-dev
input_files:
- filename: libdmg.patch
- project: docker-image
From d1a5eca891f32103ccda80ee75e158dfc7ece70d Mon Sep 17 00:00:00 2001
From: Mike Perry <mikeperry-git@torproject.org>
Date: Thu, 6 Mar 2014 19:47:05 -0800
Subject: [PATCH] Memset a UDIF header to ensure archive reproducibility.
Some of the struct padding and fields contained unitialized memory, which
caused two successive invocations to produce archives that differed in some
bytes.
---
dmg/dmglib.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dmg/dmglib.c b/dmg/dmglib.c
index f481b1f..b74e50b 100644
--- a/dmg/dmglib.c
+++ b/dmg/dmglib.c
@@ -108,7 +108,8 @@ int buildDmg(AbstractFile* abstractIn, AbstractFile* abstractOut) {
ChecksumToken dataForkToken;
UDIFResourceFile koly;
-
+ memset(&koly, 0, sizeof(koly));
+
off_t plistOffset;
uint32_t plistSize;
uint32_t dataForkChecksum;
@@ -284,7 +285,8 @@ int convertToDMG(AbstractFile* abstractIn, AbstractFile* abstractOut) {
uint64_t numSectors;
UDIFResourceFile koly;
-
+ memset(&koly, 0, sizeof(koly));
+
char partitionName[512];
off_t fileLength;
--
1.8.1.2
#!/bin/sh
set -e
rootdir=$(pwd)
distdir=/var/tmp/dist/[% project %]
mkdir /var/tmp/build
mkdir /var/tmp/dist
cd /var/tmp/dist
tar xf $rootdir/[% c('input_files_by_name/binutils') %]
mv binutils $distdir
export PATH="$distdir/bin:$PATH"
cd /var/tmp/build
tar xf $rootdir/[% project %]-[% c("version") %].tar.gz
mkdir -p builddir/mingw-w64/mingw-w64-headers32
cd builddir/mingw-w64/mingw-w64-headers32
/var/tmp/build/[% project %]-[% c("version") %]/mingw-w64-headers/configure \
--prefix=$distdir/i686-w64-mingw32 --host=i686-w64-mingw32 \
--enable-sdk=all --enable-secure-api --enable-idl
make install
cd /var/tmp/build
mkdir gcc
cd gcc
tar xjf $rootdir/gcc-[% c("var/gcc_version") %].tar.bz2
# We don't want to link against msvcrt.dll due to bug 9084.
i686-w64-mingw32-g++ -dumpspecs > $distdir/msvcr100.spec
sed 's/msvcrt/msvcr100/' -i $distdir/msvcr100.spec
# Linking libgcc against msvcrt is hard-coded...
sed 's/msvcrt/msvcr100/' -i gcc-[% c("var/gcc_version") %]/gcc/config/i386/t-mingw-w32
# LDFLAGS_FOR_TARGET does not work for some reason. Thus, we take
# CFLAGS_FOR_TARGET.
export CFLAGS_FOR_TARGET="-specs=$distdir/msvcr100.spec -Wl,--nxcompat -Wl,--dynamicbase"
gcc-[% c("var/gcc_version") %]/configure --prefix=$distdir --target=i686-w64-mingw32 --disable-multilib --enable-languages=c,c++
make -j4 all-gcc
make install-gcc
mkdir -p /var/tmp/build/builddir/mingw-w64/mingw-w64-crt32
cd /var/tmp/build/builddir/mingw-w64/mingw-w64-crt32
/var/tmp/build/[% project %]-[% c("version") %]/mingw-w64-crt/configure \
--host=i686-w64-mingw32 --prefix=$distdir/i686-w64-mingw32
make -j4
make install
mkdir -p /var/tmp/build/builddir/mingw-w64/widl32
cd /var/tmp/build/builddir/mingw-w64/widl32
/var/tmp/build/[% project %]-[% c("version") %]/mingw-w64-tools/widl/configure \
--prefix=$distdir --target=i686-w64-mingw32
make -j4
make install