1 #
   2 # Copyright (c) 2005, 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 # Java Launcher Infrastructure Library (libjli)
  28 #
  29 # This library provides shared support for the Java launcher in all of
  30 # its manifestations (java, javaw, javac, ...).
  31 #
  32 BUILDDIR = ../..
  33 LIBRARY = jli
  34 PRODUCT = java
  35 
  36 #
  37 # Must be included before Defs.gmk to be functional.
  38 #
  39 # Note that for Windows, both a dynamic and static version are built.
  40 # Doing the compiles with the static library specified can be overridden
  41 # by the link step, but not the reverse.
  42 #
  43 MS_RUNTIME_STATIC = true
  44 
  45 include $(BUILDDIR)/common/Defs.gmk
  46 
  47 ifneq ($(SYSTEM_ZLIB),true)
  48   ZIP_SRC = $(SHARE_SRC)/native/java/util/zip/zlib-$(ZLIB_VERSION)
  49 else # SYSTEM_ZLIB
  50   OTHER_CFLAGS += $(ZLIB_CFLAGS)
  51 endif #SYSTEM_ZLIB
  52 LAUNCHER_SHARE_SRC = $(SHARE_SRC)/bin
  53 
  54 # set the platform specific directory for macosx, also this platform shares
  55 # substantial family ties with its siblings (solaris and linux), thus we add
  56 # solaris src path to its compilation dependencies.
  57 ifeq ($(PLATFORM), macosx)
  58  LAUNCHER_PLATFORM_SRC = $(BUILDDIR)/../src/macosx/bin
  59  LAUNCHER_SOLARIS_PLATFORM_SRC  = $(BUILDDIR)/../src/solaris/bin
  60 else # !MACOSX
  61  LAUNCHER_PLATFORM_SRC = $(PLATFORM_SRC)/bin
  62 endif #PLATFORM
  63 
  64 ifeq ($(ZERO_BUILD), true)
  65   ERGO_FAMILY=zero
  66 else # !ZERO_BUILD
  67   ifneq (,$(findstring $(ARCH_FAMILY), amd64 x86_64))
  68     ERGO_FAMILY=i586
  69   else # !X86 FAMILY
  70     ERGO_FAMILY=$(ARCH_FAMILY)
  71   endif #ARCH_FAMILY
  72 endif # ZERO_BUILD
  73 
  74 #
  75 # Files to compile.
  76 #
  77 FILES_c = java.c \
  78           splashscreen_stubs.c \
  79           parse_manifest.c \
  80           version_comp.c \
  81           wildcard.c \
  82           jli_util.c
  83 
  84 ifneq ($(SYSTEM_ZLIB),true)
  85   FILES_c += inflate.c \
  86              inftrees.c \
  87              inffast.c \
  88              zadler32.c \
  89              zcrc32.c \
  90              zutil.c
  91 endif # SYSTEM_ZLIB
  92 
  93 # add platform specific files
  94 ifeq ($(PLATFORM), windows)
  95   FILES_c += java_md.c
  96 else # NIXES
  97   FILES_c += java_md_common.c
  98   ifeq ($(PLATFORM), macosx)
  99     FILES_c += java_md_macosx.c
 100   else # SOLARIS/LINUX
 101     FILES_c += java_md_solinux.c
 102     FILES_c += ergo.c 
 103     ERGO_ARCH_FILE = ergo_$(ERGO_FAMILY).c
 104     # if the architecture specific ergo file exists then
 105     # use it, else use the generic definitions from ergo.c
 106     ifneq ($(wildcard $(LAUNCHER_PLATFORM_SRC)/$(ERGO_ARCH_FILE)),)
 107       FILES_c += $(ERGO_ARCH_FILE)
 108     else # !ERGO_ARCH_FILE
 109       OTHER_CPPFLAGS += -DUSE_GENERIC_ERGO
 110     endif # ERGO_ARCH_FILE
 111   endif #MACOSX
 112 endif #WINDOWS
 113 
 114 # Names of arch directories
 115 LIBARCH_DEFINES = -DLIBARCHNAME='"$(LIBARCH)"'
 116 ifeq ($(PLATFORM), solaris)
 117   LIBARCH_DEFINES += -DLIBARCH32NAME='"$(LIBARCH32)"'
 118   LIBARCH_DEFINES += -DLIBARCH64NAME='"$(LIBARCH64)"'
 119 endif # PLATFORM
 120 
 121 ifeq ($(PLATFORM), macosx)
 122   OTHER_CPPFLAGS += $(LIBARCH_DEFINES) -DPACKAGE_PATH=\"$(PACKAGE_PATH)\"
 123 else # ! MACOSX
 124   OTHER_CPPFLAGS += $(LIBARCH_DEFINES)
 125 endif #PLATFORM
 126 
 127 ifneq ($(PLATFORM), windows)    # UNIX systems
 128   ifeq ($(PLATFORM), macosx)
 129     LIB_LOCATION = $(LIBDIR)/jli
 130   else # SOLARIS/LINUX
 131     LD_RUNPATH_EXTRAS += ..
 132     LIB_LOCATION = $(LIBDIR)/$(LIBARCH)/jli
 133     # Note: it is important to keep this order, meaning -lc as the
 134     # last library, otherwise it could cause compatibility issues
 135     # by pulling in SUNW_private symbols from libc
 136     LDLIBS = -ldl -lc
 137     ifeq ($(USE_PTHREADS),true)
 138       LDLIBS += -lpthread
 139     endif # USE_PTHREADS 
 140   endif # PLATFORM
 141 endif # PLATFORM
 142 
 143 ifeq ($(PLATFORM), windows)
 144   EXTRA_LIBS = advapi32.lib \
 145                comctl32.lib \
 146                user32.lib
 147   JAVALIB =
 148   OTHER_LCF = -export:JLI_Launch \
 149               -export:JLI_ManifestIterate \
 150               -export:JLI_SetTraceLauncher \
 151               -export:JLI_ReportErrorMessage \
 152               -export:JLI_ReportErrorMessageSys \
 153               -export:JLI_ReportMessage \
 154               -export:JLI_ReportExceptionDescription
 155 endif # PLATFORM
 156 
 157 OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)
 158 OTHER_INCLUDES += -I$(LAUNCHER_PLATFORM_SRC)
 159 ifneq ($(SYSTEM_ZLIB),true)
 160   OTHER_INCLUDES += -I$(ZIP_SRC)
 161 else # !SYSTEM_ZLIB
 162   LDLIBS += $(ZLIB_LIBS)
 163 endif # SYSTEM_ZLIB
 164 
 165 #
 166 # Library to compile.
 167 #
 168 include $(BUILDDIR)/common/Mapfile-vers.gmk
 169 include $(BUILDDIR)/common/Library.gmk
 170 
 171 #
 172 # On Windows, some executable objects need to be statically linked against
 173 # the jli library.  Hence, we need both a standard library (archive) and
 174 # an import library (associated with a dll).  These both usually have the
 175 # extension .LIB, so they need to be placed in different directories.  The
 176 # import library is build (as usual) in the $(OBJDIR) directory while the
 177 # standard library is built in a "static" subdirectory.  The standard library
 178 # is not delivered as part of the product, but is only needed as part of
 179 # the build process.  The import library is built by the standard rules
 180 # in Library.gmk.  The additional rules which follow build the standard
 181 # library.
 182 #
 183 ifeq ($(PLATFORM), windows)
 184   STATIC_LIBRARY = $(OBJDIR)/static/$(LIBPREFIX)$(LIBRARY).lib
 185 
 186   $(STATIC_LIBRARY): $(FILES_o)
 187         @$(prep-target)
 188         $(LIBEXE) -nologo -out:$@ $(FILES_o)
 189 
 190   library:: $(STATIC_LIBRARY)
 191 endif # PLATFORM
 192 
 193 ifeq ($(PLATFORM), macosx)
 194   # Some Obj-C code is embedded in java_md_macosx.c, we stipulate so, using
 195   # "-x" option. Not doing so will cause the compiler to choose the language
 196   # based on the filename suffix, also "-Os" optimizes the file for size.
 197   CFLAGS_$(VARIANT)/java_md_macosx.o = -Os -x objective-c
 198   # Needed for linking the various launchers
 199   LDFLAGS += -framework Cocoa -framework Security \
 200              -framework ApplicationServices
 201   # Add solaris sources containing common logic to the header path
 202   OTHER_INCLUDES += -I$(LAUNCHER_SOLARIS_PLATFORM_SRC)
 203 endif # PLATFORM
 204 
 205 STATIC_LIBRARY_DIR = $(OBJDIR)/static
 206 STATIC_LIBRARY_NAME = lib$(LIBRARY).a
 207 STATIC_LIBRARY = $(STATIC_LIBRARY_DIR)/$(STATIC_LIBRARY_NAME)
 208 
 209 $(STATIC_LIBRARY_DIR): | $(OBJDIR)
 210         @$(MKDIR) $(STATIC_LIBRARY_DIR)
 211 
 212 $(STATIC_LIBRARY): $(STATIC_LIBRARY_DIR)
 213         @$(prep-target)
 214         $(AR) $(ARFLAGS) $@ $(FILES_o)
 215 
 216 library:: $(STATIC_LIBRARY)
 217 
 218 vpath %.c $(LAUNCHER_SHARE_SRC) $(LAUNCHER_PLATFORM_SRC)
 219 ifneq ($(SYSTEM_ZLIB),true)
 220   vpath %.c $(ZIP_SRC)
 221 else # !SYSTEM_ZLIB
 222   #
 223   # Add to ambient vpath so we pick up the library files, for macos we add 
 224   # solaris sources which contains the common logic for all nixes
 225   #
 226   ifeq ($(PLATFORM), macosx)
 227     vpath %.c $(LAUNCHER_SHARE_SRC) $(ZIP_SRC) $(LAUNCHER_PLATFORM_SRC) \
 228           $(LAUNCHER_SOLARIS_PLATFORM_SRC)
 229   else # !MACOSX
 230     vpath %.c $(LAUNCHER_SHARE_SRC) $(ZIP_SRC) $(LAUNCHER_PLATFORM_SRC)
 231   endif # MACOSX
 232 endif # SYSTEM_LIB