Subject: Restore nx-libs bin/Makefile with DESTDIR fixes
From: Orion Poplawski <[email-masked]>
To: [email-masked]
Date: Wed, 12 Dec 2012 15:40:23 -0700

Package: nx-libs
Version: HEAD
Tags: patch

These patches restore bin/Makefile using the new scheme for handling the main 
Makefile.  It also adds some more support for DESTDIR/rpm systems.

-- 
Orion Poplawski
Technical Manager                     303-415-9701 x222
NWRA, Boulder Office                  FAX: 303-415-9702
3380 Mitchell Lane                       [email-masked]
Boulder, CO 80301                   http://www.nwra.com

>From 7794670678d19af028fbd9d54b1e74fa7d596877 Mon Sep 17 00:00:00 2001
From: Orion Poplawski <[email-masked]>
Date: Wed, 12 Dec 2012 15:11:22 -0700
Subject: [PATCH 1/2] Re-add bin/Makefile with DESTDIR fixes

---
 debian/Makefile.bin     | 34 ++++++++++++++++++++++++++++++++++
 debian/roll-tarballs.sh |  3 +++
 2 files changed, 37 insertions(+)
 create mode 100644 debian/Makefile.bin

diff --git a/debian/Makefile.bin b/debian/Makefile.bin
new file mode 100644
index 0000000..45f43e6
--- /dev/null
+++ b/debian/Makefile.bin
@@ -0,0 +1,34 @@
+#!/usr/bin/make -f
+
+ifndef DESTDIR
+INSTALL_DIR=install -d -o root -g root -m 755
+INSTALL_FILE=install -o root -g root -m 644
+INSTALL_PROGRAM=install -o root -g root -m 755
+else
+INSTALL_DIR=install -d -m 755
+INSTALL_FILE=install -m 644
+INSTALL_PROGRAM=install -m 755
+endif
+
+RM_FILE=rm -f
+RM_DIR=rmdir -p --ignore-fail-on-non-empty
+
+PREFIX ?= /usr/local
+BINDIR=$(PREFIX)/bin
+NXLIBDIR=$(PREFIX)/lib/nx
+X2GOLIBDIR=$(PREFIX)/lib/x2go
+
+%:
+	echo "Nothing to do for $@..."
+
+install:
+	$(INSTALL_DIR) $(DESTDIR)$(X2GOLIBDIR)/bin/
+	ln -sf $(NXLIBDIR)/bin/nxagent $(DESTDIR)$(X2GOLIBDIR)/bin/x2goagent
+	find nx* | while read file; do $(INSTALL_PROGRAM) $$file $(DESTDIR)$(BINDIR)/; done
+	find x2go* | while read file; do $(INSTALL_PROGRAM) $$file $(DESTDIR)$(BINDIR)/; done
+
+uninstall:
+	find nx* | while read file; do rm -f $(DESTDIR)$(BINDIR)/$$file; done
+	find x2go* | while read file; do rm -f $(DESTDIR)$(BINDIR)/$$file; done
+	$(RM_FILE) $(DESTDIR)$(X2GOLIBDIR)/bin/x2goagent
+	$(RM_DIR) $(DESTDIR)$(X2GOLIBDIR)/bin/
diff --git a/debian/roll-tarballs.sh b/debian/roll-tarballs.sh
index b7f0c3e..1345317 100755
--- a/debian/roll-tarballs.sh
+++ b/debian/roll-tarballs.sh
@@ -113,6 +113,9 @@ mv -v debian/changelog doc/changelog
 # copy the top-level makefile if no quilt patch created it before
 test -f Makefile || test -f debian/Makefile.nx-libs && cp -v debian/Makefile.nx-libs Makefile
 
+# copy the bin makefile if no quilt patch created it before
+test -f bin/Makefile || test -f debian/Makefile.bin && cp -v debian/Makefile.bin bin/Makefile
+
 # remove folders that we do not want to roll into the tarball
 rm -Rf ".pc/"
 rm -Rf "debian/"
-- 
1.8.0.2

>From f39e78d61845c52b2a471a7f26e02b8487fd28e8 Mon Sep 17 00:00:00 2001
From: Orion Poplawski <[email-masked]>
Date: Wed, 12 Dec 2012 15:20:12 -0700
Subject: [PATCH 2/2] Make $(DESTDIR)$(BINDIR) if necessary in bin/Makefile

---
 debian/Makefile.bin | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debian/Makefile.bin b/debian/Makefile.bin
index 45f43e6..c94ec15 100644
--- a/debian/Makefile.bin
+++ b/debian/Makefile.bin
@@ -24,6 +24,7 @@ X2GOLIBDIR=$(PREFIX)/lib/x2go
 install:
 	$(INSTALL_DIR) $(DESTDIR)$(X2GOLIBDIR)/bin/
 	ln -sf $(NXLIBDIR)/bin/nxagent $(DESTDIR)$(X2GOLIBDIR)/bin/x2goagent
+	[ ! -d $(DESTDIR)$(BINDIR) ] && $(INSTALL_DIR) $(DESTDIR)$(BINDIR)
 	find nx* | while read file; do $(INSTALL_PROGRAM) $$file $(DESTDIR)$(BINDIR)/; done
 	find x2go* | while read file; do $(INSTALL_PROGRAM) $$file $(DESTDIR)$(BINDIR)/; done
 
-- 
1.8.0.2