New file implementing support for java-based tools

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@9719 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2001-04-27 09:55:51 +00:00
parent dfc8ff1f67
commit 7f41b340aa
2 changed files with 233 additions and 0 deletions

105
java-executable.template Normal file
View file

@ -0,0 +1,105 @@
#!/bin/sh
#
# Copyright (C) 2001 Free Software Foundation, Inc.
#
# Author: Nicola Pero <nicola@brainstorm.co.uk>
# Date: April 2001
#
# This file is part of the GNUstep Makefile Package.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# You should have received a copy of the GNU General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# This is a shell script which attempts to execute a specific Java
# class (hardcoded when the shell script is installed), preparing
# CLASSPATH and LD_LIBRARY_PATH for it.
#
# The name of the script
#
tool=$0
#
# The java class to execute - harcoded when the template is intalled
# by java-tool.make
#
java_obj_file=JAVA_OBJ_FILE
#
# Check that the java class exists
#
full_java_obj_file=`dirname $tool`${java_obj_file}
if [ -z "$full_java_obj_file" ]; then
echo "$tool: Installation problem: Can't find java class $java_obj_file !"
exit 1
fi
#
# Determine the host information if needed
#
if [ -z "$GNUSTEP_HOST" ]; then
GNUSTEP_HOST=`(cd /tmp; $GNUSTEP_SYSTEM_ROOT/Makefiles/config.guess)`
GNUSTEP_HOST=`(cd /tmp; $GNUSTEP_SYSTEM_ROOT/Makefiles/config.sub $GNUSTEP_HOST)`
export GNUSTEP_HOST
fi
if [ -z "$GNUSTEP_HOST_CPU" ]; then
GNUSTEP_HOST_CPU=`$GNUSTEP_SYSTEM_ROOT/Makefiles/cpu.sh $GNUSTEP_HOST`
GNUSTEP_HOST_CPU=`$GNUSTEP_SYSTEM_ROOT/Makefiles/clean_cpu.sh $GNUSTEP_HOST_CPU`
export GNUSTEP_HOST_CPU
fi
if [ -z "$GNUSTEP_HOST_VENDOR" ]; then
GNUSTEP_HOST_VENDOR=`$GNUSTEP_SYSTEM_ROOT/Makefiles/vendor.sh $GNUSTEP_HOST`
GNUSTEP_HOST_VENDOR=`$GNUSTEP_SYSTEM_ROOT/Makefiles/clean_vendor.sh $GNUSTEP_HOST_VENDOR`
export GNUSTEP_HOST_VENDOR
fi
if [ -z "$GNUSTEP_HOST_OS" ]; then
GNUSTEP_HOST_OS=`$GNUSTEP_SYSTEM_ROOT/Makefiles/os.sh $GNUSTEP_HOST`
GNUSTEP_HOST_OS=`$GNUSTEP_SYSTEM_ROOT/Makefiles/clean_os.sh $GNUSTEP_HOST_OS`
export GNUSTEP_HOST_OS
fi
#
# Load up LD_LIBRARY_PATH
#
. $GNUSTEP_SYSTEM_ROOT/Makefiles/ld_lib_path.sh
#
# Load up CLASSPATH
#
gnustep_class_path="$GNUSTEP_USER_ROOT/Libraries/Java:$GNUSTEP_LOCAL_ROOT/Libraries/Java:$GNUSTEP_NETWORK_ROOT/Libraries/Java:$GNUSTEP_SYSTEM_ROOT/Libraries/Java"
if [ -z "$CLASSPATH" ]; then
CLASSPATH="$gnustep_class_path"
else
if ( echo ${CLASSPATH} | grep -v "${gnustep_class_path}" >/dev/null ); then
CLASSPATH="$CLASSPATH:$gnustep_class_path"
fi
fi
export CLASSPATH
#
# Find java
#
java_vm=java
if ! [ -z "$JAVA_HOME" ]; then
java_vm=$(JAVA_HOME)/bin/java
else
if ! [ -z "$JDK_HOME" ]; then
java_vm=$(JDK_HOME)/bin/java
fi
fi
#
# Run java on the object file
#
exec $java_vm $java_obj_file "$@"

128
java-tool.make Normal file
View file

@ -0,0 +1,128 @@
#
# java-tool.make
#
# Makefile rules to build Java command-line tools.
#
# Copyright (C) 2001 Free Software Foundation, Inc.
#
# Author: Nicola Pero <nicola@brainstorm.co.uk>
#
# This file is part of the GNUstep Makefile Package.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# You should have received a copy of the GNU General Public
# License along with this library; see the file COPYING.LIB.
# If not, write to the Free Software Foundation,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Why using Java if you can use Objective-C ...
# Anyway if you really want it, here we go.
#
# The name of the tools is in the JAVA_TOOL_NAME variable.
# The main class (the one implementing main) is in the
# xxx_PRINCIPAL_CLASS variable.
#
# prevent multiple inclusions
ifeq ($(JAVA_TOOL_MAKE_LOADED),)
JAVA_TOOL_MAKE_LOADED = yes
JAVA_TOOL_NAME:=$(strip $(JAVA_TOOL_NAME))
include $(GNUSTEP_MAKEFILES)/rules.make
ifeq ($(INTERNAL_java_tool_NAME),)
internal-all:: $(JAVA_TOOL_NAME:=.all.java_tool.variables)
internal-install:: $(JAVA_TOOL_NAME:=.install.java_tool.variables)
internal-uninstall:: $(JAVA_TOOL_NAME:=.uninstall.java_tool.variables)
internal-clean:: $(JAVA_TOOL_NAME:=.clean.java_tool.variables)
internal-distclean:: $(JAVA_TOOL_NAME:=.distclean.java_tool.variables)
$(JAVA_TOOL_NAME):
@$(MAKE) -f $(MAKEFILE_NAME) --no-print-directory \
$@.all.java_tool.variables
else # second pass
# This is the directory where the tools get installed. If you don't specify a
# directory they will get installed in $(GNUSTEP_LOCAL_ROOT)/Tools/Java/.
ifeq ($(JAVA_TOOL_INSTALLATION_DIR),)
JAVA_TOOL_INSTALLATION_DIR = $(GNUSTEP_TOOLS)/Java/
endif
internal-java_tool-all:: before-$(TARGET)-all \
$(JAVA_OBJ_FILES) \
after-$(TARGET)-all
before-$(TARGET)-all::
after-$(TARGET)-all::
internal-java_tool-install:: internal-java_tool-all install-java_tool
$(JAVA_TOOL_INSTALLATION_DIR):
$(MKDIRS) $(JAVA_TOOL_INSTALLATION_DIR)
internal-install-java_tool-dirs:: $(JAVA_TOOL_INSTALLATION_DIR)
if [ "$(JAVA_OBJ_FILES)" != "" ]; then \
$(MKDIRS) $(addprefix $(JAVA_TOOL_INSTALLATION_DIR)/,$(dir $(JAVA_OBJ_FILES))); \
fi
ifeq ($(PRINCIPAL_CLASS),)
$(warning You must specify PRINCIPAL_CLASS)
# But then, we are good, and try guessing
PRINCIPAL_CLASS = $(word 1 $(JAVA_OBJ_FILES))
endif
# Remove an eventual extension (.class or .java) from PRINCIPAL_CLASS;
# only take the first word of it
NORMALIZED_PRINCIPAL_CLASS = $(basename $(word 1 $(PRINCIPAL_CLASS)))
# Escape '/' so it can be passes to sed
ESCAPED_PRINCIPAL_CLASS = $(subst /,\/,$(PRINCIPAL_CLASS))
$(GNUSTEP_INSTALLATION_DIR)/Tools/$(INTERNAL_java_tool_NAME):
sed -e 's/JAVA_OBJ_FILE/$(ESCAPED_PRINCIPAL_CLASS)/g' \
$(GNUSTEP_MAKEFILES)/java-executable.template \
> $(GNUSTEP_INSTALLATION_DIR)/Tools/$(INTERNAL_java_tool_NAME); \
chmod a+x $(GNUSTEP_INSTALLATION_DIR)/Tools/$(INTERNAL_java_tool_NAME);
install-java_tool:: internal-install-java_tool-dirs \
$(GNUSTEP_INSTALLATION_DIR)/Tools/$(INTERNAL_java_tool_NAME)
if [ "$(JAVA_OBJ_FILES)" != "" ]; then \
for file in $(JAVA_OBJ_FILES) __done; do \
if [ $$file != __done ]; then \
$(INSTALL_DATA) $$file $(JAVA_TOOL_INSTALLATION_DIR)/$$file ; \
fi; \
done; \
fi
internal-java_tool-uninstall::
rm -f $(JAVA_TOOL_INSTALLATION_DIR)/$(JAVA_OBJ_FILES)
rm -f $(GNUSTEP_INSTALLATION_DIR)/Tools/$(INTERNAL_java_tool_NAME)
#
# Cleaning targets
#
internal-java_package-clean::
rm -f $(JAVA_OBJ_FILES)
internal-java_package-distclean::
endif # internal java tool name
endif # java_tool.make loaded
## Local variables:
## mode: makefile
## End: