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

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/

# 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/


# Commands:
INSTALL_DATA=install -m644
INSTALL_PROGRAM=install -m755
MKDIR=mkdir -p -m 755

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

all-nogetopt all-solaris: 
	${MAKE} -C ./highlight -f ./makefile  DISABLE_GETOPT='true'
  
install:
	@echo "This script will install highlight in the following directories:"
	@echo "Data directory:          ${data_dir}"
	@echo "Documentation directory: ${doc_dir}"
	@echo "Manual directory:        ${man_dir}"
	@echo "Binary directory:        ${bin_dir}"
	@echo

	${MKDIR} ${data_dir}
	${MKDIR} ${doc_dir}
	${MKDIR} ${data_dir}themes
	${MKDIR} ${data_dir}langDefs
	${MKDIR} ${data_dir}utils 
	${MKDIR} ${data_dir}utils/cgi ${data_dir}utils/cgi/perl ${data_dir}utils/cgi/php
	${MKDIR} ${data_dir}helpmsg
	${MKDIR} ${man_dir}
	${MKDIR} ${bin_dir}
	
	${INSTALL_DATA} ./langDefs/*.lang ${data_dir}langDefs/
	${INSTALL_DATA} ./langDefs/extensions.conf ${data_dir}
	${INSTALL_DATA} ./themes/*.style ${data_dir}themes/
	${INSTALL_DATA} ./helpmsg/* ${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} ./ChangeLog ${doc_dir}
	${INSTALL_DATA} ./COPYING ${doc_dir}
	${INSTALL_DATA} ./INSTALL ${doc_dir}
	${INSTALL_DATA} ./utils/cgi/perl/README_CGI ${doc_dir}
	${INSTALL_DATA} ./utils/cgi/php/* ${data_dir}utils/cgi/php
	${INSTALL_PROGRAM} ./utils/cgi/perl/highlight.cgi ${data_dir}utils/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 German and French"
	@echo "(highlight -H de; highlight -H fr)."
	@echo "Take a look at ${data_dir}utils for CGI scripts."
	@echo "Do not hesitate to report problems. Unknown bugs are hard to fix."
	
clean: 
	$(MAKE) -C ./highlight -f ./makefile clean

apidocs:
	doxygen Doxyfile

help:
	@echo "This makefile offers the following options:"
	@echo
	@echo "(all)         Compile using the GNU getopt_long function."
	@echo "all-nogetopt  Compile using a portable command line option parser."
	@echo "all-solaris   See all-nogetopt."
	@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 
	@echo "See highlight/makefile for compilation and linking options."

# Target needed for redhat 9.0 rpmbuild
install-strip:

.PHONY: clean all all-nogetopt all-solaris install apidocs help
