1 #
   2 # Copyright (c) 2002, 2011, 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 BUILDDIR = ../..
  27 PACKAGE = sun.awt.X11
  28 LIBRARY = awt_xawt
  29 PRODUCT = sun
  30 
  31 include $(BUILDDIR)/common/Defs.gmk
  32 
  33 GEN_DIR=$(GENSRCDIR)/sun/awt/X11
  34 
  35 CLASSES_INIT += $(TEMPDIR)/.gen.wrappers $(TEMPDIR)/.gen_icons touch.wrappers
  36 
  37 .PHONY: generated.clean
  38 
  39 #
  40 # Files
  41 #
  42 include FILES_c_unix.gmk
  43 include FILES_export_unix.gmk
  44 AUTO_FILES_JAVA_DIRS = sun/awt/X11
  45 AUTO_JAVA_PRUNE = WrapperGenerator.java
  46 
  47 LDFLAGS += -L$(OPENWIN_LIB)
  48 
  49 # For Xrender extension.
  50 ifeq ($(PLATFORM), solaris)
  51 LDFLAGS += -L/usr/openwin/sfw/lib$(ISA_DIR) -R/usr/openwin/sfw/lib$(ISA_DIR)
  52 endif
  53 
  54 ifeq ($(PLATFORM), linux)
  55 LDFLAGS += -lpthread
  56 dummy := $(shell $(MKDIR) -p $(LIB_LOCATION))
  57 endif
  58 
  59 # Since this library will be living in a subdirectory below the other libraries
  60 #   we need to add an extra runpath so that libraries in the upper directory
  61 #   are found at runtime.
  62 LD_RUNPATH_EXTRAS = ..
  63 
  64 #
  65 # Rules.
  66 #
  67 include $(BUILDDIR)/common/Mapfile-vers.gmk
  68 include $(BUILDDIR)/common/Library.gmk
  69 
  70 #
  71 # Add to the ambient vpath to pick up files in subdirectories
  72 #
  73 vpath %.c   $(SHARE_SRC)/native/sunawt/alphacomposite
  74 vpath %.c   $(PLATFORM_SRC)/native/sun/xawt
  75 vpath %.c   $(PLATFORM_SRC)/native/sun/awt
  76 vpath %.c   $(SHARE_SRC)/native/sun/awt/debug
  77 vpath %.c   $(SHARE_SRC)/native/sun/awt/image
  78 vpath %.c   $(SHARE_SRC)/native/sun/awt/image/gif
  79 vpath %.c   $(SHARE_SRC)/native/sun/awt/image/cvutils
  80 vpath %.c   $(SHARE_SRC)/native/sun/awt/shell
  81 vpath %.c   $(SHARE_SRC)/native/sun/java2d
  82 vpath %.c   $(SHARE_SRC)/native/sun/java2d/loops
  83 vpath %.c   $(SHARE_SRC)/native/sun/java2d/pipe
  84 vpath %.c   $(SHARE_SRC)/native/sun/awt/medialib
  85 vpath %.c   $(SHARE_SRC)/native/sun/awt/utility
  86 vpath %.cpp $(SHARE_SRC)/native/sun/image
  87 vpath %.c   $(SHARE_SRC)/native/sun/font
  88 vpath %.c   $(PLATFORM_SRC)/native/sun/awt/robot_child
  89 vpath %.c   $(SHARE_SRC)/native/sun/java2d/opengl
  90 vpath %.c   $(PLATFORM_SRC)/native/sun/java2d/opengl
  91 vpath %.c   $(PLATFORM_SRC)/native/sun/java2d/x11
  92 
  93 OTHER_LDLIBS = $(LIBM) -lawt -lXext -lX11 -lXrender -ldl \
  94                    $(LDFLAGS_COMMON) $(AWT_RUNPATH) $(OTHER_LDFLAGS) -lXtst -lXi
  95 
  96 ifeq  ($(PLATFORM), solaris)
  97 CPPFLAGS += -DFUNCPROTO=15
  98 dummy := $(shell $(MKDIR) -p $(LIB_LOCATION))
  99 endif
 100 
 101 CPPFLAGS += -I$(CUPS_HEADERS_PATH)
 102 
 103 CPPFLAGS += -DXAWT -DXAWT_HACK \
 104         -I$(TEMPDIR)/../../sun.awt/awt/CClassHeaders \
 105         -I$(PLATFORM_SRC)/native/sun/awt \
 106         -I$(PLATFORM_SRC)/native/sun/xawt \
 107         -I$(PLATFORM_SRC)/native/sun/jdga \
 108         -I$(SHARE_SRC)/native/sun/awt/debug \
 109         -I$(SHARE_SRC)/native/sun/awt/image/cvutils \
 110         -I$(SHARE_SRC)/native/sun/java2d \
 111         -I$(SHARE_SRC)/native/sun/java2d/loops \
 112         -I$(SHARE_SRC)/native/sun/awt/image/cvutils \
 113         -I$(SHARE_SRC)/native/sun/awt/image \
 114         -I$(SHARE_SRC)/native/sun/font \
 115         -I$(PLATFORM_SRC)/native/sun/java2d \
 116         -I$(SHARE_SRC)/native/sun/java2d/pipe \
 117         -I$(SHARE_SRC)/native/sun/java2d/opengl \
 118         -I$(PLATFORM_SRC)/native/sun/java2d/opengl \
 119         -I$(PLATFORM_SRC)/native/sun/java2d/x11 \
 120         -I$(SHARE_SRC)/native/sun/dc/path \
 121         -I$(SHARE_SRC)/native/sun/dc/doe \
 122         -I$(SHARE_SRC)/native/sun/awt/alphacomposite \
 123         -I$(SHARE_SRC)/native/sun/awt/medialib \
 124         -I$(PLATFORM_SRC)/native/sun/awt/medialib \
 125         -I$(PLATFORM_SRC)/native/sun/font \
 126         -I$(SHARE_SRC)/native/sun/awt \
 127         -I$(PLATFORM_SRC)/native/sun/awt
 128 
 129 ifeq ($(PLATFORM), linux)
 130   ifndef CROSS_COMPILE_ARCH
 131     # Allows for builds on Debian GNU Linux, X11 is in a different place 
 132     # This should really be handled at a higher-level so we don't have to
 133     # work-around this when cross-compiling
 134     CPPFLAGS += -I/usr/X11R6/include/X11/extensions \
 135                 -I/usr/include/X11/extensions \
 136                 -I$(OPENWIN_HOME)/include 
 137   else
 138     CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions \
 139                 -I$(OPENWIN_HOME)/include 
 140   endif
 141 endif
 142 
 143 # We have some odd logic here because some Solaris 10 updates
 144 # have a render.h file that suggests gradients are supported, but
 145 # the Xrender.h doesn't have the corresponding type definitions.
 146 # Earlier updates have neither. We'd like to know if there's a mismatch.
 147 # Whilst in the C preprocessor we can tell if the render.h define's are set
 148 # we can't tell anything about C declarations.
 149 # A grep of Xrender.h is the only way to know this. If they are absent
 150 # we will set a flag indicating this mismatch and the JDK source file
 151 # will interpret it to resolve the problem.
 152 ifeq ($(PLATFORM), solaris)
 153   CPPFLAGS += -I$(OPENWIN_HOME)/include/X11/extensions
 154   OS_VERSION := $(shell uname -r)
 155   XRENDER_H := $(OPENWIN_HOME)/share/include/X11/extensions/Xrender.h
 156   ifeq ($(OS_VERSION),5.10) 
 157      LINEARGRADIENT_CNT := $(shell $(EGREP) -c XLinearGradient $(XRENDER_H))
 158      ifeq ($(LINEARGRADIENT_CNT),0) 
 159        CFLAGS+= -DSOLARIS10_NO_XRENDER_STRUCTS
 160      endif
 161  endif
 162 endif
 163 
 164 ifeq ($(MILESTONE), internal)
 165   CPPFLAGS += -DINTERNAL_BUILD
 166 endif
 167 
 168 #
 169 # Generation of wrappers
 170 #
 171 SIZER_DIR=$(GEN_DIR)/generator
 172 SIZER = $(SIZER_DIR)/sizer
 173 SIZER_32_C = $(SIZER).32.c
 174 SIZER_64_C = $(SIZER).64.c
 175 CFLAGS_32=$(CFLAGS)
 176 CFLAGS_64=$(CFLAGS)
 177 
 178 ifeq ($(PLATFORM), solaris)
 179 
 180 isalist:=$(shell $(ISAINFO))
 181 
 182 ifneq (,$(findstring sparcv9, $(isalist)))
 183 # On sparcv9 we generate both 32 and 64-bit sizers in spite of ARCH_DATA_MODEL.
 184 # On sparcv9 CFLAGS already contain $(XARCH_OPTION/64), so to generate 32-bit sizer we need to change this option.
 185 CFLAGS_32=$(subst $(XARCH_OPTION/64),$(XARCH_OPTION/32),$(CFLAGS))
 186 SIZERS = $(SIZER).32 $(SIZER).64
 187 SIZERS_C = $(SIZER_32_C) $(SIZER_64_C)
 188 SIZES = $(WRAPPER_GENERATOR_DIR)/sizes.32 $(WRAPPER_GENERATOR_DIR)/sizes.64
 189 CFLAGS_64=$(CFLAGS) $(XARCH_OPTION/64)
 190 else
 191 ifneq (,$(findstring amd64, $(isalist)))
 192 # On amd64 we generate both 32 and 64-bit sizers in spite of ARCH_DATA_MODEL.
 193 # On amd64 CFLAGS already contain $(XARCH_OPTION/64), so to generate 32-bit sizer we need to change this option.
 194 CFLAGS_32=$(subst $(XARCH_OPTION/64),$(XARCH_OPTION/32),$(CFLAGS))
 195 SIZERS = $(SIZER).32 $(SIZER).64
 196 SIZERS_C = $(SIZER_32_C) $(SIZER_64_C)
 197 SIZES = $(WRAPPER_GENERATOR_DIR)/sizes.32 $(WRAPPER_GENERATOR_DIR)/sizes.64
 198 CFLAGS_64=$(CFLAGS) $(XARCH_OPTION/64)
 199 else # !sparcv9 : includes (32-bit) sparc, i586
 200 SIZERS = $(SIZER).32
 201 SIZERS_C = $(SIZER_32_C)
 202 SIZES = $(WRAPPER_GENERATOR_DIR)/sizes.32
 203 endif # amd64
 204 endif # sparcv9
 205 
 206 else # !solaris
 207 
 208 ifeq ($(ARCH_DATA_MODEL), 32)
 209 SIZERS = $(SIZER).32
 210 SIZERS_C = $(SIZER_32_C)
 211 SIZES = $(WRAPPER_GENERATOR_DIR)/sizes.32
 212 else # !32
 213 SIZERS = $(SIZER).64
 214 SIZERS_C = $(SIZER_64_C)
 215 SIZES = $(WRAPPER_GENERATOR_DIR)/sizes.64
 216 endif # 32
 217 
 218 endif # solaris
 219 
 220 # XXX Hack for 6185483 - use hard-coded sizes.
 221 # Add the 64-bit platforms that need to be included into 32-bit build
 222 # and have sizes.64-$(PLATFORM)-$(LIBARCH) hardcoded in the workspace
 223 ifeq ($(PLATFORM)-$(LIBARCH), solaris-i386)
 224 # If you define DOHACK=true for some combination of $(PLATFORM)-$(LIBARCH),
 225 # make sure you have sizes.64-$(PLATFORM)-$(LIBARCH) pre-generated in
 226 # $(PLATFORM_SRC)/classes/sun/awt/X11/generator/
 227 DOHACK=true
 228 endif # Hack
 229 
 230 ifeq ($(DOHACK), true)
 231 PREDEFINED_SIZES_TMPL=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/sizes.64-$(PLATFORM)-$(LIBARCH)
 232 PREDEFINED_SIZES=$(WRAPPER_GENERATOR_DIR)/sizes.64
 233 SIZES += $(WRAPPER_GENERATOR_DIR)/sizes.64
 234 endif
 235 
 236 ifeq ($(PLATFORM)-$(LIBARCH), solaris-amd64)
 237 DOCOMPARE=true
 238 endif
 239 # 64 bit sizers are generated on platform-libarch (left) for use 
 240 # on platform-libarch (right) and stored under the latter name.
 241 # Do compare manually stored and automatically generated pair(s) 
 242 # if DOCOMPARE=true, just after the generation.
 243 STORED_SIZES_TMPL_solaris_amd64=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/sizes.64-solaris-i386
 244 
 245 WRAPPER_GENERATOR_JAVA=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/WrapperGenerator.java
 246 WRAPPER_GENERATOR_DIR=$(GENSRCDIR)/sun/awt/X11/generator
 247 WRAPPER_GENERATOR_TEMPDIR=$(TEMPDIR)/sun/awt/X11/generator
 248 WRAPPER_GENERATOR_CLASS=$(WRAPPER_GENERATOR_TEMPDIR)/WrapperGenerator.class 
 249 XLIBTYPES=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/xlibtypes.txt
 250 
 251 $(SIZERS): $(SIZERS_C) 
 252         $(prep-target)
 253 ifndef CROSS_COMPILE_ARCH
 254         $(CC) $(CFLAGS_$(subst .,,$(suffix $@))) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
 255 else
 256         $(HOST_CC) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).c
 257 endif
 258 
 259 $(WRAPPER_GENERATOR_CLASS): $(WRAPPER_GENERATOR_JAVA)
 260         $(prep-target)
 261         $(BOOT_JAVAC_CMD) -d $(WRAPPER_GENERATOR_TEMPDIR) $(WRAPPER_GENERATOR_JAVA)
 262 
 263 $(SIZERS_C): $(WRAPPER_GENERATOR_CLASS) $(XLIBTYPES)
 264         $(prep-target)
 265         $(MKDIR) -p $(WRAPPER_GENERATOR_TEMPDIR)
 266         $(BOOT_JAVA_CMD) -cp $(WRAPPER_GENERATOR_TEMPDIR) WrapperGenerator \
 267             $(SIZER_DIR) $(XLIBTYPES) "sizer" $(subst .,,$(suffix $(basename $@)))
 268 
 269 $(SIZES): $(SIZERS)
 270         @if [ "$(DOHACK)$@" = "true$(PREDEFINED_SIZES)" ]; then \
 271             $(ECHO) COPYING $(PREDEFINED_SIZES_TMPL) into $@; \
 272             $(CP) $(PREDEFINED_SIZES_TMPL) $@; \
 273             $(CHMOD) +w $@;\
 274         else    \
 275             $(ECHO) GENERATING $@; \
 276             $(WRAPPER_GENERATOR_DIR)/sizer$(suffix $@) > $@; \
 277         fi
 278         @if [ "$(DOCOMPARE)$(suffix $@)" = "true.64" ]; then \
 279             $(ECHO) COMPARING $@ and $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
 280             $(DIFF) $@ $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
 281         fi
 282 
 283 $(TEMPDIR)/.gen.wrappers: $(SIZES) $(WRAPPER_GENERATOR_CLASS) $(XLIBTYPES)
 284         $(BOOT_JAVA_CMD) -cp $(WRAPPER_GENERATOR_TEMPDIR) WrapperGenerator \
 285             $(GEN_DIR) $(XLIBTYPES) "gen" $(WRAPPER_GENERATOR_DIR)/sizes
 286 
 287 touch.wrappers: $(TEMPDIR)/.gen.wrappers
 288         $(MKDIR) -p $(TEMPDIR)
 289         $(TOUCH) $(TEMPDIR)/.gen.wrappers
 290 
 291 generated.clean:
 292         $(RM) -r $(WRAPPER_GENERATOR_TEMPDIR)
 293         $(RM) -r $(WRAPPER_GENERATOR_DIR)
 294         $(RM) -r $(GEN_DIR)/*.java
 295         $(RM) -r $(TEMPDIR)/.gen_icons
 296 
 297 ifdef OPENJDK
 298     ICONS_PATH_PREFIX=$(PLATFORM_SRC)
 299 else
 300     ICONS_PATH_PREFIX=$(CLOSED_SRC)/solaris
 301 endif
 302 
 303 ICONS = \
 304     $(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon16.png \
 305     $(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon24.png \
 306     $(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon32.png \
 307     $(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon48.png
 308 
 309 
 310 ICONPATH=$(PLATFORM_SRC)/classes/sun/awt/X11
 311 
 312 ICONS += \
 313    $(ICONPATH)/security-icon-bw16.png \
 314    $(ICONPATH)/security-icon-interim16.png \
 315    $(ICONPATH)/security-icon-yellow16.png \
 316    $(ICONPATH)/security-icon-bw24.png \
 317    $(ICONPATH)/security-icon-interim24.png \
 318    $(ICONPATH)/security-icon-yellow24.png \
 319    $(ICONPATH)/security-icon-bw32.png \
 320    $(ICONPATH)/security-icon-interim32.png \
 321    $(ICONPATH)/security-icon-yellow32.png \
 322    $(ICONPATH)/security-icon-bw48.png \
 323    $(ICONPATH)/security-icon-interim48.png \
 324    $(ICONPATH)/security-icon-yellow48.png
 325 
 326 TEMPDIR_CLASSES = $(TEMPDIR)/classes
 327 
 328 $(TEMPDIR_CLASSES)/sun/awt/X11/ToBin.class: ToBin.java
 329         @$(prep-target)
 330         $(BOOT_JAVAC_CMD) -d $(TEMPDIR_CLASSES) $<
 331 
 332 $(TEMPDIR)/.gen_icons: $(TEMPDIR_CLASSES)/sun/awt/X11/ToBin.class $(ICONS)
 333         $(prep-target)
 334         for i in $(ICONS); do \
 335             filename=`basename $$i`; \
 336             name=`$(ECHO) $$filename | $(TR) '\-.' '__'`;  \
 337             classname=$(GEN_DIR)/XAWTIcon32_$$name.java; \
 338             $(RM) $$classname; \
 339             $(ECHO) "package sun.awt.X11;" >> $$classname ; \
 340             $(ECHO) "public class XAWTIcon32_$$name {" >> $$classname; \
 341             $(ECHO) "public static int[] $$name = { " >> $$classname;  \
 342             $(CAT) $$i | \
 343               $(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES)  \
 344                 -Djava.awt.headless=true \
 345                 sun.awt.X11.ToBin >> $$classname; \
 346             $(ECHO) "}; }" >> $$classname;  \
 347             classname=$(GEN_DIR)/XAWTIcon64_$$name.java; \
 348             $(RM) $$classname; \
 349             $(ECHO) "package sun.awt.X11;" >> $$classname ; \
 350             $(ECHO) "public class XAWTIcon64_$$name {" >> $$classname; \
 351             $(ECHO) "public static long[] $$name = { " >> $$classname;  \
 352             $(CAT) $$i | \
 353               $(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES)  \
 354                 -Djava.awt.headless=true \
 355                 sun.awt.X11.ToBin >> $$classname; \
 356             $(ECHO) "}; }" >> $$classname;  \
 357         done
 358         $(TOUCH) $@
 359 
 360 clean clobber:: generated.clean
 361 
 362 .PHONY: generated.clean robot_child
 363