1 # 2 # Copyright 1995-2007 Sun Microsystems, Inc. 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. Sun designates this 8 # particular file as subject to the "Classpath" exception as provided 9 # by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 22 # CA 95054 USA or visit www.sun.com if you need additional information or 23 # have any 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 JVMCFG = $(LIBDIR)/$(LIBARCH)/jvm.cfg 54 55 # Make sure the default rule is all 56 program_default_rule: all 57 58 program: $(ACTUAL_PROGRAM) 59 60 include $(JDK_TOPDIR)/make/common/Rules.gmk 61 62 ifdef NEVER_ACT_AS_SERVER_CLASS_MACHINE 63 OTHER_CPPFLAGS += -DNEVER_ACT_AS_SERVER_CLASS_MACHINE 64 endif 65 66 # 67 # Create a dependency on libjli (Java Launcher Infrastructure) 68 # 69 # On UNIX, this is a relative dependency using $ORIGIN. Unfortunately, to 70 # do this reliably on Linux takes a different syntax than Solaris. 71 # 72 # On Windows, this is done by using the same directory as the executable 73 # itself, as with all the Windows libraries. 74 # 75 ifneq (,$(findstring $(PLATFORM), linux solaris)) # UNIX systems 76 LDFLAGS += -L $(LIBDIR)/$(LIBARCH)/jli 77 OTHER_LDLIBS += -ljli 78 ifeq ($(PLATFORM), solaris) 79 ifeq ($(ARCH_DATA_MODEL), 32) 80 LDFLAGS += -R \$$ORIGIN/../lib/$(LIBARCH)/jli 81 LDFLAGS += -R \$$ORIGIN/../jre/lib/$(LIBARCH)/jli 82 else 83 LDFLAGS += -R \$$ORIGIN/../../lib/$(LIBARCH)/jli 84 LDFLAGS += -R \$$ORIGIN/../../jre/lib/$(LIBARCH)/jli 85 endif 86 endif 87 ifeq ($(PLATFORM), linux) 88 LDFLAGS += -Wl,-z -Wl,origin 89 LDFLAGS += -Wl,--allow-shlib-undefined 90 LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli 91 LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli 92 endif 93 endif 94 ifeq ($(PLATFORM), windows) 95 JLI_LCF = $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/jli.lcf 96 ifdef STATIC_JLI 97 LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static 98 else 99 LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME) 100 endif 101 OTHER_LDLIBS += jli.lib 102 endif 103 104 # 105 # Launcher specific files. 106 # 107 FILES_o = \ 108 $(OBJDIR)/main.$(OBJECT_SUFFIX) 109 110 # We either need to import (copy) binaries in, or build them 111 ifneq ($(IMPORT_NATIVE_BINARIES),true) 112 COMPILE_IT=true 113 else 114 COMPILE_IT=false 115 endif 116 117 ifeq ($(COMPILE_IT),true) 118 119 $(ACTUAL_PROGRAM):: classes $(JVMCFG) $(INIT) 120 121 # 122 # Windows only 123 # 124 ifeq ($(PLATFORM), windows) 125 126 # JDK name required here 127 RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \ 128 /D "JDK_INTERNAL_NAME=$(PROGRAM)" \ 129 /D "JDK_FTYPE=0x1L" 130 131 $(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE) 132 @$(prep-target) 133 ifndef LOCAL_RESOURCE_FILE 134 $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE) 135 endif 136 137 $(OBJDIR)/$(PROGRAM).lcf: $(OBJDIR)/$(PROGRAM).res $(FILES_o) 138 @$(prep-target) 139 @$(ECHO) $(FILES_o) > $@ 140 ifndef LOCAL_RESOURCE_FILE 141 @$(ECHO) $(OBJDIR)/$(PROGRAM).res >> $@ 142 endif 143 @$(ECHO) setargv.obj >> $@ 144 @$(ECHO) Created $@ 145 146 $(ACTUAL_PROGRAM):: $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX) 147 @$(install-file) 148 149 ifeq ($(ARCH_DATA_MODEL), 32) 150 STACK_SIZE=327680 151 else 152 # We need more Stack for Windows 64bit 153 STACK_SIZE=1048576 154 endif 155 156 # In VS2005 or VS2008 the link command creates a .manifest file that we want 157 # to insert into the linked artifact so we do not need to track it separately. 158 # Use ";#2" for .dll and ";#1" for .exe in the MT command below: 159 $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX):: $(OBJDIR)/$(PROGRAM).lcf $(FILES_o) $(JLI_LCF) 160 @$(prep-target) 161 @set -- $?; \ 162 $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...}; 163 $(LINK) -out:$@ /STACK:$(STACK_SIZE) \ 164 -map:$(OBJDIR)/$(PROGRAM).map $(LFLAGS) $(LDFLAGS) \ 165 @$(OBJDIR)/$(PROGRAM).lcf $(LDLIBS) 166 ifdef MT 167 $(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1 168 endif 169 170 else # PLATFORM 171 172 # 173 # Note that we have to link -lthread even when USE_PTHREADS is true. 174 # This is becuase checkForCorrectLibthread() croaks otherwise. 175 # 176 LIBTHREAD = -lthread 177 ifeq ($(USE_PTHREADS),true) 178 THREADLIBS = -lpthread $(LIBTHREAD) 179 else # USE_PTHREADS 180 THREADLIBS = $(LIBTHREAD) 181 endif # USE_PTHREADS 182 183 # 184 # This rule only applies on unix. It supports quantify and its ilk. 185 # 186 $(ACTUAL_PROGRAM):: $(FILES_o) 187 @$(prep-target) 188 @set -- $?; \ 189 $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...}; 190 @$(MKDIR) -p $(TEMPDIR) 191 $(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \ 192 $(FILES_o) $(THREADLIBS) $(LDLIBS) 193 194 endif # PLATFORM 195 196 else # COMPILE_IT 197 198 $(ACTUAL_PROGRAM):: $(JVMCFG) 199 200 # Copies in the file from the JDK_IMPORT_PATH area 201 $(ACTUAL_PROGRAM_DIR)/%: $(JDK_IMPORT_PATH)/jre/bin/% 202 @$(install-import-file) 203 $(ACTUAL_PROGRAM_DIR)/%: $(JDK_IMPORT_PATH)/bin/% 204 @$(install-import-file) 205 206 endif # COMPILE_IT 207 208 209 clean:: 210 ifeq ($(PLATFORM), windows) 211 $(RM) $(OBJDIR)/$(PROGRAM).rc 212 $(RM) $(OBJDIR)/$(PROGRAM).ico 213 $(RM) $(OBJDIR)/$(PROGRAM).lcf 214 $(RM) $(OBJDIR)/$(PROGRAM).map 215 $(RM) $(OBJDIR)/$(PROGRAM).exp 216 $(RM) $(OBJDIR)/$(PROGRAM).lib 217 $(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX) 218 $(RM) $(OBJDIR)/$(PROGRAM).ilk 219 $(RM) *.pdb 220 endif 221 222 223 clobber:: 224 $(RM) $(ACTUAL_PROGRAM) 225 226 # 227 # Now include make dependencies (created during compilation, see Rules.gmk) 228 # 229 ifeq ($(INCREMENTAL_BUILD),true) 230 # Workaround: gnumake sometimes says files is empty when it shouldn't 231 # was: files := $(foreach file, $(wildcard */$(ARCH)/*.$(DEPEND_SUFFIX)), $(file)) 232 files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null) 233 ifneq ($(strip $(files)),) 234 include $(files) 235 endif # files 236 endif # INCREMENTAL_BUILD 237 238 ifdef JAVA_ARGS 239 OTHER_CPPFLAGS += -DJAVA_ARGS='$(JAVA_ARGS)' 240 OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"' 241 endif 242 243 ifeq ($(PLATFORM), windows) 244 ifdef RELEASE 245 OTHER_CPPFLAGS += -DVERSION='"$(RELEASE)"' 246 endif 247 endif 248 249 250 ifneq ($(PLATFORM), windows) 251 HAVE_GETHRTIME=true 252 endif 253 254 ifeq ($(HAVE_GETHRTIME),true) 255 OTHER_CPPFLAGS += -DHAVE_GETHRTIME 256 endif 257 258 OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)/bin -I$(LAUNCHER_PLATFORM_SRC)/bin 259 OTHER_INCLUDES += -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3 260 261 OTHER_CPPFLAGS += -DPROGNAME='"$(PROGRAM)"' 262 VERSION_DEFINES += -DFULL_VERSION='"$(FULL_VERSION)"' 263 264 VERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \ 265 -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' 266 267 268 269 $(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c 270 @$(prep-target) 271 $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$(OBJDIR)/main.$(OBJECT_SUFFIX) \ 272 $(VERSION_DEFINES) $< 273 274 # 275 # How to install jvm.cfg. 276 # 277 ifeq ($(ZERO_BUILD), true) 278 JVMCFG_ARCH = zero 279 else 280 JVMCFG_ARCH = $(ARCH) 281 endif 282 283 $(JVMCFG): $(LAUNCHER_PLATFORM_SRC)/bin/$(JVMCFG_ARCH)/jvm.cfg 284 $(install-file) 285 286 # 287 # Default dependencies 288 # 289 290 all: build 291 292 build: program 293 294 debug: 295 $(MAKE) VARIANT=DBG build 296 297 fastdebug: 298 $(MAKE) VARIANT=DBG FASTDEBUG=true build 299 300 .PHONY: all build program clean clobber debug fastdebug