Attempt to fix a (long-standing) Makefile drawback which is documented in

previous revisions as follows:

    # XXX: Note that we don't handle PREFIX correctly at the install-* 
    # stages, i.e. any PREFIX given at the configuration time is lost, 
    # unless it is also supplied (via environment) at these stages.

With this (optional and experimental) hack, config time settings will 
become persistent.  Such persistency allows one to specify PREFIX and/or 
DESTDIR only once (at the first run).  That is, the below actions should 
work fine now:

    DESTDIR=/tmp/foo make
    make install

In previous code these variables need to be specified at each run.  For 
example:

    DESTDIR=/tmp/foo make
    DESTDIR=/tmp/foo make install

This change (as an ugly hack) is optional (and might be removed) as the 
user could always work around that issue with 'DESTDIR=/tmp/foo make 
install'.


git-svn-id: https://pandoc.googlecode.com/svn/trunk@75 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
roktas 2006-11-03 11:26:53 +00:00
parent fdfe8494ca
commit afd92376d6

View file

@ -18,12 +18,6 @@ MAIN := $(word 1, $(EXECS))
PROGS := $(EXECS) html2markdown markdown2html latex2markdown markdown2latex markdown2pdf
DOCS := README.html README BUGS TODO
#-------------------------------------------------------------------------------
# Variables to setup through environment
#-------------------------------------------------------------------------------
PREFIX ?= /usr/local
DESTDIR ?=
#-------------------------------------------------------------------------------
# Constant names and commands in source tree
#-------------------------------------------------------------------------------
@ -32,8 +26,22 @@ MANDIR := man
BUILDDIR := dist
BUILDCONF := .setup-config
BUILDCMD := runhaskell Setup.hs
BUILDVARS := vars
CONFIGURE := configure
#-------------------------------------------------------------------------------
# Variables to setup through environment
#-------------------------------------------------------------------------------
# Specify default values.
prefix := /usr/local
destdir :=
# Attempt to set variables from a previous make session.
-include $(BUILDVARS)
# Fallback to defaults but allow to get the values from environment.
PREFIX ?= $(prefix)
DESTDIR ?= $(destdir)
#-------------------------------------------------------------------------------
# Installation paths
#-------------------------------------------------------------------------------
@ -85,10 +93,13 @@ $(CABAL): cabalize $(CABAL).in
./cabalize <$(CABAL).in >$(CABAL)
.PHONY: configure
cleanup_files+=$(BUILDDIR) $(BUILDCONF)
cleanup_files+=$(BUILDDIR) $(BUILDCONF) $(BUILDVARS)
configure: $(BUILDCONF)
$(BUILDCONF): $(CABAL)
$(BUILDCMD) configure --prefix=$(PREFIX)
# Make configuration time settings persistent (definitely a hack).
@echo "PREFIX?=$(PREFIX)" >$(BUILDVARS)
@echo "DESTDIR?=$(DESTDIR)" >>$(BUILDVARS)
.PHONY: build
build: $(BUILDDIR)
@ -121,10 +132,6 @@ html/: configure
.PHONY: build-all
build-all: all build-lib-doc
# XXX: Note that we don't handle PREFIX correctly at the install-* stages,
# i.e. any PREFIX given at the configuration time is lost, unless it is
# also supplied (via environment) at these stages.
# User documents installation.
.PHONY: install-doc uninstall-doc
man_all:=$(patsubst $(MANDIR)/%,%,$(wildcard $(MANDIR)/man?/*.1))