From e5da6f28a7f33c05b1566d00cdb3c3b86b532fdc Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Mon, 6 Nov 2017 14:22:25 +0100
Subject: [PATCH] add autoconf-based installation system

---
 Makefile.am                                   |  1 +
 bin/Makefile.am                               | 19 ++++++
 ...client.pl => account-manager-client.pl.in} |  6 +-
 ...nager-web.pl => account-manager-web.pl.in} |  4 +-
 conf/Makefile.am                              |  8 +++
 configure.ac                                  | 22 +++++++
 lib/Makefile.am                               | 18 ++++++
 resources/Makefile.am                         | 62 +++++++++++++++++++
 templates/Makefile.am                         | 28 +++++++++
 9 files changed, 163 insertions(+), 5 deletions(-)
 create mode 100644 Makefile.am
 create mode 100644 bin/Makefile.am
 rename bin/{account-manager-client.pl => account-manager-client.pl.in} (99%)
 rename bin/{account-manager-web.pl => account-manager-web.pl.in} (86%)
 create mode 100644 conf/Makefile.am
 create mode 100644 configure.ac
 create mode 100644 lib/Makefile.am
 create mode 100644 resources/Makefile.am
 create mode 100644 templates/Makefile.am

diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..46871cf
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = bin conf lib resources templates
diff --git a/bin/Makefile.am b/bin/Makefile.am
new file mode 100644
index 0000000..4fe7165
--- /dev/null
+++ b/bin/Makefile.am
@@ -0,0 +1,19 @@
+bin_SCRIPTS = account-manager-client.pl
+
+www_SCRIPTS = account-manager-web.pl
+
+EXTRA_DIST = account-manager-client.pl.in account-manager-web.pl.in
+
+account-manager-client.pl: Makefile account-manager-client.pl.in
+	sed \
+		-e 's|[@]modulesdir[@]|$(modulesdir)|' \
+		-e 's|[@]sysconfdir[@]|$(sysconfdir)|' \
+		< $(srcdir)/$@.in > $@
+	chmod +x $@
+
+account-manager-web.pl: Makefile account-manager-web.pl.in
+	sed \
+		-e 's|[@]modulesdir[@]|$(modulesdir)|' \
+		-e 's|[@]sysconfdir[@]|$(sysconfdir)|' \
+		< $(srcdir)/$@.in > $@
+	chmod +x $@
diff --git a/bin/account-manager-client.pl b/bin/account-manager-client.pl.in
similarity index 99%
rename from bin/account-manager-client.pl
rename to bin/account-manager-client.pl.in
index 945ea26..8459707 100755
--- a/bin/account-manager-client.pl
+++ b/bin/account-manager-client.pl.in
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 use utf8;
-use lib qw(lib);
+use lib qw(@modulesdir@);
 use feature "switch";
 no warnings 'experimental::smartmatch';
 
@@ -46,7 +46,7 @@ pod2usage(
 ) unless $action;
 
 my $configuration = IdPAccountManager::Configuration->new(
-    file => 'conf/IdPAccountManager.conf'
+    file => '@sysconfdir@/IdPAccountManager.conf'
 );
 
 IdPAccountManager::DB->register_db(
@@ -140,7 +140,7 @@ sub list_test_accounts {
 
         die "failed to update simpleSAMLphp configuration file\n"
             unless IdPAccountManager::Tools::update_ssp_authsources(
-                $configuration->{root_manager_dir},
+                $configuration->{templates_dir},
                 $configuration
             );
 
diff --git a/bin/account-manager-web.pl b/bin/account-manager-web.pl.in
similarity index 86%
rename from bin/account-manager-web.pl
rename to bin/account-manager-web.pl.in
index 3532f5e..ac2f0f5 100755
--- a/bin/account-manager-web.pl
+++ b/bin/account-manager-web.pl.in
@@ -3,13 +3,13 @@
 use strict;
 use warnings;
 use utf8;
-use lib qw(lib);
+use lib qw(@modulesdir@);
 
 use IdPAccountManager::Configuration;
 use IdPAccountManager::WebRequest;
 
 my $configuration = IdPAccountManager::Configuration->new(
-    file => 'conf/IdPAccountManager.conf'
+    file => '@sysconfdir@/IdPAccountManager.conf'
 );
 
 ## Gives writes for the group
diff --git a/conf/Makefile.am b/conf/Makefile.am
new file mode 100644
index 0000000..97dbed6
--- /dev/null
+++ b/conf/Makefile.am
@@ -0,0 +1,8 @@
+noinst_DATA = IdPAccountManager.conf
+
+install-data-local:
+	if [ -f $(DESTDIR)$(sysconfdir)/IdPAccountManager.conf ]; then                                           \
+	    $(INSTALL_DATA) $(srcdir)/IdPAccountManager.conf $(DESTDIR)$(sysconfdir)/IdPAccountManager.conf.new; \
+	else                                                                                                     \
+	    $(INSTALL_DATA) $(srcdir)/IdPAccountManager.conf $(DESTDIR)$(sysconfdir)/IdPAccountManager.conf;     \
+	fi
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..d0fb9d9
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,22 @@
+AC_PREREQ(2.59)
+AC_INIT([IdP Account Manager], 0.1)
+AM_INIT_AUTOMAKE([foreign])
+
+wwwdir=$datadir/idp-account-manager/www
+modulesdir=$datadir/idp-account-manager/lib
+templatesdir=$datadir/idp-account-manager/templates
+
+AC_SUBST(wwwdir)
+AC_SUBST(modulesdir)
+AC_SUBST(templatesdir)
+
+AC_CONFIG_FILES(
+    Makefile
+    bin/Makefile
+    conf/Makefile
+    lib/Makefile
+    templates/Makefile
+    resources/Makefile
+)
+
+AC_OUTPUT
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 0000000..e3d61b8
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1,18 @@
+modulesdir = $(pkgdatadir)/lib
+
+nobase_modules_DATA = \
+	IdPAccountManager/Configuration.pm \
+	IdPAccountManager/Data/AuthenticationToken.pm \
+	IdPAccountManager/Data/AuthenticationToken/Manager.pm \
+	IdPAccountManager/Data/ServiceProvider.pm \
+	IdPAccountManager/Data/ServiceProvider/Manager.pm \
+	IdPAccountManager/Data/TestAccount.pm \
+	IdPAccountManager/Data/TestAccount/Manager.pm \
+	IdPAccountManager/DB.pm \
+	IdPAccountManager/DB/Object.pm \
+	IdPAccountManager/Logger.pm \
+	IdPAccountManager/SAMLMetadata.pm \
+	IdPAccountManager/Tools.pm \
+	IdPAccountManager/WebRequest.pm
+
+EXTRA_DIST = $(nobase_modules_DATA)
diff --git a/resources/Makefile.am b/resources/Makefile.am
new file mode 100644
index 0000000..7c28309
--- /dev/null
+++ b/resources/Makefile.am
@@ -0,0 +1,62 @@
+nobase_www_DATA = \
+	css/style.css \
+	foundation/css/foundation.css \
+	foundation/css/foundation.min.css \
+	foundation/css/normalize.css \
+	foundation/humans.txt \
+	foundation/img/.gitkeep \
+	foundation/index.html \
+	foundation/js/foundation/foundation.abide.js \
+	foundation/js/foundation/foundation.accordion.js \
+	foundation/js/foundation/foundation.alert.js \
+	foundation/js/foundation/foundation.clearing.js \
+	foundation/js/foundation/foundation.dropdown.js \
+	foundation/js/foundation/foundation.equalizer.js \
+	foundation/js/foundation/foundation.interchange.js \
+	foundation/js/foundation/foundation.joyride.js \
+	foundation/js/foundation/foundation.js \
+	foundation/js/foundation/foundation.magellan.js \
+	foundation/js/foundation/foundation.offcanvas.js \
+	foundation/js/foundation/foundation.orbit.js \
+	foundation/js/foundation/foundation.reveal.js \
+	foundation/js/foundation/foundation.slider.js \
+	foundation/js/foundation/foundation.tab.js \
+	foundation/js/foundation/foundation.tooltip.js \
+	foundation/js/foundation/foundation.topbar.js \
+	foundation/js/foundation.min.js \
+	foundation/js/vendor/fastclick.js \
+	foundation/js/vendor/jquery.cookie.js \
+	foundation/js/vendor/jquery.js \
+	foundation/js/vendor/modernizr.js \
+	foundation/js/vendor/placeholder.js \
+	foundation/robots.txt \
+	images/edugain_favicon.png \
+	images/edugain_logo.png \
+	images/edugain_test_idp_basics.png \
+	images/favicon_geant.ico \
+	images/favicon.png \
+	images/geant_logo_rgb_300dpi.jpg \
+	jquery-1.11.1.min.js \
+	jquery.cookie-1.4.1.min.js \
+	jquery.steps.1.1.0.min.js \
+	jquery.steps.css \
+	jquery-ui-1.11.1/images/ui-bg_diagonals-thick_18_b81900_40x40.png \
+	jquery-ui-1.11.1/images/ui-bg_diagonals-thick_20_666666_40x40.png \
+	jquery-ui-1.11.1/images/ui-bg_flat_10_000000_40x100.png \
+	jquery-ui-1.11.1/images/ui-bg_glass_100_f6f6f6_1x400.png \
+	jquery-ui-1.11.1/images/ui-bg_glass_100_fdf5ce_1x400.png \
+	jquery-ui-1.11.1/images/ui-bg_glass_65_ffffff_1x400.png \
+	jquery-ui-1.11.1/images/ui-bg_gloss-wave_35_f6a828_500x100.png \
+	jquery-ui-1.11.1/images/ui-bg_highlight-soft_100_eeeeee_1x100.png \
+	jquery-ui-1.11.1/images/ui-bg_highlight-soft_75_ffe45c_1x100.png \
+	jquery-ui-1.11.1/images/ui-icons_222222_256x240.png \
+	jquery-ui-1.11.1/images/ui-icons_228ef1_256x240.png \
+	jquery-ui-1.11.1/images/ui-icons_ef8c08_256x240.png \
+	jquery-ui-1.11.1/images/ui-icons_ffd27a_256x240.png \
+	jquery-ui-1.11.1/images/ui-icons_ffffff_256x240.png \
+	jquery-ui-1.11.1/jquery-ui.min.css \
+	jquery-ui-1.11.1/jquery-ui.min.js \
+	jquery.validate.1.13.0.min.js \
+	presentation.html
+
+EXTRA_DIST = $(nobase_www_DATA)
diff --git a/templates/Makefile.am b/templates/Makefile.am
new file mode 100644
index 0000000..a4d0c84
--- /dev/null
+++ b/templates/Makefile.am
@@ -0,0 +1,28 @@
+nobase_templates_DATA = \
+	accountProfiles/alumni1.tt2 \
+	accountProfiles/employee1.tt2 \
+	accountProfiles/fullset1.tt2 \
+	accountProfiles/generic1.tt2 \
+	accountProfiles/librarywalkin1.tt2 \
+	accountProfiles/limitedset1.tt2 \
+	accountProfiles/researcher1.tt2 \
+	accountProfiles/student1.tt2 \
+	accountProfiles/student2.tt2 \
+	accountProfiles/teacher1.tt2 \
+	accountProfiles/teacher2.tt2 \
+	accountProfiles/valid-accounts.php.tt2 \
+	mail/notification_generic_error.tt2.eml \
+	mail/send_authentication_token.tt2.eml \
+	web/account_wizard.tt2.html \
+	web/content.tt2.html \
+	web/errors.tt2.html \
+	web/generate_token.tt2.html \
+	web/home.tt2.html \
+	web/index.tt2.html \
+	web/index-nobanner.tt2.html \
+	web/notices.tt2.html \
+	web/select_sp.tt2.html \
+	web/title.tt2.html \
+	web/validate_token.tt2.html
+
+EXTRA_DIST = $(nobase_templates_DATA)
-- 
GitLab