4 from subprocess import Popen, PIPE
7 def clang_has_option(option):
8 return [o for o in Popen(['clang', option], stderr=PIPE).stderr.readlines() if "unknown argument" in o] == [ ]
12 from _sysconfigdata import build_time_vars
13 build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"])
14 if not clang_has_option("-mcet"):
15 build_time_vars["CFLAGS"] = sub("-mcet", "", build_time_vars["CFLAGS"])
16 if not clang_has_option("-fcf-protection"):
17 build_time_vars["CFLAGS"] = sub("-fcf-protection", "", build_time_vars["CFLAGS"])
19 from distutils.core import setup, Extension
21 from distutils.command.build_ext import build_ext as _build_ext
22 from distutils.command.install_lib import install_lib as _install_lib
24 class build_ext(_build_ext):
25 def finalize_options(self):
26 _build_ext.finalize_options(self)
27 self.build_lib = build_lib
28 self.build_temp = build_tmp
30 class install_lib(_install_lib):
31 def finalize_options(self):
32 _install_lib.finalize_options(self)
33 self.build_dir = build_lib
36 cflags = getenv('CFLAGS', '').split()
37 # switch off several checks (need to be at the end of cflags list)
38 cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter', '-Wno-redundant-decls' ]
40 cflags += ['-Wno-cast-function-type' ]
42 src_perf = getenv('srctree') + '/tools/perf'
43 build_lib = getenv('PYTHON_EXTBUILD_LIB')
44 build_tmp = getenv('PYTHON_EXTBUILD_TMP')
45 libtraceevent = getenv('LIBTRACEEVENT')
46 libapikfs = getenv('LIBAPI')
48 ext_sources = [f.strip() for f in open('util/python-ext-sources')
49 if len(f.strip()) > 0 and f[0] != '#']
51 # use full paths with source files
52 ext_sources = list(map(lambda x: '%s/%s' % (src_perf, x) , ext_sources))
54 perf = Extension('perf',
55 sources = ext_sources,
56 include_dirs = ['util/include'],
57 extra_compile_args = cflags,
58 extra_objects = [libtraceevent, libapikfs],
63 description='Interface with the Linux profiling infrastructure',
64 author='Arnaldo Carvalho de Melo',
65 author_email='acme@redhat.com',
67 url='http://perf.wiki.kernel.org',
69 cmdclass={'build_ext': build_ext, 'install_lib': install_lib})