1#
2#   Instance/java-tool.make
3#
4#   Instance makefile rules to build Java command-line tools.
5#
6#   Copyright (C) 2001 Free Software Foundation, Inc.
7#
8#   Author:  Nicola Pero <nicola@brainstorm.co.uk>
9#
10#   This file is part of the GNUstep Makefile Package.
11#
12#   This library is free software; you can redistribute it and/or
13#   modify it under the terms of the GNU General Public License
14#   as published by the Free Software Foundation; either version 3
15#   of the License, or (at your option) any later version.
16#
17#   You should have received a copy of the GNU General Public
18#   License along with this library; see the file COPYING.
19#   If not, write to the Free Software Foundation,
20#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
22# Why using Java if you can use Objective-C ...
23# Anyway if you really want it, here we go.
24
25#
26# The name of the tools is in the JAVA_TOOL_NAME variable.
27# The main class (the one implementing main) is in the
28# xxx_PRINCIPAL_CLASS variable.
29#
30
31ifeq ($(RULES_MAKE_LOADED),)
32include $(GNUSTEP_MAKEFILES)/rules.make
33endif
34
35.PHONY: internal-java_tool-all_ \
36        internal-java_tool-clean \
37        internal-java_tool-distclean \
38        internal-java_tool-install_ \
39        internal-java_tool-uninstall_ \
40        _FORCE
41
42# This is the directory where the shell wrapper gets installed.  You
43# want this on your path! If you don't specify a directory they will
44# get installed in $(GNUSTEP_LOCAL_ROOT)/Tools/.
45ifeq ($(JAVA_TOOL_INSTALLATION_DIR),)
46  JAVA_TOOL_INSTALLATION_DIR = $(GNUSTEP_TOOLS)
47endif
48
49# This is the directory where the java classes get installed.
50# Normally this is /usr/GNUstep/Local/Library/Libraries/Java/
51ifeq ($(JAVA_INSTALLATION_DIR),)
52  JAVA_INSTALLATION_DIR = $(GNUSTEP_JAVA)
53endif
54
55GNUSTEP_SHARED_JAVA_INSTALLATION_DIR = $(JAVA_INSTALLATION_DIR)
56include $(GNUSTEP_MAKEFILES)/Instance/Shared/java.make
57
58internal-java_tool-all_:: shared-instance-java-all
59
60internal-java_tool-install_:: shared-instance-java-install \
61                        $(JAVA_TOOL_INSTALLATION_DIR)/$(GNUSTEP_INSTANCE)
62
63PRINCIPAL_CLASS = $(strip $($(GNUSTEP_INSTANCE)_PRINCIPAL_CLASS))
64
65ifeq ($(PRINCIPAL_CLASS),)
66  $(warning You must specify PRINCIPAL_CLASS, which should be set to the full classname)
67  # But then, we are good, and try guessing.  This will only work if the class
68  # is not in a package though, which sounds unlikely.
69  PRINCIPAL_CLASS = $(word 1 $(JAVA_OBJ_FILES))
70endif
71
72# Remove an eventual extension (.class or .java) from PRINCIPAL_CLASS;
73# only take the first word of it
74NORMALIZED_PRINCIPAL_CLASS = $(basename $(word 1 $(PRINCIPAL_CLASS)))
75
76# Escape '/' so it can be passes to sed
77ESCAPED_PRINCIPAL_CLASS = $(subst /,\/,$(PRINCIPAL_CLASS))
78
79# Always rebuild this because if the PRINCIPAL_CLASS changes...
80$(JAVA_TOOL_INSTALLATION_DIR)/$(GNUSTEP_INSTANCE): _FORCE
81	$(ECHO_NOTHING)sed -e 's/JAVA_OBJ_FILE/$(ESCAPED_PRINCIPAL_CLASS)/g' \
82	    $(GNUSTEP_MAKEFILES)/java-executable.template \
83	    > $(JAVA_TOOL_INSTALLATION_DIR)/$(GNUSTEP_INSTANCE); \
84	chmod a+x $(JAVA_TOOL_INSTALLATION_DIR)/$(GNUSTEP_INSTANCE)$(END_ECHO)
85ifneq ($(CHOWN_TO),)
86	$(ECHO_CHOWNING)$(CHOWN) $(CHOWN_TO) \
87	         $(JAVA_TOOL_INSTALLATION_DIR)/$(GNUSTEP_INSTANCE)$(END_ECHO)
88endif
89
90_FORCE::
91
92
93internal-java_tool-uninstall_:: shared-instance-java-uninstall
94	$(ECHO_UNINSTALLING)rm -f $(JAVA_TOOL_INSTALLATION_DIR)/$(GNUSTEP_INSTANCE)$(END_ECHO)
95
96internal-java_tool-clean:: shared-instance-java-clean
97
98internal-java_tool-distclean::
99