jdk/makefiles/GensrcX11Wrappers.gmk
changeset 15149 64054e252871
parent 15126 bceb690ccf35
child 17046 72254abdba83
equal deleted inserted replaced
15148:7dc6d15b4380 15149:64054e252871
    21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    22 # or visit www.oracle.com if you need additional information or have any
    23 # questions.
    23 # questions.
    24 #
    24 #
    25 
    25 
       
    26 # This file is responsible for extracting the x11 native struct offsets to
       
    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.
    26 
    29 
    27 # This file is responsible for extracting the x11 native struct offsets to
    30 # To enable cross compiling, the two versions of the generated offset file,
    28 # the xawt Java library. This is done by compiling and running a native
    31 # sizes.32 and sizes.64 are committed into the source code repository.
    29 # binary, which dumps output to a text file. The offsets differ on 32 and 64
    32 # These are the ones used.
    30 # bit systems, so care must be taken here.
       
    31 
    33 
    32 # Note: Some of the more complex logic here is most likely not needed anymore.
    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.
    33 
    36 
    34 GENSRC_X11WRAPPERS :=
    37 GENSRC_X11WRAPPERS :=
       
    38 # Put temporary c-code and executable to calculate offsets here.
       
    39 # Also put verification offset file here as well.
    35 GENSRC_X11WRAPPERS_TMP := $(JDK_OUTPUTDIR)/gensrc_x11wrappers
    40 GENSRC_X11WRAPPERS_TMP := $(JDK_OUTPUTDIR)/gensrc_x11wrappers
    36 GENSRC_X11WRAPPERS_DST := $(JDK_OUTPUTDIR)/gensrc
    41 # Put the generated Java classes used to interface X11 from awt here.
       
    42 GENSRC_X11WRAPPERS_DST := $(JDK_OUTPUTDIR)/gensrc/sun/awt/X11
    37 
    43 
    38 GENSRC_SIZER_SRC := $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator
    44 # The pre-calculated offset file are stored here:
       
    45 GENSRC_SIZER_DIR := $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator
    39 
    46 
    40 # Normal case is to generate version according to target bits
    47 # Normal case is to generate only according to target bits
    41 GENSRC_SIZES := sizes.$(OPENJDK_TARGET_CPU_BITS)
    48 GENSRC_X11_VERSION := $(OPENJDK_TARGET_CPU_BITS)
    42 
       
    43 ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
    49 ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
    44 ifneq ($(OPENJDK_TARGET_OS), linux)
    50   ifneq ($(OPENJDK_TARGET_OS), linux)
    45 # On all 64-bit systems except Linux, generate both 32 and 64 bit versions
    51   # On all 64-bit systems except Linux, generate both 32 and 64 bit versions
    46 GENSRC_SIZES := sizes.32 sizes.64
    52   GENSRC_X11_VERSION := 32 64
    47 endif
    53   endif
    48 else
    54 else
    49 ifeq ($(OPENJDK_TARGET_OS), solaris)
    55   ifeq ($(OPENJDK_TARGET_OS), solaris)
    50 # As a special case, solaris 32-bit also generates the 64-bit version
    56   # As a special case, solaris 32-bit also generates the 64-bit version
    51 GENSRC_SIZES := sizes.32 sizes.64
    57   GENSRC_X11_VERSION := 32 64
    52 endif
    58   endif
    53 endif
    59 endif
    54 
    60 
    55 ##########################################################################################
    61 GENSRC_X11_SIZES_USED := $(addprefix $(GENSRC_X11WRAPPERS_TMP)/sizes.,$(GENSRC_X11_VERSION))
    56 
    62 
    57 $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.c : $(GENSRC_SIZER_SRC)/xlibtypes.txt $(BUILD_TOOLS)
    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)
    58 	$(ECHO) "Generating X11 wrapper ($*-bit version)"
    85 	$(ECHO) "Generating X11 wrapper ($*-bit version)"
    59 	$(MKDIR) -p $(@D)
    86 	$(MKDIR) -p $(@D)
    60 	$(RM) $@
    87 	$(TOOL_WRAPPERGENERATOR) $(@D) $(GENSRC_SIZER_DIR)/xlibtypes.txt "sizer" $*
    61 	$(TOOL_WRAPPERGENERATOR) $(@D) $< "sizer" $*
       
    62 
    88 
    63 $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.exe : $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.c
    89     # Compile the C code into an executable.
       
    90     $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe : $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c
    64 	$(MKDIR) -p $(@D)
    91 	$(MKDIR) -p $(@D)
    65 	$(RM) $@ $@.tmp
    92 	(cd $(@D) && $(CC) -m$* -o $@ $< \
    66 	(cd $(@D) && $(BUILD_CC) -m$* -o $@.tmp $< \
       
    67               $(X_CFLAGS) \
    93               $(X_CFLAGS) \
    68               $(X_LIBS) \
    94               $(X_LIBS) \
    69               -I$(JDK_OUTPUTDIR)/include \
    95               -I$(JDK_OUTPUTDIR)/include \
    70               -I$(JDK_TOPDIR)/src/share/javavm/export \
    96               -I$(JDK_TOPDIR)/src/share/javavm/export \
    71               -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \
    97               -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/javavm/export \
    72               -I$(JDK_TOPDIR)//src/share/native/common \
    98               -I$(JDK_TOPDIR)/src/share/native/common \
    73               -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \
    99               -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/common \
    74               -I$(JDK_TOPDIR)/src/solaris/native/sun/awt \
   100               -I$(JDK_TOPDIR)/src/solaris/native/sun/awt \
    75 	      -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
   101 	      -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
    76 	      -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils -lc)
   102 	      -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils -lc)
    77 	$(MV) $@.tmp $@
       
    78 
   103 
    79 # Run the generated sizer binary to create the sizes text file
   104     .PRECIOUS: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c
    80 $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.% : $(GENSRC_X11WRAPPERS_TMP)/sizer/sizer.%.exe
   105 
       
   106     # Run the executable create the offset file and check that it is identical
       
   107     # to the offset file in the source code repository.
       
   108     $(GENSRC_X11WRAPPERS_TMP)/sizes.%.verification : $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe
    81 	$(MKDIR) -p $(@D)
   109 	$(MKDIR) -p $(@D)
    82 	$(RM) $@ $@.tmp
   110 	$(GENSRC_X11WRAPPERS_TMP)/sizer.$*.exe | $(SORT) > $@.tmp
    83 	$< > $@.tmp
   111 	$(ECHO) Verifying $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp to $(GENSRC_X11WRAPPERS_TMP)/sizes.$*
    84 	$(MV) $@.tmp $@
   112 	$(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp $(GENSRC_X11WRAPPERS_TMP)/sizes.$*
       
   113 	mv $@.tmp $@
    85 
   114 
    86 ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-x86)
   115     GENSRC_X11WRAPPERS += $(GENSRC_X11WRAPPERS_TMP)/sizes.$(OPENJDK_TARGET_CPU_BITS).verification
    87   # On solaris-x86 we also need to create the 64-bit version, but we can't run a 64-bit binary
       
    88   # As a workaround, copy this from a pre-generated file.
       
    89 $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 : $(JDK_TOPDIR)/src/solaris/classes/sun/awt/X11/generator/sizes.64-solaris-i386
       
    90 	$(MKDIR) -p $(@D)
       
    91 	$(RM) $@
       
    92 	$(CP) $< $@
       
    93 endif
   116 endif
    94 
   117 
    95 $(GENSRC_X11WRAPPERS_DST)/_the.generated.x11 : $(foreach S,$(GENSRC_SIZES),$(GENSRC_X11WRAPPERS_TMP)/sizer/$(S)) $(BUILD_TOOLS)
       
    96 	$(RM) $@
       
    97 	$(MKDIR) -p $(@D)/sun/awt/X11
       
    98 	$(TOOL_WRAPPERGENERATOR) $(@D)/sun/awt/X11 $(GENSRC_SIZER_SRC)/xlibtypes.txt "gen" $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes
       
    99 ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), solaris-x86_64)
       
   100   # On solaris-x86_64, as a safety measure, compare the generated file with the checked-in version 
       
   101 	$(ECHO) COMPARING $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 and $(GENSRC_SIZER_SRC)/sizes.64-solaris-i386
       
   102 	$(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizer/sizes.64 $(GENSRC_SIZER_SRC)/sizes.64-solaris-i386
       
   103 endif
       
   104 	$(TOUCH) $@
       
   105 
       
   106 GENSRC_X11WRAPPERS += $(GENSRC_X11WRAPPERS_DST)/_the.generated.x11