annotate make/common/Program.gmk @ 3767:54d8193f177b

7027910: Add basic cross-compilation support and add ARM/PPC to the known architectures in the open code Summary: Cross-compilation support Reviewed-by: ohair, andrew
author dholmes
date Wed, 16 Mar 2011 18:54:50 -0400
parents 6aeed99af874
children 272483f6650b 244b27bb14f8
rev   line source
duke@0 1 #
ohair@3261 2 # Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
duke@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 #
duke@0 5 # This code is free software; you can redistribute it and/or modify it
duke@0 6 # under the terms of the GNU General Public License version 2 only, as
ohair@2362 7 # published by the Free Software Foundation. Oracle designates this
duke@0 8 # particular file as subject to the "Classpath" exception as provided
ohair@2362 9 # by Oracle in the LICENSE file that accompanied this code.
duke@0 10 #
duke@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 14 # version 2 for more details (a copy is included in the LICENSE file that
duke@0 15 # accompanied this code).
duke@0 16 #
duke@0 17 # You should have received a copy of the GNU General Public License version
duke@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
duke@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 20 #
ohair@2362 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@2362 22 # or visit www.oracle.com if you need additional information or have any
ohair@2362 23 # questions.
duke@0 24 #
duke@0 25
duke@0 26 #
duke@0 27 # Generic makefile for building executables.
duke@0 28 #
duke@0 29
duke@0 30 # WARNING: This file is shared with other workspaces.
duke@0 31 # So when it includes other files, it must use JDK_TOPDIR.
duke@0 32 #
duke@0 33
duke@0 34 #
duke@0 35 # If building programs, use a normal compile approach
duke@0 36 #
duke@0 37 ifeq ($(COMPILE_APPROACH),batch)
duke@0 38 override COMPILE_APPROACH = normal
duke@0 39 endif
duke@0 40
duke@0 41 ifndef LAUNCHER_PLATFORM_SRC
duke@0 42 LAUNCHER_PLATFORM_SRC = $(PLATFORM_SRC)
duke@0 43 endif
duke@0 44
duke@0 45 ifndef LAUNCHER_SHARE_SRC
duke@0 46 LAUNCHER_SHARE_SRC = $(SHARE_SRC)
duke@0 47 endif
duke@0 48
duke@0 49 ACTUAL_PROGRAM_NAME = $(PROGRAM)$(EXE_SUFFIX)
duke@0 50 ACTUAL_PROGRAM_DIR = $(BINDIR)
duke@0 51 ACTUAL_PROGRAM = $(ACTUAL_PROGRAM_DIR)/$(ACTUAL_PROGRAM_NAME)
duke@0 52
duke@0 53 # Make sure the default rule is all
duke@0 54 program_default_rule: all
duke@0 55
duke@0 56 program: $(ACTUAL_PROGRAM)
duke@0 57
duke@0 58 include $(JDK_TOPDIR)/make/common/Rules.gmk
duke@0 59
duke@0 60 ifdef NEVER_ACT_AS_SERVER_CLASS_MACHINE
duke@0 61 OTHER_CPPFLAGS += -DNEVER_ACT_AS_SERVER_CLASS_MACHINE
duke@0 62 endif
duke@0 63
duke@0 64 #
duke@0 65 # Create a dependency on libjli (Java Launcher Infrastructure)
duke@0 66 #
duke@0 67 # On UNIX, this is a relative dependency using $ORIGIN. Unfortunately, to
duke@0 68 # do this reliably on Linux takes a different syntax than Solaris.
duke@0 69 #
duke@0 70 # On Windows, this is done by using the same directory as the executable
duke@0 71 # itself, as with all the Windows libraries.
duke@0 72 #
duke@0 73 ifneq (,$(findstring $(PLATFORM), linux solaris)) # UNIX systems
duke@0 74 LDFLAGS += -L $(LIBDIR)/$(LIBARCH)/jli
duke@0 75 OTHER_LDLIBS += -ljli
duke@0 76 ifeq ($(PLATFORM), solaris)
duke@0 77 ifeq ($(ARCH_DATA_MODEL), 32)
duke@0 78 LDFLAGS += -R \$$ORIGIN/../lib/$(LIBARCH)/jli
duke@0 79 LDFLAGS += -R \$$ORIGIN/../jre/lib/$(LIBARCH)/jli
duke@0 80 else
duke@0 81 LDFLAGS += -R \$$ORIGIN/../../lib/$(LIBARCH)/jli
duke@0 82 LDFLAGS += -R \$$ORIGIN/../../jre/lib/$(LIBARCH)/jli
duke@0 83 endif
duke@0 84 endif
duke@0 85 ifeq ($(PLATFORM), linux)
dholmes@3767 86 LDFLAGS += $(LDFLAG_Z_ORIGIN)
duke@0 87 LDFLAGS += -Wl,--allow-shlib-undefined
duke@0 88 LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)/jli
duke@0 89 LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)/jli
duke@0 90 endif
duke@0 91 endif
duke@0 92 ifeq ($(PLATFORM), windows)
duke@0 93 JLI_LCF = $(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/jli.lcf
duke@0 94 ifdef STATIC_JLI
duke@0 95 LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)/static
duke@0 96 else
duke@0 97 LDFLAGS += -libpath:$(OUTPUTDIR)/tmp/java/jli/$(OBJDIRNAME)
duke@0 98 endif
duke@0 99 OTHER_LDLIBS += jli.lib
duke@0 100 endif
duke@0 101
duke@0 102 #
duke@0 103 # Launcher specific files.
duke@0 104 #
duke@0 105 FILES_o = \
duke@0 106 $(OBJDIR)/main.$(OBJECT_SUFFIX)
duke@0 107
mchung@2080 108 $(ACTUAL_PROGRAM):: classes $(INIT)
duke@0 109
duke@0 110 #
duke@0 111 # Windows only
duke@0 112 #
duke@0 113 ifeq ($(PLATFORM), windows)
duke@0 114
herrick@1365 115 # JDK name required here
herrick@1365 116 RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
herrick@1365 117 /D "JDK_INTERNAL_NAME=$(PROGRAM)" \
herrick@1365 118 /D "JDK_FTYPE=0x1L"
duke@0 119
duke@0 120 $(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE)
duke@0 121 @$(prep-target)
duke@0 122 ifndef LOCAL_RESOURCE_FILE
duke@0 123 $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(@) $(VERSIONINFO_RESOURCE)
duke@0 124 endif
duke@0 125
duke@0 126 $(OBJDIR)/$(PROGRAM).lcf: $(OBJDIR)/$(PROGRAM).res $(FILES_o)
duke@0 127 @$(prep-target)
duke@0 128 @$(ECHO) $(FILES_o) > $@
duke@0 129 ifndef LOCAL_RESOURCE_FILE
duke@0 130 @$(ECHO) $(OBJDIR)/$(PROGRAM).res >> $@
duke@0 131 endif
duke@0 132 @$(ECHO) setargv.obj >> $@
duke@0 133 @$(ECHO) Created $@
duke@0 134
duke@0 135 $(ACTUAL_PROGRAM):: $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
duke@0 136 @$(install-file)
duke@0 137
duke@0 138 ifeq ($(ARCH_DATA_MODEL), 32)
duke@0 139 STACK_SIZE=327680
duke@0 140 else
duke@0 141 # We need more Stack for Windows 64bit
duke@0 142 STACK_SIZE=1048576
duke@0 143 endif
duke@0 144
prr@3356 145 IMVERSION=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
prr@3356 146 $(OBJDIR)/$(PROGRAM).exe.manifest: $(JDK_TOPDIR)/src/windows/resource/java.manifest
prr@3356 147 @$(prep-target)
prr@3356 148 $(SED) 's%IMVERSION%$(IMVERSION)%g;s%PROGRAM%$(PROGRAM)%g' $< > $@
prr@3356 149
prr@3356 150 # We used a hand-crafted manifest file for all executables.
prr@3356 151 # It is tweaked to embed the build number and executable name.
tbell@795 152 # Use ";#2" for .dll and ";#1" for .exe in the MT command below:
prr@3356 153 $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX):: $(OBJDIR)/$(PROGRAM).lcf $(FILES_o) $(JLI_LCF) $(OBJDIR)/$(PROGRAM).exe.manifest
duke@0 154 @$(prep-target)
duke@0 155 @set -- $?; \
duke@0 156 $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
duke@0 157 $(LINK) -out:$@ /STACK:$(STACK_SIZE) \
duke@0 158 -map:$(OBJDIR)/$(PROGRAM).map $(LFLAGS) $(LDFLAGS) \
duke@0 159 @$(OBJDIR)/$(PROGRAM).lcf $(LDLIBS)
tbell@795 160 ifdef MT
tbell@795 161 $(MT) /manifest $(OBJDIR)/$(PROGRAM).exe.manifest /outputresource:$@;#1
tbell@795 162 endif
ohair@3419 163 @$(call binary_file_verification,$@)
duke@0 164
duke@0 165 else # PLATFORM
duke@0 166
duke@0 167 #
duke@0 168 # Note that we have to link -lthread even when USE_PTHREADS is true.
duke@0 169 # This is becuase checkForCorrectLibthread() croaks otherwise.
duke@0 170 #
duke@0 171 LIBTHREAD = -lthread
duke@0 172 ifeq ($(USE_PTHREADS),true)
duke@0 173 THREADLIBS = -lpthread $(LIBTHREAD)
duke@0 174 else # USE_PTHREADS
duke@0 175 THREADLIBS = $(LIBTHREAD)
duke@0 176 endif # USE_PTHREADS
duke@0 177
duke@0 178 #
duke@0 179 # This rule only applies on unix. It supports quantify and its ilk.
duke@0 180 #
duke@0 181 $(ACTUAL_PROGRAM):: $(FILES_o)
duke@0 182 @$(prep-target)
duke@0 183 @set -- $?; \
duke@0 184 $(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
duke@0 185 @$(MKDIR) -p $(TEMPDIR)
duke@0 186 $(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
duke@0 187 $(FILES_o) $(THREADLIBS) $(LDLIBS)
ohair@3419 188 @$(call binary_file_verification,$@)
duke@0 189
duke@0 190 endif # PLATFORM
duke@0 191
duke@0 192 clean::
duke@0 193 ifeq ($(PLATFORM), windows)
duke@0 194 $(RM) $(OBJDIR)/$(PROGRAM).rc
duke@0 195 $(RM) $(OBJDIR)/$(PROGRAM).ico
duke@0 196 $(RM) $(OBJDIR)/$(PROGRAM).lcf
duke@0 197 $(RM) $(OBJDIR)/$(PROGRAM).map
duke@0 198 $(RM) $(OBJDIR)/$(PROGRAM).exp
duke@0 199 $(RM) $(OBJDIR)/$(PROGRAM).lib
duke@0 200 $(RM) $(OBJDIR)/$(PROGRAM)$(EXE_SUFFIX)
duke@0 201 $(RM) $(OBJDIR)/$(PROGRAM).ilk
duke@0 202 $(RM) *.pdb
duke@0 203 endif
duke@0 204
duke@0 205
duke@0 206 clobber::
duke@0 207 $(RM) $(ACTUAL_PROGRAM)
duke@0 208
duke@0 209 #
duke@0 210 # Now include make dependencies (created during compilation, see Rules.gmk)
duke@0 211 #
duke@0 212 ifeq ($(INCREMENTAL_BUILD),true)
duke@0 213 # Workaround: gnumake sometimes says files is empty when it shouldn't
duke@0 214 # was: files := $(foreach file, $(wildcard */$(ARCH)/*.$(DEPEND_SUFFIX)), $(file))
duke@0 215 files := $(shell $(LS) $(OBJDIR)/*.$(DEPEND_SUFFIX) 2>/dev/null)
duke@0 216 ifneq ($(strip $(files)),)
duke@0 217 include $(files)
duke@0 218 endif # files
duke@0 219 endif # INCREMENTAL_BUILD
duke@0 220
duke@0 221 ifdef JAVA_ARGS
ohair@1777 222 OTHER_CPPFLAGS += -DJAVA_ARGS='$(JAVA_ARGS)'
ohair@1777 223 OTHER_CPPFLAGS += -DLAUNCHER_NAME='"$(LAUNCHER_NAME)"'
duke@0 224 endif
duke@0 225
duke@0 226 ifeq ($(PLATFORM), windows)
duke@0 227 ifdef RELEASE
ohair@1777 228 OTHER_CPPFLAGS += -DVERSION='"$(RELEASE)"'
duke@0 229 endif
duke@0 230 endif
duke@0 231
duke@0 232
duke@0 233 ifneq ($(PLATFORM), windows)
duke@0 234 HAVE_GETHRTIME=true
duke@0 235 endif
duke@0 236
duke@0 237 ifeq ($(HAVE_GETHRTIME),true)
duke@0 238 OTHER_CPPFLAGS += -DHAVE_GETHRTIME
duke@0 239 endif
duke@0 240
duke@0 241 OTHER_INCLUDES += -I$(LAUNCHER_SHARE_SRC)/bin -I$(LAUNCHER_PLATFORM_SRC)/bin
duke@0 242 OTHER_INCLUDES += -I$(SHARE_SRC)/native/java/util/zip/zlib-1.1.3
duke@0 243
duke@0 244 OTHER_CPPFLAGS += -DPROGNAME='"$(PROGRAM)"'
duke@0 245 VERSION_DEFINES += -DFULL_VERSION='"$(FULL_VERSION)"'
duke@0 246
duke@0 247 VERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
duke@0 248 -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"'
duke@0 249
duke@0 250
duke@0 251
duke@0 252 $(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c
duke@0 253 @$(prep-target)
duke@0 254 $(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$(OBJDIR)/main.$(OBJECT_SUFFIX) \
duke@0 255 $(VERSION_DEFINES) $<
duke@0 256
duke@0 257 #
duke@0 258 # Default dependencies
duke@0 259 #
duke@0 260
duke@0 261 all: build
duke@0 262
duke@0 263 build: program
duke@0 264
duke@0 265 debug:
duke@0 266 $(MAKE) VARIANT=DBG build
duke@0 267
duke@0 268 fastdebug:
duke@0 269 $(MAKE) VARIANT=DBG FASTDEBUG=true build
duke@0 270
duke@0 271 .PHONY: all build program clean clobber debug fastdebug