aboutsummaryrefslogtreecommitdiffstats
path: root/m4/buildconf.py
diff options
context:
space:
mode:
Diffstat (limited to 'm4/buildconf.py')
-rwxr-xr-xm4/buildconf.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/m4/buildconf.py b/m4/buildconf.py
new file mode 100755
index 0000000..9ba621f
--- /dev/null
+++ b/m4/buildconf.py
@@ -0,0 +1,83 @@
1#!/usr/bin/env python
2#
3# buildconf.py: Runs Autotools on a project.
4#
5# Copyright 2004 Edward Rudd and Paul Querna
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19
20import os
21import sys
22import popen2
23from optparse import OptionParser
24
25cmd = {}
26
27def run_cmd(command, args=""):
28 global cmd
29 rp = popen2.Popen4("%s %s" % (cmd[command], args))
30 sout = rp.fromchild.readlines()
31 for line in sout:
32 sys.stdout.write(line)
33 rv = rp.wait()
34 if rv != 0:
35 print "Error: '%s %s' returned %d" % (cmd[command], args, rv)
36 sys.exit(-1)
37
38def select_cmd(command, list, args = "--version"):
39 global cmd
40 cmd[command] = None
41 for x in list:
42 # rv = os.spawnlp(os.P_WAIT, x, args)
43 rp = popen2.Popen4("%s %s" % (x, args))
44 rv = rp.wait()
45 if rv == 0:
46 cmd[command] = x
47 break
48 if cmd[command] == None:
49 print "Errpr: Could not find suitable version for '%s', tried running: %s" % (command, list)
50 sys.exit(-1)
51
52parser = OptionParser()
53
54parser.add_option("--libtoolize", action="store_true", dest="libtoolize", default=False)
55parser.add_option("--aclocal", action="store_true", dest="aclocal", default=False)
56parser.add_option("--automake", action="store_true", dest="automake", default=False)
57parser.add_option("--autoconf", action="store_true", dest="autoconf", default=False)
58parser.add_option("--autoheader", action="store_true", dest="autoheader", default=False)
59
60(options, args) = parser.parse_args()
61
62if options.libtoolize:
63 select_cmd("libtoolize", ['libtoolize14','glibtoolize','libtoolize'])
64if options.aclocal:
65 select_cmd("aclocal", ['aclocal-1.9','aclocal-1.8','aclocal-1.7','aclocal-1.6','aclocal'])
66if options.autoheader:
67 select_cmd("autoheader", ['autoheader259','autoheader257','autoheader'])
68if options.automake:
69 select_cmd("automake", ['automake-1.9','automake-1.8','automake-1.7','automake-1.6','automake'])
70if options.autoconf:
71 select_cmd("autoconf", ['autoconf259','autoconf257','autoconf'])
72
73if options.libtoolize:
74 run_cmd("libtoolize", "--force --copy")
75if options.aclocal:
76 run_cmd("aclocal", "-I m4")
77if options.autoheader:
78 run_cmd("autoheader")
79if options.automake:
80 run_cmd("automake", "--add-missing --copy --foreign")
81if options.autoconf:
82 run_cmd("autoconf")
83