added code to enable i386 builds on x86_64 platforms
[util-vserver.git] / build-all
1 #! /bin/sh
2
3 # Copyright (C) 2004,2005,2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 #  
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
8 #  
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #  
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 set -e
19
20 J=-j8
21
22 confflags="-C --enable-maintainer-mode --prefix=/usr --sysconfdir=/etc --localstatedir=/var $CONFIGURE_FLAGS"
23 configure="`pwd`/configure $confflags"
24 make=eval\ "${CLEAN:+make $J silent.clean;} \
25             echo -e \"== executing 'make all'...\" && \
26             make $J ${SILENT:+-s silent.}all && \
27             echo -e \"\n== executing 'make check'...\" && \
28             make $J ${SILENT:+-s silent.}check"
29
30 LANG=C
31
32 case $(arch) in
33   (x86_64)      ARCH_CFLAGS=' -m64';;
34   (i?86)        ARCH_CFLAGS=' -m32';;
35 esac
36
37 CPPFLAGS=-D_FORTIFY_SOURCE=99$ARCH_CFLAGS
38
39 ## Usage: xtermTitle <title>
40 function xtermTitle
41 {
42     tty -s || return 0
43     echo -ne "\e]0;$@\007"
44 }
45
46 ## Usage: operate <dir> <configure-opts>*
47 function operate()
48 {
49     d=$1
50     shift
51     
52     echo  "******************"
53     echo $"** Operating in directory '$d'..."
54     xtermTitle "Operating in directory '$d'... ($@)"
55     
56     mkdir -p $d && cd $d
57
58     test -z "$CLEAN"                         || rm -f config.cache
59     test -e Makefile -a -z "$CONFIGURE_FLAGS"|| CCACHE_DISABLE=1 $configure "$@"
60     $make
61     cd -
62 }
63
64 case "$1" in
65     dist)
66         test -e Makefile || \
67             env \
68             CFLAGS="-O0 -g3$ARCH_CFLAGS"   \
69             CXXFLAGS="-O0 -g3$ARCH_CFLAGS" \
70             CPPFLAGS=$CPPFLAGS \
71             ./configure $confflags
72         $make
73         exit
74         ;;
75     debian-woody|debian-sarge|fc-1-90|fc-1|fc-2|fc-3)
76         cat util-vserver-"$2".tar.bz2 | \
77             ssh $1 "cd /tmp && rm -rf /tmp/util-vserver-* && \
78                     tar xjf - && cd util-vserver-$2 && \
79                     export PATH=/usr/lib/ccache:/usr/lib/ccache/bin:\$PATH && \
80                         ./configure && \
81                     make ${SILENT:+-s silent.}all && \
82                     echo -e '\n\n\n' &&
83                     make ${SILENT:+-s silent.}check"
84         exit
85         ;;
86     *)  test -z "$1" || {
87             echo $"Unknown option '$1'" >&2
88             exit 1
89         }
90 esac
91
92 test -d "Build" || {
93     d=$(mktemp -t -d build-ensc.XXXXXX)
94     rm -f Build
95     ln -sf $d Build
96 }
97
98 noopt_flags=-O0\ -g3
99 opt_flags=-O2\ -g
100 ldflags=$ARCH_CFLAGS
101
102 operate Build/diet-noopt                                       CPPFLAGS="$CPPFLAGS" CFLAGS="$noopt_flags" CXXFLAGS="$noopt_flags" LDFLAGS="$ldflags"
103 operate Build/diet-opt     --enable-release                    CPPFLAGS="$CPPFLAGS" CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags"   LDFLAGS="$ldflags"
104 operate Build/nodiet-noopt --disable-dietlibc                  CPPFLAGS="$CPPFLAGS" CFLAGS="$noopt_flags" CXXFLAGS="$noopt_flags" LDFLAGS="$ldflags"
105 operate Build/nodiet-opt   --enable-release --disable-dietlibc CPPFLAGS="$CPPFLAGS" CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags"   LDFLAGS="$ldflags"
106 #operate Build/gcc32-opt    --enable-release --disable-dietlibc CPPFLAGS="$CPPFLAGS" CC='ccache gcc32'  CXX='ccache g++' CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags" LDFLAGS="$ldflags"
107
108 operate Build/diet-opt-api   --enable-release --enable-apis=NOLEGACY                    CPPFLAGS="$CPPFLAGS" CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags" LDFLAGS="$ldflags"
109 operate Build/nodiet-opt-api --enable-release --enable-apis=NOLEGACY --disable-dietlibc CPPFLAGS="$CPPFLAGS" CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags" LDFLAGS="$ldflags"