## texk/am/man.am: Makefile fragment for kpathsea and web2c manual pages.
##
## Copyright (C) 2009-2012 Peter Breitenlohner <tex-live@tug.org>
## You may freely use, modify and/or distribute this file.
##
## requires $(man_sources)
## requires $(KPATHSEA_PATHS_H) giving the directory of kpathsea/paths.h

SUFFIXES = .1 .man .ps .dvi

.man.1:
	$(AM_V_GEN)sed -f sedscript $< >$@
man_files = $(man_sources:.man=.1)
$(man_files): sedscript

nodist_man1_MANS = $(man_files)

# At present, all but VERSION should be unused.
sedscript: $(KPATHSEA_PATHS_H)/kpathsea/paths.h
	$(AM_V_GEN)( \
	  sed -n -e '/^#define/s/#define[ 	][ 	]*\([A-Z_a-z][A-Z_a-z]*\)[ 	][ 	]*\(.*\)/s%@\1@%\2%/p' \
	  	$< \
	    | sed -e 's/"//g' -e 's/[ 	]*\/\*[^*]*\*\///g'; \
	  echo 's%@VER''SION@%$(VERSION)%'; \
	  echo 's%@BINDIR@%$(bindir)%'; \
	  echo 's%@INFODIR@%$(infodir)%'; \
	  echo 's%@TEXINPUTDIR@%$(texinputdir)%'; \
	  echo 's%@MFINPUTDIR@%$(mfinputdir)%'; \
	  echo 's%@MPINPUTDIR@%$(mpinputdir)%'; \
	  echo 's%@FONTDIR@%$(fontdir)%'; \
	  echo 's%@FMTDIR@%$(fmtdir)%'; \
	  echo 's%@BASEDIR@%$(basedir)%'; \
	  echo 's%@MEMDIR@%$(memdir)%'; \
	  echo 's%@TEXPOOLDIR@%$(texpooldir)%'; \
	  echo 's%@MFPOOLDIR@%$(mfpooldir)%'; \
	  echo 's%@MPPOOLDIR@%$(mppooldir)%'; \
	  echo 's%@FONTMAPDIR@%$(dvipsdir)%'; \
	  echo 's%@LOCALMODES@%$(localmodes)%')	>sedscript

DITROFF = groff

.1.dvi:
	$(DITROFF) -Tdvi -man $< >$@
DVIS = $(man_files:.1=.dvi)

.1.ps:
	$(DITROFF) -Tps -man $< >$@
PSS = $(man_files:.1=.ps)

DISTCLEANFILES = sedscript $(man_files) $(DVIS) $(PSS)

## end of texk/am/man.am
