From a991b8c9a1a0019ef1a36bbec49c29827a3c57a2 Mon Sep 17 00:00:00 2001
From: P. J. McDermott <pjm@nac.net>
Date: Wed, 25 Jan 2012 03:47:44 -0500
Subject: Recurse into subdirectories in build system.

---
diff --git a/Makefile.in b/Makefile.in
index af9b635..77a7368 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -33,11 +33,11 @@ MAKE = @make@
 .PHONY: all
 all: sedscript
 	@printf 'Making executable files...\n'
-	@$(MAKE) -f src/Makefile all
+	@cd src && $(MAKE) all
 	@printf 'Making library files...\n'
-	@$(MAKE) -f lib/Makefile all
+	@cd lib && $(MAKE) all
 	@printf 'Making manual pages...\n'
-	@$(MAKE) -f man/Makefile all
+	@cd man && $(MAKE) all
 
 sedscript:
 	@printf 'Writing sed script...\n'
@@ -46,27 +46,35 @@ sedscript:
 
 .PHONY: clean
 clean:
+	@printf 'Deleting sed script...\n'
+	@rm -f sedscript
 	@printf 'Cleaning executable files...\n'
-	@$(MAKE) -f src/Makefile clean
+	@cd src && $(MAKE) clean
 	@printf 'Cleaning library files...\n'
-	@$(MAKE) -f lib/Makefile clean
+	@cd lib && $(MAKE) clean
 	@printf 'Cleaning manual pages...\n'
-	@$(MAKE) -f man/Makefile clean
+	@cd man && $(MAKE) clean
 
 .PHONY: install
 install: all
+	@printf 'Generating installation configuration...\n'
+	@echo '' > install.config
+	@if [ -n '$(DESTDIR)' ]; then \
+		mkdir -p '$(DESTDIR)'; \
+		echo "DESTDIR=$$(cd '$(DESTDIR)' && pwd)" >> install.config; \
+	fi
 	@printf 'Installing executable files...\n'
-	@$(MAKE) -f src/Makefile install
+	@cd src && $(MAKE) $$(cat ../install.config) install
 	@printf 'Installing libary files...\n'
-	@$(MAKE) -f lib/Makefile install
+	@cd lib && $(MAKE) $$(cat ../install.config) install
 	@printf 'Installing manual pages...\n'
-	@$(MAKE) -f man/Makefile install
+	@cd man && $(MAKE) $$(cat ../install.config) install
 
 .PHONY: uninstall
 uninstall:
 	@printf 'Uninstalling executable files...\n'
-	@$(MAKE) -f src/Makefile uninstall
+	@cd src && $(MAKE) uninstall
 	@printf 'Uninstalling library files...\n'
-	@$(MAKE) -f lib/Makefile uninstall
+	@cd lib && $(MAKE) uninstall
 	@printf 'Uninstalling manual pages...\n'
-	@$(MAKE) -f man/Makefile uninstall
+	@cd man && $(MAKE) uninstall
diff --git a/configure b/configure
index 17f2949..93372f5 100755
--- a/configure
+++ b/configure
@@ -128,6 +128,8 @@ fi
 if [ -z "${SRCDIR}" ]; then
 	SRCDIR=$(dirname "${0}")
 fi
+# Make SRCDIR an absolute path if it isn't already.
+SRCDIR=$(cd ${SRCDIR} && pwd)
 if [ -z "${PREFIX}" ]; then
 	PREFIX=/usr/local
 fi
diff --git a/lib/Makefile.in b/lib/Makefile.in
index a29e71b..cc2f4cb 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -34,25 +34,25 @@ all: $(OBJS)
 
 $(OBJS):
 	@printf '  SED %s\n' '$@'
-	@sed -f sedscript $(SRCDIR)/lib/$@ > lib/$@
+	@sed -f ../sedscript $(SRCDIR)/lib/$@ > $@
 
 .PHONY: clean
 clean:
-	@	for obj in $(OBJS); do \
-			printf '  RM lib/%s\n' "\${obj}"; \
-			rm -f lib/\${obj}; \
-		done
+	@for obj in $(OBJS); do \
+		printf '  RM lib/%s\n' "$${obj}"; \
+		rm -f $${obj}; \
+	done
 
 .PHONY: install
 install: all
-	@	for obj in $(OBJS); do \
-			printf '  INSTALL lib/%s\n' "\${obj}"; \
-			$(INSTALL) -D lib/\${obj} "$(DESTDIR)/$(LIBDIR)"; \
-		done
+	@for obj in $(OBJS); do \
+		printf '  INSTALL lib/%s\n' "$${obj}"; \
+		$(INSTALL) -D $${obj} "$(DESTDIR)/$(LIBDIR)/$${obj}"; \
+	done
 
 .PHONY: uninstall
 uninstall:
-	@	for obj in $(OBJ); do \
-			printf '  RM %s\n' "\${obj}"; \
-			rm -f "$(DESTDIR)/$(LIBDIR)/\${obj}"; \
-		done
+	@for obj in $(OBJ); do \
+		printf '  RM %s\n' "$${obj}"; \
+		rm -f "$(DESTDIR)/$(LIBDIR)/$${obj}"; \
+	done
diff --git a/man/Makefile.in b/man/Makefile.in
index 45059ca..4da185d 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -34,25 +34,27 @@ all: $(OBJS)
 
 $(OBJS):
 	@printf '  CP man/%s\n' '$@'
-	@cp $(SRCDIR)/man/$@ man/$@
+	@cp $(SRCDIR)/man/$@ $@
 
 .PHONY: clean
 clean:
-	@	for obj in $(OBJS); do \
-			printf '  RM man/%s\n' "\${obj}"; \
-			rm -f man/\${obj}; \
-		done
+	@for obj in $(OBJS); do \
+		printf '  RM man/%s\n' "$${obj}"; \
+		rm -f $${obj}; \
+	done
 
 .PHONY: install
 install: all
-	@	for obj in $(OBJS); do \
-			printf '  INSTALL man/%s\n' "\${obj}"; \
-			$(INSTALL) -D man/\${obj} "$(DESTDIR)/$(MANDIR)"; \
-		done
+	@for obj in $(OBJS); do \
+		printf '  INSTALL man/%s\n' "$${obj}"; \
+		section=$$(echo "$${obj}" | sed 's/^.*[.]\([0-9]\)$$/\1/'); \
+		$(INSTALL) -D $${obj} "$(DESTDIR)/$(MANDIR)/man$${section}/$${obj}"; \
+	done
 
 .PHONY: uninstall
 uninstall:
-	@	for obj in $(OBJ); do \
-			printf '  RM %s\n' "\${obj}"; \
-			rm -f "$(DESTDIR)/$(MANDIR)/\${obj}"; \
-		done
+	@for obj in $(OBJ); do \
+		printf '  RM %s\n' "$${obj}"; \
+		section=$$(echo "$${obj}" | sed 's/^.*[.]\([0-9]\)$$/\1/'); \
+		rm -f "$(DESTDIR)/$(MANDIR)/man$${section}/$${obj}"; \
+	done
diff --git a/src/Makefile.in b/src/Makefile.in
index 2931f11..318b7c5 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -34,25 +34,25 @@ all: $(OBJS)
 
 $(OBJS):
 	@printf '  SED %s\n' '$@'
-	@sed -f sedscript $(SRCDIR)/src/$@ > src/$@
+	@sed -f ../sedscript $(SRCDIR)/src/$@ > $@
 
 .PHONY: clean
 clean:
-	@	for obj in $(OBJS); do \
-			printf '  RM src/%s\n' "\${obj}"; \
-			rm -f src/\${obj}; \
-		done
+	@for obj in $(OBJS); do \
+		printf '  RM src/%s\n' "$${obj}"; \
+		rm -f $${obj}; \
+	done
 
 .PHONY: install
 install: all
-	@	for obj in $(OBJS); do \
-			printf '  INSTALL src/%s\n' "\${obj}"; \
-			$(INSTALL) -D src/\${obj} "$(DESTDIR)/$(BINDIR)"; \
-		done
+	@for obj in $(OBJS); do \
+		printf '  INSTALL src/%s\n' "$${obj}"; \
+		$(INSTALL) -D $${obj} "$(DESTDIR)/$(BINDIR)/$${obj}"; \
+	done
 
 .PHONY: uninstall
 uninstall:
-	@	for obj in $(OBJ); do \
-			printf '  RM %s\n' "\${obj}"; \
-			rm -f "$(DESTDIR)/$(BINDIR)/\${obj}"; \
-		done
+	@for obj in $(OBJ); do \
+		printf '  RM %s\n' "$${obj}"; \
+		rm -f "$(DESTDIR)/$(BINDIR)/$${obj}"; \
+	done
--
cgit v0.9.1