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.
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.
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).
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.
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
26
################################################################################
27
# Check if a potential freeype library match is correct and usable
28
################################################################################
29
AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
31
POTENTIAL_FREETYPE_INCLUDE_PATH="$1"
32
POTENTIAL_FREETYPE_LIB_PATH="$2"
35
# Let's start with an optimistic view of the world :-)
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
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])
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.])
59
if test "x$FOUND_FREETYPE" = "xyes"; then
60
FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH"
61
AC_MSG_CHECKING([for freetype includes])
62
AC_MSG_RESULT([$FREETYPE_INCLUDE_PATH])
63
FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH"
64
AC_MSG_CHECKING([for freetype libraries])
65
AC_MSG_RESULT([$FREETYPE_LIB_PATH])
69
################################################################################
70
# Setup freetype (The FreeType2 font rendering library)
71
################################################################################
72
AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
74
AC_ARG_WITH(freetype, [AS_HELP_STRING([--with-freetype],
75
[specify whether to use 'system' or 'bundled' freetype.
76
The selected option applies to both build time and run time.
77
The default behaviour can be platform dependent.
78
If using 'system' and either the include files or libraries cannot be
79
located automatically, then additionally specify both using
80
--with-freetype-include and --with-freetype-lib.])])
81
AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include],
82
[specify directory for the freetype include files])])
83
AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib],
84
[specify directory for the freetype library])])
86
# This setup is to verify access to system installed freetype header and
87
# libraries. On Windows and MacOS this does not apply and using these options
88
# will report an error. On other platforms they will default to using the
89
# system libraries. If they are found automatically, nothing need be done.
90
# If they are not found, the configure "--with-freetype-*" options may be
91
# used to fix that. If the preference is to bundle on these platforms then
92
# use --with-freetype=bundled.
94
FREETYPE_BASE_NAME=freetype
98
if (test "x$with_freetype_include" = "x" && test "x$with_freetype_lib" != "x") || \
99
(test "x$with_freetype_include" != "x" && test "x$with_freetype_lib" = "x"); then
100
AC_MSG_ERROR([Must specify both or neither of --with-freetype-include and --with-freetype-lib])
103
FREETYPE_TO_USE=bundled
104
if test "x$OPENJDK_TARGET_OS" != "xwindows" && \
105
test "x$OPENJDK_TARGET_OS" != "xmacosx" && \
106
test "x$OPENJDK_TARGET_OS" != "xaix"; then
107
FREETYPE_TO_USE=system
109
if test "x$with_freetype" != "x" ; then
110
if test "x$with_freetype" = "xsystem" ; then
111
FREETYPE_TO_USE=system
112
elif test "x$with_freetype" = "xbundled" ; then
113
FREETYPE_TO_USE=bundled
114
if test "x$with_freetype_include" != "x" || \
115
test "x$with_freetype_lib" != "x" ; then
116
AC_MSG_ERROR(['bundled' cannot be specified with --with-freetype-include and --with-freetype-lib])
119
AC_MSG_ERROR([Valid values for --with-freetype are 'system' and 'bundled'])
123
if test "x$with_freetype_include" != "x" && \
124
test "x$with_freetype_lib" != "x" ; then
125
FREETYPE_TO_USE=system
128
if test "x$FREETYPE_TO_USE" = "xsystem" && \
129
(test "x$OPENJDK_TARGET_OS" = "xwindows" || \
130
test "x$OPENJDK_TARGET_OS" = "xmacosx"); then
131
AC_MSG_ERROR([Only bundled freetype can be specified on Mac and Windows])
134
if test "x$with_freetype_include" != "x" ; then
135
POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include"
137
if test "x$with_freetype_lib" != "x" ; then
138
POTENTIAL_FREETYPE_LIB_PATH="$with_freetype_lib"
141
if test "x$FREETYPE_TO_USE" = "xsystem" ; then
142
if test "x$POTENTIAL_FREETYPE_INCLUDE_PATH" != "x" && \
143
test "x$POTENTIAL_FREETYPE_LIB_PATH" != "x" ; then
144
# Okay, we got it. Check that it works.
145
LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH,
146
$POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype])
147
if test "x$FOUND_FREETYPE" != "xyes" ; then
148
AC_MSG_ERROR([Can not find or use freetype at location given by --with-freetype-lib|include])
151
# User did not specify a location, but asked for system freetype.
154
# If we have a sysroot, assume that's where we are supposed to look and
156
if test "x$SYSROOT" = "x" ; then
157
if test "x$FOUND_FREETYPE" != "xyes" ; then
158
# Check modules using pkg-config, but only if we have it (ugly output
160
if test "x$PKG_CONFIG" != "x" ; then
161
PKG_CHECK_MODULES(FREETYPE, freetype2, [FOUND_FREETYPE=yes], [FOUND_FREETYPE=no])
162
if test "x$FOUND_FREETYPE" = "xyes" ; then
163
AC_MSG_CHECKING([for freetype])
164
AC_MSG_RESULT([yes (using pkg-config)])
170
if test "x$FOUND_FREETYPE" != "xyes" ; then
171
# Check in well-known locations
172
FREETYPE_BASE_DIR="$SYSROOT/usr"
174
if test "x$OPENJDK_TARGET_CPU_BITS" = "x64" ; then
175
LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include],
176
[$FREETYPE_BASE_DIR/lib/$OPENJDK_TARGET_CPU-linux-gnu], [well-known location])
177
if test "x$FOUND_FREETYPE" != "xyes" ; then
178
LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include],
179
[$FREETYPE_BASE_DIR/lib64], [well-known location])
182
LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include],
183
[$FREETYPE_BASE_DIR/lib/i386-linux-gnu], [well-known location])
184
if test "x$FOUND_FREETYPE" != "xyes" ; then
185
LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include],
186
[$FREETYPE_BASE_DIR/lib32], [well-known location])
190
if test "x$FOUND_FREETYPE" != "xyes" ; then
191
LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include],
192
[$FREETYPE_BASE_DIR/lib], [well-known location])
195
if test "x$FOUND_FREETYPE" != "xyes" ; then
196
LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include],
197
[$FREETYPE_BASE_DIR/lib/$OPENJDK_TARGET_CPU-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI], [well-known location])
200
if test "x$FOUND_FREETYPE" != "xyes" ; then
201
LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include],
202
[$FREETYPE_BASE_DIR/lib/$OPENJDK_TARGET_CPU_AUTOCONF-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_ABI], [well-known location])
205
if test "x$FOUND_FREETYPE" != "xyes" ; then
206
FREETYPE_BASE_DIR="$SYSROOT/usr/X11"
207
LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include],
208
[$FREETYPE_BASE_DIR/lib], [well-known location])
211
if test "x$FOUND_FREETYPE" != "xyes" ; then
212
FREETYPE_BASE_DIR="$SYSROOT/usr/local"
213
LIB_CHECK_POTENTIAL_FREETYPE([$FREETYPE_BASE_DIR/include],
214
[$FREETYPE_BASE_DIR/lib], [well-known location])
216
fi # end check in well-known locations
218
if test "x$FOUND_FREETYPE" != "xyes" ; then
219
HELP_MSG_MISSING_DEPENDENCY([freetype])
220
AC_MSG_ERROR([Could not find freetype! $HELP_MSG ])
222
fi # end user specified settings
224
# Set FREETYPE_CFLAGS, _LIBS and _LIB_PATH from include and lib dir.
225
if test "x$FREETYPE_CFLAGS" = "x" ; then
226
if test -d $FREETYPE_INCLUDE_PATH/freetype2/freetype ; then
227
FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH/freetype2 -I$FREETYPE_INCLUDE_PATH"
229
FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH"
233
if test "x$FREETYPE_LIBS" = "x" ; then
234
FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -l$FREETYPE_BASE_NAME"
238
AC_MSG_RESULT([Using freetype: $FREETYPE_TO_USE])
240
AC_SUBST(FREETYPE_TO_USE)
241
AC_SUBST(FREETYPE_CFLAGS)
242
AC_SUBST(FREETYPE_LIBS)