From afc81e5cb09219770a8a5b8cd2855b45ece0a42a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 23 Feb 2011 11:57:17 +0200 Subject: Add build scripts for Windows binary --- binary/mingw/binutils-configure | 11 ++ binary/mingw/build-dist | 252 +++++++++++++++++++++++++++++ binary/mingw/gcc-4.5.1-mingw-cross.patch | 46 ++++++ binary/mingw/gcc-4.5.1-static-plugin.patch | 130 +++++++++++++++ binary/mingw/gcc-configure | 28 ++++ binary/mingw/libcutl-configure | 9 ++ binary/mingw/libodb-boost-configure | 10 ++ binary/mingw/libodb-configure | 9 ++ binary/mingw/odb-configure | 14 ++ binary/mingw/plugin-stub.c | 4 + 10 files changed, 513 insertions(+) create mode 100755 binary/mingw/binutils-configure create mode 100755 binary/mingw/build-dist create mode 100644 binary/mingw/gcc-4.5.1-mingw-cross.patch create mode 100644 binary/mingw/gcc-4.5.1-static-plugin.patch create mode 100755 binary/mingw/gcc-configure create mode 100755 binary/mingw/libcutl-configure create mode 100755 binary/mingw/libodb-boost-configure create mode 100755 binary/mingw/libodb-configure create mode 100755 binary/mingw/odb-configure create mode 100644 binary/mingw/plugin-stub.c (limited to 'binary') diff --git a/binary/mingw/binutils-configure b/binary/mingw/binutils-configure new file mode 100755 index 0000000..b50606b --- /dev/null +++ b/binary/mingw/binutils-configure @@ -0,0 +1,11 @@ +#! /bin/sh + +../binutils-2.20.51/configure \ +--disable-nls \ +--disable-shared \ +--disable-debug \ +--host i686-mingw32 \ +--target i686-mingw32 \ +--with-sysroot=/mingw \ +--prefix=/mingw \ +CFLAGS=-O2 LDFLAGS=-s diff --git a/binary/mingw/build-dist b/binary/mingw/build-dist new file mode 100755 index 0000000..c5d9968 --- /dev/null +++ b/binary/mingw/build-dist @@ -0,0 +1,252 @@ +#! /usr/bin/env bash + +# Create ODB compiler Windows distribution. +# +# -rebuild +# -pack get the source distributions from /tmp/pack/ +# +trap 'exit 1' ERR + +function error () +{ + echo "$*" 1>&2 +} + +rebuild=n +pack=n + +while [ $# -gt 0 ]; do + case $1 in + -rebuild) + rebuild=y + shift + ;; + -pack) + pack=y + rebuild=y + shift + ;; + *) + error "unknown option: $1" + exit 1 + ;; + esac +done + + +out_root=`pwd` +version=`cat $HOME/work/odb/odb/version` +install_root="/tmp/odb-$version-i686-windows" + +if [ $pack = n ]; then + src_root=$HOME/work +else + src_root=/tmp +fi + +export PATH=$out_root/cross/mingw/bin:$PATH + +# Clean everything up if we are rebuilding. +# +if [ $rebuild = y ]; then + rm -rf /mingw/* + rm -rf libplugin-stub + rm -rf gcc-build/* + rm -rf libcutl + rm -rf libodb + rm -rf libodb-boost + rm -rf odb + rm -rf odb-build/* + rm -rf $install_root + + cp -r mingw-rt/* /mingw/ + # make -C binutils-build install + cp -r mingw-binutils/* /mingw/ +fi + +if [ $pack = n ]; then + rm -f /tmp/odb-$version-i686-windows.zip +else + rm -f /tmp/pack/odb-$version-i686-windows.zip +fi + +# Build libplugin-stub +# +if [ $rebuild = y ]; then + mkdir -p libplugin-stub + cd libplugin-stub + i686-mingw32-gcc -O2 -c ../plugin-stub.c + i686-mingw32-ar cr libplugin-stub.a plugin-stub.o + i686-mingw32-ranlib libplugin-stub.a + cd .. + + mkdir -p gcc-build/gcc + cp libplugin-stub/libplugin-stub.a gcc-build/gcc/ +fi + +# Build libodb +# +if [ $pack = n ]; then + make -C $src_root/odb/libodb dist dist_prefix=$out_root/libodb + + if [ $rebuild = y ]; then + cd libodb + ./bootstrap + cd .. + fi +else + tar xfz $src_root/pack/libodb-$version.tar.gz + mv libodb-$version libodb +fi + +cd libodb + +if [ $rebuild = y ]; then + ../libodb-configure +fi + +make +cd odb +make install-data +cd ../.. + +# Build libodb-boost +# +if [ $pack = n ]; then + make -C $src_root/odb/libodb-boost dist dist_prefix=$out_root/libodb-boost + + if [ $rebuild = y ]; then + cd libodb-boost + ./bootstrap + cd .. + fi +else + tar xfz $src_root/pack/libodb-boost-$version.tar.gz + mv libodb-boost-$version libodb-boost +fi + +cd libodb-boost + +if [ $rebuild = y ]; then + ../libodb-boost-configure +fi + +make +make install-data +cd .. + +# Build libcutl +# +if [ $pack = n ]; then + make -C $src_root/cutl/libcutl dist dist_prefix=$out_root/libcutl + + if [ $rebuild = y ]; then + cd libcutl + ./bootstrap + cd .. + fi +else + cutl_version=`cat $HOME/work/cutl/libcutl/version` + tar xfz $src_root/libcutl-$cutl_version.tar.gz + mv libcutl-$cutl_version libcutl +fi + +cd libcutl + +if [ $rebuild = y ]; then + ../libcutl-configure +fi + +make +cd .. + +# Build odb +# +if [ $pack = n ]; then + make -C $src_root/odb/odb dist dist_prefix=$out_root/odb + + if [ $rebuild = y ]; then + cd odb + ./bootstrap + cd .. + fi +else + tar xfz $src_root/pack/odb-$version.tar.gz + mv odb-$version odb +fi + +mkdir -p odb-build +cd odb-build + +if [ $rebuild = y ]; then + ../odb-configure $version +fi + +make +make install-strip +rm -f $install_root/bin/odb.a +cd .. + +# Build gcc +# +mkdir -p gcc-build +cd gcc-build + +if [ $rebuild = y ]; then + ../gcc-configure +else + rm -f gcc/cc1plus.exe gcc/cc1plus-dummy.exe +fi + +make STATIC_PLUGIN_LIBS="$out_root/odb-build/odb/.libs/odb.a $out_root/libcutl/cutl/.libs/libcutl.a -lstdc++ -static-libgcc" +make install +make -C i686-mingw32/libstdc++-v3 install-strip +cd .. + +# Copy /mingw over to installation +# +cp -r /mingw $install_root/ + +# Move doc and man out of share/ +# +rm -rf $install_root/doc $install_root/man +mv $install_root/share/man $install_root/ +mv $install_root/share/doc/odb $install_root/doc +rm -r $install_root/share + +# Clean some things up. +# +rm -f $install_root/mingw/lib/libbfd.* +rm -f $install_root/mingw/include/bfd*.h +rm -f $install_root/mingw/lib/libopcodes.* +rm -f $install_root/mingw/lib/libiberty.a +rm -f `find $install_root -name '*.la'` + +# Copy msys over to installation. +# +cp -r msys/* $install_root/mingw/ + +# Copy the default options file. +# +mkdir -p $install_root/etc/odb +cp -L default.options $install_root/etc/odb/ +todos $install_root/etc/odb/default.options + +# Copy manifest. +# +cp -L manifest.txt $install_root/mingw/ +todos $install_root/mingw/manifest.txt + +# Copy README. +# +cp -L README $install_root/README +todos $install_root/README + +# Zip it up. +# +cd /tmp +zip -r odb-$version-i686-windows.zip odb-$version-i686-windows +if [ $pack = y ]; then + mv odb-$version-i686-windows.zip pack/ +fi +cd $out_root diff --git a/binary/mingw/gcc-4.5.1-mingw-cross.patch b/binary/mingw/gcc-4.5.1-mingw-cross.patch new file mode 100644 index 0000000..d63f04b --- /dev/null +++ b/binary/mingw/gcc-4.5.1-mingw-cross.patch @@ -0,0 +1,46 @@ +diff -ru gcc-4.5.1.orig/gcc/config/i386/mingw32.h gcc-4.5.1/gcc/config/i386/mingw32.h +--- gcc-4.5.1.orig/gcc/config/i386/mingw32.h 2010-04-27 22:14:19.000000000 +0200 ++++ gcc-4.5.1/gcc/config/i386/mingw32.h 2010-09-01 16:56:49.000000000 +0200 +@@ -66,7 +66,7 @@ + /* Override the standard choice of /usr/include as the default prefix + to try when searching for header files. */ + #undef STANDARD_INCLUDE_DIR +-#define STANDARD_INCLUDE_DIR "/mingw/include" ++#define STANDARD_INCLUDE_DIR "/include" + #undef STANDARD_INCLUDE_COMPONENT + #define STANDARD_INCLUDE_COMPONENT "MINGW" + +diff -ru gcc-4.5.1.orig/gcc/config/i386/t-mingw32 gcc-4.5.1/gcc/config/i386/t-mingw32 +--- gcc-4.5.1.orig/gcc/config/i386/t-mingw32 2008-09-04 10:25:25.000000000 +0200 ++++ gcc-4.5.1/gcc/config/i386/t-mingw32 2010-09-01 16:26:49.000000000 +0200 +@@ -1,5 +1,5 @@ + # Match SYSTEM_INCLUDE_DIR +-NATIVE_SYSTEM_HEADER_DIR = /mingw/include ++NATIVE_SYSTEM_HEADER_DIR = /include + + # MinGW-specific parts of LIB_SPEC + SHLIB_LC = -lmingw32 -lmingwex -lmoldname -lmsvcrt -luser32 -lkernel32 -ladvapi32 -lshell32 +diff -ru gcc-4.5.1.orig/libstdc++-v3/include/Makefile.am gcc-4.5.1/libstdc++-v3/include/Makefile.am +--- gcc-4.5.1.orig/libstdc++-v3/include/Makefile.am 2010-02-10 21:14:33.000000000 +0200 ++++ gcc-4.5.1/libstdc++-v3/include/Makefile.am 2010-09-02 10:19:37.000000000 +0200 +@@ -893,7 +893,7 @@ + ${pch1_output_builddir} ${pch2_output_builddir} ${pch3_output_builddir} + pch_output_anchors = \ + ${pch1_output_anchor} ${pch2_output_anchor} ${pch3_output_anchor} +-PCHFLAGS=-x c++-header $(CXXFLAGS) ++PCHFLAGS=-nostdinc++ -x c++-header $(CXXFLAGS) + if GLIBCXX_BUILD_PCH + pch_build = ${pch_output} + else +diff -ru gcc-4.5.1.orig/libstdc++-v3/include/Makefile.in gcc-4.5.1/libstdc++-v3/include/Makefile.in +--- gcc-4.5.1.orig/libstdc++-v3/include/Makefile.in 2010-04-02 20:18:06.000000000 +0200 ++++ gcc-4.5.1/libstdc++-v3/include/Makefile.in 2010-09-02 10:26:05.000000000 +0200 +@@ -1119,7 +1119,7 @@ + pch_output_anchors = \ + ${pch1_output_anchor} ${pch2_output_anchor} ${pch3_output_anchor} + +-PCHFLAGS = -x c++-header $(CXXFLAGS) ++PCHFLAGS = -nostdinc++ -x c++-header $(CXXFLAGS) + @GLIBCXX_BUILD_PCH_FALSE@pch_build = + @GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_output} + diff --git a/binary/mingw/gcc-4.5.1-static-plugin.patch b/binary/mingw/gcc-4.5.1-static-plugin.patch new file mode 100644 index 0000000..9e5ee7f --- /dev/null +++ b/binary/mingw/gcc-4.5.1-static-plugin.patch @@ -0,0 +1,130 @@ +diff -rubB gcc-4.5.1.orig/gcc/config.in gcc-4.5.1/gcc/config.in +--- gcc-4.5.1.orig/gcc/config.in 2010-07-31 11:34:58.000000000 +0200 ++++ gcc-4.5.1/gcc/config.in 2010-09-02 11:44:15.000000000 +0200 +@@ -131,6 +131,10 @@ + #undef ENABLE_PLUGIN + #endif + ++/* Define to enable static plugin support. */ ++#ifndef USED_FOR_TARGET ++#undef ENABLE_STATIC_PLUGIN ++#endif + + /* Define if you want all operations on RTL (the basic data structure of the + optimizer and back end) to be checked for dynamic type safety at runtime. +diff -rubB gcc-4.5.1.orig/gcc/configure.ac gcc-4.5.1/gcc/configure.ac +--- gcc-4.5.1.orig/gcc/configure.ac 2010-06-14 12:38:18.000000000 +0200 ++++ gcc-4.5.1/gcc/configure.ac 2010-09-02 11:43:40.000000000 +0200 +@@ -4600,6 +4600,15 @@ + AC_DEFINE(ENABLE_PLUGIN, 1, [Define to enable plugin support.]) + fi + ++AC_ARG_ENABLE(static-plugin, ++[ --enable-static-plugin enable static plugin support], ++enable_static_plugin=$enableval, ++enable_static_plugin==no) ++ ++if test x"$enable_static_plugin" = x"yes"; then ++ AC_DEFINE(ENABLE_STATIC_PLUGIN, 1, [Define to enable static plugin support.]) ++fi ++ + # Configure the subdirectories + # AC_CONFIG_SUBDIRS($subdirs) + +diff -rubB gcc-4.5.1.orig/gcc/cp/Make-lang.in gcc-4.5.1/gcc/cp/Make-lang.in +--- gcc-4.5.1.orig/gcc/cp/Make-lang.in 2010-04-02 21:54:46.000000000 +0200 ++++ gcc-4.5.1/gcc/cp/Make-lang.in 2010-09-02 12:37:02.000000000 +0200 +@@ -94,7 +94,8 @@ + + cc1plus-dummy$(exeext): $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBDEPS) + $(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +- $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS) ++ $(CXX_OBJS) dummy-checksum.o $(BACKEND) $(STATIC_PLUGIN_LIBS) \ ++ $(LIBS) $(BACKENDLIBS) + + cc1plus-checksum.c : cc1plus-dummy$(exeext) build/genchecksum$(build_exeext) + build/genchecksum$(build_exeext) cc1plus-dummy$(exeext) > $@ +@@ -103,7 +104,8 @@ + + cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS) + $(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +- $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS) ++ $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(STATIC_PLUGIN_LIBS) \ ++ $(LIBS) $(BACKENDLIBS) + + # Special build rules. + $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf +diff -rubB gcc-4.5.1.orig/gcc/opts.c gcc-4.5.1/gcc/opts.c +--- gcc-4.5.1.orig/gcc/opts.c 2010-05-17 12:13:28.000000000 +0200 ++++ gcc-4.5.1/gcc/opts.c 2010-09-02 11:31:24.000000000 +0200 +@@ -1829,7 +1829,7 @@ + break; + + case OPT_fplugin_: +-#ifdef ENABLE_PLUGIN ++#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) + add_new_plugin (arg); + #else + error ("Plugin support is disabled. Configure with --enable-plugin."); +@@ -1837,7 +1837,7 @@ + break; + + case OPT_fplugin_arg_: +-#ifdef ENABLE_PLUGIN ++#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) + parse_plugin_arg_opt (arg); + #else + error ("Plugin support is disabled. Configure with --enable-plugin."); +diff -rubB gcc-4.5.1.orig/gcc/plugin.c gcc-4.5.1/gcc/plugin.c +--- gcc-4.5.1.orig/gcc/plugin.c 2009-12-21 22:37:49.000000000 +0200 ++++ gcc-4.5.1/gcc/plugin.c 2010-09-02 11:36:53.000000000 +0200 +@@ -40,7 +40,7 @@ + #include "timevar.h" + #include "ggc.h" + +-#ifdef ENABLE_PLUGIN ++#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) + #include "plugin-version.h" + #endif + +@@ -602,8 +602,31 @@ + return 1; + } + ++#elif defined(ENABLE_STATIC_PLUGIN) ++ ++extern int ++plugin_init (struct plugin_name_args*, struct plugin_gcc_version*); ++ ++static int ++init_one_plugin (void **slot, void * ARG_UNUSED (info)) ++{ ++ struct plugin_name_args *plugin = (struct plugin_name_args *) *slot; ++ ++ /* Call the plugin-provided initialization routine with the arguments. */ ++ if (plugin_init (plugin, &gcc_version)) ++ { ++ error ("Fail to initialize plugin %s", plugin->full_name); ++ htab_remove_elt (plugin_name_args_tab, plugin->base_name); ++ XDELETE (plugin); ++ } ++ ++ return 1; ++} ++ + #endif /* ENABLE_PLUGIN */ + ++ ++ + /* Main plugin initialization function. Called from compile_file() in + toplev.c. */ + +@@ -616,7 +639,7 @@ + + timevar_push (TV_PLUGIN_INIT); + +-#ifdef ENABLE_PLUGIN ++#if defined(ENABLE_PLUGIN) || defined(ENABLE_STATIC_PLUGIN) + /* Traverse and initialize each plugin specified in the command-line. */ + htab_traverse_noresize (plugin_name_args_tab, init_one_plugin, NULL); + #endif diff --git a/binary/mingw/gcc-configure b/binary/mingw/gcc-configure new file mode 100755 index 0000000..548ca30 --- /dev/null +++ b/binary/mingw/gcc-configure @@ -0,0 +1,28 @@ +#! /bin/sh + +../gcc-4.5.1/configure \ +--with-pkgversion="ODB special" \ +--with-bugurl="http://www.codesynthesis.com/products/odb/" \ +--enable-threads=win32 \ +--enable-version-specific-runtime-libs \ +--enable-languages=c,c++ \ +--with-dwarf2 \ +--enable-shared \ +--disable-libssp \ +--disable-libgomp \ +--disable-sjlj-exceptions \ +--disable-win32-registry \ +--disable-nls \ +--disable-multilib \ +--disable-libstdcxx-pch \ +--host i686-mingw32 \ +--target i686-mingw32 \ +--with-sysroot=/mingw \ +--prefix=/mingw \ +--enable-static-plugin \ +--with-stage1-libs=libplugin-stub.a \ +CFLAGS=-O2 CXXFLAGS=-O2 LDFLAGS=-s + +# --disable-shared + +#echo 'make STATIC_PLUGIN_LIBS="`pwd`/../odb-build/odb/.libs/odb.a `pwd`/../libcutl/cutl/.libs/libcutl.a -lstdc++"' diff --git a/binary/mingw/libcutl-configure b/binary/mingw/libcutl-configure new file mode 100755 index 0000000..e8202da --- /dev/null +++ b/binary/mingw/libcutl-configure @@ -0,0 +1,9 @@ +#! /bin/sh + +./configure \ +--disable-shared \ +--enable-static \ +--host i686-mingw32 \ +--target i686-mingw32 \ +--prefix=/mingw \ +CXXFLAGS="-O2 -W -Wall" diff --git a/binary/mingw/libodb-boost-configure b/binary/mingw/libodb-boost-configure new file mode 100755 index 0000000..ea8dd72 --- /dev/null +++ b/binary/mingw/libodb-boost-configure @@ -0,0 +1,10 @@ +#! /bin/sh + +./configure \ +--disable-shared \ +--enable-static \ +--host i686-mingw32 \ +--target i686-mingw32 \ +--prefix=/mingw \ +--with-libodb=../libodb \ +CXXFLAGS="-O2 -W -Wall" diff --git a/binary/mingw/libodb-configure b/binary/mingw/libodb-configure new file mode 100755 index 0000000..e8202da --- /dev/null +++ b/binary/mingw/libodb-configure @@ -0,0 +1,9 @@ +#! /bin/sh + +./configure \ +--disable-shared \ +--enable-static \ +--host i686-mingw32 \ +--target i686-mingw32 \ +--prefix=/mingw \ +CXXFLAGS="-O2 -W -Wall" diff --git a/binary/mingw/odb-configure b/binary/mingw/odb-configure new file mode 100755 index 0000000..337c98f --- /dev/null +++ b/binary/mingw/odb-configure @@ -0,0 +1,14 @@ +#! /bin/sh + +../odb/configure \ +--disable-shared \ +--enable-static \ +--host i686-mingw32 \ +--target i686-mingw32 \ +--prefix=/tmp/odb-$1-i686-windows \ +--with-libcutl=../libcutl \ +--with-gxx-name='..\\mingw\\bin\\g++.exe' \ +--with-options-file='..\\etc\\odb\\default.options' \ +CPPFLAGS=-I`pwd`/../cross/mingw/include/plugin \ +CXXFLAGS="-O2 -W -Wall" \ +LDFLAGS=-static-libgcc diff --git a/binary/mingw/plugin-stub.c b/binary/mingw/plugin-stub.c new file mode 100644 index 0000000..cb4287d --- /dev/null +++ b/binary/mingw/plugin-stub.c @@ -0,0 +1,4 @@ +int plugin_init (void* args, void* version) +{ + return 1; +} -- cgit v1.1