diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000000000000000000000000000000000000..46871cf7bb86eaaec4f661b6aef2bd399a734869
--- /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 0000000000000000000000000000000000000000..4fe71658a7bb74e226b4207ba07069cd52d0f645
--- /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 945ea260236ca2625975c3d5e26f6b83de9d1747..84597078cc773b9b1783a50a7d1d071d3669373b 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 3532f5ef868c65f55bed04b529507383f567aa19..ac2f0f5de31ab112f36983a7077004d0ee7aa836 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 0000000000000000000000000000000000000000..97dbed6d683629992c68cef3bebeca706b7439f3
--- /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 0000000000000000000000000000000000000000..d0fb9d9e4322eaa5a310c5a8a9822641855f5781
--- /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 0000000000000000000000000000000000000000..e3d61b8035e53802bd20f56020cde4c81fc51b09
--- /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 0000000000000000000000000000000000000000..7c28309ff8f84016dbe2797a70fccbc25f97066d
--- /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 0000000000000000000000000000000000000000..a4d0c84db8f57738182818a0c89d407159f455bc
--- /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)