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