lib-x11.m4 revision 1674:a7ec2278c13d
1139735Simp#
2129198Scognet# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
3129198Scognet# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4129198Scognet#
5129198Scognet# This code is free software; you can redistribute it and/or modify it
6129198Scognet# under the terms of the GNU General Public License version 2 only, as
7129198Scognet# published by the Free Software Foundation.  Oracle designates this
8129198Scognet# particular file as subject to the "Classpath" exception as provided
9129198Scognet# by Oracle in the LICENSE file that accompanied this code.
10129198Scognet#
11129198Scognet# This code is distributed in the hope that it will be useful, but WITHOUT
12129198Scognet# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13129198Scognet# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14129198Scognet# version 2 for more details (a copy is included in the LICENSE file that
15182934Sraj# accompanied this code).
16129198Scognet#
17129198Scognet# You should have received a copy of the GNU General Public License version
18129198Scognet# 2 along with this work; if not, write to the Free Software Foundation,
19129198Scognet# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20129198Scognet#
21129198Scognet# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22129198Scognet# or visit www.oracle.com if you need additional information or have any
23129198Scognet# questions.
24129198Scognet#
25129198Scognet
26129198Scognet################################################################################
27129198Scognet# Setup X11 Windows system
28129198Scognet################################################################################
29129198ScognetAC_DEFUN_ONCE([LIB_SETUP_X11],
30129198Scognet[
31129198Scognet  if test "x$NEEDS_LIB_X11" = xfalse; then
32129198Scognet    if test "x${with_x}" != x; then
33129198Scognet      AC_MSG_WARN([X11 is not used, so --with-x is ignored])
34129198Scognet    fi
35129198Scognet    X_CFLAGS=
36129198Scognet    X_LIBS=
37129198Scognet  else
38129198Scognet
39129198Scognet    if test "x${with_x}" = xno; then
40129198Scognet      AC_MSG_ERROR([It is not possible to disable the use of X11. Remove the --without-x option.])
41129198Scognet    fi
42129198Scognet
43129198Scognet    if test "x${with_x}" != x &&  test "x${with_x}" != xyes; then
44129198Scognet      # The user has specified a X11 base directory. Use it for includes and
45129198Scognet      # libraries, unless explicitely overridden.
46129198Scognet      if test "x$x_includes" = xNONE; then
47129198Scognet        x_includes="${with_x}/include"
48129198Scognet      fi
49129198Scognet      if test "x$x_libraries" = xNONE; then
50129198Scognet        x_libraries="${with_x}/lib"
51129198Scognet      fi
52129198Scognet    else
53129198Scognet      # Check if the user has specified sysroot, but not --with-x, --x-includes or --x-libraries.
54129198Scognet      # Make a simple check for the libraries at the sysroot, and setup --x-includes and
55129198Scognet      # --x-libraries for the sysroot, if that seems to be correct.
56129198Scognet      if test "x$SYSROOT" != "x"; then
57129198Scognet        if test "x$x_includes" = xNONE; then
58129198Scognet          if test -f "$SYSROOT/usr/X11R6/include/X11/Xlib.h"; then
59129198Scognet            x_includes="$SYSROOT/usr/X11R6/include"
60129198Scognet          elif test -f "$SYSROOT/usr/include/X11/Xlib.h"; then
61129198Scognet            x_includes="$SYSROOT/usr/include"
62129198Scognet          fi
63266000Sian        fi
64266000Sian        if test "x$x_libraries" = xNONE; then
65266000Sian          if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then
66266079Sian            x_libraries="$SYSROOT/usr/X11R6/lib"
67266000Sian          elif test -f "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
68266079Sian            x_libraries="$SYSROOT/usr/lib64"
69266160Sian          elif test -f "$SYSROOT/usr/lib/libX11.so"; then
70266160Sian            x_libraries="$SYSROOT/usr/lib"
71129198Scognet          fi
72129198Scognet        fi
73129198Scognet      fi
74129198Scognet    fi
75129198Scognet
76129198Scognet    # Now let autoconf do it's magic
77129198Scognet    AC_PATH_X
78129198Scognet    AC_PATH_XTRA
79129198Scognet
80129198Scognet    # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
81129198Scognet    # this doesn't make sense so we remove it.
82129198Scognet    if test "x$COMPILE_TYPE" = xcross; then
83129198Scognet      X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
84212413Savg    fi
85129198Scognet
86182934Sraj    if test "x$no_x" = xyes; then
87129198Scognet      HELP_MSG_MISSING_DEPENDENCY([x11])
88182934Sraj      AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
89266070Sian    fi
90266070Sian
91266000Sian    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
92266000Sian      OPENWIN_HOME="/usr/openwin"
93266000Sian      X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"
94182934Sraj      X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
95182934Sraj          -L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \
96182934Sraj          -R$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
97147166Scognet          -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"
98266079Sian    fi
99266079Sian
100266128Sian    AC_LANG_PUSH(C)
101266079Sian    OLD_CFLAGS="$CFLAGS"
102266079Sian    CFLAGS="$CFLAGS $SYSROOT_CFLAGS $X_CFLAGS"
103129198Scognet
104129198Scognet    # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
105129198Scognet    AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
106129198Scognet        [X11_HEADERS_OK=yes],
107129198Scognet        [X11_HEADERS_OK=no; break],
108129198Scognet        [
109129198Scognet          # include <X11/Xlib.h>
110129198Scognet          # include <X11/Xutil.h>
111129198Scognet        ]
112266070Sian    )
113266000Sian
114129198Scognet    if test "x$X11_HEADERS_OK" = xno; then
115147166Scognet      HELP_MSG_MISSING_DEPENDENCY([x11])
116266079Sian      AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
117266079Sian    fi
118266079Sian
119129198Scognet    # If XLinearGradient isn't available in Xrender.h, signal that it needs to be
120129198Scognet    # defined in libawt_xawt.
121129198Scognet    AC_MSG_CHECKING([if XlinearGradient is defined in Xrender.h])
122266000Sian    AC_COMPILE_IFELSE(
123129198Scognet        [AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],
124129198Scognet            [[XLinearGradient x;]])],
125129198Scognet        [AC_MSG_RESULT([yes])],
126129198Scognet        [AC_MSG_RESULT([no])
127129198Scognet         X_CFLAGS="$X_CFLAGS -DSOLARIS10_NO_XRENDER_STRUCTS"])
128270075Sian
129270075Sian    CFLAGS="$OLD_CFLAGS"
130270075Sian    AC_LANG_POP(C)
131270075Sian  fi # NEEDS_LIB_X11
132266000Sian
133270075Sian  AC_SUBST(X_CFLAGS)
134129198Scognet  AC_SUBST(X_LIBS)
135129198Scognet])
136129198Scognet