Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] View of /branches/vis12/src/compiler/common/paths_sml.in
ViewVC logotype

View of /branches/vis12/src/compiler/common/paths_sml.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2430 - (download) (annotate)
Thu Sep 19 21:41:27 2013 UTC (5 years, 11 months ago) by jhr
File size: 3393 byte(s)
  Replace dnorm with the new "unu dnorm" command from teem.  We also dynamically
  search for teem so that the location of teem at runtime can be different from
  the location of teem at compile time.
(* 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 diderotLib = "@DIDEROT_ROOT@" // "lib"
    val diderotSrc = "@DIDEROT_ROOT@" // "src"
    val diderotInclude = diderotSrc // "include"

  (* look for an executable using the user's PATH prepended with a list of
   * additional search directories.
   *)
    fun findExe (searchDirs, name) = let
          val dirs = searchDirs @ String.fields
                (fn #":" => true | _ => false) 
                  (case (OS.Process.getEnv "PATH") of (SOME p) => p | _ => "")
          in
            case PathUtil.findExe dirs name
             of SOME p => p
              | NONE => raise Fail(concat[
                    "unable to find ", name, " executable in \"",
                    String.concatWith ":" dirs, "\""
                  ])
          end (* getPath *)

  (* directories for Teem stuff *)
    local
      val teemDir : string option ref = ref NONE
    (* return the path to the teem stuff *)
      fun resolveTeemDir subDir = (case !teemDir
             of SOME dir => dir // subDir
              | NONE => let
                  val unuPath = findExe (["@TEEM_DIR@" // "bin"], "unu")
                  val dir = OS.Path.getParent(#dir(OS.Path.splitDirFile unuPath))
                  in
                    teemDir := SOME dir;
                    dir // subDir
                  end
            (* end case *))
    in
    fun teemBin () = resolveTeemDir "bin"
    fun teemInclude () = resolveTeemDir "include"
    fun teemLib () = resolveTeemDir "lib"
    fun teemLinkFlags () = if @LD_NEEDS_RPATH@
	  then ["-Wl,-rpath=" ^ teemLib(), "-L" ^ teemLib(), "-lteem"]
	  else ["-L" ^ teemLib(), "-lteem"]
    end (* local *)

  (* installation directories for Diderot stuff *)
    val installBin = "@prefix@" // "bin"
    val installInclude = "@prefix@" // "include"
    val installLib = "@prefix@" // "lib"

  (* paths to some useful tools *)
    val cc = let
	  val (cmd::args) = String.tokens Char.isSpace "@CC@"
	  val cmd = findExe ([], cmd)
	  val args = if ("@CFLAG_MXX@" <> "") then "@CFLAG_MXX@" :: args else args
	  in
	    String.concatWith " " (cmd::args)
	  end
    val cflags = {
	    base = "@CFLAGS_BASE@",
	    pthread = "@PTHREAD_CFLAGS@",
            cl = "@CPPFLAGS_CL@",
	    debug = "-g -O0",
(*	    ndebug = "-march=native -O3 -DNDEBUG" *)  (* gcc complains about -march=native, even though the man page says it is supported *)
	    ndebug = "-O3 -DNDEBUG"
	  }
    val ld = let
	  val (cmd::args) = String.tokens Char.isSpace "@LD@"
	  val cmd = findExe ([], cmd)
	  in
	    String.concatWith " " (cmd :: args)
	  end
    val extraLibs = {
	    base = "@LIBM@",
	    pthread = "@PTHREAD_LIBS@",
	    cl = "@CL_LIBS@"
	  }

  (* other configuration options *)
    val clEnabled = @CL_ENABLED@
    val clVersion = if clEnabled
	  then let
	    val major = @CL_VERSION@ div 10000
	    val minor = (@CL_VERSION@ div 100) mod 100
	    val patch = @CL_VERSION@ mod 100
	    in
	      if patch > 0 then [major, minor, patch] else [major, minor]
	    end
	  else []
    val cudaEnabled = @CUDA_ENABLED@
    end (* local *)

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0