include nessus.tmpl

ALLDEPS = nessus.tmpl

all: libnessus-client client sslstuff


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

install: all client-install install-bin install-man install-tools
	@echo
	@echo ' --------------------------------------------------------------'
	@echo ' OpenVAS-Client has been sucessfully installed. '
	@echo ' --------------------------------------------------------------'
	@echo

install-bin:
	test -d $(DESTDIR)${bindir} || $(INSTALL_DIR) -m 755 $(DESTDIR)${bindir}
	$(INSTALL) -m $(CLIENTMODE) openvasclient-mkcert $(DESTDIR)${bindir}

install-tools:
	test -d $(DESTDIR)${datarootdir}/openvas || $(INSTALL_DIR) -m 755 $(DESTDIR)${datarootdir}/openvas
	$(INSTALL) -m $(CLIENTMODE) tools/openvas-ssh-client-rpm-creator.sh $(DESTDIR)${datarootdir}/openvas

sslstuff:
	cd ssl && $(MAKE)

install-man:
	@echo installing man pages ...
	@test -d $(DESTDIR)${mandir}/man1 || $(INSTALL_DIR) $(DESTDIR)${mandir}/man1

	$(INSTALL) -c -m 0444 ${MAN_NESSUS_1} $(DESTDIR)${mandir}/man1/OpenVAS-Client.1
	$(INSTALL) -c -m 0444 doc/openvasclient-mkcert.1 $(DESTDIR)${mandir}/man1/openvasclient-mkcert.1

client-install: client
	test -d $(DESTDIR)${bindir} || $(INSTALL_DIR) -m 755 $(DESTDIR)${bindir}
	$(INSTALL) -m $(CLIENTMODE) ${make_bindir}/OpenVAS-Client $(DESTDIR)${bindir}

client:
	cd nessus && $(MAKE)

libnessus-client:
	cd libnessus && $(MAKE)


man: $(MAN_NESSUS_1)

$(MAN_NESSUS_1) : $(MAN_NESSUS_1).in
	@sed -e '' $(MAN_NESSUS_1).in  >$(MAN_NESSUS_1)

buildcheck: all
	cd po && make

clean:
	cd nessus && $(MAKE) clean
	cd libnessus && $(MAKE) clean
	cd ssl && $(MAKE) clean
	cd src/gui && $(MAKE) clean
	cd src/openvas-lib && $(MAKE) clean
	cd src/util &&  $(MAKE) clean
	rm -rf doc/generated

distclean: clean
	[ -z "${rootdir}" ] || rm -f ${rootdir}/include/config.h ${rootdir}/include/corevers.h
	rm -f nessus.tmpl doc/OpenVAS-Client.1.cat
	[ -z "${make_bindir}" ] || rm -f $(make_bindir)/[oO]pen*
	rm -f libtool config.cache config.status config.log
	rm -f openvasclient-mkcert

dist:
	version="`cat VERSION`"; \
	rm -rf openvas-client-$${version}* ; \
	mkdir openvas-client-$${version} ; \
	tar cf openvas-client-$${version}/x.tar `cat MANIFEST`; \
	( cd openvas-client-$${version} ; tar xf x.tar ; rm -f x.tar ) ; \
	tar cf openvas-client-$${version}.tar openvas-client-$${version} ; \
	gzip -9 openvas-client-$${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
