1#! /bin/sh
2# -*- tcl -*- \
3exec tclsh "$0" ${1+"$@"}
4
5set here    [file dirname [file join [pwd] [info script]]]
6set verbose 0
7
8set o [lindex $argv 0]
9if {[string equal $o "-verbose"]} {
10    set verbose 1
11    set argv [lrange $argv 1 end]
12} elseif {[string equal $o ""] && [llength $argv] > 1} {
13    puts stderr "Usage: $argv0 ?-verbose? ?module?"
14    exit 1
15}
16
17set module [lindex $argv 0]
18array set fmts {
19    nroff n
20    html  html
21    tmml  tmml
22    latex tex
23}
24
25foreach fname [glob -nocomplain *.man] {
26    foreach fmt [array names fmts] {
27	set out [file rootname $fname].$fmts($fmt)
28	if {1 || $verbose} {
29	    puts "  $fname -> $out"
30	}
31	if {$module != {}} {
32	    exec [file join $here mpexpand] -module $module $fmt $fname $out
33	} else {
34	    exec [file join $here mpexpand] $fmt $fname $out
35	}
36    }
37}
38exit
39