1val cmdline_args = CommandLine.arguments() 2fun warn s = (TextIO.output(TextIO.stdErr, s); TextIO.flushOut TextIO.stdErr) 3 4val holdir = 5 case cmdline_args of 6 [x] => x 7 | _ => (warn "Must specify HOLDIR as first and only argument\n"; 8 Process.exit Process.failure) 9 10fun butlast0 _ [] = raise Fail "butlast - empty list" 11 | butlast0 acc [x] = List.rev acc 12 | butlast0 acc (h::t) = butlast0 (h::acc) t 13fun butlast l = butlast0 [] l 14 15val mosmldir = 16 case Process.getEnv "MOSMLLIB" of 17 (* note that if this code is running at all, the MOSMLLIB variable 18 will be set because Moscow ML under Windows depends on it *) 19 NONE => (warn "No MOSMLLIB environment variable!!\n"; 20 Process.exit Process.failure) 21 | SOME s => let 22 val {arcs,isAbs,vol} = Path.fromString s 23 val newarcs = butlast arcs @ ["bin"] 24 in 25 Path.toString {arcs = newarcs, isAbs = isAbs, vol = vol} 26 end 27 28(*--------------------------------------------------------------------------- 29 String and path operations. 30 ---------------------------------------------------------------------------*) 31 32fun normPath s = Path.toString(Path.fromString s) 33fun itstrings f [] = raise Fail "itstrings: empty list" 34 | itstrings f [x] = x 35 | itstrings f (h::t) = f h (itstrings f t); 36 37fun fullPath slist = normPath 38 (itstrings (fn chunk => fn path => Path.concat (chunk,path)) slist); 39 40val ostrm = TextIO.openOut (fullPath [holdir, "config-override"]) 41 42val _ = FileSys.chDir holdir 43val holdir = FileSys.getDir () 44 45fun pr s = TextIO.output(ostrm, s) 46val _ = (pr ("val holdir = \""^holdir^"\"\n"); 47 pr ("val mosmldir = \""^mosmldir^"\"\n"); 48 pr ("val OS = \"winNT\"\n"); 49 pr ("val dynlib_available = true\n"); 50 TextIO.closeOut ostrm) 51 52val _ = print "Configuring the system\n"; 53val _ = FileSys.mkDir (fullPath [holdir, "src", "0"]) handle _ => () 54val _ = Process.system ("mosml < tools\\smart-configure.sml") 55 56val _ = let 57 val _ = print "Adjusting sigobj/SRCFILES ... " 58 val file = fullPath [holdir, "sigobj", "SRCFILES"] 59 val instrm = TextIO.openIn file 60 fun readlines acc = 61 case TextIO.inputLine instrm of 62 "" => List.rev acc 63 | s => readlines (s::acc) 64 val lines = readlines [] 65 val _ = TextIO.closeIn instrm 66 fun adjustline s = if Path.isAbsolute s then s else fullPath [holdir, s] 67 val outstrm = TextIO.openOut file 68 val _ = app (fn s => TextIO.output(outstrm, adjustline s)) lines 69 val _ = TextIO.closeOut outstrm 70in 71 print "done\n" 72end 73 74 75val _ = print "Building the help system \n"; 76val _ = Systeml.systeml [fullPath [holdir, "bin", "build"], "help"]; 77 78val _ = Process.exit Process.success; 79