# Makefile for dhelp project

# Copyright (C) 2005 Esteban Manchado Velzquez <zoso@debian.org>

# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.

# This file is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this file; see the file COPYING.  If not, write to the Free
# Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

PACKAGE = dhelp
VERSION = 0.5.25
PREFIX_  = $(if $(PREFIX),$(PREFIX),/usr/local)
DESTDIR_ = $(DESTDIR)/$(PREFIX_)

all:

install:
	mkdir -p $(DESTDIR_) $(DESTDIR_)/sbin $(DESTDIR_)/bin $(DESTDIR_)/lib/cgi-bin $(DESTDIR_)/share/doc/dhelp
	# Executable files
	install dhelp_parse.rb $(DESTDIR_)/sbin/dhelp_parse.rb
	# Ruby libraries
	mkdir -p $(DESTDIR_)/lib/ruby/1.8
	cp lib/* $(DESTDIR_)/lib/ruby/1.8
	# Update PREFIX variable in dhelp_parse.rb
	sed 's|^PREFIX = .*|PREFIX = "$(PREFIX_)"|' $(DESTDIR_)/sbin/dhelp_parse.rb >$(DESTDIR_)/sbin/dhelp_parse
	rm -f $(DESTDIR_)/sbin/dhelp_parse.rb
	chmod a+x $(DESTDIR_)/sbin/dhelp_parse
	install dhelp $(DESTDIR_)/bin/dhelp
	install dsearch $(DESTDIR_)/lib/cgi-bin/dsearch
	# Misc files/dirs
	for file in CREDITS doc/*; do \
            cp $$file $(DESTDIR_)/share/doc/dhelp/; \
        done
	mkdir -p $(DESTDIR_)/share/doc/HTML
	mkdir -p $(DESTDIR_)/share/dhelp
	cp {index,category}.rhtml $(DESTDIR_)/share/dhelp/

test:
	RUBYLIB=lib:test ruby -w test/ts_dhelp.rb

.PHONY: test
