# Makefile for help2man
# $Id: Makefile.in,v 1.11 2003/07/09 11:05:40 bod Exp $

SHELL = @SHELL@

srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
libdir = @libdir@
mandir = @mandir@
datadir = @datadir@
infodir = @infodir@
man1dir = $(mandir)/man1
man1dir_fr = $(mandir)/fr/man1
localedir = $(datadir)/locale

DESTDIR =

CC = @CC@
PERL = @PERL@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_INFO = @INSTALL_INFO@
MAKEINFO = @MAKEINFO@
MKINSTALLDIRS = $(srcdir)/mkinstalldirs
MSGFMT = msgfmt

target = help2man
hack = hacklocaledir

basic: $(target)
check: $(target).1
all: basic check $(target).fr.1 info

install-strip: install
# No binaries to strip.

install: $(target) $(hack).so $(target).1 $(target).fr.1 $(target).info \
    po/fr.gmo
	$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
	$(MKINSTALLDIRS) $(DESTDIR)$(man1dir)
	$(MKINSTALLDIRS) $(DESTDIR)$(man1dir_fr)
	$(MKINSTALLDIRS) $(DESTDIR)$(localedir)/fr/LC_MESSAGES
	$(MKINSTALLDIRS) $(DESTDIR)$(infodir)

	$(INSTALL_PROGRAM) $(target) $(DESTDIR)$(bindir)
	$(INSTALL_PROGRAM) $(hack).so $(DESTDIR)$(libdir)
	$(INSTALL_DATA) $(target).1 $(DESTDIR)$(man1dir)
	$(INSTALL_DATA) $(target).fr.1 $(DESTDIR)$(man1dir_fr)/$(target).1
	$(INSTALL_DATA) po/fr.gmo \
	    $(DESTDIR)$(localedir)/fr/LC_MESSAGES/$(target).mo

	$(INSTALL_DATA) $(target).info $(DESTDIR)$(infodir)/$(target).info
	if test -f $(DESTDIR)$(infodir)/dir; \
	then \
	    $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) $(target).info; \
	fi

uninstall:
	rm -f $(DESTDIR)$(bindir)/$(target) \
	    $(DESTDIR)$(libdir)/$(hack).so \
	    $(DESTDIR)$(man1dir)/$(target).1 \
	    $(DESTDIR)$(man1dir_fr)/$(target).1 \
	    $(DESTDIR)$(localedir)/fr/LC_MESSAGES/$(target).mo \
	    $(DESTDIR)$(infodir)/$(target).info

	if test -f $(DESTDIR)$(infodir)/dir; \
	then \
	    $(INSTALL_INFO) --delete --info-dir=$(DESTDIR)$(infodir) \
		$(target).info; \
	fi

clean:
	-rm -f $(target) $(hack).so

mostlyclean: clean
	rm -f $(target).dvi $(target).aux $(target).cp $(target).cps \
	    $(target).fn $(target).ky $(target).log $(target).pg \
	    $(target).toc $(target).tp $(target).vr

distclean: mostlyclean
	-rm -f config.cache config.log config.status Makefile 

realclean: distclean
	-rm -f $(target).info $(target).1 $(target).fr.1 po/*.gmo

maintainer-clean: realclean
	rm -f configure

$(target): $(srcdir)/$(target).PL
	-rm -f $@
	$(PERL) $? --stdout >$@
	chmod 555 $@

$(hack).so: $(srcdir)/$(hack).c
	$(CC) -o $@ -shared $?

$(target).1: $(target) $(srcdir)/$(target).h2m
	./$(target) --include=$(srcdir)/$(target).h2m \
	    --output=$@ ./$(target)

$(target).fr.1: $(hack).so po/fr.gmo $(target) $(srcdir)/$(target).fr.h2m
	LD_PRELOAD="./$(hack).so preloadable_libintl.so" \
	TEXTDOMAIN=help2man \
	./$(target) --include=$(srcdir)/$(target).fr.h2m \
	    --output=$@ --locale=fr_FR@euro ./$(target)

po/fr.gmo: $(srcdir)/po/fr.po
	test -d po || mkdir po
	$(MSGFMT) -o $@ $?

info: $(target).info
$(target).info: $(srcdir)/$(target).texi
	$(MAKEINFO) $? -o $@

dvi: $(target).dvi
$(target).dvi: $(srcdir)/$(target).texi
	$(TEXI2DVI) $?

Makefile: $(srcdir)/Makefile.in
	./config.status

.PHONY: basic all check clean distclean dvi info install mostlyclean \
    realclean uninstall

.SUFFIXES:
