# $Id: Makefile,v 1.3 2003/04/19 06:54:19 ianmacd Exp $

ifdef ROOT
  BUILDROOT	= --prefix=$(ROOT)
  PREFIX	= $(ROOT)
else
  PREFIX	= /usr/local
endif

docfiles	= doc/dict.html doc/dict.3 doc/rdict.html doc/rdict.1

all:		install

install:	setup docs
		ruby install.rb install
		-install -d $(PREFIX)
		-install -d $(PREFIX)/bin
		install rdict $(PREFIX)/bin/rdict

setup:		config.save
		ruby install.rb setup

config config.save:
		ruby install.rb config $(BUILDROOT)

docs:		$(docfiles)

doc/dict.html:	lib/dict.rb
		rd2 lib/dict.rb > doc/dict.html

doc/rdict.html:	rdict
		rd2 rdict > doc/rdict.html

doc/dict.3:	lib/dict.rb
		rd2 -rrd/rd2man-lib.rb lib/dict.rb > doc/dict.3

doc/rdict.1:	rdict
		rd2 -rrd/rd2man-lib.rb rdict > doc/rdict.1
clean:
		-rm -f $(docfiles) config.save InstalledFiles
