Windows cross compilation scripts

* redo the cross compilation script in such a way that it'll also automatically fetch (wget) and build the dependencies
  - Currently only building of popt, gettext, zlib and png is implemented

git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8821 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2009-12-21 22:04:24 +00:00 committed by Git SVN Gateway
parent 9876e857cc
commit 115d2bfd2c
11 changed files with 457 additions and 65 deletions

16
.gitignore vendored
View File

@ -32,9 +32,21 @@
/devpkg/*
build_tools/autorevision/Debug/*
build_tools/autorevision/Release/*
win32/debug/*
win32/release/*
win32/debug
win32/release
# directories and files created when crosscompiling or Windows
win32/build
win32/downloads
win32/libs/gettext/extract-stamp
win32/libs/gettext/gettext-0.17
win32/libs/png/extract-stamp
win32/libs/png/libpng-1.2.36
win32/libs/popt/extract-stamp
win32/libs/popt/patch-stamp
win32/libs/popt/popt-1.12
win32/libs/zlib/extract-stamp
win32/libs/zlib/zlib-1.2.3
# Autogenerated files:
*.lex.[ch]

169
build_tools/download.pl Executable file
View File

@ -0,0 +1,169 @@
#!/usr/bin/env perl
#
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /COPYING for more information.
#
use strict;
use warnings;
use File::Basename;
@ARGV > 2 or die "Syntax: $0 <target dir> <filename> <md5sum> [<mirror> ...]\n";
my $target = shift @ARGV;
my $filename = shift @ARGV;
my $md5sum = shift @ARGV;
my $scriptdir = dirname($0);
my @mirrors;
my $ok;
sub localmirrors {
my @mlist;
open LM, "$scriptdir/localmirrors" and do {
while (<LM>) {
chomp $_;
push @mlist, $_;
}
close LM;
};
open CONFIG, "<".$ENV{'TOPDIR'}."/.config" and do {
while (<CONFIG>) {
/^CONFIG_LOCALMIRROR="(.+)"/ and do {
chomp;
push @mlist, $1;
};
}
close CONFIG;
};
return @mlist;
}
sub which($) {
my $prog = shift;
my $res = `which $prog`;
$res or return undef;
$res =~ /^no / and return undef;
$res =~ /not found/ and return undef;
return $res;
}
my $md5cmd = which("md5sum");
$md5cmd or $md5cmd = which("md5");
$md5cmd or die 'no md5 checksum program found, please install md5 or md5sum';
chomp $md5cmd;
sub download
{
my $mirror = shift;
my $options = $ENV{WGET_OPTIONS};
$options or $options = "";
$mirror =~ s/\/$//;
if( $mirror =~ /^file:\/\// ) {
my $cache = $mirror;
$cache =~ s/file:\/\///g;
print "Checking local cache: $cache\n";
system("mkdir -p $target/");
system("cp -f $cache/$filename $target/$filename.dl") == 0 or return;
system("$md5cmd $target/$filename.dl > \"$target/$filename.md5sum\" ") == 0 or return;
} else {
open WGET, "wget -t5 --timeout=20 $options -O- \"$mirror/$filename\" |" or die "Cannot launch wget.\n";
open MD5SUM, "| $md5cmd > \"$target/$filename.md5sum\"" or die "Cannot launch md5sum.\n";
open OUTPUT, "> $target/$filename.dl" or die "Cannot create file $target/$filename.dl: $!\n";
my $buffer;
while (read WGET, $buffer, 1048576) {
print MD5SUM $buffer;
print OUTPUT $buffer;
}
close MD5SUM;
close WGET;
close OUTPUT;
if (($? >> 8) != 0 ) {
print STDERR "Download failed.\n";
cleanup();
return;
}
}
my $sum = `cat "$target/$filename.md5sum"`;
$sum =~ /^(\w+)\s*/ or die "Could not generate md5sum\n";
$sum = $1;
if (($md5sum =~ /\w{32}/) and ($sum ne $md5sum)) {
print STDERR "MD5 sum of the downloaded file does not match (file: $sum, requested: $md5sum) - deleting download.\n";
cleanup();
return;
}
unlink "$target/$filename";
system("mv \"$target/$filename.dl\" \"$target/$filename\"");
cleanup();
}
sub cleanup
{
unlink "$target/$filename.dl";
unlink "$target/$filename.md5sum";
}
@mirrors = localmirrors();
foreach my $mirror (@ARGV) {
if ($mirror =~ /^\@SF\/(.+)$/) {
# give sourceforge a few more tries, because it redirects to different mirrors
for (1 .. 5) {
push @mirrors, "http://downloads.sourceforge.net/$1";
}
} elsif ($mirror =~ /^\@GNU\/(.+)$/) {
push @mirrors, "ftp://ftp.gnu.org/gnu/$1";
push @mirrors, "ftp://ftp.belnet.be/mirror/ftp.gnu.org/gnu/$1";
push @mirrors, "ftp://ftp.mirror.nl/pub/mirror/gnu/$1";
push @mirrors, "http://mirror.switch.ch/ftp/mirror/gnu/$1";
push @mirrors, "ftp://ftp.uu.net/archive/systems/gnu/$1";
push @mirrors, "ftp://ftp.eu.uu.net/pub/gnu/$1";
push @mirrors, "ftp://ftp.leo.org/pub/comp/os/unix/gnu/$1";
push @mirrors, "ftp://ftp.digex.net/pub/gnu/$1";
} elsif ($mirror =~ /^\@KERNEL\/(.+)$/) {
push @mirrors, "ftp://ftp.all.kernel.org/pub/$1";
push @mirrors, "http://ftp.all.kernel.org/pub/$1";
push @mirrors, "ftp://ftp.de.kernel.org/pub/$1";
push @mirrors, "http://ftp.de.kernel.org/pub/$1";
push @mirrors, "ftp://ftp.fr.kernel.org/pub/$1";
push @mirrors, "http://ftp.fr.kernel.org/pub/$1";
} elsif ($mirror =~ /^\@GNOME\/(.+)$/) {
push @mirrors, "http://ftp.gnome.org/pub/GNOME/sources/$1";
push @mirrors, "http://ftp.unina.it/pub/linux/GNOME/sources/$1";
push @mirrors, "http://fr2.rpmfind.net/linux/gnome.org/sources/$1";
push @mirrors, "ftp://ftp.dit.upm.es/pub/GNOME/sources/$1";
push @mirrors, "ftp://ftp.no.gnome.org/pub/GNOME/sources/$1";
push @mirrors, "http://ftp.acc.umu.se/pub/GNOME/sources/$1";
push @mirrors, "http://ftp.belnet.be/mirror/ftp.gnome.org/sources/$1";
push @mirrors, "http://linorg.usp.br/gnome/sources/$1";
push @mirrors, "http://mirror.aarnet.edu.au/pub/GNOME/sources/$1";
push @mirrors, "http://mirrors.ibiblio.org/pub/mirrors/gnome/sources/$1";
push @mirrors, "ftp://ftp.cse.buffalo.edu/pub/Gnome/sources/$1";
push @mirrors, "ftp://ftp.nara.wide.ad.jp/pub/X11/GNOME/sources/$1";
}
else {
push @mirrors, $mirror;
}
}
#push @mirrors, 'http://mirror1.openwrt.org';
push @mirrors, 'http://mirror2.openwrt.org/sources';
push @mirrors, 'http://downloads.openwrt.org/sources';
while (!$ok) {
my $mirror = shift @mirrors;
$mirror or die "No more mirrors to try - giving up.\n";
download($mirror);
-f "$target/$filename" and $ok = 1;
}
$SIG{INT} = \&cleanup;

View File

@ -1,25 +0,0 @@
#!/bin/sh
if [ -f __BUILD_CONFIG.USER ]; then
. __BUILD_CONFIG.USER
fi
if test "x$PREFIX" = "x"; then
PREFIX="${HOME}/svn/warzone/devpkg-2.1"
fi
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
PATH="${PREFIX}/bin:${PATH}"
__BOTHFLAGS="-pipe -m32 -march=i686 -O2 -g"
CFLAGS="${__BOTHFLAGS} ${CFLAGS}"
CXXFLAGS="${__BOTHFLAGS} ${CXXFLAGS}"
CPPFLAGS="${CPPFLAGS} -I${PREFIX}/include"
LDFLAGS="${LDFLAGS} -L${PREFIX}/lib"
if test "x$INSTALLER_VERSION" = "x"; then
INSTALLER_VERSION="2.0.8.0"
fi
if test "x$CROSSCOMPILETARGET" = "x"; then
CROSSCOMPILETARGET=mingw32
fi

View File

@ -1,46 +1,110 @@
#!/bin/bash
#!/bin/sh -e
source __BUILD_CONFIG
cd "`dirname "$0"`"
##
# Function that provides make-like behaviour for executed commands. It prints
# the commandline used to execute them before execution.
##
execute()
{
local r
echo "$@"
"$@"
}
# Some default configuration settings
HOST_TRIPLET=mingw32
INSTALLER_VERSION="2.0.8.0"
DEBUGFLAG="--disable-debug"
SPECIALFLAGS=""
CC_FOR_BUILD="gcc"
CXX_FOR_BUILD="g++"
CFLAGS_FOR_BUILD=" "
CXXFLAGS_FOR_BUILD=" "
CPPFLAGS_FOR_BUILD=" "
PREFIX="${HOME}/svn/warzone/devpkg-2.1"
for i in $@; do
if [[ "x$i" = "xdebug" ]] ; then
DEBUGFLAG="--enable-debug"
elif [[ "x$i" = "xdebug-relaxed" ]] ; then
DEBUGFLAG="--enable-debug=relaxed"
elif [[ "x$i" = "xinstaller" ]] ; then
SPECIALFLAGS="${SPECIALFLAGS}
--enable-data --enable-installer --with-installer-extdir=\"${PREFIX}\"
--with-installer-version=${INSTALLER_VERSION}"
elif [[ "x$i" = "x-j3" ]] ; then
MAKE_FLAGS="-j3"
else
CONF_EXTRA_FLAGS="${CONF_EXTRA_FLAGS}
${i}"
fi
__BOTHFLAGS="-pipe -m32 -march=i686 -O2 -g"
CFLAGS="${__BOTHFLAGS} ${CFLAGS}"
CXXFLAGS="${__BOTHFLAGS} ${CXXFLAGS}"
unset __BOTHFLAGS
if [ -f __BUILD_CONFIG.USER ]; then
source __BUILD_CONFIG.USER
fi
for arg in "$@"; do
case "$arg" in
*=*) val=`expr "X$arg" : '[^=]*=\(.*\)'` ;;
*) val=yes ;;
esac
case "$arg" in
--enable-debug* | --disable-debug)
unset DEBUGFLAG
;;
--enable-installer | --enable-installer=yes)
INSTALLERFLAG="--enable-data --enable-installer ${PREFIX:+--with-installer-extdir=\"$PREFIX\"}
${INSTALLER_VERSION:+--with-installer-version=$INSTALLER_VERSION}"
;;
-with-* | --with-* | -enable-* | --enable-*)
;;
*=*)
var=`expr "x$arg" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
expr "x$var" : ".*[^_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]" >/dev/null && {
echo "$0: error: invalid variable name: $var" >&2
exit 1
}
eval $var=\$val
export $var
;;
*)
echo "$0: error: unknown command line option: $arg" >&2
exit 1
;;
esac
done
CONF_EXTRA_FLAGS="${DEBUGFLAG}
${SPECIALFLAGS}
${CONF_EXTRA_FLAGS}"
PATH="${PREFIX}/bin:${PATH}"
if [ -z "$PKG_CONFIG_PATH" ] ; then
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
fi
if [ -n "$PREFIX" ] ; then
CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }-I${PREFIX}/include"
LDFLAGS="${LDFLAGS:+$LDFLAGS }-L${PREFIX}/lib"
fi
export PATH
export PKG_CONFIG_PATH
# Move to the root directory
cd ..
if [ -f "/proc/cpuinfo" ] ; then
MAKE_FLAGS=-j$((`grep '^processor' /proc/cpuinfo | wc -l` + 1))
fi
./autogen.sh || exit 1
./configure --target=${CROSSCOMPILETARGET} --host=${CROSSCOMPILETARGET} --enable-static --disable-shared \
--prefix="${PREFIX}" \
${CONF_EXTRA_FLAGS} \
CFLAGS="${CFLAGS}" \
CXXFLAGS="${CXXFLAGS}" \
CPPFLAGS="${CPPFLAGS}" \
LDFLAGS="${LDFLAGS}" \
CC_FOR_BUILD="gcc" \
CXX_FOR_BUILD="g++" \
CFLAGS_FOR_BUILD=" " \
CXXFLAGS_FOR_BUILD=" " \
CPPFLAGS_FOR_BUILD=" " \
PKGCONFIG_PREFIX="${PREFIX}" || exit 1
make ${MAKE_FLAGS} || exit 1
# Make sure we've got a build directory
if [ ! -d build ] ; then
mkdir build
fi
# Make sure that the dependencies have been built
execute make $MAKE_FLAGS -C libs "HOST_TRIPLET=$HOST_TRIPLET"
cd build
execute ../../autogen.sh
execute ../../configure "--host=$HOST_TRIPLET" --enable-static --disable-shared ${DEBUGFLAG:+$DEBUGFLAG} \
${PREFIX:+--prefix=$PREFIX} \
${INSTALLERFLAG:+$INSTALLERFLAG} \
CFLAGS="$CFLAGS" \
CXXFLAGS="$CXXFLAGS" \
CPPFLAGS="-I$PWD/libs/include $CPPFLAGS" \
LDFLAGS="-L$PWD/libs/lib $LDFLAGS" \
CC_FOR_BUILD="$CC_FOR_BUILD" \
CXX_FOR_BUILD="$CXX_FOR_BUILD" \
CFLAGS_FOR_BUILD="$CFLAGS_FOR_BUILD" \
CXXFLAGS_FOR_BUILD="$CXXFLAGS_FOR_BUILD" \
CPPFLAGS_FOR_BUILD="$CPPFLAGS_FOR_BUILD" \
PKGCONFIG_PREFIX="${PKGCONFIG_PREFIX:-$PREFIX}" \
"$@"
execute make $MAKE_FLAGS

23
win32/libs/Makefile Normal file
View File

@ -0,0 +1,23 @@
SUBDIRS=popt gettext zlib png
all: all-recursive
build: build-recursive
clean: clean-recursive
all-recursive:
@list='$(SUBDIRS)'; for subdir in $$list; do \
echo $(MAKE) -C $$subdir TOPDIR=../.. -$(MAKEFLAGS) all ; \
$(MAKE) -C $$subdir TOPDIR=../.. -$(MAKEFLAGS) all || exit; \
done
build-recursive:
@list='$(SUBDIRS)'; for subdir in $$list; do \
echo $(MAKE) -C $$subdir TOPDIR=../.. -$(MAKEFLAGS) build ; \
$(MAKE) -C $$subdir TOPDIR=../.. -$(MAKEFLAGS) build || exit; \
done
clean-recursive:
@list='$(SUBDIRS)'; for subdir in $$list; do \
echo $(MAKE) -C $$subdir TOPDIR=../.. -$(MAKEFLAGS) clean ; \
$(MAKE) -C $$subdir TOPDIR=../.. -$(MAKEFLAGS) clean || exit; \
done

View File

@ -0,0 +1,27 @@
PKG_NAME:=gettext
PKG_VERSION:=0.17
PKG_SOURCEBASE=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCEBASE).tar.gz
PKG_SOURCE_URL:=http://ftp.gnu.org/pub/gnu/gettext/
PKG_MD5SUM:=58a2bc6d39c0ba57823034d55d65d606
include $(TOPDIR)/rules.mk
$(PKG_SOURCEBASE) extract-stamp: $(TOPDIR)/downloads/$(PKG_SOURCE)
tar xzf $^
touch extract-stamp
$(PKG_SOURCEBASE)/config.status: extract-stamp
cd $(PKG_SOURCEBASE) && ./configure --host=$(HOST_TRIPLET) --enable-static --disable-shared --prefix=`pwd`/../$(TOPDIR)/build/libs --disable-java
$(PKG_SOURCEBASE)/gettext-runtime/intl/libintl.la: $(PKG_SOURCEBASE)/config.status
$(MAKE) -C $(PKG_SOURCEBASE)/gettext-runtime/intl install-exec
all: build
build: $(PKG_SOURCEBASE)/gettext-runtime/intl/libintl.la
clean:
$(RM) -r $(PKG_SOURCEBASE) extract-stamp
.PHONY: all build clean

26
win32/libs/png/Makefile Normal file
View File

@ -0,0 +1,26 @@
PKG_NAME:=libpng
PKG_VERSION=1.2.36
PKG_SOURCEBASE:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCEBASE).tar.bz2
PKG_SOURCE_URL:=@SF/libpng
PKG_MD5SUM:=325d67a8dd4a1f672d395c339fddd75c
include $(TOPDIR)/rules.mk
extract-stamp: $(TOPDIR)/downloads/$(PKG_SOURCE)
tar xjf $^
touch extract-stamp
$(PKG_SOURCEBASE)/configure: extract-stamp
$(PKG_SOURCEBASE)/config.status: $(PKG_SOURCEBASE)/configure
cd $(PKG_SOURCEBASE) && ./configure --host=$(HOST_TRIPLET) --prefix=`pwd`/../$(TOPDIR)/build/libs --disable-shared --enable-static CPPFLAGS=-I`pwd`/../$(TOPDIR)/build/libs/include LDFLAGS=-L`pwd`/../$(TOPDIR)/build/libs/lib
$(PKG_SOURCEBASE)/libpng.la: extract-stamp $(PKG_SOURCEBASE)/config.status
$(MAKE) -C $(PKG_SOURCEBASE) install-data
build: $(PKG_SOURCEBASE)/libpng.la
clean:
$(RM) -rf $(PKG_SOURCEBASE) extract-stamp

43
win32/libs/popt/Makefile Normal file
View File

@ -0,0 +1,43 @@
PKG_NAME:=popt
PKG_VERSION:=1.12
PKG_SOURCEBASE=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCEBASE).tar.gz
PKG_SOURCE_URL:=http://rpm5.org/files/popt/
PKG_MD5SUM:=f45290e9ac4b1cf209d0042eb6755543
include $(TOPDIR)/rules.mk
$(PKG_SOURCEBASE) extract-stamp: $(TOPDIR)/downloads/$(PKG_SOURCE)
tar xzf $^
touch extract-stamp
patch-stamp: extract-stamp
@for patch in patches/*.diff; do \
echo sed -e "s/\$$sourcebase\b/$(PKG_SOURCEBASE)/g" -e "s/\$$host_triplet\b/$(HOST_TRIPLET)/g" "$$patch" \| patch -p0 ; \
sed -e "s/\$$sourcebase\b/$(PKG_SOURCEBASE)/g" -e "s/\$$host_triplet\b/$(HOST_TRIPLET)/g" "$$patch" | patch -p0 || exit ; \
done
touch patch-stamp
$(PKG_SOURCEBASE)/configure: patch-stamp
cd $(PKG_SOURCEBASE) && libtoolize --copy --force
cd $(PKG_SOURCEBASE) && perl -p -i~ -e 's/(po\/Makefile\.in)\s+po\/Makefile\.in/$1/' configure.ac
cd $(PKG_SOURCEBASE) && perl -p -i~ -e 's/(SUBDIRS\s+=\s+po)\s+po/$1/' Makefile.am
cd $(PKG_SOURCEBASE) && aclocal -I m4
cd $(PKG_SOURCEBASE) && autoheader
cd $(PKG_SOURCEBASE) && automake -a -c
cd $(PKG_SOURCEBASE) && autoconf
$(PKG_SOURCEBASE)/config.status: $(PKG_SOURCEBASE)/configure
cd $(PKG_SOURCEBASE) && ./configure --host=$(HOST_TRIPLET) --enable-static --disable-shared --prefix=`pwd`/../$(TOPDIR)/build/libs
$(PKG_SOURCEBASE)/libpopt.la: $(PKG_SOURCEBASE)/config.status
$(MAKE) -C $(PKG_SOURCEBASE) install-data
all: build
build: $(PKG_SOURCEBASE)/libpopt.la
clean:
$(RM) -r $(PKG_SOURCEBASE) extract-stamp patch-stamp
.PHONY: all build clean

View File

@ -0,0 +1,10 @@
--- $sourcebase.orig/configure.ac
+++ $sourcebase/configure.ac
@@ -29,7 +29,6 @@
AC_ISC_POSIX
AM_C_PROTOTYPES
-AC_CHECK_VA_COPY
dnl XXX lose rpm libs
LIBS=

33
win32/libs/zlib/Makefile Normal file
View File

@ -0,0 +1,33 @@
PKG_NAME:=zlib
PKG_VERSION=1.2.3
PKG_SOURCEBASE:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCEBASE).tar.gz
PKG_SOURCE_URL:=@SF/libpng
PKG_MD5SUM:=debc62758716a169df9f62e6ab2bc634
include $(TOPDIR)/rules.mk
extract-stamp: $(TOPDIR)/downloads/$(PKG_SOURCE)
tar xzf $^
rm $(PKG_SOURCEBASE)/Makefile
touch extract-stamp
$(PKG_SOURCEBASE)/configure: extract-stamp
$(PKG_SOURCEBASE)/Makefile: $(PKG_SOURCEBASE)/configure
cd $(PKG_SOURCEBASE) && CC=$(HOST_TRIPLET)-gcc RANLIB=$(HOST_TRIPLET)-ranlib AR='$(HOST_TRIPLET)-ar rc' ./configure
$(PKG_SOURCEBASE)/libz.a: extract-stamp $(PKG_SOURCEBASE)/Makefile
$(MAKE) -C $(PKG_SOURCEBASE) libz.a
cp -p $(PKG_SOURCEBASE)/libz.a $(TOPDIR)/build/libs/lib/libz.a
cp -p $(PKG_SOURCEBASE)/zconf.h $(TOPDIR)/build/libs/include/zconf.h
cp -p $(PKG_SOURCEBASE)/zlib.h $(TOPDIR)/build/libs/include/zlib.h
all: build
build: $(PKG_SOURCEBASE)/libz.a
clean:
$(RM) -rf $(PKG_SOURCEBASE) extract-stamp
.PHONY: all build clean

10
win32/rules.mk Normal file
View File

@ -0,0 +1,10 @@
all: build
$(TOPDIR)/downloads/$(PKG_SOURCE):
@if [ ! -d "$(TOPDIR)/downloads" ] ; then \
echo mkdir -p $(TOPDIR)/downloads ; \
mkdir -p $(TOPDIR)/downloads || exit ; \
fi
$(TOPDIR)/../build_tools/download.pl $(TOPDIR)/downloads "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
.PHONY: all build clean