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 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 else # !32
 229 SIZERS = $(SIZER).64
 230 SIZERS_C = $(SIZER_64_C)
 231 SIZES = $(WRAPPER_GENERATOR_DIR)/sizes.64
 232 endif # 32
 233 endif # !macosx
 234 endif # solaris
 235 
 236 # XXX Hack for 6185483 - use hard-coded sizes.
 237 # Add the 64-bit platforms that need to be included into 32-bit build
 238 # and have sizes.64-$(PLATFORM)-$(LIBARCH) hardcoded in the workspace
 239 ifeq ($(PLATFORM)-$(LIBARCH), solaris-i386)
 240 # If you define DOHACK=true for some combination of $(PLATFORM)-$(LIBARCH),
 241 # make sure you have sizes.64-$(PLATFORM)-$(LIBARCH) pre-generated in
 242 # $(PLATFORM_SRC)/classes/sun/awt/X11/generator/
 243 DOHACK=true
 244 endif # Hack
 245 
 246 ifeq ($(DOHACK), true)
 247 PREDEFINED_SIZES_TMPL=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/sizes.64-$(PLATFORM)-$(LIBARCH)
 248 PREDEFINED_SIZES=$(WRAPPER_GENERATOR_DIR)/sizes.64
 249 SIZES += $(WRAPPER_GENERATOR_DIR)/sizes.64
 250 endif
 251 
 252 ifeq ($(PLATFORM)-$(LIBARCH), solaris-amd64)
 253 DOCOMPARE=true
 254 endif
 255 # 64 bit sizers are generated on platform-libarch (left) for use 
 256 # on platform-libarch (right) and stored under the latter name.
 257 # Do compare manually stored and automatically generated pair(s) 
 258 # if DOCOMPARE=true, just after the generation.
 259 STORED_SIZES_TMPL_solaris_amd64=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/sizes.64-solaris-i386
 260 
 261 WRAPPER_GENERATOR_JAVA=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/WrapperGenerator.java
 262 WRAPPER_GENERATOR_DIR=$(GENSRCDIR)/sun/awt/X11/generator
 263 WRAPPER_GENERATOR_TEMPDIR=$(TEMPDIR)/sun/awt/X11/generator
 264 WRAPPER_GENERATOR_CLASS=$(WRAPPER_GENERATOR_TEMPDIR)/WrapperGenerator.class 
 265 XLIBTYPES=$(PLATFORM_SRC)/classes/sun/awt/X11/generator/xlibtypes.txt
 266 
 267 $(SIZERS): $(SIZERS_C) 
 268         $(prep-target)
 269 ifndef CROSS_COMPILE_ARCH
 270         $(CC) $(CFLAGS_$(subst .,,$(suffix $@))) $(CPPFLAGS) -c -o $(SIZER)$(suffix $@).o $(SIZER)$(suffix $@).c
 271         $(CC) $(CFLAGS_$(subst .,,$(suffix $@))) -o $@ $(CPPFLAGS) $(SIZER)$(suffix $@).o
 272 else
 273         $(HOST_CC) $(CPPFLAGS) -c -o $(SIZER)$(suffix $@).o $(SIZER)$(suffix $@).c
 274         $(HOST_CC) $(CPPFLAGS) -o $@ $(SIZER)$(suffix $@).o
 275 endif
 276 
 277 $(WRAPPER_GENERATOR_CLASS): $(WRAPPER_GENERATOR_JAVA)
 278         $(prep-target)
 279         $(BOOT_JAVAC_CMD) -d $(WRAPPER_GENERATOR_TEMPDIR) $(WRAPPER_GENERATOR_JAVA)
 280 
 281 $(SIZERS_C): $(WRAPPER_GENERATOR_CLASS) $(XLIBTYPES)
 282         $(prep-target)
 283         $(MKDIR) -p $(WRAPPER_GENERATOR_TEMPDIR)
 284         $(BOOT_JAVA_CMD) -cp $(WRAPPER_GENERATOR_TEMPDIR) WrapperGenerator \
 285             $(SIZER_DIR) $(XLIBTYPES) "sizer" $(subst .,,$(suffix $(basename $@)))
 286 
 287 $(SIZES): $(SIZERS)
 288         @if [ "$(DOHACK)$@" = "true$(PREDEFINED_SIZES)" ]; then \
 289             $(ECHO) COPYING $(PREDEFINED_SIZES_TMPL) into $@; \
 290             $(CP) $(PREDEFINED_SIZES_TMPL) $@; \
 291             $(CHMOD) +w $@;\
 292         else    \
 293             $(ECHO) GENERATING $@; \
 294             $(WRAPPER_GENERATOR_DIR)/sizer$(suffix $@) > $@; \
 295         fi
 296         @if [ "$(DOCOMPARE)$(suffix $@)" = "true.64" ]; then \
 297             $(ECHO) COMPARING $@ and $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
 298             $(DIFF) $@ $(STORED_SIZES_TMPL_$(PLATFORM)_$(LIBARCH)); \
 299         fi
 300 
 301 $(TEMPDIR)/.gen.wrappers: $(SIZES) $(WRAPPER_GENERATOR_CLASS) $(XLIBTYPES)
 302         $(BOOT_JAVA_CMD) -cp $(WRAPPER_GENERATOR_TEMPDIR) WrapperGenerator \
 303             $(GEN_DIR) $(XLIBTYPES) "gen" $(WRAPPER_GENERATOR_DIR)/sizes
 304 
 305 touch.wrappers: $(TEMPDIR)/.gen.wrappers
 306         $(MKDIR) -p $(TEMPDIR)
 307         $(TOUCH) $(TEMPDIR)/.gen.wrappers
 308 
 309 generated.clean:
 310         $(RM) -r $(WRAPPER_GENERATOR_TEMPDIR)
 311         $(RM) -r $(WRAPPER_GENERATOR_DIR)
 312         $(RM) -r $(GEN_DIR)/*.java
 313         $(RM) -r $(TEMPDIR)/.gen_icons
 314 
 315 ifdef OPENJDK
 316     ICONS_PATH_PREFIX=$(PLATFORM_SRC)
 317 else
 318     ICONS_PATH_PREFIX=$(CLOSED_SRC)/solaris
 319 endif
 320 
 321 ICONS = \
 322     $(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon16.png \
 323     $(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon24.png \
 324     $(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon32.png \
 325     $(ICONS_PATH_PREFIX)/classes/sun/awt/X11/java-icon48.png
 326 
 327 
 328 ICONPATH=$(PLATFORM_SRC)/classes/sun/awt/X11
 329 
 330 ICONS += \
 331    $(ICONPATH)/security-icon-bw16.png \
 332    $(ICONPATH)/security-icon-interim16.png \
 333    $(ICONPATH)/security-icon-yellow16.png \
 334    $(ICONPATH)/security-icon-bw24.png \
 335    $(ICONPATH)/security-icon-interim24.png \
 336    $(ICONPATH)/security-icon-yellow24.png \
 337    $(ICONPATH)/security-icon-bw32.png \
 338    $(ICONPATH)/security-icon-interim32.png \
 339    $(ICONPATH)/security-icon-yellow32.png \
 340    $(ICONPATH)/security-icon-bw48.png \
 341    $(ICONPATH)/security-icon-interim48.png \
 342    $(ICONPATH)/security-icon-yellow48.png
 343 
 344 TEMPDIR_CLASSES = $(TEMPDIR)/classes
 345 
 346 $(TEMPDIR_CLASSES)/sun/awt/X11/ToBin.class: ToBin.java
 347         @$(prep-target)
 348         $(BOOT_JAVAC_CMD) -d $(TEMPDIR_CLASSES) $<
 349 
 350 $(TEMPDIR)/.gen_icons: $(TEMPDIR_CLASSES)/sun/awt/X11/ToBin.class $(ICONS)
 351         $(prep-target)
 352         for i in $(ICONS); do \
 353             filename=`basename $$i`; \
 354             name=`$(ECHO) $$filename | $(TR) '\-.' '__'`;  \
 355             classname=$(GEN_DIR)/XAWTIcon32_$$name.java; \
 356             $(RM) $$classname; \
 357             $(ECHO) "package sun.awt.X11;" >> $$classname ; \
 358             $(ECHO) "public class XAWTIcon32_$$name {" >> $$classname; \
 359             $(ECHO) "public static int[] $$name = { " >> $$classname;  \
 360             $(CAT) $$i | \
 361               $(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES)  \
 362                 -Djava.awt.headless=true \
 363                 sun.awt.X11.ToBin >> $$classname; \
 364             $(ECHO) "}; }" >> $$classname;  \
 365             classname=$(GEN_DIR)/XAWTIcon64_$$name.java; \
 366             $(RM) $$classname; \
 367             $(ECHO) "package sun.awt.X11;" >> $$classname ; \
 368             $(ECHO) "public class XAWTIcon64_$$name {" >> $$classname; \
 369             $(ECHO) "public static long[] $$name = { " >> $$classname;  \
 370             $(CAT) $$i | \
 371               $(BOOT_JAVA_CMD) -cp $(TEMPDIR_CLASSES)  \
 372                 -Djava.awt.headless=true \
 373                 sun.awt.X11.ToBin >> $$classname; \
 374             $(ECHO) "}; }" >> $$classname;  \
 375         done
 376         $(TOUCH) $@
 377 
 378 clean clobber:: generated.clean
 379 
 380 .PHONY: generated.clean robot_child
 381