gentoo: use /var/run for new /run compatibility
[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 BDIR=Build-$(hostname)
21 J=-j8
22
23 confflags="-C --enable-maintainer-mode --prefix=/usr --sysconfdir=/etc --localstatedir=/var $CONFIGURE_FLAGS"
24 configure="`pwd`/configure $confflags"
25 make=eval\ "${CLEAN:+make $J silent.clean;} \
26             echo -e \"== executing 'make all'...\" && \
27             make $J ${SILENT:+-s silent.}all && \
28             echo -e \"\n== executing 'make check'...\" && \
29             make $J ${SILENT:+-s silent.}check"
30
31 LANG=C
32
33 case $(arch) in
34   (x86_64)      ARCH_CFLAGS=' -m64';;
35   (i?86)        ARCH_CFLAGS=' -m32';;
36 esac
37
38 CPPFLAGS=-D_FORTIFY_SOURCE=99$ARCH_CFLAGS
39
40 ## Usage: xtermTitle <title>
41 function xtermTitle
42 {
43     tty -s || return 0
44     echo -ne "\e]0;$@\007"
45 }
46
47 ## Usage: operate <dir> <configure-opts>*
48 function operate()
49 {
50     d=$1
51     shift
52     
53     echo  "******************"
54     echo $"** Operating in directory '$d'..."
55     xtermTitle "Operating in directory '$d'... ($@)"
56     
57     mkdir -p $d && cd $d
58
59     test -z "$CLEAN"                         || rm -f config.cache
60     test -e Makefile -a -z "$CONFIGURE_FLAGS"|| CCACHE_DISABLE=1 $configure "$@"
61     $make
62     cd -
63 }
64
65 case "$1" in
66     dist)
67         test -e Makefile || \
68             env \
69             CFLAGS="-O0 -g3$ARCH_CFLAGS"   \
70             CXXFLAGS="-O0 -g3$ARCH_CFLAGS" \
71             CPPFLAGS="$CPPFLAGS" \
72             ./configure $confflags
73         $make
74         exit
75         ;;
76     debian-woody|debian-sarge|fc-1-90|fc-1|fc-2|fc-3)
77         cat util-vserver-"$2".tar.bz2 | \
78             ssh $1 "cd /tmp && rm -rf /tmp/util-vserver-* && \
79                     tar xjf - && cd util-vserver-$2 && \
80                     export PATH=/usr/lib/ccache:/usr/lib/ccache/bin:\$PATH && \
81                         ./configure && \
82                     make ${SILENT:+-s silent.}all && \
83                     echo -e '\n\n\n' &&
84                     make ${SILENT:+-s silent.}check"
85         exit
86         ;;
87     *)  test -z "$1" || {
88             echo $"Unknown option '$1'" >&2
89             exit 1
90         }
91 esac
92
93 test -d "$BDIR" || {
94     d=$(mktemp -t -d build-ensc.XXXXXX)
95     rm -f $BDIR
96     ln -sf $d $BDIR
97 }
98
99 noopt_flags=-O0\ -g3
100 opt_flags=-O2\ -g
101 ldflags=$ARCH_CFLAGS
102
103 operate $BDIR/diet-noopt                                       CPPFLAGS="$CPPFLAGS" CFLAGS="$noopt_flags" CXXFLAGS="$noopt_flags" LDFLAGS="$ldflags"
104 operate $BDIR/diet-opt     --enable-release                    CPPFLAGS="$CPPFLAGS" CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags"   LDFLAGS="$ldflags"
105 operate $BDIR/nodiet-noopt --disable-dietlibc                  CPPFLAGS="$CPPFLAGS" CFLAGS="$noopt_flags" CXXFLAGS="$noopt_flags" LDFLAGS="$ldflags"
106 operate $BDIR/nodiet-opt   --enable-release --disable-dietlibc CPPFLAGS="$CPPFLAGS" CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags"   LDFLAGS="$ldflags"
107 #operate $BDIR/gcc32-opt    --enable-release --disable-dietlibc CPPFLAGS="$CPPFLAGS" CC='ccache gcc32'  CXX='ccache g++' CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags" LDFLAGS="$ldflags"
108
109 operate $BDIR/diet-opt-api   --enable-release --enable-apis=NOLEGACY                    CPPFLAGS="$CPPFLAGS" CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags" LDFLAGS="$ldflags"
110 operate $BDIR/nodiet-opt-api --enable-release --enable-apis=NOLEGACY --disable-dietlibc CPPFLAGS="$CPPFLAGS" CFLAGS="$opt_flags"   CXXFLAGS="$opt_flags" LDFLAGS="$ldflags"