0N/A#
4680N/A# Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
0N/A# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A#
0N/A# This code is free software; you can redistribute it and/or modify it
0N/A# under the terms of the GNU General Public License version 2 only, as
2362N/A# published by the Free Software Foundation. Oracle designates this
0N/A# particular file as subject to the "Classpath" exception as provided
2362N/A# by Oracle in the LICENSE file that accompanied this code.
0N/A#
0N/A# This code is distributed in the hope that it will be useful, but WITHOUT
0N/A# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A# version 2 for more details (a copy is included in the LICENSE file that
0N/A# accompanied this code).
0N/A#
0N/A# You should have received a copy of the GNU General Public License version
0N/A# 2 along with this work; if not, write to the Free Software Foundation,
0N/A# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A#
2362N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A# or visit www.oracle.com if you need additional information or have any
2362N/A# questions.
0N/A#
0N/A
0N/A#
0N/A# Generic makefile for building executables.
0N/A#
0N/A
0N/A# WARNING: This file is shared with other workspaces.
0N/A# So when it includes other files, it must use JDK_TOPDIR.
0N/A#
0N/A
0N/A#
0N/A# If building programs, use a normal compile approach
0N/A#
0N/Aifeq ($(COMPILE_APPROACH),batch)
0N/A override COMPILE_APPROACH = normal
0N/Aendif
0N/A
4680N/A# set the platform specific directory for macosx, also this platform shares
4680N/A# substantial family ties with its siblings (solaris and linux), thus we add
4680N/A# solaris src path to its compilation dependencies.
4680N/Aifeq ($(PLATFORM), macosx)
4680N/A LAUNCHER_PLATFORM_SRC = $(BUILDDIR)/../src/macosx
4680N/A LAUNCHER_SOLARIS_PLATFORM_SRC = $(BUILDDIR)/../src/solaris
4680N/Aelse # ! MACOSX
4680N/A LAUNCHER_PLATFORM_SRC = $(PLATFORM_SRC)
4680N/Aendif # MACOSX
0N/A
0N/Aifndef LAUNCHER_SHARE_SRC
4680N/A LAUNCHER_SHARE_SRC = $(SHARE_SRC)
0N/Aendif
0N/A
0N/AACTUAL_PROGRAM_NAME = $(PROGRAM)$(EXE_SUFFIX)
0N/AACTUAL_PROGRAM_DIR = $(BINDIR)
0N/AACTUAL_PROGRAM = $(ACTUAL_PROGRAM_DIR)/$(ACTUAL_PROGRAM_NAME)
0N/A
0N/A# Make sure the default rule is all
0N/Aprogram_default_rule: all
0N/A
0N/Aprogram: $(ACTUAL_PROGRAM)
0N/A
4058N/A# Work-around for missing processor specific mapfiles
4058N/Aifndef CROSS_COMPILE_ARCH
4058N/A # reuse the mapfiles in the launcher's directory, the same should
4058N/A # be applicable to the tool launchers as well.
4058N/A FILES_m = $(BUILDDIR)/java/main/java/mapfile-$(ARCH)
4058N/A include $(BUILDDIR)/common/Mapfile-vers.gmk
4058N/Aendif
3983N/A
0N/Ainclude $(JDK_TOPDIR)/make/common/Rules.gmk
0N/A
0N/Aifdef NEVER_ACT_AS_SERVER_CLASS_MACHINE
4680N/A OTHER_CPPFLAGS += -DNEVER_ACT_AS_SERVER_CLASS_MACHINE
0N/Aendif
0N/A
0N/A#
0N/A# Create a dependency on libjli (Java Launcher Infrastructure)
0N/A#
0N/A# On UNIX, this is a relative dependency using $ORIGIN. Unfortunately, to
0N/A# do this reliably on Linux takes a different syntax than Solaris.
0N/A#
0N/A# On Windows, this is done by using the same directory as the executable
0N/A# itself, as with all the Windows libraries.
0N/A#
4632N/Aifeq ($(PLATFORM), macosx)
4632N/A ifneq ($(ARCH), universal)
4632N/A LDFLAGS += -Wl,-all_load
4680N/A endif # ARCH
4632N/A LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a
4632N/A
4632N/A ifeq ($(SYSTEM_ZLIB),true)
5353N/A OTHER_LDLIBS += $(ZLIB_LIBS)
4680N/A endif # SYSTEM_ZLIB
4680N/Aendif # PLATFORM
4632N/A
4680N/Aifneq (,$(findstring $(PLATFORM), linux solaris)) # UNIX systems
4680N/A LDFLAGS += -L $(LIBDIR)/$(LIBARCH)/jli
4680N/A OTHER_LDLIBS += -ljli
4680N/A ifeq ($(PLATFORM), solaris)
4680N/A ifeq ($(ARCH_DATA_MODEL), 32)
4680N/A LDFLAGS += -R \$$ORIGIN/../lib/$(LIBARCH)/jli
4680N/A LDFLAGS += -R \$$ORIGIN/../jre/lib/$(LIBARCH)/jli
4680N/A else # ! ARCH_DATA_MODEL 64-bit
4680N/A LDFLAGS += -R \$$ORIGIN/../../lib/$(LIBARCH)/jli
4680N/A LDFLAGS += -R \$$ORIGIN/../../jre/lib/$(LIBARCH)/jli
4680N/A endif # ARCH_DATA_MODEL
4680N/A endif # PLATFORM SOLARIS
4680N/A ifeq ($(PLATFORM), linux)
4680N/A LDFLAGS += $(LDFLAG_Z_ORIGIN)
4680N/A LDFLAGS += -Wl,--allow-shlib-undefined
4680N/A LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli
4680N/A LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli
4680N/A endif # PLATFORM LINUX
4680N/Aendif # PLATFORM linux solaris
4680N/A
0N/Aifeq ($(PLATFORM), windows)
4680N/A JLI_LCF = $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/jli.lcf
4680N/A ifdef STATIC_JLI
4680N/A LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static
4680N/A else # !STATIC_JLI
4680N/A LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)
4680N/A endif # STATIC_JLI
4680N/A OTHER_LDLIBS += jli.lib
4680N/Aendif # PLATFORM
0N/A
0N/A#
0N/A# Launcher specific files.
0N/A#
4680N/AFILES_o = $(OBJDIR)/main.$(OBJECT_SUFFIX)
0N/A
2080N/A$(ACTUAL_PROGRAM):: classes $(INIT)
0N/A
0N/A#
0N/A# Windows only
0N/A#
0N/Aifeq ($(PLATFORM), windows)
4680N/A # JDK name required here
4680N/A RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
4680N/A /D "JDK_INTERNAL_NAME=$(PROGRAM)" \
4680N/A /D "JDK_FTYPE=0x1L"
0N/A
4680N/A $(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE)
0N/A @$(prep-target)
4680N/A ifndef LOCAL_RESOURCE_FILE
0N/A $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
4680N/A endif # LOCAL_RESOURCE_FILE
0N/A
4680N/A $(OBJDIR)/$(PROGRAM).lcf: $(OBJDIR)/$(PROGRAM).res $(FILES_o)
0N/A @$(prep-target)
0N/A @$(ECHO) $(FILES_o) > $@
0N/A ifndef LOCAL_RESOURCE_FILE
0N/A @$(ECHO) $(OBJDIR)/$(PROGRAM).res >> $@
4680N/A endif # LOCAL_RESOURCE_FILE
0N/A @$(ECHO) Created $@
0N/A
4680N/A $(ACTUAL_PROGRAM):: $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
0N/A @$(install-file)
0N/A
4680N/A ifeq ($(ARCH_DATA_MODEL), 32)
4680N/A STACK_SIZE=327680
4680N/A else # !32 BIT
4680N/A # We need more Stack for Windows 64bit
4680N/A STACK_SIZE=1048576
4680N/A endif # ARCH_DATA_MODEL
0N/A
4680N/A IMVERSION=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
4680N/A $(OBJDIR)/$(PROGRAM).exe.manifest: $(JDK_TOPDIR)/src/windows/resource/java.manifest
3356N/A @$(prep-target)
3356N/A $(SED) 's%IMVERSION%$(IMVERSION)%g;s%PROGRAM%$(PROGRAM)%g' $< > $@
3356N/A
4915N/Aifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
4915N/A MAP_OPTION="-map:$(OBJDIR)/$(PROGRAM).map"
4915N/Aendif
4915N/A
4680N/A # We used a hand-crafted manifest file for all executables.
4680N/A # It is tweaked to embed the build number and executable name.
4680N/A # Use ";#2" for .dll and ";#1" for .exe in the MT command below:
4680N/A $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX):: $(OBJDIR)/$(PROGRAM).lcf $(FILES_o) $(JLI_LCF) $(OBJDIR)/$(PROGRAM).exe.manifest
0N/A @$(prep-target)
0N/A @set -- $?; \
0N/A $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
0N/A $(LINK) -out:$@ /STACK:$(STACK_SIZE) \
4915N/A $(MAP_OPTION) $(LFLAGS) $(LDFLAGS) \
0N/A @$(OBJDIR)/$(PROGRAM).lcf $(LDLIBS)
4680N/A ifdef MT
795N/A $(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
4680N/A endif # MT
3419N/A @$(call binary_file_verification,$@)
4956N/A ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
4956N/A ifeq ($(ZIP_DEBUGINFO_FILES),1)
4956N/A (set -e ; \
4956N/A $(CD) $(OBJDIR) ; \
4956N/A $(ZIPEXE) -q $(PROGRAM).diz $(PROGRAM).map $(PROGRAM).pdb ; \
4956N/A $(RM) $(PROGRAM).map $(PROGRAM).pdb ; \
4956N/A )
4956N/A endif
4956N/A endif
4680N/Aelse # *NIXES
4680N/A #
4680N/A # Note that we have to link -lthread even when USE_PTHREADS is true.
4680N/A # This is becuase checkForCorrectLibthread() croaks otherwise.
4680N/A #
4680N/A LIBTHREAD = -lthread
4680N/A ifeq ($(USE_PTHREADS),true)
4680N/A THREADLIBS = -lpthread $(LIBTHREAD)
4680N/A else # !USE_PTHREADS
4680N/A THREADLIBS = $(LIBTHREAD)
4680N/A endif # USE_PTHREADS
0N/A
4680N/A ifeq ($(PLATFORM), macosx)
4680N/A THREADLIBS = -pthread
4680N/A # Needed for linking the various launchers
4680N/A LDFLAGS += -framework Cocoa -framework Security \
4680N/A -framework ApplicationServices
4680N/A OTHER_CPPFLAGS += -DPACKAGE_PATH='"$(PACKAGE_PATH)"'
4632N/A
4680N/A # Default Info.plist file for the command line tools. This gets overridden by
4680N/A # some of the jvmstat tools so that they have task_for_pid() privileges
4680N/A ifndef INFO_PLIST_FILE
4680N/A INFO_PLIST_FILE = Info-cmdline.plist
4680N/A endif # INFO_PLIST_FILE
4680N/A LDFLAGS += -sectcreate __TEXT __info_plist $(LAUNCHER_PLATFORM_SRC)/lib/$(INFO_PLIST_FILE)
4680N/A else # SOLARIS/LINUX
4680N/A INFO_PLIST_FILE=
4680N/A endif # MACOSX
4632N/A
4680N/A #
4680N/A # This rule only applies on unix. It supports quantify and its ilk.
4680N/A #
5036N/A
5036N/A ifeq ($(PLATFORM), solaris)
5036N/A ifeq ($(PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
5036N/A $(ACTUAL_PROGRAM):: $(ADD_GNU_DEBUGLINK) $(FIX_EMPTY_SEC_HDR_FLAGS)
5036N/A endif
5036N/A endif
5036N/A
4680N/A $(ACTUAL_PROGRAM):: $(FILES_o)
0N/A @$(prep-target)
0N/A @set -- $?; \
4680N/A $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
0N/A @$(MKDIR) -p $(TEMPDIR)
0N/A $(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
4680N/A $(FILES_o) $(THREADLIBS) $(LDLIBS)
4680N/A ifeq ($(findstring privileged, $(INFO_PLIST_FILE)), privileged)
4632N/A -codesign -s openjdk_codesign $@
4680N/A endif # INFO_PLIST_FILE
3419N/A @$(call binary_file_verification,$@)
4956N/A ifneq ($(PLATFORM), macosx)
4956N/A ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
4956N/A ifeq ($(PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
5036N/A ifeq ($(PLATFORM), solaris)
5036N/A# gobjcopy crashes on "empty" section headers with the SHF_ALLOC flag set.
5036N/A# Use $(FIX_EMPTY_SEC_HDR_FLAGS) to clear the SHF_ALLOC flag (if set) from
5036N/A# empty section headers until a fixed $(OBJCOPY) is available.
5036N/A# An empty section header has sh_addr == 0 and sh_size == 0.
5036N/A# This problem has only been seen on Solaris X64, but we call this tool
5036N/A# on all Solaris builds just in case.
5036N/A#
5036N/A# $(OBJCOPY) --add-gnu-debuglink=... corrupts SUNW_* sections.
5036N/A# Use $(ADD_GNU_DEBUGLINK) until a fixed $(OBJCOPY) is available.
5036N/A (set -e ; \
5036N/A $(CD) $(@D) ; \
5036N/A $(FIX_EMPTY_SEC_HDR_FLAGS) $(@F) ; \
5036N/A $(OBJCOPY) --only-keep-debug $(@F) $(@F).debuginfo ; \
5036N/A $(ADD_GNU_DEBUGLINK) $(@F).debuginfo $(@F) ; \
5036N/A )
5036N/A else # PLATFORM != solaris
4956N/A (set -e ; \
4956N/A $(CD) $(@D) ; \
4956N/A $(OBJCOPY) --only-keep-debug $(@F) $(@F).debuginfo ; \
4956N/A $(OBJCOPY) --add-gnu-debuglink=$(@F).debuginfo $(@F) ; \
4956N/A )
5036N/A endif # PLATFORM == solaris
4956N/A ifeq ($(STRIP_POLICY),all_strip)
4956N/A $(STRIP) $@
4956N/A else
4956N/A ifeq ($(STRIP_POLICY),min_strip)
4956N/A ifeq ($(PLATFORM), solaris)
4956N/A $(STRIP) -x $@
4956N/A else
4956N/A # assume Linux
4956N/A $(STRIP) -g $@
4956N/A endif
4956N/A # implied else here is no stripping at all
4956N/A endif
4956N/A endif
4956N/A ifeq ($(ZIP_DEBUGINFO_FILES),1)
4956N/A (set -e ; \
4956N/A $(CD) $(@D) ; \
4956N/A $(ZIPEXE) -q $(@F).diz $(@F).debuginfo ; \
4956N/A $(RM) $(@F).debuginfo ; \
4956N/A )
4957N/A # save ZIP'ed debug info with rest of the program's build artifacts
4957N/A $(MV) $@.diz $(OBJDIR)
4957N/A else
4957N/A # save debug info with rest of the program's build artifacts
4957N/A $(MV) $@.debuginfo $(OBJDIR)
4956N/A endif
4956N/A endif # PROGRAM_SUPPORTS_FULL_DEBUG_SYMBOLS
4956N/A endif # ENABLE_FULL_DEBUG_SYMBOLS
4956N/A endif # PLATFORM-!macosx
0N/Aendif # PLATFORM
0N/A
0N/Aclean::
0N/Aifeq ($(PLATFORM), windows)
0N/A $(RM) $(OBJDIR)/$(PROGRAM).rc
0N/A $(RM) $(OBJDIR)/$(PROGRAM).ico
0N/A $(RM) $(OBJDIR)/$(PROGRAM).lcf
0N/A $(RM) $(OBJDIR)/$(PROGRAM).map
4956N/A $(RM) $(OBJDIR)/$(PROGRAM).pdb
0N/A $(RM) $(OBJDIR)/$(PROGRAM).exp
0N/A $(RM) $(OBJDIR)/$(PROGRAM).lib
0N/A $(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
0N/A $(RM) $(OBJDIR)/$(PROGRAM).ilk
0N/A $(RM) *.pdb
4956N/Aelse
4956N/A $(RM) $(OBJDIR)/$(PROGRAM).debuginfo
0N/Aendif
4956N/A $(RM) $(OBJDIR)/$(PROGRAM).diz
0N/A
0N/A
0N/Aclobber::
0N/A $(RM) $(ACTUAL_PROGRAM)
0N/A
0N/A#
0N/A# Now include make dependencies (created during compilation, see Rules.gmk)
0N/A#
0N/Aifeq ($(INCREMENTAL_BUILD),true)
4680N/A # Workaround: gnumake sometimes says files is empty when it shouldn't
4680N/A # was: files := $(foreach file, $(wildcard */$(ARCH)/*.$(DEPEND_SUFFIX)), $(file))
4680N/A files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null)
4680N/A ifneq ($(strip $(files)),)
4680N/A include $(files)
4680N/A endif # files
0N/Aendif # INCREMENTAL_BUILD
0N/A
0N/Aifdef JAVA_ARGS
4680N/A OTHER_CPPFLAGS += -DJAVA_ARGS='$(JAVA_ARGS)'
4680N/A OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"'
4680N/Aendif # JAVA_ARGS
0N/A
0N/Aifeq ($(PLATFORM), windows)
4680N/A ifdef RELEASE
4680N/A OTHER_CPPFLAGS += -DVERSION='"$(RELEASE)"'
4680N/A endif #RELEASE
4680N/Aendif #PLATFORM
0N/A
0N/A
0N/Aifneq ($(PLATFORM), windows)
4680N/A HAVE_GETHRTIME=true
4680N/Aendif #PLATFORM
0N/A
0N/Aifeq ($(HAVE_GETHRTIME),true)
4680N/A OTHER_CPPFLAGS += -DHAVE_GETHRTIME
0N/Aendif
0N/A
0N/AOTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)/bin -I$(LAUNCHER_PLATFORM_SRC)/bin
4632N/Aifeq ($(PLATFORM), macosx)
4680N/A OTHER_INCLUDES += -I$(LAUNCHER_SOLARIS_PLATFORM_SRC)/bin
4632N/A ifneq ($(SYSTEM_ZLIB), true)
4632N/A OTHER_INCLUDES += -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
4680N/A endif # SYSTEM_ZLIB
4680N/Aelse # PLATFORM !MACOSX
4632N/A OTHER_INCLUDES += -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
4632N/Aendif
0N/A
4680N/AOTHER_CPPFLAGS += -DPROGNAME='"$(PROGRAM)"'
0N/AVERSION_DEFINES += -DFULL_VERSION='"$(FULL_VERSION)"'
0N/A
0N/AVERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
4680N/A -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"'
0N/A
0N/A
0N/A
0N/A$(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c
0N/A @$(prep-target)
0N/A $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$(OBJDIR)/main.$(OBJECT_SUFFIX) \
0N/A $(VERSION_DEFINES) $<
0N/A
0N/A#
0N/A# Default dependencies
0N/A#
0N/A
0N/Aall: build
0N/A
0N/Abuild: program
0N/A
0N/Adebug:
0N/A $(MAKE) VARIANT=DBG build
0N/A
0N/Afastdebug:
0N/A $(MAKE) VARIANT=DBG FASTDEBUG=true build
0N/A
0N/A.PHONY: all build program clean clobber debug fastdebug