doc: install example .cfg files to $(docdir)/examples/

Change-Id: I8671ce33b9bf28c89f767dd1b4a1463aeb275158
diff --git a/Makefile.am b/Makefile.am
index 392d80d..f5062a2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
 AUTOMAKE_OPTIONS = foreign dist-bzip2
 
 SUBDIRS = \
+	doc \
 	src \
 	sql \
 	tests \
diff --git a/configure.ac b/configure.ac
index 1db32d4..d72a026 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,6 +64,7 @@
 
 AC_OUTPUT(
 	Makefile
+	doc/Makefile
 	src/Makefile
 	sql/Makefile
 	tests/Makefile
diff --git a/debian/osmo-hlr.install b/debian/osmo-hlr.install
index 0e2a1c4..1e3bbc6 100644
--- a/debian/osmo-hlr.install
+++ b/debian/osmo-hlr.install
@@ -1,3 +1,4 @@
 /usr/bin/osmo-hlr
 /usr/bin/osmo-hlr-db-tool
 /usr/share/doc/osmo-hlr/hlr.sql
+/usr/share/doc/osmo-hlr/examples/osmo-hlr.cfg
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..e0e5380
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,22 @@
+CFG_FILES = find $(srcdir) -name '*.cfg*' | sed -e 's,^$(srcdir),,'
+
+dist-hook:
+	for f in $$($(CFG_FILES)); do \
+		j="$(distdir)/$$f" && \
+		mkdir -p "$$(dirname $$j)" && \
+		$(INSTALL_DATA) $(srcdir)/$$f $$j; \
+	done
+
+install-data-hook:
+	for f in $$($(CFG_FILES)); do \
+		j="$(DESTDIR)$(docdir)/$$f" && \
+		mkdir -p "$$(dirname $$j)" && \
+		$(INSTALL_DATA) $(srcdir)/$$f $$j; \
+	done
+
+uninstall-hook:
+	@$(PRE_UNINSTALL)
+	for f in $$($(CFG_FILES)); do \
+		j="$(DESTDIR)$(docdir)/$$f" && \
+		$(RM) $$j; \
+	done