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

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/common/paths_sml.in
ViewVC logotype

Diff of /branches/charisee/src/compiler/common/paths_sml.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2489, Mon Oct 21 19:43:32 2013 UTC revision 2490, Mon Oct 21 21:17:25 2013 UTC
# Line 14  Line 14 
14        infixr 4 //        infixr 4 //
15      in      in
16    (* directories for Diderot stuff *)    (* directories for Diderot stuff *)
17      val diderotBin = "@DIDEROT_ROOT@" // "bin"      local
18      val diderotLib = "@DIDEROT_ROOT@" // "lib"      (* dynamically determine the installation location based on the path to diderotc.  We assume
19      val diderotSrc = "@DIDEROT_ROOT@" // "src"       * that the bin, lib, and include directories are siblings in the directory tree.
20      val diderotInclude = diderotSrc // "include"       *)
21          val installLoc : string option ref = ref NONE
22          fun installLocation () = (case !installLoc
23                 of SOME loc => loc
24                  | NONE => let
25                      val cmdPath = OS.Path.dir(CommandLine.name())
26                      val binDir = if OS.Path.isAbsolute cmdPath
27                            then cmdPath
28                            else OS.Path.mkCanonical(OS.Path.concat(OS.FileSys.getDir(), cmdPath))
29                      val diderotLoc = OS.Path.getParent binDir
30                      in
31                        installLoc := SOME diderotLoc;
32                        diderotLoc
33                      end
34                (* end case *))
35        in
36        fun diderotLib () = installLocation() // "lib"
37        fun diderotInclude () = installLocation() // "include"
38        end
39    
40      (* look for an executable using the user's PATH prepended with a list of
41       * additional search directories.
42       *)
43        fun findExe (searchDirs, name) = let
44              val dirs = searchDirs @ String.fields
45                    (fn #":" => true | _ => false)
46                      (case (OS.Process.getEnv "PATH") of (SOME p) => p | _ => "")
47              in
48                case PathUtil.findExe dirs name
49                 of SOME p => p
50                  | NONE => raise Fail(concat[
51                        "unable to find ", name, " executable in \"",
52                        String.concatWith ":" dirs, "\""
53                      ])
54              end (* getPath *)
55    
56    (* directories for Teem stuff *)    (* directories for Teem stuff *)
57      val teemBin = "@TEEM_DIR@" // "bin"      local
58      val teemInclude = "@TEEM_DIR@" // "include"        val teemDir : string option ref = ref NONE
59      val teemLib = "@TEEM_DIR@" // "lib"      (* return the path to the teem stuff *)
60      val teemLinkFlags = if @LD_NEEDS_RPATH@        fun resolveTeemDir subDir = (case !teemDir
61            then ["-Wl,-rpath=" ^ teemLib, "-L" ^ teemLib, "-lteem"]               of SOME dir => dir // subDir
62            else ["-L" ^ teemLib, "-lteem"]                | NONE => let
63                    (* extra places to look for unu *)
64                      val extraPaths = let
65                            val pl = ["@TEEM_DIR@" // "bin"]
66                            in
67                              case OS.Process.getEnv "DIDEROT_TEEM_DIR"
68                               of SOME p => (p // "bin") :: pl
69                                | NONE => pl
70                            end
71                      val unuPath = findExe (extraPaths, "unu")
72                      val dir = OS.Path.getParent(OS.Path.dir unuPath)
73                      in
74                        teemDir := SOME dir;
75                        dir // subDir
76                      end
77                (* end case *))
78        in
79        fun teemBin () = resolveTeemDir "bin"
80        fun teemInclude () = resolveTeemDir "include"
81        fun teemLib () = resolveTeemDir "lib"
82        fun teemLinkFlags () = if @LD_NEEDS_RPATH@
83              then ["-Wl,-rpath=" ^ teemLib(), "-L" ^ teemLib(), "-lteem"]
84              else ["-L" ^ teemLib(), "-lteem"]
85        end (* local *)
86    
87    (* installation directories for Diderot stuff *)    (* installation directories for Diderot stuff *)
88      val installBin = "@prefix@" // "bin"      val installBin = "@prefix@" // "bin"
# Line 33  Line 90 
90      val installLib = "@prefix@" // "lib"      val installLib = "@prefix@" // "lib"
91    
92    (* paths to some useful tools *)    (* 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: won't need the isAbsolute check in 110.75 *)  
       fun findExe (paths, name) = if OS.Path.isAbsolute name  
             then name  
             else (case PathUtil.findExe paths name  
                of SOME p => p  
                 | NONE => raise Fail(concat["unable to find ", name, " executable"])  
               (* end case *))  
     in  
     val dnorm = findExe ([diderotBin, installBin, diderotSrc // "dnorm"], "dnorm")  
93      val cc = let      val cc = let
94            val (cmd::args) = String.tokens Char.isSpace "@CC@"            val (cmd::args) = String.tokens Char.isSpace "@CC@"
95            val cmd = findExe (PATH, cmd)            val cmd = findExe ([], cmd)
96            val args = if ("@CFLAG_MXX@" <> "") then "@CFLAG_MXX@" :: args else args            val args = if ("@CFLAG_MXX@" <> "") then "@CFLAG_MXX@" :: args else args
97            in            in
98              String.concatWith " " (cmd::args)              String.concatWith " " (cmd::args)
# Line 68  Line 107 
107            }            }
108      val ld = let      val ld = let
109            val (cmd::args) = String.tokens Char.isSpace "@LD@"            val (cmd::args) = String.tokens Char.isSpace "@LD@"
110            val cmd = findExe (PATH, cmd)            val cmd = findExe ([], cmd)
111            in            in
112              String.concatWith " " (cmd :: args)              String.concatWith " " (cmd :: args)
113            end            end
114      val extraLibs = {      val extraLibs = {
115              base = "@LIBM@",              base = "@LIBM@",
116              pthread = "@PTHREAD_LIBS@",              pthread = "@PTHREAD_LIBS@",
117              cl = "@LIBS_CL@"              cl = "@CL_LIBS@"
118            }            }
     end (* local *)  
119    
120    (* other configuration options *)    (* other configuration options *)
121      val clEnabled = @CL_ENABLED@      val clEnabled = @CL_ENABLED@

Legend:
Removed from v.2489  
changed lines
  Added in v.2490

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