# OpenVAS
# $Id$
# Description: Makefile for OpenVAS-libnasl.
#
# Authors:
# Renaud Deraison <deraison@nessus.org> (Original pre-fork development)
#
# Copyright:
# Based on work Copyright (C) 1998 - 2007 Tenable Network Security, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library 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
# Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.

include nasl.tmpl

all: 
	cd nasl && ${MAKE}

nasl.tmpl: nasl.tmpl.in configure
	$(SHELL) configure $(CONFIGURE_ARGS)
	touch $@

install: all
	cd nasl && ${MAKE} install
	test -d ${DESTDIR}${includedir}/openvas || $(INSTALL_DIR) -m 755 ${DESTDIR}${includedir}/openvas
	$(INSTALL) -c -m 0444 include/nasl.h ${DESTDIR}${includedir}/openvas
	test -d ${DESTDIR}${bindir} || $(INSTALL_DIR) -m 755 ${DESTDIR}${bindir}
	$(INSTALL) -c -m 0755 openvas-libnasl-config ${DESTDIR}${bindir}/openvas-libnasl-config
	test -d ${DESTDIR}${mandir}/man1 || $(INSTALL_DIR) -m 755 ${DESTDIR}${mandir}/man1
	$(INSTALL) -c -m 0644 doc/openvas-libnasl-config.1 ${DESTDIR}${mandir}/man1
	$(INSTALL) -c -m 0644 doc/openvas-nasl.1 ${DESTDIR}${mandir}/man1
	$(INSTALL) -c -m 0644 doc/openvas-libnasl-config.1 ${DESTDIR}${mandir}/man1
	@echo
	@echo ' --------------------------------------------------------------'
	@echo ' openvas-libnasl has been sucessfully installed. '
	@echo " Make sure that $(bindir) is in your PATH before you"
	@echo " continue "
	@echo ' --------------------------------------------------------------'
	@echo

clean :
	cd nasl && ${MAKE} clean
	rm -rf doc/generated

distclean : clean
	rm -f ${rootdir}/include/config.h libtool config.cache \
	config.status config.log
	cd nasl && ${MAKE} distclean
	rm -f nasl.tmpl openvas-libnasl-config

dist:
	version="`cat VERSION`"; \
	rm -rf openvas-libnasl-$${version}* ; \
	mkdir openvas-libnasl-$${version} ; \
	tar cf openvas-libnasl-$${version}/x.tar `cat MANIFEST`; \
	( cd openvas-libnasl-$${version} ; tar xf x.tar ; rm -f x.tar ) ; \
	tar cf openvas-libnasl-$${version}.tar openvas-libnasl-$${version} ; \
	gzip -9 openvas-libnasl-$${version}.tar

# Generates basic code documentation (placed in doc/generated)
doc :
	doxygen doc/Doxyfile

# Generates more extensive code documentation with graphs 
# (placed in doc/generated) and builts doc/generated/latex/refman.pdf
doc-full:
	doxygen doc/Doxyfile_full
	if [ -d doc/generated/latex ]; then make -C doc/generated/latex; fi

.PHONY: doc
