989b412000-03-06Marcus Comstedt  static int check_jre_dir(string dir) { if(!dir || dir=="" || dir[0]!='/') return 0; if(!file_stat(dir+"/lib/rt.jar")) return 0; if(!file_stat(dir+"/lib/flavormap.properties")) return 0; return 1; } static string findjre() { string dir =
185d652000-04-05Henrik Grubbström (Grubba)  (Process.popen("java -verbose 2>&1 | sed -n -e 's/^[^/]*//' -e "
05c2702001-01-21Henrik Grubbström (Grubba)  "'s:/lib/rt\.jar.*$::' -e p -e q")||"")-"\n";
989b412000-03-06Marcus Comstedt  if(check_jre_dir(dir)) return dir; foreach(`+(@Array.map(({"/usr/local", "/usr"}), lambda(string s) { return Array.map(Array.map(({"jre*","jdk*","java*"}), glob,
5745c32000-10-14Marcus Comstedt  reverse(sort(get_dir(s)||
12e69b2000-10-16Marcus Comstedt  ({""}))))* ({}),
989b412000-03-06Marcus Comstedt  lambda(string sb) { return s+"/"+sb; }); })), string d) { if(d && d!="") if(check_jre_dir(d+"/jre")) return d+"/jre"; else if(check_jre_dir(d)) return d; } return 0; } void run(object env) { string jrehome, arch, threads_type="native_threads";
9d7abc2000-08-31Fredrik Noring  write(" Checking for Java 2 (TM)...");
989b412000-03-06Marcus Comstedt  if(!(jrehome=getenv("JREHOME"))) jrehome=findjre(); if(!jrehome) jrehome = env->get("JREHOME"); if(!jrehome) {
f47af02000-03-30Leif Stensson  write(" not found\n");
989b412000-03-06Marcus Comstedt  return; }
b973a02000-08-31Fredrik Noring  write(" JREHOME="+jrehome+"\n");
989b412000-03-06Marcus Comstedt  env->set("JREHOME", jrehome); arch = (Process.popen("(/usr/bin/uname -p||uname -p) 2>/dev/null")||"")-"\n"; if(arch=="unknown") arch = (Process.popen("uname -m | sed -e 's/^i[4-9]86/i386/'")||"")-"\n"; if(arch == "") arch = "_"; foreach(({arch+"/"+threads_type, arch+"/classic", arch}), string dir) {
1f4a6c2000-08-28Per Hedbor  mixed s = file_stat(jrehome+"/lib/"+dir);
989b412000-03-06Marcus Comstedt  if(s && s[1]==-2) env->append("LD_LIBRARY_PATH", jrehome+"/lib/"+dir); }
da5eab2000-10-30Marcus Comstedt  /* AIX */ if(file_stat(jrehome+"/bin/libjava.a")) env->append("LIBPATH", jrehome+"/bin/:"+jrehome+"/bin/classic/" );
989b412000-03-06Marcus Comstedt }