SCM Repository
Annotation of /trunk/src/compiler/common/paths_sml.in
Parent Directory
|
Revision Log
Revision 3349 - (view) (download)
1 : | jhr | 1115 | (* paths.sml |
2 : | * | ||
3 : | jhr | 3349 | * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu) |
4 : | * | ||
5 : | * COPYRIGHT (c) 2015 The University of Chicago | ||
6 : | jhr | 1115 | * All rights reserved. |
7 : | * | ||
8 : | * @configure_input@ | ||
9 : | *) | ||
10 : | |||
11 : | structure Paths = | ||
12 : | struct | ||
13 : | |||
14 : | local | ||
15 : | val // = OS.Path.concat | ||
16 : | infixr 4 // | ||
17 : | in | ||
18 : | (* directories for Diderot stuff *) | ||
19 : | jhr | 2470 | local |
20 : | (* dynamically determine the installation location based on the path to diderotc. We assume | ||
21 : | * that the bin, lib, and include directories are siblings in the directory tree. | ||
22 : | *) | ||
23 : | val installLoc : string option ref = ref NONE | ||
24 : | fun installLocation () = (case !installLoc | ||
25 : | of SOME loc => loc | ||
26 : | | NONE => let | ||
27 : | val cmdPath = OS.Path.dir(CommandLine.name()) | ||
28 : | val binDir = if OS.Path.isAbsolute cmdPath | ||
29 : | then cmdPath | ||
30 : | else OS.Path.mkCanonical(OS.Path.concat(OS.FileSys.getDir(), cmdPath)) | ||
31 : | val diderotLoc = OS.Path.getParent binDir | ||
32 : | in | ||
33 : | installLoc := SOME diderotLoc; | ||
34 : | diderotLoc | ||
35 : | end | ||
36 : | (* end case *)) | ||
37 : | in | ||
38 : | fun diderotLib () = installLocation() // "lib" | ||
39 : | fun diderotInclude () = installLocation() // "include" | ||
40 : | end | ||
41 : | jhr | 1115 | |
42 : | jhr | 2470 | (* look for an executable using the user's PATH prepended with a list of |
43 : | * additional search directories. | ||
44 : | *) | ||
45 : | fun findExe (searchDirs, name) = let | ||
46 : | val dirs = searchDirs @ String.fields | ||
47 : | (fn #":" => true | _ => false) | ||
48 : | (case (OS.Process.getEnv "PATH") of (SOME p) => p | _ => "") | ||
49 : | in | ||
50 : | case PathUtil.findExe dirs name | ||
51 : | of SOME p => p | ||
52 : | | NONE => raise Fail(concat[ | ||
53 : | "unable to find ", name, " executable in \"", | ||
54 : | String.concatWith ":" dirs, "\"" | ||
55 : | ]) | ||
56 : | end (* getPath *) | ||
57 : | |||
58 : | jhr | 1115 | (* directories for Teem stuff *) |
59 : | jhr | 2470 | local |
60 : | val teemDir : string option ref = ref NONE | ||
61 : | (* return the path to the teem stuff *) | ||
62 : | fun resolveTeemDir subDir = (case !teemDir | ||
63 : | of SOME dir => dir // subDir | ||
64 : | | NONE => let | ||
65 : | (* extra places to look for unu *) | ||
66 : | val extraPaths = let | ||
67 : | val pl = ["@TEEM_DIR@" // "bin"] | ||
68 : | in | ||
69 : | case OS.Process.getEnv "DIDEROT_TEEM_DIR" | ||
70 : | of SOME p => (p // "bin") :: pl | ||
71 : | | NONE => pl | ||
72 : | jhr | 2636 | (* end case *) |
73 : | jhr | 2470 | end |
74 : | val unuPath = findExe (extraPaths, "unu") | ||
75 : | val dir = OS.Path.getParent(OS.Path.dir unuPath) | ||
76 : | in | ||
77 : | teemDir := SOME dir; | ||
78 : | dir // subDir | ||
79 : | end | ||
80 : | (* end case *)) | ||
81 : | in | ||
82 : | fun teemBin () = resolveTeemDir "bin" | ||
83 : | fun teemInclude () = resolveTeemDir "include" | ||
84 : | fun teemLib () = resolveTeemDir "lib" | ||
85 : | fun teemLinkFlags () = if @LD_NEEDS_RPATH@ | ||
86 : | then ["-Wl,-rpath=" ^ teemLib(), "-L" ^ teemLib(), "-lteem"] | ||
87 : | else ["-L" ^ teemLib(), "-lteem"] | ||
88 : | end (* local *) | ||
89 : | jhr | 1115 | |
90 : | (* installation directories for Diderot stuff *) | ||
91 : | val installBin = "@prefix@" // "bin" | ||
92 : | val installInclude = "@prefix@" // "include" | ||
93 : | val installLib = "@prefix@" // "lib" | ||
94 : | |||
95 : | (* paths to some useful tools *) | ||
96 : | val cc = let | ||
97 : | val (cmd::args) = String.tokens Char.isSpace "@CC@" | ||
98 : | jhr | 2470 | val cmd = findExe ([], cmd) |
99 : | jhr | 1990 | val args = if ("@CFLAG_MXX@" <> "") then "@CFLAG_MXX@" :: args else args |
100 : | jhr | 1115 | in |
101 : | String.concatWith " " (cmd::args) | ||
102 : | end | ||
103 : | jhr | 1232 | val cflags = { |
104 : | base = "@CFLAGS_BASE@", | ||
105 : | pthread = "@PTHREAD_CFLAGS@", | ||
106 : | jhr | 1840 | cl = "@CPPFLAGS_CL@", |
107 : | jhr | 1232 | debug = "-g -O0", |
108 : | (* ndebug = "-march=native -O3 -DNDEBUG" *) (* gcc complains about -march=native, even though the man page says it is supported *) | ||
109 : | ndebug = "-O3 -DNDEBUG" | ||
110 : | } | ||
111 : | jhr | 1842 | val ld = let |
112 : | val (cmd::args) = String.tokens Char.isSpace "@LD@" | ||
113 : | jhr | 2470 | val cmd = findExe ([], cmd) |
114 : | jhr | 1842 | in |
115 : | String.concatWith " " (cmd :: args) | ||
116 : | end | ||
117 : | jhr | 1232 | val extraLibs = { |
118 : | base = "@LIBM@", | ||
119 : | pthread = "@PTHREAD_LIBS@", | ||
120 : | jhr | 2470 | cl = "@CL_LIBS@" |
121 : | jhr | 1232 | } |
122 : | |||
123 : | (* other configuration options *) | ||
124 : | val clEnabled = @CL_ENABLED@ | ||
125 : | val clVersion = if clEnabled | ||
126 : | then let | ||
127 : | val major = @CL_VERSION@ div 10000 | ||
128 : | val minor = (@CL_VERSION@ div 100) mod 100 | ||
129 : | val patch = @CL_VERSION@ mod 100 | ||
130 : | in | ||
131 : | if patch > 0 then [major, minor, patch] else [major, minor] | ||
132 : | end | ||
133 : | else [] | ||
134 : | val cudaEnabled = @CUDA_ENABLED@ | ||
135 : | jhr | 1115 | end (* local *) |
136 : | |||
137 : | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |