# makefile.in -- makefile for gwaves documentation directory.
# Copyright (C) 2025-2026 Gerardo Ballabio
#
# This program 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 3 of the License, or
# (at your option) any later version.
#
# This program 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 program.  If not, see <http://www.gnu.org/licenses/>.

prefix = ${DESTDIR}@prefix@

AC = makefile gwaves.1 gwaves-C.omf
BAK = *~

FIGURES = figure1.png
LICENSES = gpl-3.0.dbk fdl-1.3.dbk
XML_DEPS = ${FIGURES} ${LICENSES}
HTML = gwaves.html
HTML_DEPS = ${FIGURES}
PDF = gwaves.pdf
OMF = gwaves-C.omf

.SUFFIXES : .xml .html .pdf

.xml.html :
	xmlto html-nochunks $<
.xml.pdf :
	xmlto --with-dblatex pdf $<

default:

html : ${HTML}
pdf : ${PDF}

# other targets
clean :
	- rm -f ${BAK}
distclean : clean
	- rm -rf ${AC} ${PDF}

install-xml :
	mkdir -p ${prefix}/share/gnome/help/gwaves/C
	cp gwaves.xml ${XML_DEPS} ${prefix}/share/gnome/help/gwaves/C
install-html :
	mkdir -p ${prefix}/share/doc/gwaves
	cp ${HTML} ${HTML_DEPS} ${prefix}/share/doc/gwaves
install-man :
	mkdir -p ${prefix}/share/man/man1
	cp gwaves.1 ${prefix}/share/man/man1
	gzip -9 -f ${prefix}/share/man/man1/gwaves.1
install-omf :
	mkdir -p ${prefix}/share/omf/gwaves
	cp ${OMF} ${prefix}/share/omf/gwaves
install-pdf :
	mkdir -p ${prefix}/share/doc/gwaves
	cp ${PDF} ${prefix}/share/doc/gwaves
# don't install pdf by default (not shipped with source tarball)
install : install-xml install-html install-man install-omf

uninstall-xml :
	- cd ${prefix}/share/gnome/help/gwaves/C && \
	  rm -f gwaves.xml ${XML_DEPS}
	- rmdir ${prefix}/share/gnome/help/gwaves/C
	- rmdir ${prefix}/share/gnome/help/gwaves
uninstall-html :
	- cd ${prefix}/share/doc/gwaves && rm -f ${HTML} ${HTML_DEPS}
	- rmdir ${prefix}/share/doc/gwaves
uninstall-man :
	- cd ${prefix}/share/man/man1 && rm -f gwaves.1.gz
uninstall-omf :
	- cd ${prefix}/share/omf/gwaves && rm -f ${OMF}
	- rmdir ${prefix}/share/omf/gwaves
uninstall-pdf :
	- cd ${prefix}/share/doc/gwaves && rm -f ${PDF}
	- rmdir ${prefix}/share/doc/gwaves
uninstall : uninstall-xml uninstall-html uninstall-man uninstall-omf \
	    uninstall-pdf

# dependencies
gwaves.html : ${FIGURES}
gwaves.pdf : ${FIGURES}
