From 7aa8e8453068b2ee5d23a4efbc2e26d47ae5e506 Mon Sep 17 00:00:00 2001
From: Christian Pointner <equinox@helsinki.at>
Date: Tue, 13 Apr 2010 11:44:59 +0000
Subject: added configure script and Makefile for Installation


diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1f99b40
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,62 @@
+##
+##  rhimport
+##
+##  Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+##
+##  This file is part of rhimport.
+##
+##  rhimport is free software: you can redistribute it and/or modify
+##  it under the terms of the GNU General Public License as published by
+##  the Free Software Foundation, either version 3 of the License, or
+##  any later version.
+##
+##  rhimport is distributed in the hope that it will be useful,
+##  but WITHOUT ANY WARRANTY; without even the implied warranty of
+##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+##  GNU General Public License for more details.
+##
+##  You should have received a copy of the GNU General Public License
+##  along with rhimport. If not, see <http://www.gnu.org/licenses/>.
+##
+
+ifneq ($(MAKECMDGOALS),distclean)
+include include.mk
+endif
+
+.PHONY: clean distclean
+
+EXECUTABLE := rhimport
+
+all: $(EXECUTABLE)
+
+distclean: clean
+	find . -name "*.\~*" -exec rm -rf {} \;
+	rm -f include.mk
+
+clean:
+
+INSTALL_TARGETS := install-bin install-share
+REMOVE_TARGETS := remove-bin remove-share
+
+install: $(INSTALL_TARGETS)
+
+install-bin:
+	$(INSTALL) -d $(DESTDIR)$(BINDIR)
+	$(INSTALL) -m 755 $(EXECUTABLE) $(DESTDIR)$(BINDIR)
+	@sed s#/usr/local/share/rhimport/#$(SHAREDIR)/$(EXECUTABLE)/#g -i $(DESTDIR)$(BINDIR)/$(EXECUTABLE)
+
+install-share:
+	$(INSTALL) -d $(DESTDIR)$(SHAREDIR)/$(EXECUTABLE)
+	$(INSTALL) -m 644 rhimport.pm $(DESTDIR)$(SHAREDIR)/$(EXECUTABLE)
+	$(INSTALL) -m 644 gui_callbacks.pm $(DESTDIR)$(SHAREDIR)/$(EXECUTABLE)
+	$(INSTALL) -m 644 rhimport.glade $(DESTDIR)$(SHAREDIR)/$(EXECUTABLE)
+
+uninstall: remove
+
+remove: $(REMOVE_TARGETS)
+
+remove-bin:
+	rm -f $(DESTDIR)$(BINDIR)/$(EXECUTABLE)
+
+remove-share:
+	rm -rf $(DESTDIR)$(SHAREDIR)/$(EXECUTABLE)
diff --git a/configure b/configure
new file mode 100755
index 0000000..b3692af
--- /dev/null
+++ b/configure
@@ -0,0 +1,87 @@
+#!/bin/sh
+#
+#
+#  rhimport
+#
+#  Copyright (C) 2009 Christian Pointner <equinox@helsinki.at>
+#
+#  This file is part of rhimport.
+#
+#  rhimport is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  any later version.
+#
+#  rhimport is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with rhimport. If not, see <http://www.gnu.org/licenses/>.
+#
+
+PREFIX='/usr/local'
+BINDIR=''
+SHAREDIR=''
+
+print_usage() {
+  echo "configure --help                    print this"
+  echo "          --prefix=<PREFIX>         the installation prefix (default: /usr/local)"
+  echo "          --bindir=<DIR>            the path to the bin directory (default: $PREFIX/bin)"
+  echo "          --sharedir=<DIR>          the path to shared resources (default: $PREFIX/share"
+}
+
+for arg
+do
+  case $arg in
+  --prefix=*)
+    PREFIX=${arg#--prefix=}
+  ;;
+  --bindir=*)
+    BINDIR=${arg#--bindir=}
+  ;;
+  --sharedir=*)
+    SHAREDIR=${arg#--sharedir=}
+  ;;
+  --help)
+    print_usage
+    exit 0
+  ;;
+  *)
+    ERRORS="$ERRORS $arg"
+  ;;
+  esac
+done
+
+if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then
+  for error in $ERRORS; do
+    echo "Unknown argument: $error"
+  done
+
+  print_usage
+  exit 1
+fi
+
+rm -f include.mk
+if [ -z "$BINDIR" ]; then
+  BINDIR=$PREFIX/bin
+fi
+
+if [ -z "$SHAREDIR" ]; then
+  SHAREDIR=$PREFIX/share
+fi
+
+cat >> include.mk <<EOF
+# this file was created automatically
+# do not edit this file directly 
+# use ./configure instead
+
+INSTALL := install
+
+PREFIX := $PREFIX
+BINDIR := $BINDIR
+SHAREDIR := $SHAREDIR
+EOF
+
+exit 0
diff --git a/rhimport b/rhimport
index b59ebfd..2e4729e 100755
--- a/rhimport
+++ b/rhimport
@@ -28,8 +28,9 @@ use DBI;
 use Gtk2;
 use Gtk2::GladeXML;
 
-use lib '/usr/share/perl5/rhimport/';
+use lib '/usr/local/share/rhimport/';
 use rhimport;
+my $glade_file = '/usr/local/share/rhimport/rhimport.glade';
 
 my $DBHOST = "airplay";
 my $DBUSER = "rivendell";
@@ -322,7 +323,7 @@ sub dropbox_updated_gui()
 if(!$FILE || !$DROPBOX) {
   Gtk2->init;
 
-  $guixml = Gtk2::GladeXML->new('rhimport.glade');
+  $guixml = Gtk2::GladeXML->new($glade_file);
   $guixml or die "can't load glade xml file";
   require gui_callbacks;
 
diff --git a/rhimport.pm b/rhimport.pm
index 48b5b17..dc08479 100644
--- a/rhimport.pm
+++ b/rhimport.pm
@@ -31,7 +31,7 @@ use File::Spec;
 
 my $ssh_host = "airplay";
 my $ssh_user = "rhimport";
-my $ssh_key_file = "id_dsa"; # "/etc/rhimport/import_key";
+my $ssh_key_file = "~/.rhimport/import.key";
 my $ssh_dir = "/programm/.rhimport";
 my $rdimport_wrapper = "/usr/local/bin/dropbox_newfile.pl";
 
-- 
cgit v0.10.2