aboutsummaryrefslogtreecommitdiffstats
path: root/extras/cross-compile-libs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xextras/cross-compile-libs214
1 files changed, 214 insertions, 0 deletions
diff --git a/extras/cross-compile-libs b/extras/cross-compile-libs
new file mode 100755
index 0000000..984c597
--- /dev/null
+++ b/extras/cross-compile-libs
@@ -0,0 +1,214 @@
+#!/bin/bash
+#
+# cross-compile win32 libraries for syslog-win32
+# on exit libraries are in cross-libs directory
+#
+# required environment variables: DISTFILES
+# honoured environment variables: CFLAGS, HOST
+#
+
+#
+# define distfiles
+#
+libiconv=libiconv-1.9.2.tar.gz
+gettext=gettext-0.14.1.tar.gz
+zlib=zlib-1.2.2.tar.bz2
+regex=regex-0.12.tar.gz
+glib=glib-2.6.3.tar.bz2
+
+function distfiles()
+{
+ echo $libiconv
+ echo $gettext
+ echo $zlib
+ echo $regex
+ echo $glib
+}
+
+#
+# check DISTFILES and distfiles
+#
+if [ -z "$DISTFILES" ] ; then
+ echo "You should specify location of source tarballs with the help of DISTFILES environment variable"
+ exit 1
+fi
+
+for file in `distfiles` ; do
+ if [ -f "$DISTFILES"/$file ] ; then continue ; fi
+ echo $file not found
+ exit 1
+done
+
+#
+# set environment variables if not set yet
+#
+if [ -z "$CFLAGS" ] ; then
+ export CFLAGS="-Os -g"
+fi
+
+if [ -z "$HOST" ] ; then
+ export HOST=i686-pc-mingw32
+fi
+
+#
+# a wrapper for subsequent commands
+#
+function run()
+{
+ echo "$@"
+ "$@" || exit 1
+}
+
+#
+# unpack routine
+#
+function unpack_tarball()
+{
+ if [[ zip == ${1:(-3)} ]] ; then
+ run unzip "$1"
+ else
+ if [[ bz2 == ${1:(-3)} ]] ; then arch=j
+ elif [[ gz == ${1:(-2)} ]] ; then arch=z
+ elif [[ tar == ${1:(-3)} ]] ; then arch=
+ else
+ echo "Unknown distfile type"
+ exit 1
+ fi
+ run tar -x${arch}f "$1"
+ fi
+}
+
+#
+# create build directories
+#
+export PREFIX=`pwd`/cross-libs
+run mkdir -p cross-libs
+run mkdir -p cross-build
+run pushd cross-build
+
+#
+# build libiconv
+#
+unpack_tarball "$DISTFILES"/$libiconv
+run pushd libiconv*
+run ./configure --prefix="$PREFIX" --host=$HOST --disable-nls
+run make
+run make install
+run popd
+run rm -Rf libiconv*
+
+#
+# build gettext
+#
+unpack_tarball "$DISTFILES"/$gettext
+run pushd gettext*/gettext-runtime
+CPPFLAGS=-I"$PREFIX"/include LDFLAGS=-L"$PREFIX"/lib \
+run ./configure --prefix="$PREFIX" --host=$HOST --enable-relocatable --with-libiconv-prefix="$PREFIX"
+run make
+run make install
+run popd
+run rm -Rf gettext*
+
+#
+# build zlib
+# TO DO: use original makefile; dllname must be like in official windoze distro
+#
+unpack_tarball "$DISTFILES"/$zlib
+run pushd zlib*
+cat >configure.ac <<EOF
+AC_INIT(zlib,1.2.2)
+AM_INIT_AUTOMAKE
+AC_CANONICAL_HOST
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AC_OUTPUT(Makefile)
+EOF
+cat >Makefile.am <<EOF
+lib_LTLIBRARIES = libz.la
+libz_la_SOURCES = adler32.c compress.c crc32.c deflate.c gzio.c \
+ infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c
+include_HEADERS = zlib.h
+libz_la_LDFLAGS = -no-undefined -release 1
+EOF
+run aclocal
+run libtoolize
+run autoconf
+run automake --foreign --add-missing
+run ./configure --prefix="$PREFIX" --host=$HOST
+run make
+run make install
+run popd
+run rm -Rf zlib*
+
+#
+# build regex
+# NOT NEEDED
+#
+unpack_tarball "$DISTFILES"/$regex
+run pushd regex*
+cat >configure.ac <<EOF
+AC_INIT(regex,0.12)
+AM_INIT_AUTOMAKE
+AC_CANONICAL_HOST
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AC_OUTPUT(Makefile)
+EOF
+cat >Makefile.am <<EOF
+lib_LTLIBRARIES = libregex.la
+libregex_la_SOURCES = regex.c
+include_HEADERS = regex.h
+libregex_la_LDFLAGS = -no-undefined
+EOF
+run rm -f configure.in
+run aclocal
+run libtoolize
+run autoconf
+run automake --foreign --add-missing
+run ./configure --prefix="$PREFIX" --host=$HOST
+run make
+run make install
+run popd
+run rm -Rf regex*
+
+#
+# build glib
+#
+unpack_tarball "$DISTFILES"/$glib
+run pushd glib*
+#
+# according to glib documentation, win32.cache is needed to skip tests that cannot be run in cross-compile environment
+#
+cat >win32.cache <<EOF
+glib_cv_long_long_format=I64
+glib_cv_stack_grows=no
+EOF
+run chmod a-w win32.cache
+#
+# remove policy that does not allow us to build static library for win32
+#
+run patch -Np1 -i ../../glib-static-win32.patch
+run aclocal --force
+run libtoolize --force
+run autoconf --force
+run automake --foreign --add-missing --force
+OBJDUMP=$HOST-objdump CFLAGS='-Os -g' \
+CPPFLAGS=-I"$PREFIX"/include \
+LDFLAGS=-L"$PREFIX"/lib \
+run ./configure --prefix="$PREFIX" --host=$HOST --with-libintl --disable-gtk-doc --cache-file=win32.cache --enable-static
+WINDRES=$HOST-windres run make
+run make install
+run popd
+run rm -Rf glib*
+#
+# explanations:
+# - setting OBJDUMP is required for libtool's file format checking
+# - WINDRES is required for resource compiling
+#
+
+#
+# strip libraries and cleanup
+#
+run popd
+$HOST-strip -s cross-libs/bin/*
+run rmdir cross-build