1/* 2 * post stuff to WWWDIR for web access 3 * index generated from *.mm 4 */ 5 6WWWDIR = wwwfiles public_html 7WWWSAVE = 8WWWSTYLE = 9WWWTYPES = 10 11.WWW.semaphore : .SEMAPHORE 12 13.EXPORT : WWWSTYLE WWWTYPES 14 15/* 16 * item :WWW: [style=frame] [save=pattern] file ... 17 * 18 * `item'.mm generates index.html 19 * other files copied to $(WWWDIR)/`item' 20 * sets up www.bin 21 */ 22 23":WWW:" : .MAKE .OPERATOR 24 local A B D I J L X E P R M 25 .WWW.LOCAL .WWW.REMOTE : .DO.NOTHING 26 WWWDIR := $(HOME:X=$(WWWDIR):T=F:O=1) 27 B := $(*:N=*.mm::O=1:B) 28 D := $(WWWDIR)/$(B) 29 M := $(WWWDIR)/man/man1 30 R := $(>:N!=*=*) 31 for I $(>:N=*=*) 32 A := WWW$(I:/=.*//:F=%(upper)s) 33 $(A) := $(I:/.*=//) 34 end 35 (html_info) : $$(MM2HTMLINFO) $$(MM2HTMLINIT) 36 if WWWSTYLE == "frame" 37 %.html %-index.html : %.mm (html_info) 38 $(MM2HTML) $(MM2HTMLFLAGS) $(%:N=faq.*:?> $(<:O=1)?-f $(%) -x?) -o WWWTYPES=$(WWWTYPES:@Q:@Q) $(WWWSOURCE.$(%)) $(>) 39 else 40 %.html : %.mm (html_info) 41 $(MM2HTML) $(MM2HTMLFLAGS) -o WWWTYPES=$(WWWTYPES:@Q:@Q) $(>) $(WWWSOURCE.$(%)) > $(<) 42 end 43 %.html : %.1 (html_info) 44 $(MM2HTML) $(MM2HTMLFLAGS) $(>) $(WWWSOURCE.$(%)) > $(<) 45 %-man.html : $(BINDIR)/% (html_info) 46 ignore $(>) --html 2> $(<) 47 .DO.WWW.MAN : .USE 48 if { test '' = '$(*)' || { strings $(*) | egrep -q '\[\+NAME\?|libcmd\.|cmd[0-9][0-9]\.' ;} ;} && [[ "$( $(<:B) '--???html' -- 2>&1 )" == version=[1-9]* ]] 49 then ( $(<:B) '--??html' -- 2>$(<) ) || true 50 fi 51 if 0 52 $(M)/%.html : .DONTCARE $(INSTALLROOT)/bin/% 53 $(@.DO.WWW.MAN) 54 end 55 if "$(<)" 56 D := $(<) 57 elif ! "$(R)" 58 return 59 end 60 .WWW .WWW.BIN : $(D) $(M) - 61 $(D) $(M) : 62 $(SILENT) test -d $(<) || mkdir $(<) 63 if ( J = "$(R:N=*.mm)" ) 64 for I $(J:G=%.html) 65 if I == "*-index.html" 66 O := $(D)/index.html 67 else 68 O := $(I:D=$(D):B:S) 69 end 70 .WWW : $(O) 71 $(O) :COPY: $(I) 72 end 73 end 74 .WWW.req : .FUNCTION 75 return $(*$(%:T=SR):N=-l*:T=F:P=B:N!=-l*|/*) 76 A = 0 77 for I $(R:N!=*.mm) 78 if I == "-" 79 let A = ! A 80 elif I == "-l*" 81 L := $(I:/-l//) 82 if J = "$(.DLL.NAME. $(L) $($(L).VERSION):T=F)" 83 X += $(J) 84 end 85 elif A || "$(I:A=.COMMAND|.ARCHIVE)" || "$(I:D:D:N=$(INSTALLROOT))" || "$(I:N=*-www)" 86 X += $(I) 87 if "$(I:A=.COMMAND)" 88 X += $$(.WWW.req $(I)) 89 J := $(I:/-www$//) 90 eval 91 .WWW : $(J:D=$(M):B:S=.html) 92 $(J:D=$(M):B:S=.html) : $(I) $(I:B:S=.1:T=F:?$(I:B:S=.1)??) 93 if strings $$(*:O=1) | egrep -q '\[\+NAME\?|libcmd\.|cmd[0-9][0-9]\.' 94 then $$(IGNORE) $$(*:O=1) '--??html' -- 2>&1 95 elif test '' != '$$(*:N=*.1)' 96 then $$(MM2HTML) $$(*:N=*.1) 97 fi > $$(<) 98 end 99 end 100 else 101 if I == "*.html" 102 $(I) : .TERMINAL 103 end 104 .WWW : $(D)/$(I) 105 $(D)/$(I) :COPY: $(I) 106 end 107 end 108 if "$(X:V)" 109 .WWW.EDIT. : .FUNCTION 110 local E I J 111 for I $(.INSTALL.LIST.:C,^$(INSTALLROOT)/,,:N!=lib/lib/*) 112 for J $(%) 113 if "$(I:B:S)" == "$(J:B:S)" 114 E += -s ',^$(J)$,$(I),' 115 end 116 end 117 end 118 return $(E) 119 .WWW.LIST. : .FUNCTION 120 local E I J 121 for I $(.INSTALL.LIST.:C,^$(INSTALLROOT)/,,:N!=lib/lib/*) 122 for J $(%) 123 if "$(I:B:S)" == "$(J:B:S)" 124 E += $(I) 125 end 126 end 127 end 128 return $(E) 129 .WWW .WWW.BIN : $(D)/$(B)-$(CC.HOSTTYPE).tgz 130 $(D)/$(B)-$(CC.HOSTTYPE).tgz : $(X:V) 131 cat > X.$(tmp).X <<! 132 This archive contains $(CC.HOSTTYPE) binaries for 133 $(.WWW.LIST. $(*)) 134 Add the bin directory to PATH and the lib directory 135 to LD_LIBRARY_PATH or its equivalent for your system. 136 Use the --?help and --man options for online help, 137 documentation and contact info. 138 ! 139 $(PAX) -wvf $(<) -x tar:gzip -s "/X.$(tmp).X/README/" $(.WWW.EDIT. $(*)) -s ',\(.*\)-www$,bin/\1,' -s ',.*/lib/,lib/,' X.$(tmp).X $(*:N!=-l*) 140 $(RM) -f X.$(tmp).X 141 end 142 143/* 144 * item ... :WWWBIN: index.mm file ... host:arch ... 145 * 146 * home page control 147 * `host' of type `arch' for www.bin files 148 */ 149 150":WWWBIN:" : .MAKE .OPERATOR 151 local HOST ITEM ARCH BINS DIRS G 152 .WWW.NOMAN. += $(<) 153 for HOST $(>) 154 TYPE := $(HOST:/.*://) 155 HOST := $(HOST:/:.*//) 156 WWWTYPES += $(TYPE) 157 ARCH := $(PWD:D:C,/$(CC.HOSTTYPE)/,/$(TYPE)/) 158 BINS := 159 DIRS := 160 for ITEM $(<) 161 if TYPE == "$(CC.HOSTTYPE)" 162 G := $("index.mm":G=%.html:D=$(WWWDIR)/$(ITEM):B:S) 163 .WWW.LOCAL : $(G) 164 eval 165 $(G) : .JOINT $(ARCH)/$(ITEM)/$(ITEM).mm (html_info) .WWW.semaphore .FORCE 166 cd $$(*:D) 167 $$(MAKE) $$(-) $$(=) www 168 end 169 else 170 BINS += $(WWWDIR)/$(ITEM)/$(ITEM)-$(TYPE).tgz 171 DIRS += $(ARCH)/$(ITEM) 172 end 173 end 174 .WWW.REMOTE : $(BINS) 175 ARCH := $(ARCH:C,/src/.*,,) 176 eval 177 $(BINS) :JOINT: .FORCE .WWW.semaphore 178 rsh $(HOST) " 179 eval \"\`bin/package debug use\`\" 180 PATH=\$PATH:$(PATH):/usr/ccs/bin 181 umask 022 182 for dir in $(DIRS) 183 do cd \$dir 184 $(MAKE) $(-) $(=) --errorid=\$dir www.bin 185 done 186 " 187 end 188 end 189 190/* 191 * :WWWPOST: [ host [ dir [ tmp ] ] ] 192 * 193 * post local $(WWWDIR) to host:dir putting archives in host:tmp/www-*.pax 194 * defaults: host=www dir=$(WWWDIR) tmp=tmp 195 */ 196 197":WWWPOST:" : .MAKE .OPERATOR 198 local ( host dir tmp ignore ... ) $(>) www $(WWWDIR:B:S) tmp ignore 199 :ALL: delta.pax 200 .WWW.ALL : .WWW.REMOTE - .WWW.LOCAL 201 eval 202 .POST : .VIRTUAL base.pax delta.pax 203 case "$$(>)" in 204 '') ;; 205 *) $$(>:C,.*,rcp & $(host):$(tmp)/$(dir)-&;,) 206 rsh $(host) ' 207 umask 022 208 PATH=$HOME/bin:$PATH 209 cd $(dir) 210 pax -rvf $HOME/$(tmp)/$(dir)-delta.pax -z $HOME/$(tmp)/$(dir)-base.pax 211 ' 212 ;; 213 esac 214 end 215 base.pax : 216 cd $(WWWDIR) 217 pax -wvf $(<:P=A) . 218 .base.list. : .FUNCTION 219 local X 220 X := $(sh pax -f $(%:N=*.pax):C,\n, ,G:C,^,$$(WWWDIR)/,) 221 $(X) : .DONTCARE 222 return $(X) 223 delta.pax : .WWW.ALL base.pax $$(.base.list. $$(*)) 224 cd $(WWWDIR) 225 pax -wvf $(<:P=A) -z $(*:N=*.pax:P=A) . 226 227.WWW.FAQ : .USE 228 { 229 set -o noglob 230 print .xx title=\"$(<:B:/\..*//) FAQ index\" 231 print .MT 4 232 print .TL 233 print 234 print .H 1 \"$(<:B:/\..*//) FAQ index\" 235 print .BL 236 for i in $(*) 237 do exec < $i || exit 1 238 e=0 l=0 x=y 239 while read -r op a1 a2 240 do case $op in 241 .H) case $e in 242 0) e=1 ;; 243 1) print .LE ;; 244 esac 245 print .sp 246 print .LI 247 a2=${a2//\"/} 248 a2=${a2%\ [Ff][Aa][Qq]} 249 f=${i%.*}.html 250 f=${f#*/} 251 print .xx link=\"$f' '$a2\" 252 print .sp 253 print .NL 254 ;; 255 .AL|.BL|.NL) 256 case $x in 257 y) x=x ;; 258 *) x=xx$x ;; 259 esac 260 ;; 261 .LE) x=${x%xx} 262 ;; 263 .LI) case $x in 264 x) x= 265 print .LI 266 ;; 267 esac 268 ;; 269 .sp) case $x in 270 '') x=x ;; 271 esac 272 ;; 273 *) case $x in 274 '') print -r -- $op $a1 $a2 ;; 275 esac 276 ;; 277 esac 278 done 279 case $e in 280 1) print .LE ;; 281 esac 282 done 283 print .LE 284 } > $(<) 285 286/* 287 * [ dir ] :WWWPAGE: [ source ... ] file.mm file 288 * 289 * *.mm generates *.html 290 * faq.*.mm generates faq.mm 291 * other files copied to $(WWWDIR)[/dir] 292 * files after - (toggle) are just asserted on :: 293 */ 294 295":WWWPAGE:" : .MAKE .OPERATOR 296 local B D I J O P Q S X G A 297 A = 0 298 D := $(<:O=1) 299 P := $(>:N!=*=*) 300 S := $(>:N=*=*) 301 if X = "$(P:B:S:N=faq.*.mm)" 302 Q := $(D:+$(D).)faq.mm 303 $(Q) : .WWW.FAQ $(X) 304 P += $(Q) 305 end 306 if D 307 B := $(D:B) 308 if D != "/*" 309 D := $(WWWDIR)/$(D) 310 $(D) :INSTALLDIR: 311 .WWW.LOCAL : $(D) 312 end 313 for I $(<:B) 314 .WWW.LOCAL : $(WWWDIR)/man/man1/$(I).html 315 $(WWWDIR)/man/man1/$(I).html : .DONTCARE 316 end 317 for I $(P) 318 if I == "-" 319 let A = !A 320 continue 321 end 322 if A || I == "$(WWWSAVE)" 323 :: $(I) 324 continue 325 end 326 if "$(I:T=FD)" 327 .SOURCE : $(I) 328 if "$(<)" 329 WWWSOURCE.$(<:O=1) += $(I:T=F:P=L=*) 330 end 331 continue 332 end 333 if I == "*.html" 334 $(I) : .TERMINAL 335 O := $(I) 336 X := $(I) 337 elif ( G = "$(I:G=%.html)" ) 338 $(G) : .IMPLICIT $(S) $(I) 339 if $(G:O) > 1 340 for J $(G) 341 if J == "*-index.html" 342 if J == "faq.*.*" 343 continue 344 end 345 O := index.html 346 else 347 O := $(J) 348 end 349 .WWW.LOCAL : $(D)/$(O) 350 $(D)/$(O) :INSTALL: $(J) 351 end 352 continue 353 end 354 if X 355 X := $(I) 356 else 357 X := index 358 end 359 I := $(I:B:S=.html) 360 O := $(X:B:S=.html) 361 else 362 O := $(I) 363 end 364 $(D)/$(O) :INSTALL: $(I) 365 .WWW.LOCAL : $(D)/$(O) 366 end 367 else 368 for I $(P) 369 if I == "-" 370 let A = !A 371 continue 372 end 373 if A || I == "$(WWWSAVE)" 374 :: $(I) 375 continue 376 end 377 if "$(I:T=FD)" 378 .SOURCE : $(I) 379 continue 380 end 381 if I == "*.html" 382 $(I) : .TERMINAL 383 O := $(I) 384 elif ( O = "$(I:G=%.html)" ) 385 $(O) : $(S) .IMPLICIT $(I) 386 end 387 for J $(O) 388 if J == "*-index.html" 389 X := index.html 390 else 391 X := $(J) 392 end 393 X := $(WWWDIR)/$(X) 394 .WWW.LOCAL : $(X) 395 $(X) :COPY: $(J) 396 end 397 end 398 end 399 400/* 401 * rhs done by default 402 */ 403 404":WWWALL:" : .MAKE .OPERATOR 405 .WWW.ALL : $(>) 406 407":WWWMAN:" : .MAKE .OPERATOR 408 .INIT : .WWW.MAN 409 .WWW.MAN. := $(>) 410 .WWW.MAN : .MAKE .FORCE 411 local H I 412 for I $(.WWW.MAN.) 413 .WWW.LOCAL : $(WWWDIR)/man/man1/$(I:B).html 414 $(WWWDIR)/man/man1/$(I:B).html : .DO.WWW.MAN $(I) 415 end 416 for I $(sh builtin:B) 417 .WWW.LOCAL : $(WWWDIR)/man/man1/$(I).html 418 $(WWWDIR)/man/man1/$(I).html : .DO.WWW.MAN - 419 end 420 for I $("$(BINDIR)/*([!-.])":P=G:B) 421 if I != "*_*" 422 H := $(WWWDIR)/man/man1/$(I).html 423 if ! "$(*$(H))" && I != "$(.WWW.NOMAN.:/ /|/G)" 424 .WWW.LOCAL : $(H) 425 end 426 elif "$(PATH:/:/ /G:X=$(I:/.*_//):T=F:O=1)" 427 H := $(WWWDIR)/man/man1/$(I:/.*_//).html 428 .WWW.LOCAL : $(H) 429 $(H) : .DO.WWW.MAN $(BINDIR)/$(I) 430 end 431 end 432 433.WWW.SED. : .FUNCTION 434 local E T 435 E = s/^\(\.xx.link=.*\)%HOSTTYPE%\(.*\)%HOSTTYPE%\(.*\)/ 436 for T $(%) 437 E := $(E:V)\$$("\n").LI\$$("\n")\1$(T)\2$(T)\3 438 end 439 return $(E:V)/ 440 441/* 442 * mm scan support 443 */ 444 445.SCAN.mm : .SCAN 446 O|S| 447 I|.sn %|A.DONTCARE|M$$(%)| 448 I|.so %|A.DONTCARE|M$$(%)| 449 450.ATTRIBUTE.%.mm : .SCAN.mm 451