# $Id: makefile,v 1.31 1994/03/18 06:25:44 sra Exp $ # This makefile should work on any unix machine with the basic unix # text processing tool set. I don't claim that it's pretty, just that # it works and that it automates almost all of the processing magic # involved in generating these documents. Feel free to invent a # better way to do this. # Unless you've got a special reason to do something weird, you # probably just want to use the default target, which will check the # line lengths in the un-filled portion of the source files then # generate .txt and .mib files from the nroff source. If you want to # verify that the generated .txt files comply with the RFC Editor's # line and page length limits, try the "checktxts" target. SRCS = resolver.rf server.rf MIBS = resolver.mib server.mib TXTS = resolver.txt server.txt TOCS = resolver.toc server.toc # These limits are from RFC-1111. MAXLINE = 72 MAXPAGE = 58 # Magic delimiters in NROFF source. MIBDELIM1 = %%% BEGIN ASN\.1 %%% MIBDELIM2 = %%% END ASN\.1 %%% # This should match the numeric parameter to the ".ba" NROFF command. INDENT = 3 .SUFFIXES: .mib .txt .rf all: checkmibs mibs txts tags mibs: $(MIBS) txts: $(TXTS) clean: ; rm -f $(MIBS) $(TXTS) $(TOCS) TAGS $(MIBS) $(TXTS): makefile # Produce a text file that looks a lot like an RFC document. # Most of the hairy stuff here is generating the table of contents. # Comment out the last line if you want to keep the .toc file around. .rf.txt: rm -f $*.toc $*.tmp; touch $*.tmp until cmp -s $*.toc $*.tmp; do\ mv $*.tmp $*.toc;\ (echo '%%% TOC %%%'; echo '.xp t')\ | nroff -me -Tlpr -i $<\ | sed -n '/%%% TOC %%%/,$$s/^ *\([0-9].*\)$$/\1/p' >$*.tmp;\ done rm -f $*.tmp nroff -me -Tlpr $<\ | sed -e 's/_//g' -e 's/.//g'\ | awk 'p==1 {print " "; p=0} {print} /\[Page [0-9]*\]$$/ {p=1}'\ >$@ rm -f $*.toc # Produce a text file that can be used as input to a MIB compiler. .rf.mib: awk '/$(MIBDELIM1)/,/$(MIBDELIM2)/ { if ($$0 !~ /^\./) print }' $< >$@ # Check the line lengths in the MIB portion of the NROFF document # (where we have NROFF's automatic line filling turned off). # Source dependency is for Mach (CMU) make's auto-checkout feature. checkmibs: $(SRCS) @for i in $(SRCS); do awk '\ /$(MIBDELIM1)/,/$(MIBDELIM2)/ { \ if (length > $(MAXLINE) - $(INDENT)) \ printf "%s:%d: line too long: %s\n", FILENAME, NR, $$0; \ } \ ' $$i; done # Check the .txt outputs for RFC-1111 compliance. checktxts: txts @for i in $(TXTS); do echo "Checking $$i"; awk '\ length > $(MAXLINE) { \ printf "%s:%d: line too long: %s\n", FILENAME, NR, $$0; \ } \ / / { \ ph = NR + 1; \ } \ (NR - ph) > $(MAXPAGE) && /\[Page [0-9]*\]$$/ { \ printf "%s:%d: page too long: %s\n", FILENAME, NR, $$0; \ } \ ' $$i; done # Automatically update the MIB UTC timestamp and the I-D expire date. # This will only work if you've got gawk installed (sorry, but date # manipulation is just too painful with the v7 unix toolset). Also, # we assume that setting TZ='' will make gawk write dates in GMT. # Last, note that the I-D expire time algorithm is buggy (what date # is six months from 30 August?), so we just calculate 187 days in the # future on the theory that after a certain number of decimal places # nobody gives a hoot. update-timestamps: $(SRCS) @for i in $(SRCS); do\ if [ -w $$i ]; then\ base=`basename $$i .rf`;\ rm -f $$base.old ; cp -p $$i $$base.old;\ TZ='' gawk <$$i '\ BEGIN {\ now = systime();\ utctime = strftime("%y%m%d%H%MZ", now);\ expire = strftime("%e %B %Y", now+(187*24*60*60));\ today = strftime("%B %Y", now);\ sub(/^ +/, "", expire);\ }\ /[123]?[0-9] [A-Z][a-z]+ [0-9][0-9][0-9][0-9]/ {\ gsub(/[123]?[0-9] [A-Z][a-z]+ [0-9][0-9][0-9][0-9]/, expire);\ }\ /^ *LAST-UPDATED +"[0-9]+Z" *$$/ {\ gsub(/[0-9]+Z/, utctime);\ }\ length==$(MAXLINE) && /^ +[A-Z][a-z]+ [0-9][0-9][0-9][0-9]$$/ {\ $$0 = sprintf("%$(MAXLINE)s", today);\ }\ /^\.he .*[A-Z][a-z]+ [0-9][0-9][0-9][0-9]/ {\ gsub(/[A-Z][a-z]+ [0-9][0-9][0-9][0-9]/, today);\ }\ {\ print;\ }\ ' >$$base.new && mv -f $$base.new $$i\ && ( if diff $$base.old $$i; then true; else true; fi );\ else\ echo "$$i is write protected, timestamps not updated";\ fi;\ done tags: TAGS # Generate an emacs tags file for a MIB. TAGS: $(SRCS) @echo Generating TAGS table; for i in $(SRCS); do awk '\ filename == "" { \ filename = FILENAME \ } \ $$0 ~ /^[a-zA-Z0-9]+ +OBJECT-(GROUP|IDENTITY|TYPE)$$/ || \ $$0 ~ /^[a-zA-Z0-9]+ +::= +TEXTUAL-CONVENTION$$/ { \ tag[ntags++] = $$1 " " NR "," NC \ } \ { \ NC += length \ } \ END { \ for (i = 0; i < ntags; ++i) \ n += length(tag[i]) + 1; \ print " \n" filename "," n; \ for (i = 0; i < ntags; ++i) \ print tag[i]; \ } \ ' $$i; done >$@ # Put copies of the sources where other people can get them. # I don't expect this to work anywhere but on Mach386. PUBDIR=/u/ftp/pub/sra/dns-mib PUBLST=makefile $(SRCS) $(TXTS) $(MIBS) PUBFOO=$(PUBLST;.*;$(PUBDIR)/&;) install: $(PUBFOO) $(PUBFOO): $$(@F) rm -f $@ cp -p $(@F) $@ chmod 444 $@ # Targets to auto-mosy the MIBs. Are we having fun yet? # # The rubbish for the resolver MIB is to extract the stuff in the server MIB # on which the resolver MIB depends, since mosy no like undefined TCs. # # To examine the text that's mailed to mosy, do "make 'MOSY=cat >$@' mosy" MOSY=mail mosy@dbc.mtview.ca.us mosy: server.mosy resolver.mosy server.mosy: server.mib $(MOSY)