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