2006-07-24 10:28:57 -03:00
|
|
|
#!@EXENAME@
|
2006-04-15 05:13:05 -03:00
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import getopt
|
|
|
|
from distutils import sysconfig
|
|
|
|
|
2010-03-18 21:08:44 -03:00
|
|
|
valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
|
2006-04-15 05:13:05 -03:00
|
|
|
'ldflags', 'help']
|
|
|
|
|
|
|
|
def exit_with_usage(code=1):
|
2010-03-18 21:08:44 -03:00
|
|
|
print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0],
|
2006-04-15 05:13:05 -03:00
|
|
|
'|'.join('--'+opt for opt in valid_opts))
|
|
|
|
sys.exit(code)
|
|
|
|
|
|
|
|
try:
|
|
|
|
opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
|
|
|
|
except getopt.error:
|
|
|
|
exit_with_usage()
|
|
|
|
|
|
|
|
if not opts:
|
|
|
|
exit_with_usage()
|
|
|
|
|
|
|
|
pyver = sysconfig.get_config_var('VERSION')
|
|
|
|
getvar = sysconfig.get_config_var
|
|
|
|
|
2010-03-18 21:08:44 -03:00
|
|
|
opt_flags = [flag for (flag, val) in opts]
|
|
|
|
|
|
|
|
if '--help' in opt_flags:
|
|
|
|
exit_with_usage(code=0)
|
|
|
|
|
|
|
|
for opt in opt_flags:
|
|
|
|
if opt == '--prefix':
|
|
|
|
print sysconfig.PREFIX
|
|
|
|
|
|
|
|
elif opt == '--exec-prefix':
|
|
|
|
print sysconfig.EXEC_PREFIX
|
|
|
|
|
|
|
|
elif opt in ('--includes', '--cflags'):
|
|
|
|
flags = ['-I' + sysconfig.get_python_inc(),
|
|
|
|
'-I' + sysconfig.get_python_inc(plat_specific=True)]
|
|
|
|
if opt == '--cflags':
|
|
|
|
flags.extend(getvar('CFLAGS').split())
|
|
|
|
print ' '.join(flags)
|
|
|
|
|
|
|
|
elif opt in ('--libs', '--ldflags'):
|
2014-10-01 20:58:58 -03:00
|
|
|
libs = ['-lpython' + pyver]
|
|
|
|
libs += getvar('LIBS').split()
|
|
|
|
libs += getvar('SYSLIBS').split()
|
2010-03-18 21:08:44 -03:00
|
|
|
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
|
|
|
|
# shared library in prefix/lib/.
|
|
|
|
if opt == '--ldflags':
|
|
|
|
if not getvar('Py_ENABLE_SHARED'):
|
|
|
|
libs.insert(0, '-L' + getvar('LIBPL'))
|
2013-03-04 18:31:04 -04:00
|
|
|
if not getvar('PYTHONFRAMEWORK'):
|
|
|
|
libs.extend(getvar('LINKFORSHARED').split())
|
2010-03-18 21:08:44 -03:00
|
|
|
print ' '.join(libs)
|
2006-04-15 05:13:05 -03:00
|
|
|
|