# RFCHOST =	ftp://ftp.nordu.net
RFCHOST =	ftp://ftp.ietf.org
RFCDIR =	rfc

IANAHOST =	http://www.iana.org
IANADIR =	assignments

PREFIX =	/usr/local
ALLDIR =	$(PREFIX)/share/snmp/rfc.orig
INSTDIR =	$(PREFIX)/share/snmp/rfc

MIBS =	SNMPv2-TC.txt SNMPv2-TM.txt SNMPv2-SMI.txt SNMPv2-MIB.txt \
	SNMPv2-CONF.txt HCNUM-TC.txt INET-ADDRESS-MIB.txt \
	SNMP-FRAMEWORK-MIB.txt SNMP-MPD-MIB.txt SNMP-USER-BASED-SM-MIB.txt \
	SNMP-VIEW-BASED-ACM-MIB.txt SNMP-COMMUNITY-MIB.txt \
	SNMP-TARGET-MIB.txt SNMP-NOTIFICATION-MIB.txt SNMP-PROXY-MIB.txt \
	AGENTX-MIB.txt SMUX-MIB.txt \
	DISMAN-SCRIPT-MIB.txt  DISMAN-SCHEDULE-MIB.txt \
	IANA-LANGUAGE-MIB.txt IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt \
	IF-MIB.txt IF-INVERTED-STACK-MIB.txt \
	IP-MIB.txt IP-FORWARD-MIB.txt TCP-MIB.txt UDP-MIB.txt \
	IANAifType-MIB.txt EtherLike-MIB.txt \
	IPV6-TC.txt IPV6-MIB.txt IPV6-ICMP-MIB.txt \
	IPV6-TCP-MIB.txt IPV6-UDP-MIB.txt \
	HOST-RESOURCES-MIB.txt HOST-RESOURCES-TYPES.txt \
	NETWORK-SERVICES-MIB.txt MTA-MIB.txt \
	RMON-MIB.txt \
	RFC1155-SMI.txt RFC1213-MIB.txt

MIBDEPS = Makefile.mib mibfetch smistrip

all:	$(MIBS)

allmibs:	ianamibs rfcmibs

rfc:	allmibs
	rm -fr $(INSTDIR)
	mkdir $(INSTDIR)
	cp $(ALLDIR)/* $(INSTDIR)
	if test `uname` = SunOS ; \
	then gpatch -d $(INSTDIR) < rfcmibs.diff; \
	else patch -d $(INSTDIR) < rfcmibs.diff; \
	fi
	rm -f $(INSTDIR)/*orig

clean:
	rm $(MIBS)

SNMP-FRAMEWORK-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3411

SNMP-MPD-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3412 SNMP-MPD-MIB

SNMP-TARGET-MIB.txt SNMP-NOTIFICATION-MIB.txt SNMP-PROXY-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3413

SNMP-USER-BASED-SM-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3414 SNMP-USER-BASED-SM-MIB

SNMP-VIEW-BASED-ACM-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3415

SNMP-COMMUNITY-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2576

SNMPv2-SMI.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2578 SNMPv2-SMI

SNMPv2-TC.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2579

SNMPv2-CONF.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2580

SNMPv2-TM.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3417

SNMPv2-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3418

AGENTX-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2742

SMUX-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 1227 SMUX-MIB

DISMAN-SCHEDULE-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3231

DISMAN-SCRIPT-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3165

IF-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2863

IF-INVERTED-STACK-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2864

HCNUM-TC.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2856

INET-ADDRESS-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3291

EtherLike-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 3635

IANAifType-MIB.txt:	$(MIBDEPS)
	./mibfetch -x $(IANAHOST) $(IANADIR) ianaiftype-mib

IANA-LANGUAGE-MIB.txt:	$(MIBDEPS)
	./mibfetch -x $(IANAHOST) $(IANADIR) ianalanguage-mib

IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt:	$(MIBDEPS)
	./mibfetch -x $(IANAHOST) $(IANADIR) ianaaddressfamilynumbers-mib

IP-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2011

IP-FORWARD-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2096

TCP-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2012

UDP-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2013

IPV6-TC.txt IPV6-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2465

IPV6-ICMP-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2466

IPV6-TCP-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2452

IPV6-UDP-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2454

HOST-RESOURCES-MIB.txt HOST-RESOURCES-TYPES.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2790

RMON-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2819

NETWORK-SERVICES-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2788

MTA-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 2789

RFC1155-SMI.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 1155

RFC1213-MIB.txt:	$(MIBDEPS)
	./mibfetch $(RFCHOST) $(RFCDIR) 1213

ianamibs:	ianalist
	[ -d $(ALLDIR) ] || mkdir $(ALLDIR)
	cat ianalist | while read file mibs; \
		do \
		  if [ "$$file" != "#" ]; \
		  then \
		    ./mibfetch -d $(ALLDIR) -x $(IANAHOST) $(IANADIR) $$file $$mibs; \
		  fi; \
		done

rfcmibs:	rfclist
	[ -d $(ALLDIR) ] || mkdir $(ALLDIR)
	cat rfclist | while read rfc mibs; \
		do \
		  if [ "$$rfc" != "#" ]; \
		  then \
		    ./mibfetch -d $(ALLDIR) $(RFCHOST) $(RFCDIR) $$rfc $$mibs; \
		  fi; \
		done
