@@ -18,12 +18,6 @@ MAIN := $(word 1, $(EXECS))
18PROGS := $(EXECS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
18PROGS := $(EXECS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
19DOCS := README.html README BUGS TODO
19DOCS := README.html README BUGS TODO
21−#-------------------------------------------------------------------------------
22−# Variables to setup through environment
23−#-------------------------------------------------------------------------------
27#-------------------------------------------------------------------------------
21#-------------------------------------------------------------------------------
28# Constant names and commands in source tree
22# Constant names and commands in source tree
29#-------------------------------------------------------------------------------
23#-------------------------------------------------------------------------------
@@ -32,8 +26,22 @@ MANDIR := man
32BUILDDIR := dist
26BUILDDIR := dist
33BUILDCONF := .setup-config
27BUILDCONF := .setup-config
34BUILDCMD := runhaskell Setup.hs
28BUILDCMD := runhaskell Setup.hs
35CONFIGURE := configure
30CONFIGURE := configure
32+#-------------------------------------------------------------------------------
33+# Variables to setup through environment
34+#-------------------------------------------------------------------------------
36+# Specify default values.
39+# Attempt to set variables from a previous make session.
41+# Fallback to defaults but allow to get the values from environment.
37#-------------------------------------------------------------------------------
45#-------------------------------------------------------------------------------
38# Installation paths
46# Installation paths
39#-------------------------------------------------------------------------------
47#-------------------------------------------------------------------------------
@@ -85,10 +93,13 @@ $(CABAL): cabalize $(CABAL).in
85 ./cabalize <$(CABAL).in >$(CABAL)
93 ./cabalize <$(CABAL).in >$(CABAL)
87.PHONY: configure
95.PHONY: configure
88−cleanup_files+=$(BUILDDIR) $(BUILDCONF)
96+cleanup_files+=$(BUILDDIR) $(BUILDCONF) $(BUILDVARS)
89configure: $(BUILDCONF)
97configure: $(BUILDCONF)
90$(BUILDCONF): $(CABAL)
98$(BUILDCONF): $(CABAL)
91 $(BUILDCMD) configure --prefix=$(PREFIX)
99 $(BUILDCMD) configure --prefix=$(PREFIX)
100+ # Make configuration time settings persistent (definitely a hack).
101+ @echo "PREFIX?=$(PREFIX)" >$(BUILDVARS)
102+ @echo "DESTDIR?=$(DESTDIR)" >>$(BUILDVARS)
93.PHONY: build
104.PHONY: build
94build: $(BUILDDIR)
105build: $(BUILDDIR)
@@ -121,10 +132,6 @@ html/: configure
121.PHONY: build-all
132.PHONY: build-all
122build-all: all build-lib-doc
133build-all: all build-lib-doc
124−# XXX: Note that we don't handle PREFIX correctly at the install-* stages,
125−# i.e. any PREFIX given at the configuration time is lost, unless it is
126−# also supplied (via environment) at these stages.
128# User documents installation.
135# User documents installation.
129.PHONY: install-doc uninstall-doc
136.PHONY: install-doc uninstall-doc
130man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))
137man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))