1 # 2 # Copyright (c) 1995, 2010, 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 # Generic makefile for building executables. 28 # 29 30 # WARNING: This file is shared with other workspaces. 31 # So when it includes other files, it must use JDK_TOPDIR. 32 # 33 34 # 35 # If building programs, use a normal compile approach 36 # 37 ifeq ($(COMPILE_APPROACH),batch) 38 override COMPILE_APPROACH = normal 39 endif 40 41 ifndef LAUNCHER_PLATFORM_SRC 42 LAUNCHER_PLATFORM_SRC = $(PLATFORM_SRC) 43 endif 44 45 ifndef LAUNCHER_SHARE_SRC 46 LAUNCHER_SHARE_SRC = $(SHARE_SRC) 47 endif 48 49 ACTUAL_PROGRAM_NAME = $(PROGRAM)$(EXE_SUFFIX) 50 ACTUAL_PROGRAM_DIR = $(BINDIR) 51 ACTUAL_PROGRAM = $(ACTUAL_PROGRAM_DIR)/$(ACTUAL_PROGRAM_NAME) 52 53 # Make sure the default rule is all 54 program_default_rule: all 55 56 program: $(ACTUAL_PROGRAM) 57 58 include $(JDK_TOPDIR)/make/common/Rules.gmk 59 60 ifdef NEVER_ACT_AS_SERVER_CLASS_MACHINE 61 OTHER_CPPFLAGS += -DNEVER_ACT_AS_SERVER_CLASS_MACHINE 62 endif 63 64 # 65 # Create a dependency on libjli (Java Launcher Infrastructure) 66 # 67 # On UNIX, this is a relative dependency using $ORIGIN. Unfortunately, to 68 # do this reliably on Linux takes a different syntax than Solaris. 69 # 70 # On Windows, this is done by using the same directory as the executable 71 # itself, as with all the Windows libraries. 72 # 73 ifneq (,$(findstring $(PLATFORM), linux solaris)) # UNIX systems 74 LDFLAGS += -L $(LIBDIR)/$(LIBARCH)/jli 75 OTHER_LDLIBS += -ljli 76 ifeq ($(PLATFORM), solaris) 77 ifeq ($(ARCH_DATA_MODEL), 32) 78 LDFLAGS += -R \$$ORIGIN/../lib/$(LIBARCH)/jli 79 LDFLAGS += -R \$$ORIGIN/../jre/lib/$(LIBARCH)/jli 80 else 81 LDFLAGS += -R \$$ORIGIN/../../lib/$(LIBARCH)/jli 82 LDFLAGS += -R \$$ORIGIN/../../jre/lib/$(LIBARCH)/jli 83 endif 84 endif 85 ifeq ($(PLATFORM), linux) 86 LDFLAGS += $(LDFLAG_Z_ORIGIN) 87 LDFLAGS += -Wl,--allow-shlib-undefined 88 LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli 89 LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli 90 endif 91 endif 92 ifeq ($(PLATFORM), windows) 93 JLI_LCF = $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/jli.lcf 94 ifdef STATIC_JLI 95 LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static 96 else 97 LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME) 98 endif 99 OTHER_LDLIBS += jli.lib 100 endif 101 102 # 103 # Launcher specific files. 104 # 105 FILES_o = \ 106 $(OBJDIR)/main.$(OBJECT_SUFFIX) 107 108 $(ACTUAL_PROGRAM):: classes $(INIT) 109 110 # 111 # Windows only 112 # 113 ifeq ($(PLATFORM), windows) 114 115 # JDK name required here 116 RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \ 117 /D "JDK_INTERNAL_NAME=$(PROGRAM)" \ 118 /D "JDK_FTYPE=0x1L" 119 120 $(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE) 121 @$(prep-target) 122 ifndef LOCAL_RESOURCE_FILE 123 $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE) 124 endif 125 126 $(OBJDIR)/$(PROGRAM).lcf: $(OBJDIR)/$(PROGRAM).res $(FILES_o) 127 @$(prep-target) 128 @$(ECHO) $(FILES_o) > $@ 129 ifndef LOCAL_RESOURCE_FILE 130 @$(ECHO) $(OBJDIR)/$(PROGRAM).res >> $@ 131 endif 132 @$(ECHO) setargv.obj >> $@ 133 @$(ECHO) Created $@ 134 135 $(ACTUAL_PROGRAM):: $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX) 136 @$(install-file) 137 138 ifeq ($(ARCH_DATA_MODEL), 32) 139 STACK_SIZE=327680 140 else 141 # We need more Stack for Windows 64bit 142 STACK_SIZE=1048576 143 endif 144 145 IMVERSION=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER) 146 $(OBJDIR)/$(PROGRAM).exe.manifest: $(JDK_TOPDIR)/src/windows/resource/java.manifest 147 @$(prep-target) 148 $(SED) 's%IMVERSION%$(IMVERSION)%g;s%PROGRAM%$(PROGRAM)%g' $< > $@ 149 150 # We used a hand-crafted manifest file for all executables. 151 # It is tweaked to embed the build number and executable name. 152 # Use ";#2" for .dll and ";#1" for .exe in the MT command below: 153 $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX):: $(OBJDIR)/$(PROGRAM).lcf $(FILES_o) $(JLI_LCF) $(OBJDIR)/$(PROGRAM).exe.manifest 154 @$(prep-target) 155 @set -- $?; \ 156 $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...}; 157 $(LINK) -out:$@ /STACK:$(STACK_SIZE) \ 158 -map:$(OBJDIR)/$(PROGRAM).map $(LFLAGS) $(LDFLAGS) \ 159 @$(OBJDIR)/$(PROGRAM).lcf $(LDLIBS) 160 ifdef MT 161 $(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1 162 endif 163 @$(call binary_file_verification,$@) 164 165 else # PLATFORM 166 167 # 168 # Note that we have to link -lthread even when USE_PTHREADS is true. 169 # This is becuase checkForCorrectLibthread() croaks otherwise. 170 # 171 LIBTHREAD = -lthread 172 ifeq ($(USE_PTHREADS),true) 173 THREADLIBS = -lpthread $(LIBTHREAD) 174 else # USE_PTHREADS 175 THREADLIBS = $(LIBTHREAD) 176 endif # USE_PTHREADS 177 178 # 179 # This rule only applies on unix. It supports quantify and its ilk. 180 # 181 $(ACTUAL_PROGRAM):: $(FILES_o) 182 @$(prep-target) 183 @set -- $?; \ 184 $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...}; 185 @$(MKDIR) -p $(TEMPDIR) 186 $(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \ 187 $(FILES_o) $(THREADLIBS) $(LDLIBS) 188 @$(call binary_file_verification,$@) 189 190 endif # PLATFORM 191 192 clean:: 193 ifeq ($(PLATFORM), windows) 194 $(RM) $(OBJDIR)/$(PROGRAM).rc 195 $(RM) $(OBJDIR)/$(PROGRAM).ico 196 $(RM) $(OBJDIR)/$(PROGRAM).lcf 197 $(RM) $(OBJDIR)/$(PROGRAM).map 198 $(RM) $(OBJDIR)/$(PROGRAM).exp 199 $(RM) $(OBJDIR)/$(PROGRAM).lib 200 $(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX) 201 $(RM) $(OBJDIR)/$(PROGRAM).ilk 202 $(RM) *.pdb 203 endif 204 205 206 clobber:: 207 $(RM) $(ACTUAL_PROGRAM) 208 209 # 210 # Now include make dependencies (created during compilation, see Rules.gmk) 211 # 212 ifeq ($(INCREMENTAL_BUILD),true) 213 # Workaround: gnumake sometimes says files is empty when it shouldn't 214 # was: files := $(foreach file, $(wildcard */$(ARCH)/*.$(DEPEND_SUFFIX)), $(file)) 215 files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null) 216 ifneq ($(strip $(files)),) 217 include $(files) 218 endif # files 219 endif # INCREMENTAL_BUILD 220 221 ifdef JAVA_ARGS 222 OTHER_CPPFLAGS += -DJAVA_ARGS='$(JAVA_ARGS)' 223 OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' 224 endif 225 226 ifeq ($(PLATFORM), windows) 227 ifdef RELEASE 228 OTHER_CPPFLAGS += -DVERSION='"$(RELEASE)"' 229 endif 230 endif 231 232 233 ifneq ($(PLATFORM), windows) 234 HAVE_GETHRTIME=true 235 endif 236 237 ifeq ($(HAVE_GETHRTIME),true) 238 OTHER_CPPFLAGS += -DHAVE_GETHRTIME 239 endif 240 241 OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)/bin -I$(LAUNCHER_PLATFORM_SRC)/bin 242 OTHER_INCLUDES += -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3 243 244 OTHER_CPPFLAGS += -DPROGNAME='"$(PROGRAM)"' 245 VERSION_DEFINES += -DFULL_VERSION='"$(FULL_VERSION)"' 246 247 VERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \ 248 -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' 249 250 251 252 $(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c 253 @$(prep-target) 254 $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$(OBJDIR)/main.$(OBJECT_SUFFIX) \ 255 $(VERSION_DEFINES) $< 256 257 # 258 # Default dependencies 259 # 260 261 all: build 262 263 build: program 264 265 debug: 266 $(MAKE) VARIANT=DBG build 267 268 fastdebug: 269 $(MAKE) VARIANT=DBG FASTDEBUG=true build 270 271 .PHONY: all build program clean clobber debug fastdebug