1877108e4SArnaldo Carvalho de Melo#!/usr/bin/python2 2877108e4SArnaldo Carvalho de Melo 31b7155f7SRobert Richterfrom os import getenv 41b7155f7SRobert Richter 5*4be92cf0SArnaldo Carvalho de Melocc = getenv("CC") 6*4be92cf0SArnaldo Carvalho de Meloif cc == "clang": 7*4be92cf0SArnaldo Carvalho de Melo from _sysconfigdata import build_time_vars 8*4be92cf0SArnaldo Carvalho de Melo from re import sub 9*4be92cf0SArnaldo Carvalho de Melo build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"]) 10*4be92cf0SArnaldo Carvalho de Melo 11*4be92cf0SArnaldo Carvalho de Melofrom distutils.core import setup, Extension 12*4be92cf0SArnaldo Carvalho de Melo 139941c96aSJiri Olsafrom distutils.command.build_ext import build_ext as _build_ext 149941c96aSJiri Olsafrom distutils.command.install_lib import install_lib as _install_lib 159941c96aSJiri Olsa 169941c96aSJiri Olsaclass build_ext(_build_ext): 179941c96aSJiri Olsa def finalize_options(self): 189941c96aSJiri Olsa _build_ext.finalize_options(self) 199941c96aSJiri Olsa self.build_lib = build_lib 209941c96aSJiri Olsa self.build_temp = build_tmp 219941c96aSJiri Olsa 229941c96aSJiri Olsaclass install_lib(_install_lib): 239941c96aSJiri Olsa def finalize_options(self): 249941c96aSJiri Olsa _install_lib.finalize_options(self) 259941c96aSJiri Olsa self.build_dir = build_lib 269941c96aSJiri Olsa 279941c96aSJiri Olsa 289c12cf95SJiri Olsacflags = getenv('CFLAGS', '').split() 299c12cf95SJiri Olsa# switch off several checks (need to be at the end of cflags list) 309c12cf95SJiri Olsacflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ] 31877108e4SArnaldo Carvalho de Melo 3267d52689SJiri Olsasrc_perf = getenv('srctree') + '/tools/perf' 339941c96aSJiri Olsabuild_lib = getenv('PYTHON_EXTBUILD_LIB') 349941c96aSJiri Olsabuild_tmp = getenv('PYTHON_EXTBUILD_TMP') 3545bff41aSArnaldo Carvalho de Melolibtraceevent = getenv('LIBTRACEEVENT') 36285a8f24SJiri Olsalibapikfs = getenv('LIBAPI') 379941c96aSJiri Olsa 386a5c13afSNamhyung Kimext_sources = [f.strip() for f in file('util/python-ext-sources') 396a5c13afSNamhyung Kim if len(f.strip()) > 0 and f[0] != '#'] 406a5c13afSNamhyung Kim 4167d52689SJiri Olsa# use full paths with source files 4267d52689SJiri Olsaext_sources = map(lambda x: '%s/%s' % (src_perf, x) , ext_sources) 4367d52689SJiri Olsa 44877108e4SArnaldo Carvalho de Meloperf = Extension('perf', 456a5c13afSNamhyung Kim sources = ext_sources, 46f6bbc1daSArnaldo Carvalho de Melo include_dirs = ['util/include'], 471b7155f7SRobert Richter extra_compile_args = cflags, 48553873e1SBorislav Petkov extra_objects = [libtraceevent, libapikfs], 491b7155f7SRobert Richter ) 50877108e4SArnaldo Carvalho de Melo 51877108e4SArnaldo Carvalho de Melosetup(name='perf', 52877108e4SArnaldo Carvalho de Melo version='0.1', 53877108e4SArnaldo Carvalho de Melo description='Interface with the Linux profiling infrastructure', 54877108e4SArnaldo Carvalho de Melo author='Arnaldo Carvalho de Melo', 55877108e4SArnaldo Carvalho de Melo author_email='acme@redhat.com', 56877108e4SArnaldo Carvalho de Melo license='GPLv2', 57877108e4SArnaldo Carvalho de Melo url='http://perf.wiki.kernel.org', 589941c96aSJiri Olsa ext_modules=[perf], 599941c96aSJiri Olsa cmdclass={'build_ext': build_ext, 'install_lib': install_lib}) 60