diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-07-04 18:29:00 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-07-04 18:29:53 +0300 |
commit | 41e14829aa6ff0a777cfa832244a57e6602451a6 (patch) | |
tree | 68ac6eab21535addae52ddd0efe6c8a6541c7e7c | |
parent | 38e33514347a440994d63acea38dbd3768181819 (diff) | |
download | mailman-41e14829aa6ff0a777cfa832244a57e6602451a6.tar.gz mailman-41e14829aa6ff0a777cfa832244a57e6602451a6.tar.bz2 |
Revamp GNUmakefile
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | GNUmakefile | 116 |
2 files changed, 81 insertions, 36 deletions
@@ -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 -# 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. +# 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: # -# 3. make PREFIX=prefix install-Mailman -# Installs scripts in the Mailman subdirectory. -# Installation directory is $(PREFIX)/Mailman. Set MAILMANDIR -# to override. +# 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 # -# 4. make PREFIX=prefix install-templates -# Installs templates to $(PREFIX)/templates. Set TEMPLATESDIR -# to override. +# If all these variables are supplied, PREFIX can be omitted. # -# 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. +# 2. make install +# Installs everything. +# Following targets can be used instead of install: # -# 7. make PREFIX=prefix install-htdocs -# Installs static HTML files to $(PREFIX)/htdocs. Set HTDOCSDIR -# to override. +# 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 \ 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 |