(* paths.sml * * COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu) * All rights reserved. * * @configure_input@ *) structure Paths = struct local val // = OS.Path.concat infixr 4 // in (* directories for Diderot stuff *) val diderotBin = "@DIDEROT_ROOT@" // "bin" val diderotInclude = "@DIDEROT_ROOT@" // "src/include" val diderotSrc = "@DIDEROT_ROOT@" // "src" val diderotLib = diderotSrc // "lib" (* directories for Teem stuff *) val teemBin = "@TEEM_DIR@" // "bin" val teemInclude = "@TEEM_DIR@" // "include" val teemLib = "@TEEM_DIR@" // "lib" val teemLinkFlags = if @LD_NEEDS_RPATH@ then ["-Wl,-rpath=" ^ teemLib, "-L" ^ teemLib, "-lteem"] else ["-L" ^ teemLib, "-lteem"] (* installation directories for Diderot stuff *) val installBin = "@prefix@" // "bin" val installInclude = "@prefix@" // "include" val installLib = "@prefix@" // "lib" (* paths to some useful tools *) local (* get the user's PATH environment variable as a list of paths. Note that this is * executed at build time. *) val PATH = let val path = (case (OS.Process.getEnv "PATH") of (SOME p) => p | _ => "") in String.fields (fn #":" => true | _ => false) path end (* getPath *) (* FIXME: with SML/NJ 110.73, we'll be able to use PathUtil.findExe *) fun findExe (paths, name) = let fun isExe p = OS.FileSys.access(p, [OS.FileSys.A_EXEC]) in if OS.Path.isAbsolute name then if isExe name then name else raise Fail(name ^" is not executable") else (case PathUtil.existsFile isExe paths name of SOME cmd => cmd | NONE => raise Fail(concat["unable to find ", name, " executable"]) (* end case *)) end in val dnorm = findExe ([diderotBin, installBin, diderotSrc // "dnorm"], "dnorm") val cc = let val (cmd::args) = String.tokens Char.isSpace "@CC@" val cmd = findExe (PATH, cmd) val args = if ("@CFLAG_M64@" <> "") then "@CFLAG_M64@" :: args else args in String.concatWith " " (cmd::args) end val cflags = "@CFLAGS@ @PTHREAD_CFLAGS@" val extraLibs = "@PTHREAD_LIBS@ @LIBM@" end (* local *) end (* local *) end