include nessus.tmpl

ALLDEPS = nessus.tmpl nessus-config

all: $(ALLDEPS) $(CIPHER_MAKE)
	cd libpcap-nessus && ${MAKE}
	cd libnessus && ${MAKE}
	cd libhosts_gatherer && ${MAKE}

nessus-config: nessus-config.pre Makefile nessus.tmpl
	@echo Creating $@ ...
	@test -z "$(CIPHER_SUBDIR)" || (\
		cd $(CIPHER_SUBDIR) && ${MAKE} ldflags.out )
	@eval LDFLAGS=\"$(CIPHER_LDFLAGS)\" ; \
	 eval  CFLAGS=\"$(CIPHER_CFLAGS)\" ; \
	 sed -e 's?%CIPHER_LDFLAGS%?'"$$LDFLAGS"'?' \
	     -e  's?%CIPHER_CFLAGS%?'"$$CFLAGS"'?' \
	     nessus-config.pre >$@

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

win32:
	cd libpcap-nessus    && ${MAKE} distclean
	cd libhosts_gatherer && ${MAKE} distclean
	cd $(CIPHER_SUBDIR)  && ${MAKE} win32-prep
	@echo
	@echo ' --------------------------------------------------------------'
	@echo ' The header files necessary and some docs have been generated,'
	@echo ' now.  Go ahead and move the nessus lib to a windows box where'
	@echo ' it can be compiled using nmake (all Micro$$oft stuff.)'
	@echo ' --------------------------------------------------------------'
	@echo

cipher-make :
	cd $(CIPHER_SUBDIR) && ${MAKE}

cipher-install :
	cd $(CIPHER_SUBDIR) && ${MAKE} install

install : $(CIPHER_INSTALL)
	test -d ${prefix} || ${INSTALL_DIR} -m 755 ${prefix}
	test -d ${includedir}/nessus || ${INSTALL_DIR} -m 755 ${includedir}/nessus
	cd libnessus && ${MAKE} install
	cd libhosts_gatherer && ${MAKE} install
	cd libpcap-nessus && ${MAKE} install 
	test -d ${includedir}/nessus || ${INSTALL_DIR} -m 755 ${includedir}/nessus
###	soft migration to no public includes.h file -- jordan
	rm -f ${includedir}/nessus/includes.h
	$(INSTALL) -m 0444 include/libnessus.h ${includedir}/nessus
	$(INSTALL) -m 0444 include/harglists.h ${includedir}/nessus
	$(INSTALL) -m 0444 include/libvers.h   ${includedir}/nessus
	$(INSTALL) -m 0444 include/getopt.h    ${includedir}/nessus
	$(INSTALL) -m 0755 nessus-config ${bindir}/nessus-config
	test -d ${mandir}/man1 || ${INSTALL_DIR} -m 755 ${mandir}/man1
	$(INSTALL) -m 0644 nessus-config.1 ${mandir}/man1

	@echo
	@echo ' --------------------------------------------------------------'
	@echo ' nessus-libraries has been sucessfully installed. '
	@echo " Make sure that $(bindir) is in your PATH before you"
	@echo " continue "
	@echo ' --------------------------------------------------------------'
	@echo

clean :
	-cd libnessus && ${MAKE} clean
	-cd libhosts_gatherer && ${MAKE} clean
	-cd libpcap-nessus && ${MAKE} clean
	[ ! -d "$(CIPHER_SUBDIR)" ] || (cd $(CIPHER_SUBDIR) && [ ! -f Makefile ] || ${MAKE} $@)
	
distclean : clean
	rm -f ${rootdir}/include/config.h libtool config.cache \
	config.status config.log ${rootdir}/include/libvers.h 
	-cd libnessus && ${MAKE} distclean
	-cd libhosts_gatherer && ${MAKE} distclean
	-cd libpcap-nessus && ${MAKE} distclean
	[ ! -d "$(CIPHER_SUBDIR)" ] || (cd $(CIPHER_SUBDIR) && [ ! -f Makefile ] || ${MAKE} $@)
	rm -f nessus.tmpl nessus-config nessus-config.pre

dist:
	version="`date +%Y%m%d`"; \
	cd ..; \
	tar cf nessus-libraries-$${version}.tar \
		`cat nessus-libraries/MANIFEST | sed 's/^/nessus-libraries\//'`; \
	rm -f nessus-libraries-$${version}.tar.gz; \
	gzip -9 nessus-libraries-$${version}.tar


distcheck:
	find . -type f | sed -e 's/^.\///' -e '/~$$/d' -e '/CVS/d' \
			     -e '/\.o$$/d' -e '/^nessus.tmpl$$/d' \
			     -e '/\.aux$$/d' -e '/\.log$$/d' -e '/\.dvi$$/d' \
		             -e '/\.toc$$/d' \
			     -e '/\.lo$$/d' -e '/\.a$$/d' -e '/^libtool$$/d' \
			     -e '/config\.cache$$/d' \
			     -e '/config\.log$$/d' \
			     -e '/config\.status$$/d' \
			     -e '/^include\/config\.h$$/d' \
			     -e '/^libpcap-nessus\/scanner\.c$$/d' \
			     -e '/^libpcap-nessus\/tokdefs\.h$$/d' \
			     -e '/^libpcap-nessus\/version\.c$$/d' \
			     -e '/^libpcap-nessus\/grammar\.c$$/d' \
			     -e '/^libpcap-nessus\/Makefile$$/d' \
			     -e '/\.libs\//d' -e '/\.la$$/d' \
		| sort | diff -cb - MANIFEST
