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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3123 - (download) (annotate)
Tue Mar 24 09:33:07 2015 UTC (4 years, 2 months ago) by jhr
File size: 4270 byte(s)
  fixing CL_VERSION info
(* 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 *)
    local
    (* dynamically determine the installation location based on the path to diderotc.  We assume
     * that the bin, lib, and include directories are siblings in the directory tree.
     *)
      val installLoc : string option ref = ref NONE
      fun installLocation () = (case !installLoc
	     of SOME loc => loc
	      | NONE => let
		  val cmdPath = OS.Path.dir(CommandLine.name())
		  val binDir = if OS.Path.isAbsolute cmdPath
			then cmdPath
			else OS.Path.mkCanonical(OS.Path.concat(OS.FileSys.getDir(), cmdPath))
		  val diderotLoc = OS.Path.getParent binDir
		  in
		    installLoc := SOME diderotLoc;
		    diderotLoc
		  end
	    (* end case *))
    in
    fun diderotLib () = installLocation() // "lib"
    fun diderotInclude () = installLocation() // "include"
    end

  (* 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
		(* extra places to look for unu *)
		  val extraPaths = let
			val pl = ["@TEEM_DIR@" // "bin"]
			in
			  case OS.Process.getEnv "DIDEROT_TEEM_DIR"
			   of SOME p => (p // "bin") :: pl
			    | NONE => pl
			  (* end case *)
			end
                  val unuPath = findExe (extraPaths, "unu")
                  val dir = OS.Path.getParent(OS.Path.dir 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 = "@LIBS_CL@"
	  }

  (* other configuration options *)
    val clEnabled = @CL_ENABLED@
    val clVersion = if clEnabled
	  then let
	  (* assume a numbering scheme equivalent to __OPENCL_VERSION__ *)
	    val major = @CL_VERSION@ div 100
	    val minor = (@CL_VERSION@ div 10) mod 10
	    val patch = @CL_VERSION@ mod 10
	    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