# Makefile for the phcl-MicroEmacs package
# Copyright 2008 Parliament Hill Computers Ltd, derived from that of Dave Conroy and Daniel Lawrence
# PHCL has done the wrapping for RPM.
# Author: ADDW December 2008
# SCCS: @(#)Makefile	1.2 12/30/08 15:05:39

PACKAGE=phcl-MicroEmacs
PROGS=me
SOURCES=aline.h ansi.c basic.c bind.c buffer.c crypt.c dg10.c display.c dolock.c ebind.h edef.h efunc.h egapc.c emdmap.h epath.h estruct.h eval.c evar.h evers.h exec.c expand.c file.c fileio.c hp110.c hp150.c ibmpc.c input.c isearch.c line.c lock.c main.c malloc.c mapkey.c prefix.c random.c region.c search.c spawn.c st520.c tag.c t.c tcap.c termio.c tipc.c vmsvt.c vt52.c window.c word.c z309.c
BUILDPROGS=Makefile.orig
SUBDIRS=docs
CONFIGS=
DOCS=README
RCFILE=DotEmacsrc

SPECFILE=$(PACKAGE).spec
VERSION := $(shell sed -ne '/^%define \+version \+/s///p' $(SPECFILE) )
DESTDIR=/usr/local
BINDIR=$(DESTDIR)/bin/
DOCDIR=$(DESTDIR)/share/doc/$(PACKAGE)-$(VERSION)
MAKEFILE=Makefile
BUILDFILES=$(SPECFILE) $(MAKEFILE)

# Default target is to make the programs - not install
progs:	$(PROGS)

# Create directories then copy in script and documentation:
install:	$(PROGS)
	install -d $(BINDIR) $(DOCDIR)
	install -p $(PROGS) $(BINDIR)
	install -p -m 644 $(RCFILE) $(DOCS) $(DOCDIR)
	for d in $(SUBDIRS); do make -C $$d install ; done

# Create a tar file for distribution
dist:	$(PACKAGE)-$(VERSION).tar.gz

# The tar file for distribution:
$(PACKAGE)-$(VERSION).tar.gz: $(DOCS) $(BUILDPROGS) $(BUILDFILES) $(SOURCES) $(CONFIGS) $(RCFILE)
	mkdir -p .BuildDist/$(PACKAGE)-$(VERSION)
	cp -al $^ .BuildDist/$(PACKAGE)-$(VERSION)
	for d in $(SUBDIRS); do make -C $$d VERSION=$(VERSION) copy-dist ; done
	cd .BuildDist && tar czf ../$@ $(PACKAGE)-$(VERSION)
	rm -rf .BuildDist/$(PACKAGE)-$(VERSION)

cleandist:
	rm -f $(PACKAGE)-$(VERSION).tar.gz

clean:	cleandist
	for d in $(SUBDIRS); do make -C $$d VERSION=$(VERSION) clean ; done

include Makefile.orig

# end
