Add pkgconfig files for libsepol, libselinux, and libsemanage.

Having a pkgconfig files allows the pkg-config tool to be used to
query the presence of the library (or a particular version of it),
and to obtain the C flags and linker arguments to build with it.

Based on Debian patches by Manoj Srivastava <srivasta@debian.org>.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
This commit is contained in:
Eamon Walsh 2009-10-20 22:24:10 -04:00
parent 6f4660679f
commit 12777502c6
7 changed files with 65 additions and 6 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@
*.a
*.s
*.mo
*.pc
# Misc
*.patch

View File

@ -12,10 +12,12 @@ RUBYPLATFORM ?= $(shell ruby -e 'print RUBY_PLATFORM')
RUBYINC ?= $(LIBDIR)/ruby/$(RUBYLIBVER)/$(RUBYPLATFORM)
RUBYINSTALL ?= $(LIBDIR)/ruby/site_ruby/$(RUBYLIBVER)/$(RUBYPLATFORM)
VERSION = $(shell cat ../VERSION)
LIBVERSION = 1
LIBA=libselinux.a
TARGET=libselinux.so
LIBPC=libselinux.pc
SWIGIF= selinuxswig_python.i selinuxswig_python_exception.i
SWIGRUBYIF= selinuxswig_ruby.i
SWIGCOUT= selinuxswig_wrap.c
@ -56,7 +58,7 @@ SWIG = swig -Wall -python -o $(SWIGCOUT) -outdir ./
SWIGRUBY = swig -Wall -ruby -o $(SWIGRUBYCOUT) -outdir ./
all: $(LIBA) $(LIBSO)
all: $(LIBA) $(LIBSO) $(LIBPC)
pywrap: all $(SWIGSO) $(AUDIT2WHYSO)
@ -82,6 +84,9 @@ $(LIBSO): $(LOBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -ldl -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro
ln -sf $@ $(TARGET)
$(LIBPC): $(LIBPC).in
sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBDIR):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
selinuxswig_python_exception.i: ../include/selinux/selinux.h
sh exception.sh > $@
@ -111,6 +116,8 @@ install: all
install -m 644 $(LIBA) $(LIBDIR)
test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
install -m 755 $(LIBSO) $(SHLIBDIR)
test -d $(LIBDIR)/pkgconfig || install -m 755 -d $(LIBDIR)/pkgconfig
install -m 644 $(LIBPC) $(LIBDIR)/pkgconfig
cd $(LIBDIR) && ln -sf ../../`basename $(SHLIBDIR)`/$(LIBSO) $(TARGET)
install-pywrap: pywrap
@ -127,7 +134,7 @@ relabel:
/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
clean:
-rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
-rm -f $(LIBPC) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
distclean: clean
rm -f $(GENERATED) $(SWIGFILES)

View File

@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=@includedir@
Name: libselinux
Description: SELinux utility library
Version: @VERSION@
URL: http://userspace.selinuxproject.org/
Requires.private: libsepol
Libs: -L${libdir} -lselinux
Cflags: -I${includedir}

View File

@ -23,10 +23,12 @@ LFLAGS = -s
YACC = bison
YFLAGS = -d
VERSION = $(shell cat ../VERSION)
LIBVERSION = 1
LIBA=libsemanage.a
TARGET=libsemanage.so
LIBPC=libsemanage.pc
SWIGIF= semanageswig_python.i
SWIGRUBYIF= semanageswig_ruby.i
SWIGCOUT= semanageswig_wrap.c
@ -53,7 +55,7 @@ SWIGRUBY = swig -Wall -ruby -o $(SWIGRUBYCOUT) -outdir ./
GENERATED=$(SWIGCOUT) $(SWIGRUBYCOUT) $(wildcard conf-*.[ch])
all: $(LIBA) $(LIBSO)
all: $(LIBA) $(LIBSO) $(LIBPC)
pywrap: all $(SWIGLOBJ) $(SWIGSO)
@ -79,6 +81,9 @@ $(LIBSO): $(LOBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -lsepol -lselinux -lbz2 -lustr -L$(LIBDIR) -Wl,-soname,$(LIBSO),--version-script=libsemanage.map,-z,defs
ln -sf $@ $(TARGET)
$(LIBPC): $(LIBPC).in
sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBDIR):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
conf-scan.c: conf-scan.l conf-parse.h
$(LEX) $(LFLAGS) -t $< > $@
@ -119,6 +124,8 @@ install: all
install -m 644 $(LIBA) $(LIBDIR)
test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
install -m 755 $(LIBSO) $(SHLIBDIR)
test -d $(LIBDIR)/pkgconfig || install -m 755 -d $(LIBDIR)/pkgconfig
install -m 644 $(LIBPC) $(LIBDIR)/pkgconfig
test -f $(DEFAULT_SEMANAGE_CONF_LOCATION) || install -m 644 -D semanage.conf $(DEFAULT_SEMANAGE_CONF_LOCATION)
cd $(LIBDIR) && ln -sf ../../`basename $(SHLIBDIR)`/$(LIBSO) $(TARGET)
@ -134,7 +141,7 @@ relabel:
/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
clean:
rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) conf-parse.c conf-parse.h conf-scan.c
rm -f $(LIBPC) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGSO) $(TARGET) conf-parse.c conf-parse.h conf-scan.c
distclean: clean
rm -f $(SWIGCOUT) $(SWIGFILES)

View File

@ -0,0 +1,13 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=@includedir@
Name: libsemanage
Description: SELinux management library
Version: @VERSION@
URL: http://userspace.selinuxproject.org/
Requires.private: libselinux libsepol ustr
Libs: -L${libdir} -lsemanage
Libs.private: -lbz2
Cflags: -I${includedir}

View File

@ -1,19 +1,22 @@
# Installation directories.
PREFIX ?= $(DESTDIR)/usr
INCLUDEDIR ?= $(PREFIX)/include
LIBDIR ?= $(PREFIX)/lib
SHLIBDIR ?= $(DESTDIR)/lib
VERSION = $(shell cat ../VERSION)
LIBVERSION = 1
LIBA=libsepol.a
TARGET=libsepol.so
LIBPC=libsepol.pc
LIBSO=$(TARGET).$(LIBVERSION)
OBJS= $(patsubst %.c,%.o,$(wildcard *.c))
LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c))
CFLAGS ?= -Werror -Wall -W -Wundef -Wshadow -Wmissing-noreturn -Wmissing-format-attribute
override CFLAGS += -I. -I../include -D_GNU_SOURCE
all: $(LIBA) $(LIBSO)
all: $(LIBA) $(LIBSO) $(LIBPC)
$(LIBA): $(OBJS)
$(AR) rcs $@ $^
@ -23,6 +26,9 @@ $(LIBSO): $(LOBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -Wl,-soname,$(LIBSO),--version-script=libsepol.map,-z,defs
ln -sf $@ $(TARGET)
$(LIBPC): $(LIBPC).in
sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBDIR):; s:@includedir@:$(INCLUDEDIR):' < $< > $@
%.o: %.c
$(CC) $(CFLAGS) -fPIC -c -o $@ $<
@ -34,13 +40,15 @@ install: all
install -m 644 $(LIBA) $(LIBDIR)
test -d $(SHLIBDIR) || install -m 755 -d $(SHLIBDIR)
install -m 755 $(LIBSO) $(SHLIBDIR)
test -d $(LIBDIR)/pkgconfig || install -m 755 -d $(LIBDIR)/pkgconfig
install -m 644 $(LIBPC) $(LIBDIR)/pkgconfig
cd $(LIBDIR) && ln -sf ../../`basename $(SHLIBDIR)`/$(LIBSO) $(TARGET)
relabel:
/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
clean:
-rm -f $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET)
-rm -f $(LIBPC) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET)
indent:
../../scripts/Lindent $(wildcard *.[ch])

View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=@includedir@
Name: libsepol
Description: SELinux policy library
Version: @VERSION@
URL: http://userspace.selinuxproject.org/
Libs: -L${libdir} -lsepol
Cflags: -I${includedir}