#################################################################
# Makefile.in for Samba Documentation
# Authors:	James Moore <jmoore@php.net>
#               Gerald Carter <jerry@samba.org>
#
# Please see http://www.samba.org/samba/cvs.html
# for information on getting the latest  
# source and doucmentation source files.  
#

# Autoconf Variables
SRCDIR = @srcdir@
JADE = @JADE@
NSGMLS = @NSGMLS@
ONSGMLS=@ONSGMLS@
SGMLSPL=@SGMLSPL@
HTMLDOC=@HTMLDOC@
PERL=@PERL@
#CATALOG = @CATALOG@
MANDIR=../manpages
HTMLDIR=../htmldocs

#Stylesheets and Dependicies
SGML_SHARE=@SGML_SHARE@
#SGML_CATALOG_FILES=$(SGML_CATALOG_FILES):./dbsgml/catalog
HTML_STYLESHEET = $(srcdir)/stylesheets/html.dsl
HTML_DEPS = $(srcdir)/stylesheets/html-common.dsl $(srcdir)/stylesheets/common.dsl

MANPAGES=$(MANDIR)/findsmb.1 $(MANDIR)/smbclient.1 \
	$(MANDIR)/smbspool.8 $(MANDIR)/lmhosts.5 \
	$(MANDIR)/smbcontrol.1  $(MANDIR)/smbstatus.1 \
	$(MANDIR)/make_smbcodepage.1  $(MANDIR)/smbd.8 \
	$(MANDIR)/smbtar.1 $(MANDIR)/nmbd.8 $(MANDIR)/smbmnt.8 \
	$(MANDIR)/smbumount.8 $(MANDIR)/nmblookup.1 \
	$(MANDIR)/smbmount.8 $(MANDIR)/swat.8 $(MANDIR)/rpcclient.1	 \
	$(MANDIR)/smbpasswd.5 $(MANDIR)/testparm.1 $(MANDIR)/samba.7 \
	$(MANDIR)/smbpasswd.8 $(MANDIR)/testprns.1 \
	$(MANDIR)/smb.conf.5 $(MANDIR)/wbinfo.1 \
	$(MANDIR)/smbcacls.1 $(MANDIR)/smbsh.1 $(MANDIR)/winbindd.8 

SGMLMANSRC=manpages/findsmb.1.sgml manpages/smbclient.1.sgml \
	manpages/smbspool.8.sgml manpages/lmhosts.5.sgml \
	manpages/smbcontrol.1.sgml manpages/smbstatus.1.sgml \
	manpages/make_smbcodepage.1.sgml  manpages/smbd.8.sgml \
	manpages/smbtar.1.sgml manpages/nmbd.8.sgml manpages/smbmnt.8.sgml \
	manpages/smbumount.8.sgml manpages/nmblookup.1.sgml \
	manpages/smbmount.8.sgml manpages/swat.8.sgml \
	manpages/rpcclient.1.sgml manpages/smbpasswd.5.sgml \
	manpages/testparm.1.sgml manpages/samba.7.sgml \
	manpages/smbpasswd.8.sgml manpages/testprns.1.sgml \
	manpages/smb.conf.5.sgml \
	manpages/wbinfo.1.sgml manpages/smbcacls.1.sgml \
	manpages/smbsh.1.sgml manpages/winbindd.8.sgml

HOWTOSRC=projdoc/DOMAIN_MEMBER.sgml projdoc/NT_Security.sgml \
	projdoc/msdfs_setup.sgml projdoc/printer_driver2.sgml \
	projdoc/UNIX_INSTALL.sgml projdoc/winbind.sgml projdoc/OS2-Client-HOWTO.sgml \
	projdoc/Samba-PDC-HOWTO.sgml projdoc/ENCRYPTION.sgml

FAQSRC=faq/samba-pdc-faq.sgml



######################################################################
# Make instructions
######################################################################
all: man

man: $(MANPAGES)

FAQ: $(FAQSRC)
	@echo Building SAMBA PDC FAQ...
	@(for i in $?; do \
	   htmlfile=`basename $$i | sed "s/\.sgml/\.html/g"`; \
	   echo "Making $$htmlfile"; \
	   $(JADE) -t sgml -V nochunks -d  $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl \
	      -f /tmp/jade.log $$i > ../htmldocs/$$htmlfile; \
	   cat /tmp/jade.log | grep -v DTDDECL; \
	   /bin/rm -f /tmp/jade.log; \
	done)

HOWTO: $(HOWTOSRC)
	@echo Building HOWTO pages...
	@(for i in $?; do \
	   htmlfile=`basename $$i | sed "s/\.sgml/\.html/g"`; \
	   echo "Making $$htmlfile"; \
	   cat $$i | $(PERL) scripts/make-article.pl > /tmp/`basename $$i`; \
	   $(JADE) -t sgml -V nochunks -d  $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl \
	      -f /tmp/jade.log /tmp/`basename $$i` > ../htmldocs/$$htmlfile; \
	   cat /tmp/jade.log | grep -v DTDDECL; \
	   /bin/rm -f /tmp/jade.log /tmp/`basename $$i`; \
	done)


## I'm using htmldoc here to produc the PDF output.  If you want
## Postscript output, you can run 
##
##           sgmltools -b ps projdoc/samba-doc.sgml
##
proj-doc: 
	echo Building Samba-HOWTO-Collections...
	@(cd projdoc; $(JADE) -t sgml -V nochunks -d  $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl samba-doc.sgml > ../samba-doc.html)
	@$(HTMLDOC) -f ../Samba-HOWTO-Collection.pdf samba-doc.html
	@/bin/mv -f samba-doc.html ../htmldocs/Samba-HOWTO-Collection.html





## generate all HTML man pages
man-html-all: $(SGMLMANSRC)
	@echo Building HTML formatted man pages...
	@(for i in $?; do \
	   htmlfile=`basename $$i | sed "s/\.sgml/\.html/g"`; \
	   echo "Making $$htmlfile"; \
	   $(JADE) -t sgml -V nochunks -d  $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl \
	      -f /tmp/jade.log $$i > ../htmldocs/$$htmlfile; \
	   cat /tmp/jade.log | grep -v DTDDECL; \
	   /bin/rm -f /tmp/jade.log; \
	done)

## generate all man pages
man-all: $(SGMLMANSRC)
	@echo Building man pages...
	@(for i in $?; do \
		manfile=`basename $$i | sed "s/\.sgml//g"`; \
		echo "Making $$manfile"; \
		$(ONSGMLS) -f /tmp/docbook2x.log $$i | $(SGMLSPL) \
	           $(SGML_SHARE)/docbook2X/docbook2man-spec.pl; \
		cat /tmp/docbook2x.log | grep -v DTDDECL; \
		/bin/rm -f /tmp/docbook2x.log; \
		cat $$manfile | $(PERL) scripts/strip-links.pl > $(MANDIR)/$$manfile; \
		/bin/rm -f $$manfile; \
	  done)




##
## these rules are for building individual files
##
$(MANDIR)/findsmb.1:  manpages/findsmb.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbclient.1: manpages/smbclient.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbspool.8: manpages/smbspool.8.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/lmhosts.5: manpages/lmhosts.5.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbcontrol.1: manpages/smbcontrol.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbstatus.1: manpages/smbstatus.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/make_smbcodepage.1: manpages/make_smbcodepage.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbd.8: manpages/smbd.8.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbtar.1: manpages/smbtar.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/nmbd.8: manpages/nmbd.8.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbmnt.8: manpages/smbmnt.8.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbumount.8: manpages/smbumount.8.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/nmblookup.1: manpages/nmblookup.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbmount.8: manpages/smbmount.8.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/swat.8: manpages/swat.8.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/rpcclient.1: manpages/rpcclient.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbpasswd.5: manpages/smbpasswd.5.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/testparm.1: manpages/testparm.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/samba.7: manpages/samba.7.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbpasswd.8: manpages/smbpasswd.8.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/testprns.1: manpages/testprns.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smb.conf.5: manpages/smb.conf.5.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/wbinfo.1: manpages/wbinfo.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbcacls.1: manpages/smbcacls.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/smbsh.1 : manpages/smbsh.1.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`

$(MANDIR)/winbindd.8: manpages/winbindd.8.sgml
	@echo "Making $@"
	@$(ONSGMLS) $< | $(SGMLSPL) $(SGML_SHARE)/docbook2X/docbook2man-spec.pl
	@cat `basename $@` | $(PERL) scripts/strip-links.pl > $@
	@/bin/rm -f `basename $@`
	@echo "Making HTML version of $@"
	@$(JADE) -t sgml -V nochunks -d $(SGML_SHARE)/dsssl/docbook/html/docbook.dsl $< > $(HTMLDIR)/`basename $< | sed "s/\.sgml/\.html/g"`


## Clean Rule
clean: 
	/bin/rm -f manpage.*
