mirror of
https://github.com/SELinuxProject/setools
synced 2025-03-11 07:18:15 +00:00
setup.py: locate libsepol.a
Use distutils' features to find libsepol.a. Also sensitive to SEPOL env variable for specifying the full path to libsepol.a.
This commit is contained in:
parent
c271d94c5d
commit
febc2af594
17
setup.py
17
setup.py
@ -5,9 +5,11 @@ from setuptools import setup
|
||||
import distutils.log as log
|
||||
from distutils.core import Extension
|
||||
from distutils.cmd import Command
|
||||
from distutils.unixccompiler import UnixCCompiler
|
||||
from setuptools.command.build_ext import build_ext
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
from os.path import join
|
||||
|
||||
|
||||
@ -54,6 +56,17 @@ class BuildExtCommand(build_ext):
|
||||
self.run_command('build_lex')
|
||||
build_ext.run(self)
|
||||
|
||||
|
||||
try:
|
||||
static_sepol = [os.environ['SEPOL']]
|
||||
except KeyError:
|
||||
# try to find libsepol.a. The find_library_file function
|
||||
# chooses dynamic libraries over static ones, so
|
||||
# this assumes that the static lib is in the same directory
|
||||
# as the dynamic lib.
|
||||
dynamic_sepol = UnixCCompiler().find_library_file(['/usr/lib64', '/usr/lib'], 'sepol')
|
||||
static_sepol = dynamic_sepol.replace(".so", ".a")
|
||||
|
||||
ext_py_mods = [Extension('setools.policyrep._qpol',
|
||||
['setools/policyrep/qpol.i',
|
||||
'libqpol/avrule_query.c',
|
||||
@ -114,8 +127,8 @@ ext_py_mods = [Extension('setools.policyrep._qpol',
|
||||
'-Wno-cast-qual', # libsepol/libselinux uses const-to-nonconst casts
|
||||
'-Wno-shadow', # SWIG generates shadow variables
|
||||
'-fno-exceptions'],
|
||||
extra_link_args=['-Wl,--version-script=libqpol/libqpol.map',
|
||||
'/usr/lib/libsepol.a'],
|
||||
extra_objects=[static_sepol],
|
||||
extra_link_args=['-Wl,--version-script=libqpol/libqpol.map'],
|
||||
swig_opts=['-Ilibqpol/include'])]
|
||||
|
||||
setup(name='setools',
|
||||
|
Loading…
Reference in New Issue
Block a user