7 log_name
= 'config.log'
8 if os
.path
.isfile(log_name
):
12 log_file
= open(log_name
, 'a')
20 def msg_checking(msg
):
21 print "Checking", msg
, "...",
24 write_log("Execute: %s" % cmd
)
25 full_cmd
= '%s 1>>%s 2>&1' % (cmd
, log_name
)
26 return os
.system(full_cmd
)
28 def run_test(input, flags
= ''):
30 f
= open('_temp.c', 'w')
33 compile_cmd
= '%s -o _temp _temp.c %s' % (os
.environ
.get('CC', 'cc'),
35 write_log("executing test: %s" % compile_cmd
)
36 if not execute(compile_cmd
):
39 execute('rm -f _temp.c _temp')
49 system("touch conf.aotest");
54 def find_ao(ao_prefix
= '/usr/local', enable_aotest
= 1):
55 """A rough translation of ao.m4"""
60 ao_include_dir
= ao_prefix
+ '/include'
61 ao_lib_dir
= ao_prefix
+ '/lib'
64 msg_checking('for Ao')
67 execute('rm -f conf.aotest')
70 run_test(ao_test_program
, "-I" + ao_include_dir
)
71 if not os
.path
.isfile('conf.aotest'):
72 raise RuntimeError, "Did not produce output"
73 execute('rm conf.aotest')
76 print "test program failed"
81 return {'ao_libs' : ao_libs
,
82 'ao_lib_dir' : ao_lib_dir
,
83 'ao_include_dir' : ao_include_dir
}
86 f
= open('Setup', 'w')
87 for item
in data
.items():
88 f
.write('%s = %s\n' % item
)
90 print "Wrote Setup file"
94 --prefix Give the prefix in which ao was installed
95 (separated by a space)''' % sys
.argv
[0]
99 def arg_check(data
, argv
, pos
, arg_type
, key
):
100 "Register an command line arg which takes an argument"
102 print arg_type
, "needs an argument"
104 data
[key
] = argv
[pos
]
108 for pos
in range(len(argv
)):
109 if argv
[pos
] == '--help':
111 if argv
[pos
] == '--prefix':
113 arg_check(data
, argv
, pos
, "Ao Prefix", 'prefix')
118 prefix
= args
.get('prefix', '/usr/local')
120 data
= find_ao(ao_prefix
= prefix
)
122 print "Config failure"
126 if __name__
== '__main__':