lib-x11.m4 revision 2251:e51f798914a8
133965Sjdp#
233965Sjdp# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
333965Sjdp# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
433965Sjdp#
533965Sjdp# This code is free software; you can redistribute it and/or modify it
633965Sjdp# under the terms of the GNU General Public License version 2 only, as
738891Sjdp# published by the Free Software Foundation.  Oracle designates this
8130570Sobrien# particular file as subject to the "Classpath" exception as provided
938891Sjdp# by Oracle in the LICENSE file that accompanied this code.
1038891Sjdp#
11130570Sobrien# This code is distributed in the hope that it will be useful, but WITHOUT
12130570Sobrien# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13130570Sobrien# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14130570Sobrien# version 2 for more details (a copy is included in the LICENSE file that
1538891Sjdp# accompanied this code).
1677310Sobrien#
1738891Sjdp# You should have received a copy of the GNU General Public License version
1878837Sobrien# 2 along with this work; if not, write to the Free Software Foundation,
1978837Sobrien# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2078837Sobrien#
2178837Sobrien# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2238891Sjdp# or visit www.oracle.com if you need additional information or have any
2338891Sjdp# questions.
2438891Sjdp#
2533965Sjdp
26218822Sdim################################################################################
2733965Sjdp# Setup X11 Windows system
2833965Sjdp################################################################################
2933965SjdpAC_DEFUN_ONCE([LIB_SETUP_X11],
3033965Sjdp[
3133965Sjdp  if test "x$NEEDS_LIB_X11" = xfalse; then
3233965Sjdp    if (test "x${with_x}" != x && test "x${with_x}" != xno); then
33218822Sdim      AC_MSG_WARN([X11 is not used, so --with-x is ignored])
3433965Sjdp    fi
3533965Sjdp    X_CFLAGS=
3633965Sjdp    X_LIBS=
3733965Sjdp  else
3833965Sjdp
3933965Sjdp    if test "x${with_x}" = xno; then
4033965Sjdp      AC_MSG_ERROR([It is not possible to disable the use of X11. Remove the --without-x option.])
4133965Sjdp    fi
42218822Sdim
43218822Sdim    if test "x${with_x}" != x &&  test "x${with_x}" != xyes; then
44218822Sdim      # The user has specified a X11 base directory. Use it for includes and
45218822Sdim      # libraries, unless explicitely overridden.
46218822Sdim      if test "x$x_includes" = xNONE; then
47218822Sdim        x_includes="${with_x}/include"
4877310Sobrien      fi
49218822Sdim      if test "x$x_libraries" = xNONE; then
50218822Sdim        x_libraries="${with_x}/lib"
51218822Sdim      fi
52218822Sdim    else
53218822Sdim      # Check if the user has specified sysroot, but not --with-x, --x-includes or --x-libraries.
5477310Sobrien      # Make a simple check for the libraries at the sysroot, and setup --x-includes and
5577310Sobrien      # --x-libraries for the sysroot, if that seems to be correct.
56218822Sdim      if test "x$SYSROOT" != "x"; then
57218822Sdim        if test "x$x_includes" = xNONE; then
58218822Sdim          if test -f "$SYSROOT/usr/X11R6/include/X11/Xlib.h"; then
59218822Sdim            x_includes="$SYSROOT/usr/X11R6/include"
6038891Sjdp          elif test -f "$SYSROOT/usr/include/X11/Xlib.h"; then
6138891Sjdp            x_includes="$SYSROOT/usr/include"
6233965Sjdp          fi
6360517Sobrien        fi
6460517Sobrien        if test "x$x_libraries" = xNONE; then
6560517Sobrien          if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then
66130570Sobrien            x_libraries="$SYSROOT/usr/X11R6/lib"
6760517Sobrien          elif test -f "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
68130570Sobrien            x_libraries="$SYSROOT/usr/lib64"
6960517Sobrien          elif test -f "$SYSROOT/usr/lib/libX11.so"; then
70130570Sobrien            x_libraries="$SYSROOT/usr/lib"
71130570Sobrien          fi
72130570Sobrien        fi
73130570Sobrien      fi
7460517Sobrien    fi
7560517Sobrien
7660517Sobrien    # Now let autoconf do it's magic
77218822Sdim    AC_PATH_X
78218822Sdim    AC_PATH_XTRA
79218822Sdim
8033965Sjdp    # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
8133965Sjdp    # this doesn't make sense so we remove it.
8260517Sobrien    if test "x$COMPILE_TYPE" = xcross; then
8360517Sobrien      X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
8460517Sobrien    fi
8533965Sjdp
8660517Sobrien    if test "x$no_x" = xyes; then
8733965Sjdp      HELP_MSG_MISSING_DEPENDENCY([x11])
8833965Sjdp      AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
8960517Sobrien    fi
9060517Sobrien
9160517Sobrien    if test "x$OPENJDK_TARGET_OS" = xsolaris; then
9260517Sobrien      OPENWIN_HOME="/usr/openwin"
9360517Sobrien      X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"
9433965Sjdp      X_LIBS="-L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \
9533965Sjdp          -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"
9633965Sjdp    fi
9733965Sjdp
9833965Sjdp    AC_LANG_PUSH(C)
9933965Sjdp    OLD_CFLAGS="$CFLAGS"
10033965Sjdp    CFLAGS="$CFLAGS $SYSROOT_CFLAGS $X_CFLAGS"
10133965Sjdp
10233965Sjdp    # Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
10333965Sjdp    AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
10433965Sjdp        [X11_HEADERS_OK=yes],
10533965Sjdp        [X11_HEADERS_OK=no; break],
10633965Sjdp        [
10733965Sjdp          # include <X11/Xlib.h>
108218822Sdim          # include <X11/Xutil.h>
109218822Sdim        ]
11033965Sjdp    )
111218822Sdim
112218822Sdim    if test "x$X11_HEADERS_OK" = xno; then
113218822Sdim      HELP_MSG_MISSING_DEPENDENCY([x11])
114218822Sdim      AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
115218822Sdim    fi
11633965Sjdp
11733965Sjdp    # If XLinearGradient isn't available in Xrender.h, signal that it needs to be
11833965Sjdp    # defined in libawt_xawt.
11933965Sjdp    AC_MSG_CHECKING([if XlinearGradient is defined in Xrender.h])
12033965Sjdp    AC_COMPILE_IFELSE(
12133965Sjdp        [AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],
12233965Sjdp            [[XLinearGradient x;]])],
12333965Sjdp        [AC_MSG_RESULT([yes])],
124218822Sdim        [AC_MSG_RESULT([no])
12533965Sjdp         X_CFLAGS="$X_CFLAGS -DSOLARIS10_NO_XRENDER_STRUCTS"])
126218822Sdim
127218822Sdim    CFLAGS="$OLD_CFLAGS"
128218822Sdim    AC_LANG_POP(C)
129218822Sdim  fi # NEEDS_LIB_X11
130218822Sdim
13133965Sjdp  AC_SUBST(X_CFLAGS)
132130570Sobrien  AC_SUBST(X_LIBS)
133130570Sobrien])
134218822Sdim