make/autoconf/lib-freetype.m4
changeset 47216 71c04702a3d5
parent 46252 15f3e60ff095
child 48035 69d409f1b81e
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 #
       
     2 # Copyright (c) 2011, 2017, 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 ################################################################################
       
    27 # Build the freetype lib from source
       
    28 ################################################################################
       
    29 AC_DEFUN([LIB_BUILD_FREETYPE],
       
    30 [
       
    31   FREETYPE_SRC_PATH="$1"
       
    32   BUILD_FREETYPE=yes
       
    33 
       
    34   # Check if the freetype sources are acessible..
       
    35   if ! test -d $FREETYPE_SRC_PATH; then
       
    36     AC_MSG_WARN([--with-freetype-src specified, but can not find path "$FREETYPE_SRC_PATH" - ignoring --with-freetype-src])
       
    37     BUILD_FREETYPE=no
       
    38   fi
       
    39   # ..and contain a vc2010 project file
       
    40   vcxproj_path="$FREETYPE_SRC_PATH/builds/windows/vc2010/freetype.vcxproj"
       
    41   if test "x$BUILD_FREETYPE" = xyes && ! test -s $vcxproj_path; then
       
    42     AC_MSG_WARN([Can not find project file $vcxproj_path (you may try a newer freetype version) - ignoring --with-freetype-src])
       
    43     BUILD_FREETYPE=no
       
    44   fi
       
    45   # Now check if configure found a version of 'msbuild.exe'
       
    46   if test "x$BUILD_FREETYPE" = xyes && test "x$MSBUILD" == x ; then
       
    47     AC_MSG_WARN([Can not find an msbuild.exe executable (you may try to install .NET 4.0) - ignoring --with-freetype-src])
       
    48     BUILD_FREETYPE=no
       
    49   fi
       
    50 
       
    51   # Ready to go..
       
    52   if test "x$BUILD_FREETYPE" = xyes; then
       
    53     # msbuild requires trailing slashes for output directories
       
    54     freetype_lib_path="$FREETYPE_SRC_PATH/lib$OPENJDK_TARGET_CPU_BITS/"
       
    55     freetype_lib_path_unix="$freetype_lib_path"
       
    56     freetype_obj_path="$FREETYPE_SRC_PATH/obj$OPENJDK_TARGET_CPU_BITS/"
       
    57     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(vcxproj_path)
       
    58     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(freetype_lib_path)
       
    59     BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(freetype_obj_path)
       
    60     if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
       
    61       freetype_platform=x64
       
    62     else
       
    63       freetype_platform=win32
       
    64     fi
       
    65 
       
    66     # The original freetype project file is for VS 2010 (i.e. 'v100'),
       
    67     # so we have to adapt the toolset if building with any other toolsed (i.e. SDK).
       
    68     # Currently 'PLATFORM_TOOLSET' is set in 'TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT'/
       
    69     # 'TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT' in toolchain_windows.m4
       
    70     AC_MSG_NOTICE([Trying to compile freetype sources with PlatformToolset=$PLATFORM_TOOLSET to $freetype_lib_path_unix ...])
       
    71 
       
    72     # First we try to build the freetype.dll
       
    73     $ECHO -e "@echo off\n"\
       
    74         "$MSBUILD $vcxproj_path "\
       
    75         "/p:PlatformToolset=$PLATFORM_TOOLSET "\
       
    76         "/p:Configuration=\"Release Multithreaded\" "\
       
    77         "/p:Platform=$freetype_platform "\
       
    78         "/p:ConfigurationType=DynamicLibrary "\
       
    79         "/p:TargetName=freetype "\
       
    80         "/p:OutDir=\"$freetype_lib_path\" "\
       
    81         "/p:IntDir=\"$freetype_obj_path\" > freetype.log" > freetype.bat
       
    82     cmd /c freetype.bat
       
    83 
       
    84     if test -s "$freetype_lib_path_unix/freetype.dll"; then
       
    85       # If that succeeds we also build freetype.lib
       
    86       $ECHO -e "@echo off\n"\
       
    87           "$MSBUILD $vcxproj_path "\
       
    88           "/p:PlatformToolset=$PLATFORM_TOOLSET "\
       
    89           "/p:Configuration=\"Release Multithreaded\" "\
       
    90           "/p:Platform=$freetype_platform "\
       
    91           "/p:ConfigurationType=StaticLibrary "\
       
    92           "/p:TargetName=freetype "\
       
    93           "/p:OutDir=\"$freetype_lib_path\" "\
       
    94           "/p:IntDir=\"$freetype_obj_path\" >> freetype.log" > freetype.bat
       
    95       cmd /c freetype.bat
       
    96 
       
    97       if test -s "$freetype_lib_path_unix/freetype.lib"; then
       
    98         # Once we build both, lib and dll, set freetype lib and include path appropriately
       
    99         POTENTIAL_FREETYPE_INCLUDE_PATH="$FREETYPE_SRC_PATH/include"
       
   100         POTENTIAL_FREETYPE_LIB_PATH="$freetype_lib_path_unix"
       
   101         AC_MSG_NOTICE([Compiling freetype sources succeeded! (see freetype.log for build results)])
       
   102       else
       
   103         BUILD_FREETYPE=no
       
   104       fi
       
   105     else
       
   106       BUILD_FREETYPE=no
       
   107     fi
       
   108   fi
       
   109 ])
       
   110 
       
   111 ################################################################################
       
   112 # Check if a potential freeype library match is correct and usable
       
   113 ################################################################################
       
   114 AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
       
   115 [
       
   116   POTENTIAL_FREETYPE_INCLUDE_PATH="$1"
       
   117   POTENTIAL_FREETYPE_LIB_PATH="$2"
       
   118   METHOD="$3"
       
   119 
       
   120   # Let's start with an optimistic view of the world :-)
       
   121   FOUND_FREETYPE=yes
       
   122 
       
   123   # First look for the canonical freetype main include file ft2build.h.
       
   124   if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
       
   125     # Oh no! Let's try in the freetype2 directory. This is needed at least at Mac OS X Yosemite.
       
   126     POTENTIAL_FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH/freetype2"
       
   127     if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
       
   128       # Fail.
       
   129       FOUND_FREETYPE=no
       
   130     fi
       
   131   fi
       
   132 
       
   133   if test "x$FOUND_FREETYPE" = xyes; then
       
   134     # Include file found, let's continue the sanity check.
       
   135     AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD])
       
   136 
       
   137     # Reset to default value
       
   138     FREETYPE_BASE_NAME=freetype
       
   139     FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}"
       
   140     if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then
       
   141       if test "x$OPENJDK_TARGET_OS" = xmacosx \
       
   142           && test -s "$POTENTIAL_FREETYPE_LIB_PATH/${LIBRARY_PREFIX}freetype.6${SHARED_LIBRARY_SUFFIX}"; then
       
   143         # On Mac OS X Yosemite, the symlink from libfreetype.dylib to libfreetype.6.dylib disappeared. Check
       
   144         # for the .6 version explicitly.
       
   145         FREETYPE_BASE_NAME=freetype.6
       
   146         FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}"
       
   147         AC_MSG_NOTICE([Compensating for missing symlink by using version 6 explicitly])
       
   148       else
       
   149         AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.])
       
   150         FOUND_FREETYPE=no
       
   151       fi
       
   152     else
       
   153       if test "x$OPENJDK_TARGET_OS" = xwindows; then
       
   154         # On Windows, we will need both .lib and .dll file.
       
   155         if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib"; then
       
   156           AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location.])
       
   157           FOUND_FREETYPE=no
       
   158         fi
       
   159       elif test "x$OPENJDK_TARGET_OS" = xsolaris \
       
   160           && test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then
       
   161         # Found lib in isa dir, use that instead.
       
   162         POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR"
       
   163         AC_MSG_NOTICE([Rewriting to use $POTENTIAL_FREETYPE_LIB_PATH instead])
       
   164       fi
       
   165     fi
       
   166   fi
       
   167 
       
   168   if test "x$FOUND_FREETYPE" = xyes; then
       
   169     BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_INCLUDE_PATH)
       
   170     BASIC_FIXUP_PATH(POTENTIAL_FREETYPE_LIB_PATH)
       
   171 
       
   172     FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH"
       
   173     AC_MSG_CHECKING([for freetype includes])
       
   174     AC_MSG_RESULT([$FREETYPE_INCLUDE_PATH])
       
   175     FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH"
       
   176     AC_MSG_CHECKING([for freetype libraries])
       
   177     AC_MSG_RESULT([$FREETYPE_LIB_PATH])
       
   178   fi
       
   179 ])
       
   180 
       
   181 ################################################################################
       
   182 # Setup freetype (The FreeType2 font rendering library)
       
   183 ################################################################################
       
   184 AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
       
   185 [
       
   186   AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
       
   187       [specify prefix directory for the freetype package
       
   188       (expecting the libraries under PATH/lib and the headers under PATH/include)])])
       
   189   AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include],
       
   190       [specify directory for the freetype include files])])
       
   191   AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib],
       
   192       [specify directory for the freetype library])])
       
   193   AC_ARG_WITH(freetype-src, [AS_HELP_STRING([--with-freetype-src],
       
   194       [specify directory with freetype sources to automatically build the library (experimental, Windows-only)])])
       
   195   AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
       
   196       [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])
       
   197   AC_ARG_WITH(freetype-license, [AS_HELP_STRING([--with-freetype-license],
       
   198       [if bundling freetype, also bundle this license file])])
       
   199 
       
   200   # Need to specify explicitly since it needs to be overridden on some versions of macosx
       
   201   FREETYPE_BASE_NAME=freetype
       
   202   FREETYPE_CFLAGS=
       
   203   FREETYPE_LIBS=
       
   204   FREETYPE_BUNDLE_LIB_PATH=
       
   205 
       
   206   if test "x$NEEDS_LIB_FREETYPE" = xfalse; then
       
   207     if (test "x$with_freetype" != x  && test "x$with_freetype" != xno) || \
       
   208         (test "x$with_freetype_include" != x && test "x$with_freetype_include" != xno) || \
       
   209         (test "x$with_freetype_lib" != x && test "x$with_freetype_lib" != xno) || \
       
   210         (test "x$with_freetype_src" != x && test "x$with_freetype_src" != xno); then
       
   211       AC_MSG_WARN([[freetype not used, so --with-freetype[-*] is ignored]])
       
   212     fi
       
   213     if (test "x$enable_freetype_bundling" != x && test "x$enable_freetype_bundling" != xno); then
       
   214       AC_MSG_WARN([freetype not used, so --enable-freetype-bundling is ignored])
       
   215     fi
       
   216   else
       
   217     # freetype is needed to build; go get it!
       
   218 
       
   219     BUNDLE_FREETYPE="$enable_freetype_bundling"
       
   220 
       
   221     if  test "x$with_freetype_src" != x; then
       
   222       if test "x$OPENJDK_TARGET_OS" = xwindows; then
       
   223         # Try to build freetype if --with-freetype-src was given on Windows
       
   224         LIB_BUILD_FREETYPE([$with_freetype_src])
       
   225         if test "x$BUILD_FREETYPE" = xyes; then
       
   226           # Okay, we built it. Check that it works.
       
   227           LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype-src])
       
   228           if test "x$FOUND_FREETYPE" != xyes; then
       
   229             AC_MSG_ERROR([Can not use the built freetype at location given by --with-freetype-src])
       
   230           fi
       
   231         else
       
   232           AC_MSG_NOTICE([User specified --with-freetype-src but building freetype failed. (see freetype.log for build results)])
       
   233           AC_MSG_ERROR([Consider building freetype manually and using --with-freetype instead.])
       
   234         fi
       
   235       else
       
   236         AC_MSG_WARN([--with-freetype-src is currently only supported on Windows - ignoring])
       
   237       fi
       
   238     fi
       
   239 
       
   240     if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
       
   241       # User has specified settings
       
   242 
       
   243       if test "x$BUNDLE_FREETYPE" = x; then
       
   244         # If not specified, default is to bundle freetype
       
   245         BUNDLE_FREETYPE=yes
       
   246       fi
       
   247 
       
   248       if test "x$with_freetype" != x; then
       
   249         POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype/include"
       
   250         POTENTIAL_FREETYPE_LIB_PATH="$with_freetype/lib"
       
   251       fi
       
   252 
       
   253       # Allow --with-freetype-lib and --with-freetype-include to override
       
   254       if test "x$with_freetype_include" != x; then
       
   255         POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include"
       
   256       fi
       
   257       if test "x$with_freetype_lib" != x; then
       
   258         POTENTIAL_FREETYPE_LIB_PATH="$with_freetype_lib"
       
   259       fi
       
   260 
       
   261       if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != x && test "x$POTENTIAL_FREETYPE_LIB_PATH" != x; then
       
   262         # Okay, we got it. Check that it works.
       
   263         LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype])
       
   264         if test "x$FOUND_FREETYPE" != xyes; then
       
   265           AC_MSG_ERROR([Can not find or use freetype at location given by --with-freetype])
       
   266         fi
       
   267       else
       
   268         # User specified only one of lib or include. This is an error.
       
   269         if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" = x ; then
       
   270           AC_MSG_NOTICE([User specified --with-freetype-lib but not --with-freetype-include])
       
   271           AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
       
   272         else
       
   273           AC_MSG_NOTICE([User specified --with-freetype-include but not --with-freetype-lib])
       
   274           AC_MSG_ERROR([Need both freetype lib and include paths. Consider using --with-freetype instead.])
       
   275         fi
       
   276       fi
       
   277     else
       
   278       # User did not specify settings, but we need freetype. Try to locate it.
       
   279 
       
   280       if test "x$BUNDLE_FREETYPE" = x; then
       
   281         # If not specified, default is to bundle freetype only on windows
       
   282         if test "x$OPENJDK_TARGET_OS" = xwindows; then
       
   283           BUNDLE_FREETYPE=yes
       
   284         else
       
   285           BUNDLE_FREETYPE=no
       
   286         fi
       
   287       fi
       
   288 
       
   289       # If we have a sysroot, assume that's where we are supposed to look and skip pkg-config.
       
   290       if test "x$SYSROOT" = x; then
       
   291         if test "x$FOUND_FREETYPE" != xyes; then
       
   292           # Check modules using pkg-config, but only if we have it (ugly output results otherwise)
       
   293           if test "x$PKG_CONFIG" != x; then
       
   294             PKG_CHECK_MODULES(FREETYPE, freetype2, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
       
   295             if test "x$FOUND_FREETYPE" = xyes; then
       
   296               # On solaris, pkg_check adds -lz to freetype libs, which isn't necessary for us.
       
   297               FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's/-lz//g'`
       
   298               # 64-bit libs for Solaris x86 are installed in the amd64 subdirectory, change lib to lib/amd64
       
   299               if test "x$OPENJDK_TARGET_OS" = xsolaris && test "x$OPENJDK_TARGET_CPU" = xx86_64; then
       
   300                 FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's?/lib?/lib/amd64?g'`
       
   301               fi
       
   302               # PKG_CHECK_MODULES will set FREETYPE_CFLAGS and _LIBS, but we don't get a lib path for bundling.
       
   303               if test "x$BUNDLE_FREETYPE" = xyes; then
       
   304                 AC_MSG_NOTICE([Found freetype using pkg-config, but ignoring since we can not bundle that])
       
   305                 FOUND_FREETYPE=no
       
   306               else
       
   307                 AC_MSG_CHECKING([for freetype])
       
   308                 AC_MSG_RESULT([yes (using pkg-config)])
       
   309               fi
       
   310             fi
       
   311           fi
       
   312         fi
       
   313       fi
       
   314 
       
   315       if test "x$FOUND_FREETYPE" != xyes; then
       
   316         # Check in well-known locations
       
   317         if test "x$OPENJDK_TARGET_OS" = xwindows; then
       
   318           FREETYPE_BASE_DIR="$PROGRAMFILES/GnuWin32"
       
   319           BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
       
   320           LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
       
   321           if test "x$FOUND_FREETYPE" != xyes; then
       
   322             FREETYPE_BASE_DIR="$ProgramW6432/GnuWin32"
       
   323             BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
       
   324             LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
       
   325           fi
       
   326           if test "x$FOUND_FREETYPE" != xyes; then
       
   327             FREETYPE_BASE_DIR="$HOME/freetype"
       
   328             BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(FREETYPE_BASE_DIR)
       
   329             if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
       
   330               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib64], [well-known location])
       
   331             else
       
   332               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib32], [well-known location])
       
   333             fi
       
   334             if test "x$FOUND_FREETYPE" != xyes && test -d $FREETYPE_BASE_DIR \
       
   335                 && test -s "$FREETYPE_BASE_DIR/builds/windows/vc2010/freetype.vcxproj" && test "x$MSBUILD" != x; then
       
   336               # Source is available, as a last resort try to build freetype in default location
       
   337               LIB_BUILD_FREETYPE($FREETYPE_BASE_DIR)
       
   338               if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
       
   339                 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib64], [well-known location])
       
   340               else
       
   341                 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib32], [well-known location])
       
   342               fi
       
   343             fi
       
   344           fi
       
   345         else
       
   346           FREETYPE_BASE_DIR="$SYSROOT/usr"
       
   347           LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
       
   348 
       
   349           if test "x$FOUND_FREETYPE" != xyes; then
       
   350             FREETYPE_BASE_DIR="$SYSROOT/usr/X11"
       
   351             LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
       
   352           fi
       
   353           if test "x$FOUND_FREETYPE" != xyes; then
       
   354             FREETYPE_BASE_DIR="$SYSROOT/usr/local"
       
   355             LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
       
   356           fi
       
   357 
       
   358           if test "x$OPENJDK_TARGET_OS" = xmacosx; then
       
   359             if test "x$FOUND_FREETYPE" != xyes; then
       
   360               # Due to changes in OSX 10.11 XQuartz now installs to /opt/X11
       
   361               FREETYPE_BASE_DIR="$SYSROOT/opt/X11"
       
   362               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib], [well-known location])
       
   363             fi
       
   364           fi
       
   365 
       
   366           if test "x$FOUND_FREETYPE" != xyes; then
       
   367             FREETYPE_BASE_DIR="$SYSROOT/usr"
       
   368             if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
       
   369               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/$OPENJDK_TARGET_CPU-linux-gnu], [well-known location])
       
   370             else
       
   371               LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib/i386-linux-gnu], [well-known location])
       
   372               if test "x$FOUND_FREETYPE" != xyes; then
       
   373                 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], [$FREETYPE_BASE_DIR/lib32], [well-known location])
       
   374               fi
       
   375             fi
       
   376           fi
       
   377         fi
       
   378       fi # end check in well-known locations
       
   379 
       
   380       if test "x$FOUND_FREETYPE" != xyes; then
       
   381         HELP_MSG_MISSING_DEPENDENCY([freetype])
       
   382         AC_MSG_ERROR([Could not find freetype! $HELP_MSG ])
       
   383       fi
       
   384     fi # end user specified settings
       
   385 
       
   386     # Set FREETYPE_CFLAGS, _LIBS and _LIB_PATH from include and lib dir.
       
   387     if test "x$FREETYPE_CFLAGS" = x; then
       
   388       BASIC_FIXUP_PATH(FREETYPE_INCLUDE_PATH)
       
   389       if test -d $FREETYPE_INCLUDE_PATH/freetype2/freetype; then
       
   390         FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH/freetype2 -I$FREETYPE_INCLUDE_PATH"
       
   391       else
       
   392         FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH"
       
   393       fi
       
   394     fi
       
   395 
       
   396     if test "x$FREETYPE_LIBS" = x; then
       
   397       BASIC_FIXUP_PATH(FREETYPE_LIB_PATH)
       
   398       if test "x$OPENJDK_TARGET_OS" = xwindows; then
       
   399         FREETYPE_LIBS="$FREETYPE_LIB_PATH/$FREETYPE_BASE_NAME.lib"
       
   400       else
       
   401         FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -l$FREETYPE_BASE_NAME"
       
   402       fi
       
   403     fi
       
   404 
       
   405     # Try to compile it
       
   406     AC_MSG_CHECKING([if we can compile and link with freetype])
       
   407     AC_LANG_PUSH(C++)
       
   408     PREV_CXXCFLAGS="$CXXFLAGS"
       
   409     PREV_LIBS="$LIBS"
       
   410     PREV_CXX="$CXX"
       
   411     CXXFLAGS="$CXXFLAGS $FREETYPE_CFLAGS"
       
   412     LIBS="$LIBS $FREETYPE_LIBS"
       
   413     CXX="$FIXPATH $CXX"
       
   414     AC_LINK_IFELSE([AC_LANG_SOURCE([[
       
   415           #include<ft2build.h>
       
   416           #include FT_FREETYPE_H
       
   417           int main () {
       
   418             FT_Init_FreeType(NULL);
       
   419             return 0;
       
   420           }
       
   421         ]])],
       
   422         [
       
   423           AC_MSG_RESULT([yes])
       
   424         ],
       
   425         [
       
   426           AC_MSG_RESULT([no])
       
   427           AC_MSG_NOTICE([Could not compile and link with freetype. This might be a 32/64-bit mismatch.])
       
   428           AC_MSG_NOTICE([Using FREETYPE_CFLAGS=$FREETYPE_CFLAGS and FREETYPE_LIBS=$FREETYPE_LIBS])
       
   429 
       
   430           HELP_MSG_MISSING_DEPENDENCY([freetype])
       
   431 
       
   432           AC_MSG_ERROR([Can not continue without freetype. $HELP_MSG])
       
   433         ]
       
   434     )
       
   435     CXXCFLAGS="$PREV_CXXFLAGS"
       
   436     LIBS="$PREV_LIBS"
       
   437     CXX="$PREV_CXX"
       
   438     AC_LANG_POP(C++)
       
   439 
       
   440     AC_MSG_CHECKING([if we should bundle freetype])
       
   441     if test "x$BUNDLE_FREETYPE" = xyes; then
       
   442       FREETYPE_BUNDLE_LIB_PATH="$FREETYPE_LIB_PATH"
       
   443     fi
       
   444     AC_MSG_RESULT([$BUNDLE_FREETYPE])
       
   445 
       
   446   fi # end freetype needed
       
   447 
       
   448   FREETYPE_LICENSE=""
       
   449   if test "x$with_freetype_license" = "xyes"; then
       
   450     AC_MSG_ERROR([--with-freetype-license must have a value])
       
   451   elif test "x$with_freetype_license" != "x"; then
       
   452     AC_MSG_CHECKING([for freetype license])
       
   453     AC_MSG_RESULT([$with_freetype_license])
       
   454     FREETYPE_LICENSE="$with_freetype_license"
       
   455     BASIC_FIXUP_PATH(FREETYPE_LICENSE)
       
   456     if test ! -f "$FREETYPE_LICENSE"; then
       
   457       AC_MSG_ERROR([$FREETYPE_LICENSE cannot be found])
       
   458     fi
       
   459   fi
       
   460 
       
   461   AC_SUBST(FREETYPE_BUNDLE_LIB_PATH)
       
   462   AC_SUBST(FREETYPE_CFLAGS)
       
   463   AC_SUBST(FREETYPE_LIBS)
       
   464   AC_SUBST(FREETYPE_LICENSE)
       
   465 ])