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