Home | History | Annotate | Download | only in bin
      1 #!/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/bin/python2.7
      2 
      3 import sys
      4 import os
      5 import getopt
      6 from distutils import sysconfig
      7 
      8 valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
      9               'ldflags', 'help']
     10 
     11 def exit_with_usage(code=1):
     12     print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0],
     13                                             '|'.join('--'+opt for opt in valid_opts))
     14     sys.exit(code)
     15 
     16 try:
     17     opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
     18 except getopt.error:
     19     exit_with_usage()
     20 
     21 if not opts:
     22     exit_with_usage()
     23 
     24 pyver = sysconfig.get_config_var('VERSION')
     25 getvar = sysconfig.get_config_var
     26 
     27 opt_flags = [flag for (flag, val) in opts]
     28 
     29 if '--help' in opt_flags:
     30     exit_with_usage(code=0)
     31 
     32 for opt in opt_flags:
     33     if opt == '--prefix':
     34         print sysconfig.PREFIX
     35 
     36     elif opt == '--exec-prefix':
     37         print sysconfig.EXEC_PREFIX
     38 
     39     elif opt in ('--includes', '--cflags'):
     40         flags = ['-I' + sysconfig.get_python_inc(),
     41                  '-I' + sysconfig.get_python_inc(plat_specific=True)]
     42         if opt == '--cflags':
     43             flags.extend(getvar('CFLAGS').split())
     44         print ' '.join(flags)
     45 
     46     elif opt in ('--libs', '--ldflags'):
     47         libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
     48         libs.append('-lpython'+pyver)
     49         # add the prefix/lib/pythonX.Y/config dir, but only if there is no
     50         # shared library in prefix/lib/.
     51         if opt == '--ldflags':
     52             if not getvar('Py_ENABLE_SHARED'):
     53                 libs.insert(0, '-L' + getvar('LIBPL'))
     54             if not getvar('PYTHONFRAMEWORK'):
     55                 libs.extend(getvar('LINKFORSHARED').split())
     56         print ' '.join(libs)
     57 
     58