RMICompilation.gmk revision 1862:5f3d162d11fc
1189251Ssam#
2252726Srpaulo# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3252726Srpaulo# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4189251Ssam#
5252726Srpaulo# This code is free software; you can redistribute it and/or modify it
6252726Srpaulo# under the terms of the GNU General Public License version 2 only, as
7189251Ssam# published by the Free Software Foundation.  Oracle designates this
8189251Ssam# particular file as subject to the "Classpath" exception as provided
9189251Ssam# by Oracle in the LICENSE file that accompanied this code.
10189251Ssam#
11189251Ssam# This code is distributed in the hope that it will be useful, but WITHOUT
12189251Ssam# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13214734Srpaulo# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14214734Srpaulo# version 2 for more details (a copy is included in the LICENSE file that
15214734Srpaulo# accompanied this code).
16214734Srpaulo#
17189251Ssam# You should have received a copy of the GNU General Public License version
18214734Srpaulo# 2 along with this work; if not, write to the Free Software Foundation,
19214734Srpaulo# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20189251Ssam#
21189251Ssam# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22189251Ssam# or visit www.oracle.com if you need additional information or have any
23189251Ssam# questions.
24189251Ssam#
25189251Ssam
26189251Ssam# Setup make rules for creating an RMI compilation.
27189251Ssam#
28189251Ssam# Parameter 1 is the name of the rule. This name is used as variable prefix,
29189251Ssam# and the targets generated are listed in a variable by that name.
30189251Ssam#
31189251Ssam# Remaining parameters are named arguments. These include:
32189251Ssam#   CLASSES:=List of classes to generate stubs for
33189251Ssam#   CLASSES_DIR:=Directory where to look for classes
34189251Ssam#   STUB_CLASSES_DIR:=Directory in where to put stub classes
35189251Ssam#   RUN_V11:=Set to run rmic with -v1.1
36189251Ssam#   RUN_V12:=Set to run rmic with -v1.2
37189251Ssam#   KEEP_GENERATED:=Set to keep generated sources around
38189251SsamSetupRMICompilation = $(NamedParamsMacroTemplate)
39189251Ssamdefine SetupRMICompilationBody
40189251Ssam
41189251Ssam  $1_DEP_FILE := $$($1_STUB_CLASSES_DIR)/_the.$1_rmic.generated
42189251Ssam
43189251Ssam  $1_CLASSES_SLASH := $$(subst .,/,$$($1_CLASSES))
44189251Ssam  $1_CLASS_FILES := $$(addprefix $$($1_CLASSES_DIR)/,$$(addsuffix .class,$$($1_CLASSES_SLASH)))
45189251Ssam  $1_STUB_FILES := $$(addprefix $$($1_STUB_CLASSES_DIR)/,$$(addsuffix _Stub.class,$$($1_CLASSES_SLASH)))
46189251Ssam  $1_TARGETS := $$($1_STUB_FILES)
47189251Ssam  $1_ARGS :=
48189251Ssam  ifneq (,$$($1_RUN_V11))
49189251Ssam    $1_SKEL_FILES := $$(addprefix $$($1_STUB_CLASSES_DIR)/,$$(addsuffix _Skel.class,$$($1_CLASSES_SLASH)))
50189251Ssam    $1_TARGETS += $$($1_SKEL_FILES)
51189251Ssam    $1_ARGS += -v1.1
52189251Ssam  endif
53189251Ssam  ifneq (,$$($1_RUN_V12))
54189251Ssam    $1_ARGS += -v1.2
55189251Ssam  endif
56189251Ssam
57189251Ssam  $1_TIE_BASE_FILES := $$(foreach f,$$($1_CLASSES_SLASH),$$(dir $$f)_$$(notdir $$f))
58189251Ssam  $1_TIE_FILES := $$(addprefix $$($1_STUB_CLASSES_DIR)/org/omg/stub/,$$(addsuffix _Tie.class,$$($1_TIE_BASE_FILES)))
59189251Ssam  $1_TIE_STDPKG_FILES := $$(addprefix $$($1_STUB_CLASSES_DIR)/,$$(addsuffix _Tie.class,$$($1_TIE_BASE_FILES)))
60189251Ssam
61189251Ssam  ifneq (,$$($1_KEEP_GENERATED))
62189251Ssam    $1_ARGS += -keepgenerated
63189251Ssam    $1_TARGETS += $$(subst .class,.java,$$($1_TARGETS))
64189251Ssam  endif
65189251Ssam
66189251Ssam  $1_DOLLAR_SAFE_CLASSES := $$(subst $$$$,\$$$$,$$($1_CLASSES))
67189251Ssam
68189251Ssam  $$($1_TARGETS): $$($1_DEP_FILE) $$($1_CLASS_FILES)
69189251Ssam
70189251Ssam  $$($1_DEP_FILE): $$($1_CLASS_FILES)
71189251Ssam	$$(call LogInfo, Running rmic $$($1_ARGS) for $$($1_DOLLAR_SAFE_CLASSES))
72189251Ssam	$$(call MakeDir, $$($1_STUB_CLASSES_DIR))
73189251Ssam	$(RMIC) $$($1_ARGS) -classpath "$$($1_CLASSES_DIR)" \
74189251Ssam	    -d $$($1_STUB_CLASSES_DIR) $$($1_DOLLAR_SAFE_CLASSES); \
75189251Ssam	if [ "x$$($1_ARGS2)" != "x" ]; then \
76189251Ssam	  $(ECHO) $(LOG_INFO) Running rmic $$($1_ARGS2) for $$($1_DOLLAR_SAFE_CLASSES) && \
77189251Ssam	  $(RMIC) $$($1_ARGS2) -classpath "$$($1_CLASSES_DIR)" \
78189251Ssam	      -d $$($1_STUB_CLASSES_DIR) $$($1_DOLLAR_SAFE_CLASSES); \
79189251Ssam	fi; \
80189251Ssam	$(TOUCH) $$@
81189251Ssam
82189251Ssam
83189251Ssam  $1 := $$($1_TARGETS) $$($1_DEP_FILE)
84189251Ssam
85189251Ssamendef
86189251Ssam