]> err.no Git - sope/blob - gnustep-make/java-executable.template
use %p for pointer formats
[sope] / gnustep-make / java-executable.template
1 #!/bin/sh
2 #
3 # Copyright (C) 2001 Free Software Foundation, Inc.
4 #
5 # Author: Nicola Pero <nicola@brainstorm.co.uk>
6 # Date: April 2001
7
8 # This file is part of the GNUstep Makefile Package.
9 #
10 # This library is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License
12 # as published by the Free Software Foundation; either version 2
13 # of the License, or (at your option) any later version.
14
15 # You should have received a copy of the GNU General Public
16 # License along with this library; see the file COPYING.LIB.
17 # If not, write to the Free Software Foundation,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 # This is a shell script which attempts to execute a specific Java
21 # class (hardcoded when the shell script is installed), preparing
22 # CLASSPATH and LD_LIBRARY_PATH for it.
23
24 #
25 # The name of the script
26 #
27 tool=$0
28
29 #
30 # The directory we are in
31 #
32 tool_dir=`dirname $tool`
33
34 #
35 # The java class to execute - harcoded when the template is intalled 
36 # by java-tool.make.
37 #
38 java_obj_file=JAVA_OBJ_FILE
39
40 #
41 # Check that the java class exists
42 #
43 full_java_obj_file=${tool_dir}/Java/${java_obj_file}.class
44
45 if [ ! -f "$full_java_obj_file" ]; then
46   echo "$tool: Installation problem: Can't find java class $java_obj_file !"
47   exit 1
48 fi
49
50 #
51 # Determine the host information if needed
52 #
53 if [ -z "$GNUSTEP_HOST" ]; then
54     GNUSTEP_HOST=`(cd /tmp; $GNUSTEP_SYSTEM_ROOT/Library/Makefiles/config.guess)`
55     GNUSTEP_HOST=`(cd /tmp; $GNUSTEP_SYSTEM_ROOT/Library/Makefiles/config.sub $GNUSTEP_HOST)`
56     export GNUSTEP_HOST
57 fi
58 if [ -z "$GNUSTEP_HOST_CPU" ]; then
59     GNUSTEP_HOST_CPU=`$GNUSTEP_SYSTEM_ROOT/Library/Makefiles/cpu.sh $GNUSTEP_HOST`
60     GNUSTEP_HOST_CPU=`$GNUSTEP_SYSTEM_ROOT/Library/Makefiles/clean_cpu.sh $GNUSTEP_HOST_CPU`
61     export GNUSTEP_HOST_CPU
62 fi
63 if [ -z "$GNUSTEP_HOST_VENDOR" ]; then
64     GNUSTEP_HOST_VENDOR=`$GNUSTEP_SYSTEM_ROOT/Library/Makefiles/vendor.sh $GNUSTEP_HOST`
65     GNUSTEP_HOST_VENDOR=`$GNUSTEP_SYSTEM_ROOT/Library/Makefiles/clean_vendor.sh $GNUSTEP_HOST_VENDOR`
66     export GNUSTEP_HOST_VENDOR
67 fi
68 if [ -z "$GNUSTEP_HOST_OS" ]; then
69     GNUSTEP_HOST_OS=`$GNUSTEP_SYSTEM_ROOT/Library/Makefiles/os.sh $GNUSTEP_HOST`
70     GNUSTEP_HOST_OS=`$GNUSTEP_SYSTEM_ROOT/Library/Makefiles/clean_os.sh $GNUSTEP_HOST_OS`
71    export GNUSTEP_HOST_OS
72 fi
73
74 #
75 # Load up LD_LIBRARY_PATH
76 #
77 . $GNUSTEP_SYSTEM_ROOT/Library/Makefiles/ld_lib_path.sh
78
79 #
80 # Load up CLASSPATH
81 #
82 gnustep_class_path="$GNUSTEP_USER_ROOT/Library/Libraries/Java:$GNUSTEP_LOCAL_ROOT/Library/Libraries/Java:$GNUSTEP_NETWORK_ROOT/Library/Libraries/Java:$GNUSTEP_SYSTEM_ROOT/Library/Libraries/Java"
83
84 if [ -z "$CLASSPATH" ]; then
85   CLASSPATH="$gnustep_class_path"
86 else
87   if ( echo ${CLASSPATH} | grep -v "${gnustep_class_path}" >/dev/null ); then
88     CLASSPATH="$CLASSPATH:$gnustep_class_path"
89   fi
90 fi
91
92 if ( echo ${CLASSPATH} | grep -v "\./" >/dev/null ); then
93   CLASSPATH="$CLASSPATH:./"
94 fi
95
96 export CLASSPATH
97
98 #
99 # Find java
100 #
101 java_vm=java
102 if [ ! -z "$JAVA_HOME" ]; then
103   java_vm=${JAVA_HOME}/bin/java
104 else
105   if [ ! -z "$JDK_HOME" ]; then
106     java_vm=${JDK_HOME}/bin/java
107   fi
108 fi
109
110 #
111 # Run java on the object file
112 #
113 cd ${tool_dir}/Java
114 exec $java_vm $java_obj_file "$@"
115