erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2012, 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 | |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 26 | # This file is responsible for extracting the x11 native struct offsets to |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 27 | # the xawt Java library. The tool needs to be run on the os/arch that |
| 28 | # will host the final jvm, thus the tool cannot be used when cross compiling. |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 29 | |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 30 | # To enable cross compiling, the two versions of the generated offset file, |
| 31 | # sizes.32 and sizes.64 are committed into the source code repository. |
| 32 | # These are the ones used. |
| 33 | |
| 34 | # However when not cross compiling, the offset generator tool is built and |
| 35 | # run, to verify that it still generates the same sizes.32 and sizes.64. |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 36 | |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 37 | GENSRC_X11WRAPPERS := |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 38 | # Put temporary c-code and executable to calculate offsets here. |
| 39 | # Also put verification offset file here as well. |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 40 | GENSRC_X11WRAPPERS_TMP := $(JDK_OUTPUTDIR)/gensrc_x11wrappers |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 41 | # Put the generated Java classes used to interface X11 from awt here. |
| 42 | GENSRC_X11WRAPPERS_DST := $(JDK_OUTPUTDIR)/gensrc/sun/awt/X11 |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 43 | |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 44 | # The pre-calculated offset file are stored here: |
| 45 | GENSRC_SIZER_DIR := $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 46 | |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 47 | # Normal case is to generate only according to target bits |
| 48 | GENSRC_X11_VERSION := $(OPENJDK_TARGET_CPU_BITS) |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 49 | ifeq ($(OPENJDK_TARGET_CPU_BITS), 64) |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 50 | ifneq ($(OPENJDK_TARGET_OS), linux) |
| 51 | # On all 64-bit systems except Linux, generate both 32 and 64 bit versions |
| 52 | GENSRC_X11_VERSION := 32 64 |
| 53 | endif |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 54 | else |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 55 | ifeq ($(OPENJDK_TARGET_OS), solaris) |
| 56 | # As a special case, solaris 32-bit also generates the 64-bit version |
| 57 | GENSRC_X11_VERSION := 32 64 |
| 58 | endif |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 59 | endif |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 60 | |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 61 | GENSRC_X11_SIZES_USED := $(addprefix $(GENSRC_X11WRAPPERS_TMP)/sizes.,$(GENSRC_X11_VERSION)) |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 62 | |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 63 | # Copy only the sizes.* files that are actually needed. WrapperGenerator picks up any it finds from the |
| 64 | # file prefix it is given so those not needed need to be hidden. |
| 65 | $(GENSRC_X11WRAPPERS_TMP)/sizes.%: $(GENSRC_SIZER_DIR)/sizes.% |
| 66 | $(MKDIR) -p $(@D) |
| 67 | $(RM) '$@' |
| 68 | $(SORT) $< > $@ |
| 69 | |
| 70 | # Run the tool on the offset files copied from the source repository to generate several Java classes |
| 71 | # used in awt. |
| 72 | $(JDK_OUTPUTDIR)/gensrc/_the.generated.x11 : $(GENSRC_X11_SIZES_USED) $(BUILD_TOOLS) |
| 73 | $(MKDIR) -p $(GENSRC_X11WRAPPERS_DST) |
| 74 | $(TOOL_WRAPPERGENERATOR) $(GENSRC_X11WRAPPERS_DST) $(GENSRC_SIZER_DIR)/xlibtypes.txt "gen" $(GENSRC_X11WRAPPERS_TMP)/sizes |
| 75 | $(TOUCH) $@ |
| 76 | |
| 77 | GENSRC_X11WRAPPERS += $(JDK_OUTPUTDIR)/gensrc/_the.generated.x11 |
| 78 | |
| 79 | ifneq ($(COMPILE_TYPE),cross) |
| 80 | # This is not a cross compile, regenerate the offset file, so that we |
| 81 | # can compare it with the version in the source code repository. |
| 82 | |
| 83 | # Generate the C code for the program that will output the offset file. |
| 84 | $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c : $(GENSRC_SIZER_DIR)/xlibtypes.txt $(BUILD_TOOLS) |
ohair | b71409c | 2012-10-26 14:23:29 -0700 | [diff] [blame] | 85 | $(ECHO) "Generating X11 wrapper ($*-bit version)" |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 86 | $(MKDIR) -p $(@D) |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 87 | $(TOOL_WRAPPERGENERATOR) $(@D) $(GENSRC_SIZER_DIR)/xlibtypes.txt "sizer" $* |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 88 | |
omajid | 90c7a10 | 2013-04-29 12:34:53 -0400 | [diff] [blame] | 89 | # use -m32/-m64 only if the compiler supports it |
| 90 | ifeq ($(COMPILER_SUPPORTS_TARGET_BITS_FLAG),true) |
| 91 | MEMORY_MODEL_FLAG="-m$*" |
| 92 | endif |
| 93 | |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 94 | # Compile the C code into an executable. |
| 95 | $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe : $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 96 | $(MKDIR) -p $(@D) |
omajid | 90c7a10 | 2013-04-29 12:34:53 -0400 | [diff] [blame] | 97 | (cd $(@D) && $(CC) $(MEMORY_MODEL_FLAG) -o $@ $< \ |
ohrstrom | 5048dab | 2012-10-29 13:41:38 -0700 | [diff] [blame] | 98 | $(X_CFLAGS) \ |
| 99 | $(X_LIBS) \ |
erikj | af85fc4 | 2012-07-03 16:10:44 -0700 | [diff] [blame] | 100 | -I$(JDK_OUTPUTDIR)/include \ |
| 101 | -I$(JDK_TOPDIR)/src/share/javavm/export \ |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 102 | -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \ |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 103 | -I$(JDK_TOPDIR)/src/share/native/common \ |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 104 | -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \ |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 105 | -I$(JDK_TOPDIR)/src/solaris/native/sun/awt \ |
| 106 | -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \ |
| 107 | -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils -lc) |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 108 | |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 109 | .PRECIOUS: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 110 | |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 111 | # Run the executable create the offset file and check that it is identical |
| 112 | # to the offset file in the source code repository. |
| 113 | $(GENSRC_X11WRAPPERS_TMP)/sizes.%.verification : $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe |
ohair | 46fcac9 | 2012-09-18 11:29:24 -0700 | [diff] [blame] | 114 | $(MKDIR) -p $(@D) |
erikj | 1d2bbde | 2013-01-22 09:01:35 +0100 | [diff] [blame] | 115 | $(GENSRC_X11WRAPPERS_TMP)/sizer.$*.exe | $(SORT) > $@.tmp |
| 116 | $(ECHO) Verifying $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp to $(GENSRC_X11WRAPPERS_TMP)/sizes.$* |
| 117 | $(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp $(GENSRC_X11WRAPPERS_TMP)/sizes.$* |
| 118 | mv $@.tmp $@ |
| 119 | |
| 120 | GENSRC_X11WRAPPERS += $(GENSRC_X11WRAPPERS_TMP)/sizes.$(OPENJDK_TARGET_CPU_BITS).verification |
erikj | e78df74 | 2012-06-07 20:40:50 -0700 | [diff] [blame] | 121 | endif |
| 122 | |