webgui: installation, distribution
diff --git a/src/Makefile.am b/src/Makefile.am
index 1075be4..b0c8c8b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,65 +1,41 @@
-ARCSID = @ARCSID@
-RCSID = @RCSID@
-
 SRCS=mod_netconf.c \
-     notification-server.c \
-     test-client.c
+     notification-server.c
 
 HDRS=message_type.h \
      notification_module.h \
      mod_netconf.h
 
-all: module client webgui-backend
+noinst_PROGRAMS=webgui-backend test-client
+webgui_backend_SOURCES=mod_netconf.c notification-server.c message_type.h notification_module.h mod_netconf.h
+test_client_SOURCES=test-client.c
 
-module: mod_netconf.c
-	$(APXS) $(LIBS) $(ARCSID) $(CFLAGS) -c mod_netconf.c notification-server.c
+EXTRA_DIST=$(SRCS) $(HDRS)
 
-client: test-client.c
-	gcc $(RCSID) -std=gnu99 -Wall -g -ljson -I/usr/include/json test-client.c -o test-client
+dist-hook:
+	cp $(SRC) $(HDRS) $(distdir)
 
-notification-test: notification-server.c
-	gcc $(RCSID) -std=gnu99 -Wall -g -lwebsockets -DTEST_NOTIFICATION_SERVER notification-server.c -o notification-test
+all: mod_netconf.so test-client webgui-backend
 
-install-exec-local: module
-	$(APXS) -i -a mod_netconf.la
+mod_netconf.so: mod_netconf.c notification-server.c
+	$(APXS) $(LIBS) $(CFLAGS) -c -o $@ $(srcdir)/mod_netconf.c $(srcdir)/notification-server.c
 
-install-data-local: $(TARGETS)
-	[ -d $(DESTDIR)/etc/httpd/modules ] || \
-		(mkdir -p $(DESTDIR)/$(libdir)/httpd/modules; chmod 755 $(DESTDIR)/$(libdir)/httpd/modules)
-	[ -d $(DESTDIR)/$(sysconfdir)/httpd/conf.d/ ] || \
-		mkdir -p $(DESTDIR)/$(sysconfdir)/httpd/conf.d/; chmod 755 $(DESTDIR)/$(sysconfdir)/httpd/conf.d/;
-	cp mod_netconf.conf $(DESTDIR)/$(sysconfdir)/httpd/conf.d/
-#install-exec-local: $(TARGETS)
-#	$(APXS) -i $(NAME).la
+test-client$(EXEEXT): test-client.c
+	gcc -std=gnu99 -Wall -g -ljson -I/usr/include/json -o $@ $<
+
+#notification-test$(EXEEXT): notification-server.c
+#	gcc -std=gnu99 -Wall -g -lwebsockets -DTEST_NOTIFICATION_SERVER -o $@ $<
+
+install-exec-local: mod_netconf.so
+	[ "x$(httpdmoduledir)" != x ] || \
+	$(APXS) -i -a mod_netconf.la && \
+	{ mkdir -p "$(httpdmoduledir)"; $(APXS) -i -S LIBEXECDIR="$(httpdmoduledir)" -a mod_netconf.la; }
+
+webgui-backend$(EXEEXT): mod_netconf.c notification-server.c mod_netconf.h
+	gcc -Wall -g @SAVED_CFLAGS@ -DHTTPD_INDEPENDENT  `apr-1-config  --cflags --cppflags --includes --link-ld` -I/usr/include/httpd @SAVED_LIBS@ -laprutil-1 -o $@ $(srcdir)/mod_netconf.c $(srcdir)/notification-server.c
 
 clean-local:
 	rm -rf .libs *.la *.lo *.slo test-client webgui-backend
 
-#.PHONY: tarball
-#tarball: $(SRCS) $(HEADERS)
-#	@rm -rf $(NAME)-$(VERSION);
-#	@mkdir $(NAME)-$(VERSION);
-#	for i in $(SRCS) $(HDRS) mod_netconf.conf README configure.in configure \
-#	    Makefile.in VERSION $(NAME).spec.in install-sh; do \
-#	    [ -d $(NAME)-$(VERSION)/$$(dirname $$i) ] || (mkdir -p $(NAME)-$(VERSION)/$$(dirname $$i)); \
-#		cp $$i $(NAME)-$(VERSION)/$$i; \
-#	done;
-#	@rm -rf $(RPMDIR)/SOURCES/; \
-#	mkdir -p $(RPMDIR)/SOURCES/; \
-#	tar -c -z -f $(RPMDIR)/SOURCES/$(NAME)-$(VERSION)-$(RELEASE).tar.gz \
-#	    $(NAME)-$(VERSION); \
-#	rm -rf $(NAME)-$(VERSION);
-#
-#.PHONY: rpm
-#rpm: tarball
-#	mkdir -p $(RPMDIR)/BUILD $(RPMDIR)/RPMS $(RPMDIR)/SRPMS
-#	$(RPMBUILD) -ba $(PKGNAME).spec \
-#	--define "_topdir `pwd`/$(RPMDIR)";
-#
-#.PHONY: distclean
-#distclean:
-#	rm -rf $(RPMDIR)
-
-webgui-backend: mod_netconf.c notification-server.c mod_netconf.h
-	gcc -Wall -g @SAVED_CFLAGS@ -DHTTPD_INDEPENDENT  $(RCSID) `apr-1-config  --cflags --cppflags --includes --link-ld` -I/usr/include/httpd @SAVED_LIBS@ -laprutil-1 -o $@ mod_netconf.c notification-server.c
+distclean-local:
+	rm -rf $(RPMDIR)