source: trunk/dports/_resources/port1.0/group/java-1.0.tcl @ 96958

Last change on this file since 96958 was 96958, checked in by ciserlohn@…, 7 years ago

java portgroup: also set JAVA_HOME in configure.env and destroot.env

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1# et:ts=4
2# java-1.0.tcl
3#
4# $Id: java-1.0.tcl 96958 2012-08-22 20:34:50Z ciserlohn@macports.org $
5#
6# Copyright (c) 2012 The MacPorts Project,
7# All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions are
11# met:
12#
13# 1. Redistributions of source code must retain the above copyright
14#    notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright
16#    notice, this list of conditions and the following disclaimer in the
17#    documentation and/or other materials provided with the distribution.
18# 3. Neither the name of Apple Computer, Inc. nor the names of its
19#    contributors may be used to endorse or promote products derived from
20#    this software without specific prior written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33#
34
35# Search for a good value for JAVA_HOME
36proc find_java_home {} {
37    set home_value ""
38
39    # Default to any valid value that made it through the environment
40    if { [info exists ::env(JAVA_HOME)] } {
41        set val $::env(JAVA_HOME)
42        if { [file isdirectory $val] } {
43            set home_value $val
44            ui_debug "Discovered JAVA_HOME via env: $home_value"
45        }
46    }
47
48    # First, ask the system where java home is
49    if { ![file isdirectory $home_value] && ![catch {set val [exec "/usr/libexec/java_home"]}] } {
50        set home_value $val
51        ui_debug "Discovered JAVA_HOME via /usr/libexec/java_home: $home_value"
52    }
53
54    # Fall back to more conventional way to find java home
55    if { ![file isdirectory $home_value] } {
56        foreach loc { "/System/Library/Frameworks/JavaVM.framework/Home" } {
57            if { [file isdirectory $loc] } {
58                set home_value $loc
59                ui_debug "Discovered JAVA_HOME via search path: $home_value"
60                break
61            }
62        }
63    }
64
65    # Warn user if we couldn't find a likely JAVA_HOME
66    if { ![file isdirectory $home_value]} {
67        ui_warn "No value for java JAVA_HOME was automatically discovered"
68    }
69
70    return $home_value
71}
72
73# Set the best value we can find for JAVA_HOME
74configure.env   JAVA_HOME=[find_java_home]
75build.env       JAVA_HOME=[find_java_home]
76destroot.env    JAVA_HOME=[find_java_home]
Note: See TracBrowser for help on using the repository browser.