TARG = bin/snmpget bin/snmpgetnext bin/snmpset bin/snmptranslate bin/snmpwalk bin/snmpbulkwalk bin/snmptest bin/snmptrapd bin/snmpnetstat bin/snmpd

SUBDIRS = snmplib agent apps local ov man
INSTALLDIRS = snmplib agent apps local man mibs

CPP = @CPP@ -I. -I$(srcdir) -DDONT_INC_STRUCTS -DBINDIR=$(bindir) $(EXTRACPPFLAGS)

all:	sedscript EXAMPLE.conf subdirs

sedscript: sedscript.in config.h agent/mibgroup/mibdefs.h
	$(CPP) -DPREFIX=$(prefix) -DLIBDIR=$(libdir) -DDATADIR=$(datadir) $(srcdir)/sedscript.in | sed 's/REMOVEME//g;s# */#/#g;s/ *#/#/g;s#/ *#/#g;' | egrep '^s[/#]' > sedscript

subdirs:
	for i in $(SUBDIRS) ; do \
        ( cd $$i ; $(MAKE) ) ; \
	done

distall: ${srcdir}/configure ${srcdir}/config.h 

install:    subdirs installdirs
	for i in $(INSTALLDIRS) ; do \
        ( cd $$i ; $(MAKE) install ) ; \
	done
	@if test -f $(snmplibdir)/mib.txt; then echo "*** warning: $(snmplibdir)/mib.txt exists, but is no longer needed.  You might wish to remove it as we will still try to read it even though its not necessary."; fi


installdirs:
	@$(SHELL) $(srcdir)/mkinstalldirs $(snmplibdir) $(mibdir)


apps/snmpget apps/snmpgetnext apps/snmpset apps/snmptranslate apps/snmpwalk apps/snmpbulkwalk apps/snmptest apps/snmptrapd apps/snmpnetstat/snmpnetstat agent/snmpd: makeall

depend:
	cd snmplib; make depend
	cd apps; make depend
	cd agent; make depend

nosysdepend:
	cd snmplib; make nosysdepend
	cd apps; make nosysdepend
	cd agent; make nosysdepend

makefileindepend:
	cd snmplib; make makefileindepend
	cd apps; make makefileindepend
	cd agent; make makefileindepend

clean:
	for i in $(SUBDIRS) ; do \
        ( cd $$i ; $(MAKE) clean ) ; \
	done
	rm -f EXAMPLE.conf sedscript ucd-snmp.txt

distclean: clean configclean

configclean:
	rm -f config.cache config.status config.log config.h
	rm -f snmplib/Makefile Makefile agent/Makefile apps/Makefile apps/snmpnetstat/Makefile agent/mibgroup/Makefile local/Makefile
	rm -f mib_module_config.h agent/mibgroup/mib_module_includes.h agent/mibgroup/mib_module_inits.h agent/mibgroup/mib_module_loads.h

configure: configure.in aclocal.m4
	cd ${srcdir} && autoconf
	echo "Please run configure now."
	sh -c exit 2

# autoheader might not change config.h.in, so touch a stamp file.
config.h.in: stamp-h.in
stamp-h.in: configure.in acconfig.h
	cd ${srcdir} && autoheader
	echo timestamp > ${srcdir}/stamp-h.in

config.h: stamp-h
stamp-h: config.h.in config.status
	CONFIG_FILES= ./config.status
	echo timestamp > ${srcdir}/stamp-h

touchit:
	touch configure config.h.in
	touch config.h config.status
	touch stamp-h stamp-h.in
	touch Makefile

Makefile: Makefile.in config.status
	CONFIG_HEADERS= ./config.status

config.status: configure
	./config.status --recheck

EXAMPLE.conf: sedscript EXAMPLE.conf.def
	$(SED) -f sedscript $(srcdir)/EXAMPLE.conf.def > EXAMPLE.conf

TAGS:
	find $(srcdir) -name '*.[ch]' -print | etags -
