	# Installation script for highlight.
# See INSTALL for details.


# Destination directory for installation (intended for packagers)
DESTDIR =

# Location where the highlight data files will be installed:
data_dir = ${DESTDIR}/usr/share/highlight/

# Location where the highlight binary will be installed:
#bin_dir = ${DESTDIR}/usr/local/bin/
bin_dir = ${DESTDIR}/usr/bin/

# Location where the highlight man page will be installed:
man_dir = ${DESTDIR}/usr/share/man/man1/

# Location where the highlight documentation will be installed:
doc_dir = ${DESTDIR}/usr/share/doc/highlight/

# Location where the highlight examples will be installed:
examples_dir = ${DESTDIR}/usr/share/doc/highlight/examples/

# Location where the highlight config files will be installed:
conf_dir = $(DESTDIR)/etc/highlight/

# Commands:
INSTALL_DATA=install -m644
INSTALL_PROGRAM=install -m755
MKDIR=mkdir -p -m 755
RMDIR=rm -r -f

all:
	${MAKE} -C ./highlight -f ./makefile HL_DATA_DIR=${data_dir}

all-localgetopt:
	${MAKE} -C ./highlight -f ./makefile HL_DATA_DIR=${data_dir} USE_LOCAL_GETOPT='true'

install:
	@echo "This script will install highlight in the following directories:"
	@echo "Data directory:          ${data_dir}"
	@echo "Documentation directory: ${doc_dir}"
	@echo "Examples directory:      ${examples_dir}"
	@echo "Manual directory:        ${man_dir}"
	@echo "Binary directory:        ${bin_dir}"
	@echo "Configuration directory: ${conf_dir}"
	@echo

	${MKDIR} ${doc_dir}
	${MKDIR} ${conf_dir}
	${MKDIR} ${examples_dir} \
		${examples_dir}cgi \
		${examples_dir}cgi/perl \
		${examples_dir}cgi/php \
		${examples_dir}swig
	${MKDIR} ${data_dir} \
		${data_dir}themes \
		${data_dir}langDefs \
		${data_dir}indentSchemes \
		${data_dir}helpmsg
	${MKDIR} ${man_dir}
	${MKDIR} ${bin_dir}

	${INSTALL_DATA} ./langDefs/*.lang ${data_dir}langDefs/
	${INSTALL_DATA} ./*.conf ${conf_dir}
	${INSTALL_DATA} ./themes/*.style ${data_dir}themes/
	${INSTALL_DATA} ./indentSchemes/*.indent ${data_dir}indentSchemes/
	${INSTALL_DATA} ./helpmsg/*.help ${data_dir}helpmsg/
	${INSTALL_DATA} ./man/highlight.1.gz ${man_dir}
	${INSTALL_DATA} ./AUTHORS ${doc_dir}
	${INSTALL_DATA} ./README ${doc_dir}
	${INSTALL_DATA} ./README_DE ${doc_dir}
	${INSTALL_DATA} ./README_INDENT ${doc_dir}
	${INSTALL_DATA} ./ChangeLog ${doc_dir}
#	${INSTALL_DATA} ./COPYING ${doc_dir}
#	${INSTALL_DATA} ./INSTALL ${doc_dir}
	${INSTALL_DATA} ./examples/cgi/php/* ${examples_dir}cgi/php
	${INSTALL_DATA} ./examples/swig/*.py ./examples/swig/*.pl ${examples_dir}swig
	${INSTALL_DATA} ./examples/swig/*.i ./examples/swig/makefile ${examples_dir}swig
	${INSTALL_DATA} ./examples/swig/README_SWIG ${doc_dir}
	${INSTALL_PROGRAM} ./examples/cgi/perl/highlight.cgi ${examples_dir}cgi/perl
	${INSTALL_PROGRAM} ./highlight/highlight ${bin_dir}

	@echo
	@echo "Done."
	@echo "Type highlight --help or man highlight for instructions."
	@echo "Highlight help is also available in Brazilian, Czech, German, French and Spanish"
	@echo "(highlight -H [br|cs|de|en|es|fr])."
	@echo "Take a look at ${examples_dir} for CGI scripts and a SWIG language bindings."
	@echo "Do not hesitate to report problems. Unknown bugs are hard to fix."

uninstall:
	@echo "Removing highlight files from system..."
	${RMDIR} ${data_dir}
	${RMDIR} ${doc_dir}
	${RMDIR} ${conf_dir}
	rm ${man_dir}highlight.1.gz
	rm ${bin_dir}highlight
	@echo "Done. Have a nice day!"

clean:
	$(MAKE) -C ./highlight -f ./makefile clean

apidocs:
	doxygen Doxyfile

help:
	@echo "This makefile offers the following options:"
	@echo
	@echo "(all)            Compile for Linux systems."
	@echo "all-localgetopt  Compile using a local copy of getopt."
	@echo "install*         Copy all data files to the directory ${data_dir}."
	@echo "clean            Remove object files and binary."
	@echo "apidocs          Generate HTML API documentation using doxygen."
	@echo "uninstall*       Remove highlight files from system."
	@echo
	@echo "* Command needs root privileges."
	@echo "See highlight/makefile for compilation and linking options."

# Target needed for redhat 9.0 rpmbuild
install-strip:

.PHONY: clean all all-localgetopt install apidocs help uninstall install-strip
