1 #
   2 # Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 #
  27 # Makefile for building simple launchers
  28 #
  29 
  30 BUILDDIR = ..
  31 PACKAGE = launcher
  32 PRODUCT = sun
  33 include $(BUILDDIR)/common/Defs.gmk
  34 
  35 # The PROGRAM and MAIN_CLASS must be defined
  36 ifndef PROGRAM
  37   build: no_program
  38   no_program:
  39         $(ECHO) "No PROGRAM name defined"
  40         exit 1
  41 endif
  42 ifndef MAIN_CLASS
  43   build: no_main
  44   no_main:
  45         $(ECHO) "No MAIN_CLASS name defined"
  46         exit 1
  47 endif
  48 
  49 # Some tools need the wildcard expansion option
  50 ifeq ($(PROGRAM),javac)
  51   WILDCARDS=true
  52   MAIN_JAVA_ARGS += -J-Xss4m -J-ea:com.sun.tools...
  53   NEVER_ACT_AS_SERVER_CLASS_MACHINE=true
  54 endif
  55 ifeq ($(PROGRAM),javadoc)
  56   WILDCARDS=true
  57   NEVER_ACT_AS_SERVER_CLASS_MACHINE=true
  58 endif
  59 ifeq ($(PROGRAM),javap)
  60   WILDCARDS=true
  61   NEVER_ACT_AS_SERVER_CLASS_MACHINE=true
  62 endif
  63 ifeq ($(PROGRAM),javah)
  64   WILDCARDS=true
  65   NEVER_ACT_AS_SERVER_CLASS_MACHINE=true
  66 endif
  67 ifeq ($(PROGRAM),serialver)
  68   WILDCARDS=true
  69 endif
  70 
  71 # GUI tools need X11
  72 ifeq ($(PROGRAM),appletviewer)
  73   GUI_TOOL=true
  74 endif
  75 ifeq ($(PROGRAM),policytool)
  76   GUI_TOOL=true
  77 endif
  78 
  79 # SA tools
  80 ifeq ($(PROGRAM),jstack)
  81   SA_TOOL=true
  82 endif
  83 ifeq ($(PROGRAM),jsadebugd)
  84   SA_TOOL=true
  85 endif
  86 ifeq ($(PROGRAM),jinfo)
  87   SA_TOOL=true
  88 endif
  89 ifeq ($(PROGRAM),jmap)
  90   SA_TOOL=true
  91 endif
  92 
  93 # special idlj launcher
  94 ifeq ($(PROGRAM),orbd)
  95   IDLJ_TOOL=true
  96 endif
  97 ifeq ($(PROGRAM),servertool)
  98   IDLJ_TOOL=true
  99 endif
 100 ifeq ($(PROGRAM),tnameserv)
 101   IDLJ_TOOL=true
 102 endif
 103 
 104 # idlj itself only
 105 ifeq ($(PROGRAM),idlj)
 106   ifndef STANDALONE_CORBA_WS
 107     FILES_c = $(SHARE_SRC)/native/bin/$(PROGRAM).c \
 108               $(SHARE_SRC)/native/bin/utility.c
 109   endif
 110 endif
 111 
 112 # rmic only
 113 ifeq ($(PROGRAM),rmic)
 114   ifdef STANDALONE_CORBA_WS
 115     FILES_c = $(SHARE_SRC)/native/bin/$(PROGRAM).c \
 116               $(SHARE_SRC)/native/bin/utility.c
 117   endif
 118   WILDCARDS=true
 119 endif
 120 
 121 # IDLJ_TOOL only uses different source files
 122 ifeq ($(IDLJ_TOOL),true)
 123   ifdef STANDALONE_CORBA_WS
 124     FILES_c = $(SHARE_SRC)/native/bin/idlj.c  \
 125               $(SHARE_SRC)/native/bin/utility.c
 126   endif
 127 endif
 128 
 129 # jdb only
 130 ifeq ($(PROGRAM),jdb)
 131   # Override the default APP_CLASSPATH to pick up sa-jdi.jar also.
 132   #   Default is defined in src/[solaris,windows]/bin/java_md.h
 133   #   PROGRAM, JAVA_ARGS, and APP_CLASSPATH are used in src/share/bin/java.c
 134   #   SA is currently not available on windows (for any ARCH), or linux-ia64:
 135   ifneq ($(ARCH), ia64)
 136     JDB_CLASSPATH = { "/lib/tools.jar", "/lib/sa-jdi.jar", "/classes" }
 137     OTHER_CPPFLAGS += -DAPP_CLASSPATH='$(JDB_CLASSPATH)'
 138   endif
 139 endif
 140 
 141 # jconsole only
 142 ifeq ($(PROGRAM),jconsole)
 143   JCONSOLE_CLASSPATH = { "/lib/jconsole.jar", "/lib/tools.jar", "/classes" }
 144   OTHER_CPPFLAGS += -DAPP_CLASSPATH='$(JCONSOLE_CLASSPATH)'
 145   ifeq ($(PLATFORM), windows)
 146     OTHER_CPPFLAGS += -DJAVAW
 147     LDLIBS_COMMON  += user32.lib
 148     MAIN_JAVA_ARGS += -J-Djconsole.showOutputViewer
 149   endif
 150 endif
 151 
 152 # GUI tools
 153 ifeq ($(GUI_TOOL),true)
 154   ifneq ($(PLATFORM), windows)
 155     # Anything with a GUI needs X11 to be linked in.
 156     OTHER_LDLIBS += -L$(OPENWIN_LIB) -lX11
 157   endif
 158 endif
 159 
 160 # SA tools need special app classpath
 161 ifeq ($(SA_TOOL),true)
 162   SA_CLASSPATH = { "/lib/tools.jar", "/lib/sa-jdi.jar", "/classes" }
 163   OTHER_CPPFLAGS += -DAPP_CLASSPATH='$(SA_CLASSPATH)'
 164 endif
 165 
 166 # Wildcards
 167 ifeq ($(WILDCARDS),true)
 168   OTHER_CPPFLAGS += -DEXPAND_CLASSPATH_WILDCARDS
 169 endif
 170 
 171 # Always tell native code what the main class is
 172 OTHER_CPPFLAGS += -DMAIN_CLASS='"$(MAIN_CLASS)"'
 173 
 174 # Construct initializer for initial arguments to java
 175 ALL_ARGS = -J-ms8m $(MAIN_JAVA_ARGS) $(MAIN_CLASS) $(MAIN_ARGS)
 176 JAVA_ARGS = { $(ALL_ARGS:%="%",)  }
 177 
 178 # Always report launcher info
 179 build: launcher_info
 180 
 181 # Print info macro
 182 define printLauncherSetting
 183 if [ "$2" != "" ] ; then $(PRINTF) "%-16s %s\n" "$1:" "$2"; fi
 184 endef
 185 
 186 # Report basic information about this launcher
 187 launcher_info:
 188         @$(ECHO) "========================================================="
 189         @$(call printLauncherSetting,LAUNCHER,$(PROGRAM))
 190         @$(call printLauncherSetting,MAIN_CLASS,$(MAIN_CLASS))
 191         @$(call printLauncherSetting,MAIN_JAVA_ARGS,$(MAIN_JAVA_ARGS))
 192         @$(call printLauncherSetting,MAIN_ARGS,$(MAIN_ARGS))
 193         @$(call printLauncherSetting,ALL_ARGS,$(ALL_ARGS))
 194         @$(ECHO) "========================================================="
 195 
 196 #
 197 # Rules for building a program
 198 #
 199 include $(BUILDDIR)/common/Program.gmk
 200