1 # 2 # Copyright (c) 2011, 2020, 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 # Check if a potential freeype library match is correct and usable 28 ################################################################################ 29 AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE], 30 [ 31 POTENTIAL_FREETYPE_INCLUDE_PATH="$1" 32 POTENTIAL_FREETYPE_LIB_PATH="$2" 33 METHOD="$3" 34 35 # Let's start with an optimistic view of the world :-) 36 FOUND_FREETYPE=yes 37 38 # First look for the canonical freetype main include file ft2build.h. 39 if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then 40 # Oh no! Let's try in the freetype2 directory. 41 POTENTIAL_FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH/freetype2" 42 if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then 43 # Fail. 44 FOUND_FREETYPE=no 45 fi 46 fi 47 48 if test "x$FOUND_FREETYPE" = "xyes"; then 49 # Include file found, let's continue the sanity check. 50 AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD]) 51 52 FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}" 53 if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then 54 AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.]) 55 FOUND_FREETYPE=no 56 else 57 if test "x$OPENJDK_TARGET_OS" = "xsolaris" \ 58 && test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then 59 # Found lib in isa dir, use that instead. 60 POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR" 61 AC_MSG_NOTICE([Rewriting to use $POTENTIAL_FREETYPE_LIB_PATH instead]) 62 fi 63 fi 64 fi 65 66 if test "x$FOUND_FREETYPE" = "xyes"; then 67 FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH" 68 AC_MSG_CHECKING([for freetype includes]) 69 AC_MSG_RESULT([$FREETYPE_INCLUDE_PATH]) 70 FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH" 71 AC_MSG_CHECKING([for freetype libraries]) 72 AC_MSG_RESULT([$FREETYPE_LIB_PATH]) 73 fi 74 ]) 75 76 ################################################################################ 77 # Setup freetype (The FreeType2 font rendering library) 78 ################################################################################ 79 AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], 80 [ 81 AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype], 82 [specify whether to use 'system' or 'bundled' freetype. 83 The selected option applies to both build time and run time. 84 The default behaviour can be platform dependent. 85 If using 'system' and either the include files or libraries cannot be 86 located automatically, then additionally specify both using 87 --with-freetype-include and --with-freetype-lib.])]) 88 AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include], 89 [specify directory for the freetype include files])]) 90 AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib], 91 [specify directory for the freetype library])]) 92 93 # This setup is to verify access to system installed freetype header and 94 # libraries. On Windows and MacOS this does not apply and using these options 95 # will report an error. On other platforms (Linux, Solaris), they will 96 # default to using the system libraries. If they are found automatically, 97 # nothing need be done. If they are not found, the configure 98 # "--with-freetype-*" options may be used to fix that. If the preference is 99 # to bundle on these platforms then use --with-freetype=bundled. 100 101 FREETYPE_BASE_NAME=freetype 102 FREETYPE_CFLAGS= 103 FREETYPE_LIBS= 104 105 if (test "x$with_freetype_include" = "x" && test "x$with_freetype_lib" != "x") || \ 106 (test "x$with_freetype_include" != "x" && test "x$with_freetype_lib" = "x"); then 107 AC_MSG_ERROR([Must specify both or neither of --with-freetype-include and --with-freetype-lib]) 108 fi 109 110 FREETYPE_TO_USE=bundled 111 if test "x$OPENJDK_TARGET_OS" != "xwindows" && \ 112 test "x$OPENJDK_TARGET_OS" != "xmacosx" && \ 113 test "x$OPENJDK_TARGET_OS" != "xaix"; then 114 FREETYPE_TO_USE=system 115 fi 116 if test "x$with_freetype" != "x" ; then 117 if test "x$with_freetype" = "xsystem" ; then 118 FREETYPE_TO_USE=system 119 elif test "x$with_freetype" = "xbundled" ; then 120 FREETYPE_TO_USE=bundled 121 if test "x$with_freetype_include" != "x" || \ 122 test "x$with_freetype_lib" != "x" ; then 123 AC_MSG_ERROR(['bundled' cannot be specified with --with-freetype-include and --with-freetype-lib]) 124 fi 125 else 126 AC_MSG_ERROR([Valid values for --with-freetype are 'system' and 'bundled']) 127 fi 128 fi 129 130 if test "x$with_freetype_include" != "x" && \ 131 test "x$with_freetype_lib" != "x" ; then 132 FREETYPE_TO_USE=system 133 fi 134 135 if test "x$FREETYPE_TO_USE" = "xsystem" && \ 136 (test "x$OPENJDK_TARGET_OS" = "xwindows" || \ 137 test "x$OPENJDK_TARGET_OS" = "xmacosx"); then 138 AC_MSG_ERROR([Only bundled freetype can be specified on Mac and Windows]) 139 fi 140 141 if test "x$with_freetype_include" != "x" ; then 142 POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include" 143 fi 144 if test "x$with_freetype_lib" != "x" ; then 145 POTENTIAL_FREETYPE_LIB_PATH="$with_freetype_lib" 146 fi 147 148 if test "x$FREETYPE_TO_USE" = "xsystem" ; then 149 if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != "x" && \ 150 test "x$POTENTIAL_FREETYPE_LIB_PATH" != "x" ; then 151 # Okay, we got it. Check that it works. 152 LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, 153 $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype]) 154 if test "x$FOUND_FREETYPE" != "xyes" ; then 155 AC_MSG_ERROR([Can not find or use freetype at location given by --with-freetype-lib|include]) 156 fi 157 else 158 # User did not specify a location, but asked for system freetype. 159 # Try to locate it. 160 161 # If we have a sysroot, assume that's where we are supposed to look and 162 # skip pkg-config. 163 if test "x$SYSROOT" = "x" ; then 164 if test "x$FOUND_FREETYPE" != "xyes" ; then 165 # Check modules using pkg-config, but only if we have it (ugly output 166 # results otherwise) 167 if test "x$PKG_CONFIG" != "x" ; then 168 PKG_CHECK_MODULES(FREETYPE, freetype2, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no]) 169 if test "x$FOUND_FREETYPE" = "xyes" ; then 170 # On solaris, pkg_check adds -lz to freetype libs, which isn't 171 # necessary for us. 172 FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's/-lz//g'` 173 # 64-bit libs for Solaris x86 are installed in the amd64 174 # subdirectory, change lib to lib/amd64 175 if test "x$OPENJDK_TARGET_OS" = "xsolaris" && \ 176 test "x$OPENJDK_TARGET_CPU" = "xx86_64" ; then 177 FREETYPE_LIBS=`$ECHO $FREETYPE_LIBS | $SED 's?/lib?/lib/amd64?g'` 178 fi 179 AC_MSG_CHECKING([for freetype]) 180 AC_MSG_RESULT([yes (using pkg-config)]) 181 fi 182 fi 183 fi 184 fi 185 186 if test "x$FOUND_FREETYPE" != "xyes" ; then 187 # Check in well-known locations 188 FREETYPE_BASE_DIR="$SYSROOT/usr" 189 190 if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" ; then 191 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], 192 [$FREETYPE_BASE_DIR/lib/$OPENJDK_TARGET_CPU-linux-gnu], [well-known location]) 193 if test "x$FOUND_FREETYPE" != "xyes" ; then 194 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], 195 [$FREETYPE_BASE_DIR/lib64], [well-known location]) 196 fi 197 else 198 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], 199 [$FREETYPE_BASE_DIR/lib/i386-linux-gnu], [well-known location]) 200 if test "x$FOUND_FREETYPE" != "xyes" ; then 201 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], 202 [$FREETYPE_BASE_DIR/lib32], [well-known location]) 203 fi 204 fi 205 206 if test "x$FOUND_FREETYPE" != "xyes" ; then 207 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], 208 [$FREETYPE_BASE_DIR/lib], [well-known location]) 209 fi 210 211 if test "x$FOUND_FREETYPE" != "xyes" ; then 212 FREETYPE_BASE_DIR="$SYSROOT/usr/X11" 213 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], 214 [$FREETYPE_BASE_DIR/lib], [well-known location]) 215 fi 216 217 if test "x$FOUND_FREETYPE" != "xyes" ; then 218 FREETYPE_BASE_DIR="$SYSROOT/usr/local" 219 LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include], 220 [$FREETYPE_BASE_DIR/lib], [well-known location]) 221 fi 222 fi # end check in well-known locations 223 224 if test "x$FOUND_FREETYPE" != "xyes" ; then 225 HELP_MSG_MISSING_DEPENDENCY([freetype]) 226 AC_MSG_ERROR([Could not find freetype! $HELP_MSG ]) 227 fi 228 fi # end user specified settings 229 230 # Set FREETYPE_CFLAGS, _LIBS and _LIB_PATH from include and lib dir. 231 if test "x$FREETYPE_CFLAGS" = "x" ; then 232 if test -d $FREETYPE_INCLUDE_PATH/freetype2/freetype ; then 233 FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH/freetype2 -I$FREETYPE_INCLUDE_PATH" 234 else 235 FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH" 236 fi 237 fi 238 239 if test "x$FREETYPE_LIBS" = "x" ; then 240 FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -l$FREETYPE_BASE_NAME" 241 fi 242 fi 243 244 AC_MSG_RESULT([Using freetype: $FREETYPE_TO_USE]) 245 246 AC_SUBST(FREETYPE_TO_USE) 247 AC_SUBST(FREETYPE_CFLAGS) 248 AC_SUBST(FREETYPE_LIBS) 249 ])