--- keyutils-1.5.9.orig/Makefile	2014-02-21 16:18:24.000000000 +0100
+++ keyutils-1.5.9/Makefile	2014-05-06 13:48:58.025306027 +0200
@@ -1,5 +1,5 @@
-CPPFLAGS	:= -I.
-CFLAGS		:= -g -Wall -Werror
+CPPFLAGS	?= -I.
+CFLAGS		?= -g -Wall -Werror
 INSTALL		:= install
 DESTDIR		:=
 SPECFILE	:= keyutils.spec
@@ -54,29 +54,8 @@ LIBNAME		:= libkeyutils.so.$(APIVERSION)
 # Guess at the appropriate lib directory and word size
 #
 ###############################################################################
-ifeq ($(origin LIBDIR),undefined)
-LIBDIR		:= $(shell ldd /usr/bin/make | grep '\(/libc\)' | sed -e 's!.*\(/.*\)/libc[.].*!\1!')
-endif
-ifeq ($(origin USRLIBDIR),undefined)
-USRLIBDIR	:= $(patsubst /lib/%,/usr/lib/%,$(LIBDIR))
-endif
-BUILDFOR	:= $(shell file /usr/bin/make | sed -e 's!.*ELF \(32\|64\)-bit.*!\1!')-bit
-
-LNS		:= ln -sf
-
-ifeq ($(origin CFLAGS),undefined)
-ifeq ($(BUILDFOR),32-bit)
-CFLAGS		+= -m32
-LIBDIR		:= /lib
 USRLIBDIR	:= /usr/lib
-else
-ifeq ($(BUILDFOR),64-bit)
-CFLAGS		+= -m64
-LIBDIR		:= /lib64
-USRLIBDIR	:= /usr/lib64
-endif
-endif
-endif
+LNS		:= ln -sf
 
 ###############################################################################
 #
@@ -95,7 +74,7 @@ endif
 # Normal build rule
 #
 ###############################################################################
-all: $(DEVELLIB) keyctl request-key key.dns_resolver
+all: $(DEVELLIB)
 
 ###############################################################################
 #
@@ -156,38 +135,15 @@ key.dns_resolver: key.dns_resolver.o $(D
 ###############################################################################
 install: all
 ifeq ($(NO_ARLIB),0)
-	$(INSTALL) -D -m 0644 $(ARLIB) $(DESTDIR)$(USRLIBDIR)/$(ARLIB)
+	$(INSTALL) -d $(DESTDIR)$(USRLIBDIR)
+	$(INSTALL) -m 0644 $(ARLIB) $(DESTDIR)$(USRLIBDIR)/$(ARLIB)
 endif
-	$(INSTALL) -D $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(LIBNAME)
-	$(LNS) $(LIBNAME) $(DESTDIR)$(LIBDIR)/$(SONAME)
-	mkdir -p $(DESTDIR)$(USRLIBDIR)
-	$(LNS) $(LIBDIR)/$(SONAME) $(DESTDIR)$(USRLIBDIR)/$(DEVELLIB)
-	$(INSTALL) -D keyctl $(DESTDIR)$(BINDIR)/keyctl
-	$(INSTALL) -D request-key $(DESTDIR)$(SBINDIR)/request-key
-	$(INSTALL) -D request-key-debug.sh $(DESTDIR)$(SHAREDIR)/request-key-debug.sh
-	$(INSTALL) -D key.dns_resolver $(DESTDIR)$(SBINDIR)/key.dns_resolver
-	$(INSTALL) -D -m 0644 request-key.conf $(DESTDIR)$(ETCDIR)/request-key.conf
-	mkdir -p $(DESTDIR)$(ETCDIR)/request-key.d
-	mkdir -p $(DESTDIR)$(MAN1)
-	$(INSTALL) -m 0644 $(wildcard man/*.1) $(DESTDIR)$(MAN1)
-	mkdir -p $(DESTDIR)$(MAN3)
-	$(INSTALL) -m 0644 $(wildcard man/*.3) $(DESTDIR)$(MAN3)
-	mkdir -p $(DESTDIR)$(MAN5)
-	$(INSTALL) -m 0644 $(wildcard man/*.5) $(DESTDIR)$(MAN5)
-	mkdir -p $(DESTDIR)$(MAN7)
-	$(INSTALL) -m 0644 $(wildcard man/*.7) $(DESTDIR)$(MAN7)
-	mkdir -p $(DESTDIR)$(MAN8)
-	$(INSTALL) -m 0644 $(wildcard man/*.8) $(DESTDIR)$(MAN8)
-	$(LNS) keyctl_describe.3 $(DESTDIR)$(MAN3)/keyctl_describe_alloc.3
-	$(LNS) keyctl_get_security.3 $(DESTDIR)$(MAN3)/keyctl_get_security_alloc.3
-	$(LNS) keyctl_instantiate.3 $(DESTDIR)$(MAN3)/keyctl_instantiate_iov.3
-	$(LNS) keyctl_instantiate.3 $(DESTDIR)$(MAN3)/keyctl_reject.3
-	$(LNS) keyctl_instantiate.3 $(DESTDIR)$(MAN3)/keyctl_negate.3
-	$(LNS) keyctl_instantiate.3 $(DESTDIR)$(MAN3)/keyctl_assume_authority.3
-	$(LNS) keyctl_link.3 $(DESTDIR)$(MAN3)/keyctl_unlink.3
-	$(LNS) keyctl_read.3 $(DESTDIR)$(MAN3)/keyctl_read_alloc.3
-	$(LNS) recursive_key_scan.3 $(DESTDIR)$(MAN3)/recursive_session_key_scan.3
-	$(INSTALL) -D -m 0644 keyutils.h $(DESTDIR)$(INCLUDEDIR)/keyutils.h
+	$(INSTALL) -d $(DESTDIR)$(USRLIBDIR)
+	$(INSTALL) $(LIBNAME) $(DESTDIR)$(USRLIBDIR)/$(LIBNAME)
+	$(LNS) $(LIBNAME) $(DESTDIR)$(USRLIBDIR)/$(SONAME)
+	$(LNS) $(USRLIBDIR)/$(SONAME) $(DESTDIR)$(USRLIBDIR)/$(DEVELLIB)
+	$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)
+	$(INSTALL) -m 0644 keyutils.h $(DESTDIR)$(INCLUDEDIR)/keyutils.h
 
 ###############################################################################
 #
@@ -231,7 +187,7 @@ tarball: $(ZTARBALL)
 SRCBALL	:= rpmbuild/SOURCES/$(TARBALL)
 
 BUILDID	:= .local
-dist	:= $(word 2,$(shell grep "%dist" /etc/rpm/macros.dist))
+dist	:= OpenADK
 release	:= $(word 2,$(shell grep ^Release: $(SPECFILE)))
 release	:= $(subst %{?dist},$(dist),$(release))
 release	:= $(subst %{?buildid},$(BUILDID),$(release))
