Move to new Makefile that can build with or without PYTHON being set

This commit is contained in:
Dan Walsh 2011-08-22 11:04:32 -04:00
parent 00e063e5f5
commit 4eca5fc79f
2 changed files with 35 additions and 11 deletions

View File

@ -207,6 +207,29 @@ index d777547..e22be70 100644
+
+.SH "SEE ALSO"
+.BR selinux "(8)"
diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 15f7c1a..7680008 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -10,7 +10,8 @@ LIBDIR ?= $(PREFIX)/lib
SHLIBDIR ?= $(PREFIX)/lib
INCLUDEDIR ?= $(PREFIX)/include
PYLIBVER ?= $(shell $(PYTHON) -c 'import sys;print("python%d.%d" % sys.version_info[0:2])')
-PYINC ?= $(shell pkg-config --cflags `basename $(PYTHON)`)
+PYINC ?= $(shell pkg-config --cflags $(PYPREFIX))
+PYTHONLIBDIR ?= $(shell pkg-config --libs $(PYPREFIX))
PYLIBDIR ?= $(LIBDIR)/$(PYLIBVER)
RUBYLIBVER ?= $(shell ruby -e 'print RUBY_VERSION.split(".")[0..1].join(".")')
RUBYPLATFORM ?= $(shell ruby -e 'print RUBY_PLATFORM')
@@ -78,7 +79,7 @@ $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
$(CC) $(filter-out -Werror, $(CFLAGS)) -I$(RUBYINC) -fPIC -DSHARED -c -o $@ $<
$(SWIGSO): $(SWIGLOBJ)
- $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lselinux -L$(LIBDIR) -Wl,-soname,$@
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lselinux -L$(LIBDIR) $(PYTHONLIBDIR) -Wl,-soname,$@,-z,defs
$(SWIGRUBYSO): $(SWIGRUBYLOBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L. -lselinux -L$(LIBDIR) -Wl,-soname,$@
diff --git a/libselinux/src/callbacks.c b/libselinux/src/callbacks.c
index b245364..7c47222 100644
--- a/libselinux/src/callbacks.c

View File

@ -7,7 +7,7 @@
Summary: SELinux library and simple utilities
Name: libselinux
Version: 2.1.4
Release: 1%{?dist}
Release: 2%{?dist}
License: Public Domain
Group: System Environment/Libraries
Source: %{name}-%{version}.tgz
@ -102,11 +102,10 @@ needed for developing SELinux applications.
# a specific runtime:
BuildPythonWrapper() {
BinaryName=$1
Prefix=$2
# Perform the build from the upstream Makefile:
make \
PYTHON=$BinaryName PYPREFIX=$Prefix \
PYTHON=$BinaryName \
LIBDIR="%{_libdir}" CFLAGS="-g %{optflags}" %{?_smp_mflags} \
pywrap
}
@ -115,9 +114,9 @@ make clean
make LIBDIR="%{_libdir}" CFLAGS="-g %{optflags}" %{?_smp_mflags} swigify
make LIBDIR="%{_libdir}" CFLAGS="-g %{optflags}" %{?_smp_mflags} all
BuildPythonWrapper %{__python} python2
BuildPythonWrapper %{__python}
%if 0%{?with_python3}
BuildPythonWrapper %{__python3} python3
BuildPythonWrapper %{__python3}
%endif # with_python3
make LIBDIR="%{_libdir}" CFLAGS="-g %{optflags}" %{?_smp_mflags} rubywrap
@ -125,15 +124,14 @@ make LIBDIR="%{_libdir}" CFLAGS="-g %{optflags}" %{?_smp_mflags} rubywrap
%install
InstallPythonWrapper() {
BinaryName=$1
Prefix=$2
make \
PYTHON=$BinaryName PYPREFIX=$Prefix \
PYTHON=$BinaryName \
LIBDIR="%{_libdir}" CFLAGS="-g %{optflags}" %{?_smp_mflags} \
pywrap
make \
PYTHON=$BinaryName PYPREFIX=$Prefix \
PYTHON=$BinaryName \
DESTDIR="%{buildroot}" LIBDIR="%{buildroot}%{_libdir}" \
SHLIBDIR="%{buildroot}/%{_lib}" BINDIR="%{buildroot}%{_sbindir}" \
install install-pywrap
@ -148,9 +146,9 @@ mkdir -p %{buildroot}/var/run/setrans
mkdir -p %{buildroot}/etc/tmpfiles.d
echo "d /var/run/setrans 0755 root root" > %{buildroot}/etc/tmpfiles.d/libselinux.conf
InstallPythonWrapper %{__python} python2
InstallPythonWrapper %{__python}
%if 0%{?with_python3}
InstallPythonWrapper %{__python3} python3
InstallPythonWrapper %{__python3}
%endif # with_python3
make DESTDIR="%{buildroot}" LIBDIR="%{buildroot}%{_libdir}" SHLIBDIR="%{buildroot}/%{_lib}" BINDIR="%{buildroot}%{_sbindir}" install install-rubywrap
@ -225,7 +223,7 @@ exit 0
%defattr(-,root,root,-)
%dir %{python3_sitearch}/selinux
%dir %{python3_sitearch}/selinux/__pycache__
%{python3_sitearch}/selinux/*.py
%{python3_sitearch}/selinux/*.py*
%{python3_sitearch}/selinux/*.so
%{python3_sitearch}/selinux/__pycache__/*
%endif with_python3
@ -235,6 +233,9 @@ exit 0
%{ruby_sitearch}/selinux.so
%changelog
* Mon Aug 22 2011 Dan Walsh <dwalsh@redhat.com> - 2.1.4-2
- Move to new Makefile that can build with or without PYTHON being set
* Thu Aug 18 2011 Dan Walsh <dwalsh@redhat.com> - 2.1.4-1
-Update to upstream
2.1.4 2011-0817