Description: Various Makefile bugfixes and improvements
 Fix 1: Allow Debian packaging to override which directory we expect to find
 libsepol.a in.
 .
 Fix 2: Add clean-pywrap/clean-rubywrap targets and pass all of the *wrap
 targets through to the src/Makefile (EG: install-pywrap/install-rubywrap).
 .
 Fix 3: Newer SWIG only wants a single .i file on the command line, and
 errors out if you give it extras (which are already included).  Fix the
 command line in the $(SWIGCOUT) target and make "swigify" depend on it.
 .
 The first fix was extracted from the old Debian patch.
 .
 Tweaked for version 2.1.9 by Russell Coker
Author: Kyle Moffett <Kyle.D.Moffett@boeing.com>

---
Forwarded: no
Last-Update: 2012-09-25

--- a/Makefile
+++ b/Makefile
@@ -32,16 +32,8 @@ all install relabel clean distclean inde
 swigify: all
 	$(MAKE) -C src swigify $@
 
-pywrap: 
-	$(MAKE) -C src pywrap $@
-
-rubywrap: 
-	$(MAKE) -C src rubywrap $@
-
-install-pywrap: 
-	$(MAKE) -C src install-pywrap $@
-
-install-rubywrap: 
-	$(MAKE) -C src install-rubywrap $@
+## Various pywrap/rubywrap targets
+%wrap:
+	$(MAKE) -C src $@
 
 test:
--- a/src/Makefile
+++ b/src/Makefile
@@ -85,6 +85,10 @@ ifneq (,$(filter i386,$(ARCH)))
 TLSFLAGS += -mno-tls-direct-seg-refs
 endif
 
+ifeq (,$(strip $(LIBSEPOLDIR)))
+LIBSEPOLDIR=$(LIBDIR)
+endif
+
 SWIG = swig -Wall -python -o $(SWIGCOUT) -outdir ./ $(EMFLAGS)
 
 SWIGRUBY = swig -Wall -ruby -o $(SWIGRUBYCOUT) -outdir ./ $(EMFLAGS)
@@ -125,7 +129,7 @@ $(AUDIT2WHYLOBJ): audit2why.c
 	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
-	$(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBDIR)/libsepol.a -L$(LIBDIR)
+	$(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBSEPOLDIR)/libsepol.a -L$(LIBDIR)
 
 %.o:  %.c policy.h
 	$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
@@ -133,6 +137,7 @@ $(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
 %.lo:  %.c policy.h
 	$(CC) $(CFLAGS) -fPIC -DSHARED -c -o $@ $<
 
+swigify: $(SWIGCOUT)
 $(SWIGCOUT): $(SWIGIF)
 	$(SWIG) $<
 
@@ -141,9 +146,6 @@ $(SWIGPYOUT): $(SWIGCOUT)
 $(SWIGRUBYCOUT): $(SWIGRUBYIF)
 	$(SWIGRUBY) $<
 
-swigify: $(SWIGIF)
-	$(SWIG) $<
-
 install: all 
 	test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
 	install -m 644 $(LIBA) $(LIBDIR)
@@ -166,8 +168,14 @@ install-rubywrap: rubywrap
 relabel:
 	/sbin/restorecon $(SHLIBDIR)/$(LIBSO)
 
-clean: 
-	-rm -f $(LIBPC) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(SWIGLOBJ) $(SWIGRUBYLOBJ) $(SWIGSO) $(TARGET) $(AUDIT2WHYSO) *.o *.lo *~
+clean-pywrap:
+	-rm -f $(SWIGLOBJ) $(SWIGSO) $(AUDIT2WHYLOBJ) $(AUDIT2WHYSO)
+
+clean-rubywrap:
+	-rm -f $(SWIGRUBYLOBJ) $(SWIGRUBYSO)
+
+clean: clean-pywrap clean-rubywrap
+	-rm -f $(LIBPC) $(OBJS) $(LOBJS) $(LIBA) $(LIBSO) $(TARGET) *.o *.lo *~
 
 distclean: clean
 	rm -f $(GENERATED) $(SWIGFILES)
