1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
|
#!/bin/sh
#
# ConfigureMe: apply appropriate default local configuration options
#
# Copyright: 2001 Alan Robertson <alanr@unix.sh>
# License: GNU General Public License (GPL)
#
Usage() {
cat <<-!
Usage: $0 {configure|make|install|dist|distcheck|package|flags|bootstrap} [--xxx=yyy]
$0 is a wrapper to invoke GNU 'configure' with options that match
common conventions associated with this machine (i.e. $CFENV)
You may also, if you wish, supply additional 'configure' options in
their usual '--xxx=yyy' form.
It will also build, make, install or create packages for the
build environment.
$0 does not know how to create packages for every environment,
nor is the information on "common conventions" necessarily correct.
Patches to this process are solicited -- especially in these areas.
!
if
[ -x ./configure ]
then
echo "Legal configure arguments are:"
./configure --help
fi
exit 1
}
#
# The vast majority of cases here have not been tested yet...
# If you don't think the treatment of your favorite OS is right,
# then submit a patch. Some of these conventions were wild guesses...
#
# autoconf "--enable-XXX" options generally have their default {yes|no}
# set, and perhaps acted upon, in "configure.in".
#
# But we will also allow many of them to take a "try" setting,
# interpreted there as:
# "try to act as if 'yes' had been specified, but if this proves
# troublesome, then continue as if 'no' had been specified".
# By using these from here in "ConfigureMe", this allows the beginner
# to make rapid, successful progress (albeit suboptimal) with an
# implicit sense of achievement, rather than the demoralisation from
# an unnecessarily failed 'yes' specification.
# (David Lee, 2005)
cmd=$0
pathtotop=`dirname ${cmd}`
PACKAGECMD=""
ConfigureLinux() {
DFLAGS=""
if
[ -f /etc/UnitedLinux-release -a -s /etc/UnitedLinux-release ]
then
distro="United Linux"
PACKAGECMD="$MAKE_CMD rpm"
DFLAGS="--with-ucd-snmp-devel=ucdsnmp --with-group-id=90 --with-ccmuser-id=90"
elif
[ -f /etc/SuSE-release -a -s /etc/SuSE-release ]
then
distro="SuSE Linux"
PACKAGECMD="$MAKE_CMD rpm"
# -fno-unit-at-a-time is replaced by -fno-toplevel-reorder in gcc4.2
# But apparently it shouldn't be required
# http://www.gnu.org/software/gcc/gcc-4.2/changes.html
#export CFLAGS="$CFLAGS -fno-unit-at-a-time"
DFLAGS="--with-group-id=90 --with-ccmuser-id=90"
R=`cat /etc/SuSE-release | grep 'VERSION *= *' | sed -e 's%.*= *%%'`
case $R in
[78].*) DFLAGS="$DFLAGS --mandir=/usr/share/man --disable-snmp-subagent --disable-swig --with-ucd-snmp-devel=ucdsnmp";;
esac
elif
[ -f /etc/redhat-release -a -s /etc/redhat-release ]
then
distro="RedHat Linux"
PACKAGECMD="$MAKE_CMD rpm"
DFLAGS="--mandir=/usr/share/man"
elif
[ -f /etc/conectiva-release -a -s /etc/conectiva-release ]
then
distro="Conectiva Linux"
PACKAGECMD="$MAKE_CMD rpm"
DFLAGS="--with-group-id=17 --mandir=/usr/share/man --infodir=/usr/share/info --with-ccmuser-id=17"
elif
[ -f /etc/debian_version -a -s /etc/debian_version ]
then
distro="Debian GNU/Linux"
PACKAGECMD="$MAKE_CMD deb"
DFLAGS="--mandir=/usr/share/man"
elif
[ -f /etc/gentoo-release -a -s /etc/gentoo-release ]
then
distro="Gentoo Linux"
PACKAGECMD="$MAKE_CMD dist"
DFLAGS="--with-group-name=cluster --with-ccmuser-name=cluster --with-group-id=65 --with-ccmuser-id=65"
else
distro="Generic Linux"
fi
CFENV="$distro"
FLAGS="--prefix=/usr --sysconfdir=/etc --localstatedir=/var $DFLAGS --disable-rpath"
}
ConfigureAIX() {
CFENV="AIX (freeware toolbox)"
FLAGS="--disable-ldirectord --prefix /opt/freeware"
}
ConfigureFreeBSD() {
FLAGS="--prefix=/usr/local --sysconfdir=/usr/local/etc --localstatedir=/var --enable-all --with-group-id=90 --with-ccmuser-id=90 --disable-rpath"
CFENV="FreeBSD"
}
ConfigureOpenBSD() {
FLAGS="--prefix=/usr/local --sysconfdir=/etc --localstatedir=/var --with-group-id=584 --with-ccmuser-id=584 --disable-rpath --with-group-name=_heartbeat --with-ccmuser-name=_heartbeat --with-ocf-root=/usr/local/lib/ocf/ --enable-fatal-warnings=no"
export LDFLAGS="-liconv -L/usr/local/lib/libnet-1.0"
export LIBNETCONFIG=/usr/local/bin/libnet-config-1.0
export AUTOCONF_VERSION=2.61
CFENV="OpenBSD"
}
ConfigureNetBSD() {
FLAGS="--disable-ldirectord --prefix=/usr/local --sysconfdir=/usr/local/etc --localstatedir=/var --with-group-id=90 --with-ccmuser-id=90 --disable-rpath"
CFENV="NetBSD"
}
ConfigureGenericBSD() {
FLAGS="--disable-ldirectord --prefix=/usr/local --sysconfdir=/usr/local/etc --localstatedir=/var --with-group-id=90 --with-ccmuser-id=90 --disable-rpath"
CFENV="Generic BSD"
}
ConfigureSolaris() {
# PKGNAME: see comment in "configure.in"
PKGNAME="LXHAhb"
FLAGS="--disable-ldirectord --prefix=/opt/$PKGNAME --sysconfdir=/etc/opt/$PKGNAME --localstatedir=/var/opt/$PKGNAME --with-pkgname=$PKGNAME --disable-rpath"
CFENV="Solaris"
PACKAGECMD="$MAKE_CMD pkg"
}
ConfigureDarwin() {
for dir in / /sw /opt/local; do
if [ -d $dir ]; then
install_prefix=$dir
fi
done
FLAGS="--prefix=${install_prefix}"
FLAGS="$FLAGS --with-initdir=/private/etc/mach_init.d"
FLAGS="$FLAGS --localstatedir=${install_prefix}/var"
FLAGS="$FLAGS --with-group-name=admin --with-ccmuser-name=daemon"
FLAGS="$FLAGS --enable-fatal-warnings=yes"
FLAGS="$FLAGS --disable-rpath"
export CFENV="Darwin"
}
ConfigureGenericUNIX() {
echo "Configuring for generic UNIX system"
FLAGS="--disable-ldirectord --prefix=/usr --sysconfdir=/etc --localstatedir=/var"
CFENV="Generic UNIX"
}
lcase() {
# Convert to lower-case in a portable way
if
[ X"`echo A | dd conv=lcase 2>/dev/null`" = Xa ]
then
dd conv=lcase 2>/dev/null
else
tr ['A-Z'] ['a-z']
fi
}
GetConfigureFLAGS() {
if
[ "X$MAKE" != "X" ]
then
MAKE_CMD="$MAKE"
elif
which gmake > /dev/null
then
MAKE_CMD="gmake"
else
MAKE_CMD="make"
fi
case $CROSSCOMPILE in
yes) GetCrossConfigureFlags;;
*) GetNativeConfigureFlags;;
esac
}
GetNativeConfigureFlags() {
case `uname -s | lcase` in
linux) ConfigureLinux;;
aix) ConfigureAIX;;
freebsd) ConfigureFreeBSD;;
openbsd) ConfigureOpenBSD;;
netbsd) ConfigureOpenBSD;;
*bsd) ConfigureGenericBSD;;
sunos) ConfigureSolaris;;
darwin) ConfigureDarwin;;
*) ConfigureGenericUNIX;;
esac
}
GetCrossConfigureFlags() {
case $CC in
# Don't force endianness on ARM - it can be either type
*arm*) FLAGS="--prefix=/usr/local/arm-linux/arm-linux --sysconfdir=/etc --localstatedir=/var";;
*) echo "Error: Unsupported cross-compiler: [$CC]"; exit 1;;
esac
}
Run() {
echo "Running $@"
"$@"
}
PackageItUp() {
if
[ "X$PACKAGECMD" = X ]
then
echo "Do not know how to build a package for $CFENV" >&2
return 1
else
Run $PACKAGECMD
fi
}
do_configure () {
# Do autotools bootstrap if needed.
# Should only be needed by developers and geeks because any
# distributed stable versions (tar.gz etc.) should already have
# "configure" etc. set up.
if [ ! -x ${pathtotop}/configure ]
then
Run ${pathtotop}/autogen.sh
fi
Run ${pathtotop}/configure "$@"
}
cmd=`echo $1 | lcase`
case $cmd in
cross-*) CROSSCOMPILE=yes; cmd=`echo $cmd |cut -c7-`;;
*) CROSSCOMPILE=no;;
esac
GetConfigureFLAGS
echo ""
echo "Configure flags for $CFENV: $FLAGS" >&2
if
[ $# -le 0 ]
then
Usage
fi
shift
case $cmd in
flags)
echo $FLAGS $@
;;
cf|conf|configure)
do_configure $FLAGS $@
;;
boot|bootstrap)
rm -f ${pathtotop}/configure
do_configure $FLAGS $@
;;
make|build)
do_configure $FLAGS $@ && \
Run $MAKE_CMD;;
install)
do_configure $FLAGS $@ && \
Run $MAKE_CMD install
;;
dist)
do_configure $FLAGS $@ && \
Run $MAKE_CMD dist
;;
distcheck)
do_configure $FLAGS $@ && \
. ./heartbeat/lib/ha_config && \
Run $MAKE_CMD DESTDIR="$PWD/heartbeat-$VERSION/=inst" distcheck
;;
pkg|package|rpm|deb|dpkg)
do_configure $FLAGS $@ && \
PackageItUp
;;
*)
Usage
;;
esac
|