Debian Codegraph @

ConfigureMe

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