aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--GNUmakefile124
2 files changed, 85 insertions, 40 deletions
diff --git a/.gitignore b/.gitignore
index 5c342e1..c647e54 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
*~
\#*
.emacs*
+.config
listarchive
*.tar
*.tar.gz
diff --git a/GNUmakefile b/GNUmakefile
index 27707ac..73e92b1 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,45 +1,59 @@
# usage:
#
-# 1. make PREFIX=prefix [MAILMANSRC=mdir] install
+# 1. make config PREFIX=dir [MAILMANSRC=dir] [NAME=VAL]...
+# Configure the system. PREFIX is installation prefix. MAILMANSRC is
+# the name of the Mailman source tree directory (must be writable).
+# Other meaningful variables are:
+#
+# MAILMANDIR - Top installation directory for mailman script.
+# Default: $(PREFIX)/Mailman
+# BINDIR - Installation directory for executable scripts.
+# Default: $(PREFIX)/bin
+# HTDOCSDIR - Installation directory for static HTML pages.
+# Default: $(PREFIX)/htdocs
+# TEMPLATESDIR - Top installation directory for templates.
+# Default: $(PREFIX)/templates
+# MANDIR - Top installation directory for manual pages.
+# Default: $(PREFIX)/man
+# CGIDIR - Installation directory for listarchive CGI
+# Default: $(PREFIX)/cgi-bin
+#
+# If all these variables are supplied, PREFIX can be omitted.
+#
+# 2. make install
# Installs everything.
-#
-# 2. make PREFIX=prefix [MAILMANSRC=mdir] install-cgi
-# Builds (if necessary) and installs the listarchive cgi.
-# MAILMANSRC must be set for building the program.
-# Installation directory is $(PREFIX)/cgi-bin. Set CGIDIR
-# to override.
-#
-# 3. make PREFIX=prefix install-Mailman
-# Installs scripts in the Mailman subdirectory.
-# Installation directory is $(PREFIX)/Mailman. Set MAILMANDIR
-# to override.
-#
-# 4. make PREFIX=prefix install-templates
-# Installs templates to $(PREFIX)/templates. Set TEMPLATESDIR
-# to override.
-#
-# 5. make PREFIX=prefix install-bin
-# Installs binary scripts to $(PREFIX)/bin. Set BINDIR to
-# override.
-#
-# 6. make PREFIX=prefix install-man
-# Installs manpages to $(PREFIX)/man. Set MANDIR to override.
-#
-# 7. make PREFIX=prefix install-htdocs
-# Installs static HTML files to $(PREFIX)/htdocs. Set HTDOCSDIR
-# to override.
+# Following targets can be used instead of install:
+#
+# install-cgi - Builds (if necessary) and installs the listarchive
+# cgi.
+# install-Mailman - Installs scripts in the Mailman subdirectory.
+# install-templates - Installs templates.
+# install-bin - Installs scripts,
+# install-man - Installs manpages.
+# install-htdocs - Installs static HTML files.
#
-# 8. make MAILMANSRC=mdir listarchive
-# Builds the listarchive cgi.
+# 3. make listarchive
+# Builds the listarchive cgi in $(MAILMANSRC)/src.
#
-# 9. make clean
+# 4. make clean
# Remove created files.
#
-# 10. make help
+# 5. make distclean
+# Remove all created files and configuration cache.
+#
+# 6. make help
# Shows this help list.
#
# usage ends
+ifneq (,$(wildcard .config))
+ include .config
+else ifeq (,$(MAKECMDGOALS))
+ # Nothing
+else ifeq (,$(findstring $(MAKECMDGOALS),help config))
+ $(error Please run make config first)
+endif
+
help:
@sed -n \
-e '/# usage ends/,$$d' \
@@ -51,12 +65,43 @@ help:
-e :a \
-e '/^usage:/,$$p' $(firstword $(MAKEFILE_LIST))
+DEFSRC = $(firstword $(wildcard /usr/src/mailman-[0-9][0-9.]*))
+
+config:
+ @(for var in PREFIX MAILMANDIR BINDIR HTDOCSDIR \
+ TEMPLATESDIR MANDIR CGIDIR; \
+ do \
+ eval x=\$${$$var}; \
+ if [ -n "$$x" ]; then \
+ echo "$$var=$$x"; \
+ fi; \
+ done; \
+ if [ -n "$$MAILMANSRC" ]; then \
+ echo "MAILMANSRC=$$MAILMANSRC"; \
+ elif [ -n "$(DEFSRC)" ]; then \
+ echo >&2 "assuming MAILMANSRC=$(DEFSRC)"; \
+ echo "MAILMANSRC=$(DEFSRC)"; \
+ else \
+ echo >&2 "Please set MAILMANSRC to point to the mailman-2.x tree"; \
+ exit 1; \
+ fi) > .config.tmp
+ @if ! grep -q ^PREFIX .config.tmp && \
+ test "$$(sed -r -n -e 's/^(MAILMANDIR|BINDIR|HTDOCSDIR|TEMPLATESDIR|MANDIR|CGIDIR)=.*/x/p' .config.tmp | tr -d '\n')" != xxxxxx; then \
+ echo >&2 "PREFIX must be supplied"; \
+ rm .config.tmp; \
+ exit 1; \
+ fi
+ @mv .config.tmp .config
+
listarchive:
- @if [ -z "$(MAILMANSRC)" ]; then \
+ @if [ -z "$(MAILMANSRC)" ]; then \
echo >&2 "Please set MAILMANSRC to point to the mailman-2.x tree"; \
- false; \
+ exit 1; \
+ elif ! test -w $(MAILMANSRC)/src; then \
+ echo >&2 "$(MAILMANSRC)/src must be writable"; \
+ exit 1; \
else \
- make -C $(MAILMANSRC)/src CGI_PROGS=`pwd`/listarchive `pwd`/listarchive; \
+ make -C $(MAILMANSRC)/src CGI_PROGS=listarchive listarchive; \
fi
define geninstall
@@ -65,10 +110,6 @@ install-$(1):;
tar -C $(1) -cf - . | tar -C $$(DESTDIR)$$($(shell echo $(1) | tr '[:lower:]' '[:upper:]')DIR) -xpf -
endef
-ifndef PREFIX
- $(if $(subst help,,$(MAKECMDGOALS)),$(error Please supply PREFIX))
-endif
-
MAILMANDIR = $(PREFIX)/Mailman
BINDIR = $(PREFIX)/bin
HTDOCSDIR = $(PREFIX)/htdocs
@@ -87,9 +128,12 @@ $(foreach tgt,$(TARGETS),$(eval $(call geninstall,$(tgt))))
install-cgi: listarchive
install -d $(DESTDIR)$(CGIDIR)
- install -o root -g mailman -m 2755 listarchive $(DESTDIR)$(CGIDIR)
+ install -o root -g mailman -m 2755 $(MAILMANSRC)/src/listarchive $(DESTDIR)$(CGIDIR)
install: install-cgi $(foreach tgt,$(TARGETS), install-$(tgt))
clean:
- rm listarchive
+ @rm -f $(MAILMANSRC)/src/listarchive
+
+distclean: clean
+ @rm -f .config

Return to:

Send suggestions and report system problems to the System administrator.