Program.gmk revision 4680
0N/A#
0N/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
0N/A# published by the Free Software Foundation. Oracle designates this
0N/A# particular file as subject to the "Classpath" exception as provided
0N/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#
0N/A# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A# or visit www.oracle.com if you need additional information or have any
0N/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
0N/A# set the platform specific directory for macosx, also this platform shares
0N/A# substantial family ties with its siblings (solaris and linux), thus we add
0N/A# solaris src path to its compilation dependencies.
460N/Aifeq ($(PLATFORM), macosx)
460N/A LAUNCHER_PLATFORM_SRC = $(BUILDDIR)/../src/macosx
0N/A LAUNCHER_SOLARIS_PLATFORM_SRC = $(BUILDDIR)/../src/solaris
460N/Aelse # ! MACOSX
0N/A LAUNCHER_PLATFORM_SRC = $(PLATFORM_SRC)
0N/Aendif # MACOSX
0N/A
0N/Aifndef LAUNCHER_SHARE_SRC
0N/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
0N/A# Work-around for missing processor specific mapfiles
0N/Aifndef CROSS_COMPILE_ARCH
0N/A # reuse the mapfiles in the launcher's directory, the same should
0N/A # be applicable to the tool launchers as well.
0N/A FILES_m = $(BUILDDIR)/java/main/java/mapfile-$(ARCH)
0N/A include $(BUILDDIR)/common/Mapfile-vers.gmk
0N/Aendif
0N/A
0N/Ainclude $(JDK_TOPDIR)/make/common/Rules.gmk
0N/A
0N/Aifdef NEVER_ACT_AS_SERVER_CLASS_MACHINE
0N/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#
0N/Aifeq ($(PLATFORM), macosx)
0N/A ifneq ($(ARCH), universal)
0N/A LDFLAGS += -Wl,-all_load
0N/A endif # ARCH
0N/A LDFLAGS += $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static/libjli.a
0N/A
0N/A ifeq ($(SYSTEM_ZLIB),true)
0N/A OTHER_LDLIBS += -lz
0N/A endif # SYSTEM_ZLIB
0N/Aendif # PLATFORM
0N/A
0N/Aifneq (,$(findstring $(PLATFORM), linux solaris)) # UNIX systems
0N/A LDFLAGS += -L $(LIBDIR)/$(LIBARCH)/jli
0N/A OTHER_LDLIBS += -ljli
0N/A ifeq ($(PLATFORM), solaris)
0N/A ifeq ($(ARCH_DATA_MODEL), 32)
0N/A LDFLAGS += -R \$$ORIGIN/../lib/$(LIBARCH)/jli
0N/A LDFLAGS += -R \$$ORIGIN/../jre/lib/$(LIBARCH)/jli
0N/A else # ! ARCH_DATA_MODEL 64-bit
0N/A LDFLAGS += -R \$$ORIGIN/../../lib/$(LIBARCH)/jli
0N/A LDFLAGS += -R \$$ORIGIN/../../jre/lib/$(LIBARCH)/jli
0N/A endif # ARCH_DATA_MODEL
0N/A endif # PLATFORM SOLARIS
0N/A ifeq ($(PLATFORM), linux)
0N/A LDFLAGS += $(LDFLAG_Z_ORIGIN)
0N/A LDFLAGS += -Wl,--allow-shlib-undefined
0N/A LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli
0N/A LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli
0N/A endif # PLATFORM LINUX
0N/Aendif # PLATFORM linux solaris
0N/A
0N/Aifeq ($(PLATFORM), windows)
0N/A JLI_LCF = $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/jli.lcf
0N/A ifdef STATIC_JLI
0N/A LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static
0N/A else # !STATIC_JLI
0N/A LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)
0N/A endif # STATIC_JLI
OTHER_LDLIBS += jli.lib
endif # PLATFORM
#
# Launcher specific files.
#
FILES_o = $(OBJDIR)/main.$(OBJECT_SUFFIX)
$(ACTUAL_PROGRAM):: classes $(INIT)
#
# Windows only
#
ifeq ($(PLATFORM), windows)
# JDK name required here
RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
/D "JDK_INTERNAL_NAME=$(PROGRAM)" \
/D "JDK_FTYPE=0x1L"
$(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE)
@$(prep-target)
ifndef LOCAL_RESOURCE_FILE
$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
endif # LOCAL_RESOURCE_FILE
$(OBJDIR)/$(PROGRAM).lcf: $(OBJDIR)/$(PROGRAM).res $(FILES_o)
@$(prep-target)
@$(ECHO) $(FILES_o) > $@
ifndef LOCAL_RESOURCE_FILE
@$(ECHO) $(OBJDIR)/$(PROGRAM).res >> $@
endif # LOCAL_RESOURCE_FILE
@$(ECHO) setargv.obj >> $@
@$(ECHO) Created $@
$(ACTUAL_PROGRAM):: $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
@$(install-file)
ifeq ($(ARCH_DATA_MODEL), 32)
STACK_SIZE=327680
else # !32 BIT
# We need more Stack for Windows 64bit
STACK_SIZE=1048576
endif # ARCH_DATA_MODEL
IMVERSION=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
$(OBJDIR)/$(PROGRAM).exe.manifest: $(JDK_TOPDIR)/src/windows/resource/java.manifest
@$(prep-target)
$(SED) 's%IMVERSION%$(IMVERSION)%g;s%PROGRAM%$(PROGRAM)%g' $< > $@
# We used a hand-crafted manifest file for all executables.
# It is tweaked to embed the build number and executable name.
# Use ";#2" for .dll and ";#1" for .exe in the MT command below:
$(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX):: $(OBJDIR)/$(PROGRAM).lcf $(FILES_o) $(JLI_LCF) $(OBJDIR)/$(PROGRAM).exe.manifest
@$(prep-target)
@set -- $?; \
$(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
$(LINK) -out:$@ /STACK:$(STACK_SIZE) \
-map:$(OBJDIR)/$(PROGRAM).map $(LFLAGS) $(LDFLAGS) \
@$(OBJDIR)/$(PROGRAM).lcf $(LDLIBS)
ifdef MT
$(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
endif # MT
@$(call binary_file_verification,$@)
else # *NIXES
#
# Note that we have to link -lthread even when USE_PTHREADS is true.
# This is becuase checkForCorrectLibthread() croaks otherwise.
#
LIBTHREAD = -lthread
ifeq ($(USE_PTHREADS),true)
THREADLIBS = -lpthread $(LIBTHREAD)
else # !USE_PTHREADS
THREADLIBS = $(LIBTHREAD)
endif # USE_PTHREADS
ifeq ($(PLATFORM), macosx)
THREADLIBS = -pthread
# Needed for linking the various launchers
LDFLAGS += -framework Cocoa -framework Security \
-framework ApplicationServices
OTHER_CPPFLAGS += -DPACKAGE_PATH='"$(PACKAGE_PATH)"'
# Default Info.plist file for the command line tools. This gets overridden by
# some of the jvmstat tools so that they have task_for_pid() privileges
ifndef INFO_PLIST_FILE
INFO_PLIST_FILE = Info-cmdline.plist
endif # INFO_PLIST_FILE
LDFLAGS += -sectcreate __TEXT __info_plist $(LAUNCHER_PLATFORM_SRC)/lib/$(INFO_PLIST_FILE)
else # SOLARIS/LINUX
INFO_PLIST_FILE=
endif # MACOSX
#
# This rule only applies on unix. It supports quantify and its ilk.
#
$(ACTUAL_PROGRAM):: $(FILES_o)
@$(prep-target)
@set -- $?; \
$(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
@$(MKDIR) -p $(TEMPDIR)
$(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
$(FILES_o) $(THREADLIBS) $(LDLIBS)
ifeq ($(findstring privileged, $(INFO_PLIST_FILE)), privileged)
-codesign -s openjdk_codesign $@
endif # INFO_PLIST_FILE
@$(call binary_file_verification,$@)
endif # PLATFORM
clean::
ifeq ($(PLATFORM), windows)
$(RM) $(OBJDIR)/$(PROGRAM).rc
$(RM) $(OBJDIR)/$(PROGRAM).ico
$(RM) $(OBJDIR)/$(PROGRAM).lcf
$(RM) $(OBJDIR)/$(PROGRAM).map
$(RM) $(OBJDIR)/$(PROGRAM).exp
$(RM) $(OBJDIR)/$(PROGRAM).lib
$(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
$(RM) $(OBJDIR)/$(PROGRAM).ilk
$(RM) *.pdb
endif
clobber::
$(RM) $(ACTUAL_PROGRAM)
#
# Now include make dependencies (created during compilation, see Rules.gmk)
#
ifeq ($(INCREMENTAL_BUILD),true)
# Workaround: gnumake sometimes says files is empty when it shouldn't
# was: files := $(foreach file, $(wildcard */$(ARCH)/*.$(DEPEND_SUFFIX)), $(file))
files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null)
ifneq ($(strip $(files)),)
include $(files)
endif # files
endif # INCREMENTAL_BUILD
ifdef JAVA_ARGS
OTHER_CPPFLAGS += -DJAVA_ARGS='$(JAVA_ARGS)'
OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"'
endif # JAVA_ARGS
ifeq ($(PLATFORM), windows)
ifdef RELEASE
OTHER_CPPFLAGS += -DVERSION='"$(RELEASE)"'
endif #RELEASE
endif #PLATFORM
ifneq ($(PLATFORM), windows)
HAVE_GETHRTIME=true
endif #PLATFORM
ifeq ($(HAVE_GETHRTIME),true)
OTHER_CPPFLAGS += -DHAVE_GETHRTIME
endif
OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)/bin -I$(LAUNCHER_PLATFORM_SRC)/bin
ifeq ($(PLATFORM), macosx)
OTHER_INCLUDES += -I$(LAUNCHER_SOLARIS_PLATFORM_SRC)/bin
ifneq ($(SYSTEM_ZLIB), true)
OTHER_INCLUDES += -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
endif # SYSTEM_ZLIB
else # PLATFORM !MACOSX
OTHER_INCLUDES += -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
endif
OTHER_CPPFLAGS += -DPROGNAME='"$(PROGRAM)"'
VERSION_DEFINES += -DFULL_VERSION='"$(FULL_VERSION)"'
VERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
-DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"'
$(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c
@$(prep-target)
$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$(OBJDIR)/main.$(OBJECT_SUFFIX) \
$(VERSION_DEFINES) $<
#
# Default dependencies
#
all: build
build: program
debug:
$(MAKE) VARIANT=DBG build
fastdebug:
$(MAKE) VARIANT=DBG FASTDEBUG=true build
.PHONY: all build program clean clobber debug fastdebug