mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
Acked-By: Steve Beattie <steve@nxnw.org> This patch allows libapparmor to be built out of tree.
This commit is contained in:
parent
b02e3ff0cd
commit
c3f9d75abe
9 changed files with 127 additions and 130 deletions
|
@ -8,6 +8,7 @@ AC_PROG_SED
|
|||
|
||||
AC_PATH_PROG([SWIG], [swig])
|
||||
|
||||
sinclude(m4/ac_pod2man.m4)
|
||||
PROG_POD2MAN
|
||||
|
||||
AC_MSG_CHECKING(Checking for Python)
|
||||
|
@ -69,7 +70,9 @@ doc/Makefile
|
|||
src/Makefile
|
||||
swig/Makefile
|
||||
swig/perl/Makefile
|
||||
swig/perl/Makefile.PL
|
||||
swig/python/Makefile
|
||||
swig/python/setup.py
|
||||
swig/ruby/Makefile
|
||||
testsuite/Makefile
|
||||
testsuite/config/Makefile
|
||||
|
|
|
@ -23,10 +23,10 @@ noinst_HEADERS = grammar.h parser.h scanner.h af_protos.h
|
|||
|
||||
libapparmor_la_SOURCES = grammar.y libaalogparse.c change_hat.c scanner.c
|
||||
libapparmor_la_LDFLAGS = -version-info 1:2:0 -XCClinker -dynamic \
|
||||
-Wl,--version-script=libapparmor.map -Wl,-soname=libapparmor.so.1
|
||||
-Wl,--version-script=$(top_srcdir)/src/libapparmor.map -Wl,-soname=libapparmor.so.1
|
||||
|
||||
libimmunix_la_SOURCES = change_hat.c libimmunix_warning.c
|
||||
libimmunix_la_LDFLAGS = -version-info 1:2:0 -Wl,--version-script=libapparmor.map -Wl,-soname=libimmunix.so.1
|
||||
libimmunix_la_LDFLAGS = -version-info 1:2:0 -Wl,--version-script=$(top_srcdir)/src/libapparmor.map -Wl,-soname=libimmunix.so.1
|
||||
|
||||
tst_aalogmisc_SOURCES = tst_aalogmisc.c
|
||||
tst_aalogmisc_LDADD = .libs/libapparmor.a
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
use ExtUtils::MakeMaker;
|
||||
|
||||
use vars qw($CCFLAGS $OBJECT $VERSION $OPTIMIZE);
|
||||
|
||||
WriteMakefile(
|
||||
'NAME' => 'LibAppArmor',
|
||||
'MAKEFILE' => 'Makefile.perl',
|
||||
'FIRST_MAKEFILE' => 'Makefile.perl',
|
||||
);
|
17
libraries/libapparmor/swig/perl/Makefile.PL.in
Normal file
17
libraries/libapparmor/swig/perl/Makefile.PL.in
Normal file
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/perl -w
|
||||
|
||||
use ExtUtils::MakeMaker;
|
||||
|
||||
use vars qw($CFLAGS $OBJECT $VERSION $OPTIMIZE);
|
||||
|
||||
WriteMakefile(
|
||||
'NAME' => 'LibAppArmor',
|
||||
'MAKEFILE' => 'Makefile.perl',
|
||||
'FIRST_MAKEFILE' => 'Makefile.perl',
|
||||
'ABSTRACT' => q[Perl interface to AppArmor] ,
|
||||
'VERSION' => q[@VERSION@],
|
||||
'INC' => q[-I@top_srcdir@/src @CFLAGS@],
|
||||
'LIBS' => q[-L@top_builddir@/src/.libs/ -lapparmor @LIBS@],
|
||||
'OBJECT' => 'libapparmor_wrap.o', # $(OBJ_EXT)
|
||||
) ;
|
||||
|
|
@ -1,34 +1,30 @@
|
|||
EXTRA_DIST =Makefile.PL libapparmor_wrap.c LibAppArmor.pm examples/*.pl
|
||||
noinst_DATA =LibAppArmor.so
|
||||
|
||||
if HAVE_PERL
|
||||
libapparmor_wrap.c: $(srcdir)/../SWIG/libapparmor.i
|
||||
$(SWIG) -perl -I$(srcdir)/../../src -module LibAppArmor -o $@ $(srcdir)/../SWIG/libapparmor.i
|
||||
|
||||
PERL_MAKEFILE = Makefile.perl
|
||||
MOSTLYCLEANFILES=libapparmor_wrap.c LibAppArmor.pm
|
||||
|
||||
WRAPPER_SOURCES = libapparmor_wrap.c LibAppArmor.pm
|
||||
Makefile.perl: Makefile.PL
|
||||
$(PERL) $< PREFIX=$(prefix) MAKEFILE=$@
|
||||
|
||||
all-local: .build-stamp
|
||||
LibAppArmor.so: libapparmor_wrap.c Makefile.perl
|
||||
if test ! -f libapparmor_wrap.c; then cp $(srcdir)/libapparmor_wrap.c . ; fi
|
||||
$(MAKE) -fMakefile.perl
|
||||
if test $(top_srcdir) != $(top_builddir) ; then rm -f libapparmor_wrap.c ; fi
|
||||
|
||||
.build-stamp: $(WRAPPER_SOURCES) $(PERL_MAKEFILE)
|
||||
make -f $(PERL_MAKEFILE)
|
||||
touch .build-stamp
|
||||
install-exec-local: Makefile.perl
|
||||
$(MAKE) -fMakefile.perl install_vendor
|
||||
|
||||
check-local: .build-stamp
|
||||
make -f $(PERL_MAKEFILE) test
|
||||
# sadly there is no make uninstall for perl
|
||||
#uninstall-local: Makefile.perl
|
||||
#$(MAKE) -fMakefile.perl uninstall
|
||||
|
||||
install-exec-local: .build-stamp
|
||||
make -f $(PERL_MAKEFILE) install_vendor
|
||||
|
||||
clean-local: $(PERL_MAKEFILE)
|
||||
make -f $(PERL_MAKEFILE) clean
|
||||
rm -f $(PERL_MAKEFILE).old
|
||||
rm -rf build
|
||||
|
||||
$(PERL_MAKEFILE): Makefile.PL
|
||||
$(PERL) Makefile.PL VERSION="0.1" OBJECT="../../src/.libs/libapparmor.so libapparmor_wrap.o" CCFLAGS="-I../../src -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -Wdeclaration-after-statement" OPTIMIZE="$(CFLAGS) -shared -I$(includedir) -D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe -Wdeclaration-after-statement"
|
||||
|
||||
|
||||
$(WRAPPER_SOURCES): ../SWIG/*.i
|
||||
$(SWIG) -perl -I../../src -I../SWIG -o libapparmor_wrap.c libapparmor.i
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = Makefile.PL $(WRAPPER_SOURCES) examples/*.pl
|
||||
clean-local:
|
||||
if test -f Makefile.perl; then $(MAKE) -fMakefile.perl realclean; fi
|
||||
#rm -f Makefile.perl Makefile.perl.old
|
||||
rm -f *.so # *.o
|
||||
|
||||
endif
|
|
@ -1,17 +1,23 @@
|
|||
if HAVE_PYTHON
|
||||
BUILT_SOURCES = libapparmor_wrap.c
|
||||
|
||||
SWIG_SOURCES = ../SWIG/libapparmor.i
|
||||
EXTRA_DIST = libapparmor_wrap.c
|
||||
|
||||
libapparmor_wrap.c: $(srcdir)/../SWIG/libapparmor.i
|
||||
$(SWIG) -python -I$(srcdir)/../../src -module LibAppArmor -o $@ $(srcdir)/../SWIG/libapparmor.i
|
||||
mv LibAppArmor.py __init__.py
|
||||
|
||||
pkgpython_PYTHON = LibAppArmor.py
|
||||
pkgpyexec_LTLIBRARIES = _libapparmor.la
|
||||
_libapparmor_la_SOURCES = libapparmor_wrap.c $(SWIG_SOURCES)
|
||||
_libapparmor_la_CPPFLAGS = $(SWIG_PYTHON_CFLAGS) -I$(top_srcdir)/src -I/usr/include/python
|
||||
_libapparmor_la_LDFLAGS = -module
|
||||
_libapparmor_la_LIBADD = ../../src/.libs/libapparmor.so
|
||||
MOSTLYCLEANFILES=libapparmor_wrap.c __init__.py
|
||||
|
||||
libapparmor_wrap.c: $(SWIG_SOURCES)
|
||||
$(SWIG) -python -I$(top_srcdir)/src -o $@ $<
|
||||
all-local: libapparmor_wrap.c setup.py
|
||||
if test ! -f libapparmor_wrap.c; then cp $(srcdir)/libapparmor_wrap.c . ; fi
|
||||
$(PYTHON) setup.py build
|
||||
|
||||
endif
|
||||
install-exec-local:
|
||||
$(PYTHON) setup.py install --root="/$(DESTDIR)" --prefix="$(prefix)"
|
||||
|
||||
clean-local:
|
||||
if test -x "$(PYTHON)"; then $(PYTHON) setup.py clean; fi
|
||||
rm -rf build
|
||||
if test $(top_srcdir) != $(top_builddir) ; then rm -f libapparmor_wrap.c ; fi
|
||||
|
||||
endif
|
||||
|
|
19
libraries/libapparmor/swig/python/setup.py.in
Normal file
19
libraries/libapparmor/swig/python/setup.py.in
Normal file
|
@ -0,0 +1,19 @@
|
|||
from distutils.core import setup, Extension
|
||||
import string
|
||||
|
||||
setup(name = 'LibAppArmor',
|
||||
version = '@VERSION@',
|
||||
author = 'AppArmor Dev Team',
|
||||
author_email = 'Apparmor-dev@forge.novell.com',
|
||||
url = 'http://developer.novell.com/wiki/index.php/Apparmor',
|
||||
description = 'AppArmor python bindings',
|
||||
download_url = 'http://developer.novell.com/wiki/index.php/Special:Downloads/apparmor',
|
||||
package_dir = {'libapparmor1': '@srcdir@'},
|
||||
packages = [ 'libapparmor1' ],
|
||||
ext_package = 'libapparmor1',
|
||||
ext_modules = [Extension('_libapparmor', ['libapparmor_wrap.c'],
|
||||
include_dirs=['@top_srcdir@/src'],
|
||||
extra_link_args = string.split('-L@top_builddir@/src/.libs -lapparmor'),
|
||||
# static: extra_link_args = string.split('@top_builddir@/src/.libs/libapparmor.a'),
|
||||
)],
|
||||
)
|
|
@ -1,24 +1,28 @@
|
|||
if HAVE_RUBY
|
||||
|
||||
RUBY_MAKEFILE = Makefile.ruby
|
||||
EXTRA_DIST = extconf.rb LibAppArmor_wrap.c examples/*.rb
|
||||
noinst_DATA = LibAppArmor.so
|
||||
|
||||
WRAPPER_FILES = LibAppArmor_wrap.* LibAppArmor.so extension.mak .build-stamp
|
||||
LibAppArmor_wrap.c : $(srcdir)/../SWIG/libapparmor.i
|
||||
$(SWIG) -ruby -module LibAppArmor -I$(top_srcdir)/src -o $@ $(srcdir)/../SWIG/libapparmor.i
|
||||
|
||||
BUILT_SOURCES = LibAppArmor_wrap.c
|
||||
MOSTLYCLEANFILES=LibAppArmor_wrap.c
|
||||
|
||||
all-local: .build-stamp
|
||||
Makefile.ruby: extconf.rb
|
||||
PREFIX=$(prefix) $(RUBY) $< --with-LibAppArmor-include=$(top_srcdir)/src
|
||||
|
||||
.build-stamp: LibAppArmor_wrap.c
|
||||
CFLAGS="$(CFLAGS) -I../../src" $(RUBY) extconf.rb build
|
||||
touch .build-stamp
|
||||
LibAppArmor.so: LibAppArmor_wrap.c Makefile.ruby
|
||||
$(MAKE) -fMakefile.ruby
|
||||
|
||||
install-exec-local: .build-stamp
|
||||
make -f $(RUBY_MAKEFILE) install
|
||||
install-exec-local: Makefile.ruby
|
||||
$(MAKE) -fMakefile.ruby install
|
||||
|
||||
LibAppArmor_wrap.c: ../SWIG/*.i
|
||||
$(SWIG) -ruby -I../SWIG -I../../src -o ./LibAppArmor_wrap.c libapparmor.i
|
||||
#uninstall
|
||||
#./lib/ruby/site_ruby/1.8/i686-linux/LibAppArmor.so
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = extconf.rb $(BUILT_SOURCES) examples/*.rb
|
||||
clean-local:
|
||||
if test -f Makefile.ruby; then $(MAKE) -fMakefile.ruby clean; fi
|
||||
rm -f Makefile.ruby Makefile.new
|
||||
rm -f *.o *.so *.log
|
||||
|
||||
endif
|
||||
|
|
|
@ -1,76 +1,37 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'mkmf'
|
||||
require 'ftools'
|
||||
|
||||
$CFLAGS += " " + (ENV['CFLAGS'] || "") + (ENV['CXXFLAGS'] || "")
|
||||
$LDFLAGS = "../../src/.libs/libapparmor.so"
|
||||
|
||||
def usage
|
||||
puts <<EOF
|
||||
Usage: ruby extconf.rb command
|
||||
build Build the extension
|
||||
clean Clean the source directory
|
||||
install Install the extention
|
||||
test Test the extension
|
||||
wrap Generate SWIG wrappers
|
||||
EOF
|
||||
exit
|
||||
# hack 1: ruby black magic to write a Makefile.new instead of a Makefile
|
||||
alias open_orig open
|
||||
def open(path, mode=nil, perm=nil)
|
||||
path = 'Makefile.new' if path == 'Makefile'
|
||||
if block_given?
|
||||
open_orig(path, mode, perm) { |io| yield(io) }
|
||||
else
|
||||
open_orig(path, mode, perm)
|
||||
end
|
||||
end
|
||||
|
||||
cmd = ARGV.shift or usage()
|
||||
cmd = cmd.downcase
|
||||
|
||||
usage() unless ['build', 'clean', 'install', 'test', 'wrap'].member? cmd
|
||||
usage() if ARGV.shift
|
||||
|
||||
class Commands
|
||||
def initialize(&block)
|
||||
@block = block
|
||||
end
|
||||
|
||||
def execute
|
||||
@block.call
|
||||
end
|
||||
if ENV['PREFIX']
|
||||
prefix = CONFIG['prefix']
|
||||
%w[ prefix sitedir datadir infodir mandir oldincludedir ].each do |key|
|
||||
CONFIG[key] = CONFIG[key].sub(/#{prefix}/, ENV['PREFIX'])
|
||||
end
|
||||
end
|
||||
|
||||
Build = Commands.new {
|
||||
# I don't think we can tell mkmf to generate a makefile with a different name
|
||||
if File.exists?("Makefile")
|
||||
File.rename("Makefile", "Makefile.old")
|
||||
end
|
||||
create_makefile('LibAppArmor')
|
||||
File.rename("Makefile", "Makefile.ruby")
|
||||
if File.exists?("Makefile.old")
|
||||
File.rename("Makefile.old", "Makefile")
|
||||
end
|
||||
system("make -f Makefile.ruby")
|
||||
}
|
||||
Install = Commands.new {
|
||||
Build.execute
|
||||
if defined? Prefix
|
||||
# strip old prefix and add the new one
|
||||
oldPrefix = Config::CONFIG["prefix"]
|
||||
if defined? Debian
|
||||
archDir = Config::CONFIG["archdir"]
|
||||
libDir = Config::CONFIG["rubylibdir"]
|
||||
else
|
||||
archDir = Config::CONFIG["sitearchdir"]
|
||||
libDir = Config::CONFIG["sitelibdir"]
|
||||
end
|
||||
archDir = Prefix + archDir.gsub(/^#{oldPrefix}/,"")
|
||||
libDir = Prefix + libDir.gsub(/^#{oldPrefix}/,"")
|
||||
else
|
||||
archDir = Config::CONFIG["sitearchdir"]
|
||||
libDir = Config::CONFIG["sitelibdir"]
|
||||
dir_config('LibAppArmor')
|
||||
if find_library('apparmor', 'parse_record', '../../src/.libs') and
|
||||
have_header('aalogparse.h')
|
||||
create_makefile('LibAppArmor')
|
||||
|
||||
# hack 2: strip all rpath references
|
||||
open('Makefile.ruby', 'w') do |out|
|
||||
IO.foreach('Makefile.new') do |line|
|
||||
out.puts line.gsub(/-Wl,-R'[^']*'/, '')
|
||||
end
|
||||
[archDir,libDir].each { |path| File.makedirs path }
|
||||
binary = 'LibAppArmor.so'
|
||||
File.install "./"+binary, archDir+"/"+binary, 0555, true
|
||||
File.install "./LibAppArmor.so", libDir+"/LibAppArmor.so", 0555, true
|
||||
}
|
||||
end
|
||||
else
|
||||
puts 'apparmor lib not found'
|
||||
end
|
||||
|
||||
availableCommands = {
|
||||
"build" => Build,
|
||||
"install" => Install
|
||||
}
|
||||
|
||||
availableCommands[cmd].execute
|
||||
|
|
Loading…
Add table
Reference in a new issue