common/autoconf/libraries.m4

changeset 2220
47fda751abb6
parent 2215
7a73b8b4ac8a
child 2223
01cc48ed67f3
equal deleted inserted replaced
2219:cb1203f48728 2220:47fda751abb6
249 249
250 AC_SUBST(CUPS_CFLAGS) 250 AC_SUBST(CUPS_CFLAGS)
251 251
252 ]) 252 ])
253 253
254 AC_DEFUN([LIB_BUILD_FREETYPE],
255 [
256 FREETYPE_SRC_PATH="$1"
257 BUILD_FREETYPE=yes
258
259 # Check if the freetype sources are acessible..
260 if ! test -d $FREETYPE_SRC_PATH; then
261 AC_MSG_WARN([--with-freetype-src specified, but can't find path "$FREETYPE_SRC_PATH" - ignoring --with-freetype-src])
262 BUILD_FREETYPE=no
263 fi
264 # ..and contain a vc2010 project file
265 vcxproj_path="$FREETYPE_SRC_PATH/builds/windows/vc2010/freetype.vcxproj"
266 if test "x$BUILD_FREETYPE" = xyes && ! test -s $vcxproj_path; then
267 AC_MSG_WARN([Can't find project file $vcxproj_path (you may try a newer freetype version) - ignoring --with-freetype-src])
268 BUILD_FREETYPE=no
269 fi
270 # Now check if configure found a version of 'msbuild.exe'
271 if test "x$BUILD_FREETYPE" = xyes && test "x$MSBUILD" == x ; then
272 AC_MSG_WARN([Can't find an msbuild.exe executable (you may try to install .NET 4.0) - ignoring --with-freetype-src])
273 BUILD_FREETYPE=no
274 fi
275
276 # Ready to go..
277 if test "x$BUILD_FREETYPE" = xyes; then
278
279 # msbuild requires trailing slashes for output directories
280 freetype_lib_path="$FREETYPE_SRC_PATH/lib$OPENJDK_TARGET_CPU_BITS/"
281 freetype_lib_path_unix="$freetype_lib_path"
282 freetype_obj_path="$FREETYPE_SRC_PATH/obj$OPENJDK_TARGET_CPU_BITS/"
283 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(vcxproj_path)
284 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(freetype_lib_path)
285 BASIC_WINDOWS_REWRITE_AS_WINDOWS_MIXED_PATH(freetype_obj_path)
286 if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
287 freetype_platform=x64
288 else
289 freetype_platform=win32
290 fi
291
292 # The original freetype project file is for VS 2010 (i.e. 'v100'),
293 # so we have to adapt the toolset if building with any other toolsed (i.e. SDK).
294 # Currently 'PLATFORM_TOOLSET' is set in 'TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT'/
295 # 'TOOLCHAIN_CHECK_POSSIBLE_WIN_SDK_ROOT' in toolchain_windows.m4
296 AC_MSG_NOTICE([Trying to compile freetype sources with PlatformToolset=$PLATFORM_TOOLSET to $freetype_lib_path_unix ...])
297
298 # First we try to build the freetype.dll
299 $ECHO -e "@echo off\n"\
300 "$MSBUILD $vcxproj_path "\
301 "/p:PlatformToolset=$PLATFORM_TOOLSET "\
302 "/p:Configuration=\"Release Multithreaded\" "\
303 "/p:Platform=$freetype_platform "\
304 "/p:ConfigurationType=DynamicLibrary "\
305 "/p:TargetName=freetype "\
306 "/p:OutDir=\"$freetype_lib_path\" "\
307 "/p:IntDir=\"$freetype_obj_path\" > freetype.log" > freetype.bat
308 cmd /c freetype.bat
309
310 if test -s "$freetype_lib_path_unix/freetype.dll"; then
311 # If that succeeds we also build freetype.lib
312 $ECHO -e "@echo off\n"\
313 "$MSBUILD $vcxproj_path "\
314 "/p:PlatformToolset=$PLATFORM_TOOLSET "\
315 "/p:Configuration=\"Release Multithreaded\" "\
316 "/p:Platform=$freetype_platform "\
317 "/p:ConfigurationType=StaticLibrary "\
318 "/p:TargetName=freetype "\
319 "/p:OutDir=\"$freetype_lib_path\" "\
320 "/p:IntDir=\"$freetype_obj_path\" >> freetype.log" > freetype.bat
321 cmd /c freetype.bat
322
323 if test -s "$freetype_lib_path_unix/freetype.lib"; then
324 # Once we build both, lib and dll, set freetype lib and include path appropriately
325 POTENTIAL_FREETYPE_INCLUDE_PATH="$FREETYPE_SRC_PATH/include"
326 POTENTIAL_FREETYPE_LIB_PATH="$freetype_lib_path_unix"
327 AC_MSG_NOTICE([Compiling freetype sources succeeded! (see freetype.log for build results)])
328 else
329 BUILD_FREETYPE=no
330 fi
331 else
332 BUILD_FREETYPE=no
333 fi
334 fi
335 ])
336
254 AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE], 337 AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
255 [ 338 [
256 POTENTIAL_FREETYPE_INCLUDE_PATH="$1" 339 POTENTIAL_FREETYPE_INCLUDE_PATH="$1"
257 POTENTIAL_FREETYPE_LIB_PATH="$2" 340 POTENTIAL_FREETYPE_LIB_PATH="$2"
258 METHOD="$3" 341 METHOD="$3"
259 342
260 # First check if the files exists. 343 # First check if the files exists.
261 if test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then 344 if test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
262 # We found an arbitrary include file. That's a good sign. 345 # We found an arbitrary include file. That's a good sign.
263 AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD]) 346 AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD])
264 FOUND_FREETYPE=yes 347 FOUND_FREETYPE=yes
306 (expecting the libraries under PATH/lib and the headers under PATH/include)])]) 389 (expecting the libraries under PATH/lib and the headers under PATH/include)])])
307 AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include], 390 AC_ARG_WITH(freetype-include, [AS_HELP_STRING([--with-freetype-include],
308 [specify directory for the freetype include files])]) 391 [specify directory for the freetype include files])])
309 AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib], 392 AC_ARG_WITH(freetype-lib, [AS_HELP_STRING([--with-freetype-lib],
310 [specify directory for the freetype library])]) 393 [specify directory for the freetype library])])
394 AC_ARG_WITH(freetype-src, [AS_HELP_STRING([--with-freetype-src],
395 [specify directory with freetype sources to automatically build the library (experimental, Windows-only)])])
311 AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling], 396 AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
312 [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])]) 397 [disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])
313 398
314 FREETYPE_CFLAGS= 399 FREETYPE_CFLAGS=
315 FREETYPE_LIBS= 400 FREETYPE_LIBS=
316 FREETYPE_BUNDLE_LIB_PATH= 401 FREETYPE_BUNDLE_LIB_PATH=
317 402
318 if test "x$FREETYPE_NOT_NEEDED" = xyes; then 403 if test "x$FREETYPE_NOT_NEEDED" = xyes; then
319 if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then 404 if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x || test "x$with_freetype_src" != x; then
320 AC_MSG_WARN([freetype not used, so --with-freetype is ignored]) 405 AC_MSG_WARN([freetype not used, so --with-freetype is ignored])
321 fi 406 fi
322 if test "x$enable_freetype_bundling" != x; then 407 if test "x$enable_freetype_bundling" != x; then
323 AC_MSG_WARN([freetype not used, so --enable-freetype-bundling is ignored]) 408 AC_MSG_WARN([freetype not used, so --enable-freetype-bundling is ignored])
324 fi 409 fi
325 else 410 else
326 # freetype is needed to build; go get it! 411 # freetype is needed to build; go get it!
327 412
328 BUNDLE_FREETYPE="$enable_freetype_bundling" 413 BUNDLE_FREETYPE="$enable_freetype_bundling"
414
415 if test "x$with_freetype_src" != x; then
416 if test "x$OPENJDK_TARGET_OS" = xwindows; then
417 # Try to build freetype if --with-freetype-src was given on Windows
418 LIB_BUILD_FREETYPE([$with_freetype_src])
419 if test "x$BUILD_FREETYPE" = xyes; then
420 # Okay, we built it. Check that it works.
421 LIB_CHECK_POTENTIAL_FREETYPE($POTENTIAL_FREETYPE_INCLUDE_PATH, $POTENTIAL_FREETYPE_LIB_PATH, [--with-freetype-src])
422 if test "x$FOUND_FREETYPE" != xyes; then
423 AC_MSG_ERROR([Can not use the built freetype at location given by --with-freetype-src])
424 fi
425 else
426 AC_MSG_NOTICE([User specified --with-freetype-src but building freetype failed. (see freetype.log for build results)])
427 AC_MSG_ERROR([Consider building freetype manually and using --with-freetype instead.])
428 fi
429 else
430 AC_MSG_WARN([--with-freetype-src is currently only supported on Windows - ignoring])
431 fi
432 fi
329 433
330 if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then 434 if test "x$with_freetype" != x || test "x$with_freetype_include" != x || test "x$with_freetype_lib" != x; then
331 # User has specified settings 435 # User has specified settings
332 436
333 if test "x$BUNDLE_FREETYPE" = x; then 437 if test "x$BUNDLE_FREETYPE" = x; then
334 # If not specified, default is to bundle freetype 438 # If not specified, default is to bundle freetype
335 BUNDLE_FREETYPE=yes 439 BUNDLE_FREETYPE=yes
336 fi 440 fi
337 441
338 if test "x$with_freetype" != x; then 442 if test "x$with_freetype" != x; then
339 POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype/include" 443 POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype/include"
340 POTENTIAL_FREETYPE_LIB_PATH="$with_freetype/lib" 444 POTENTIAL_FREETYPE_LIB_PATH="$with_freetype/lib"
341 fi 445 fi
342 446
343 # Allow --with-freetype-lib and --with-freetype-include to override 447 # Allow --with-freetype-lib and --with-freetype-include to override
344 if test "x$with_freetype_include" != x; then 448 if test "x$with_freetype_include" != x; then
345 POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include" 449 POTENTIAL_FREETYPE_INCLUDE_PATH="$with_freetype_include"
346 fi 450 fi
347 if test "x$with_freetype_lib" != x; then 451 if test "x$with_freetype_lib" != x; then
469 FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH/freetype2 -I$FREETYPE_INCLUDE_PATH" 573 FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH/freetype2 -I$FREETYPE_INCLUDE_PATH"
470 else 574 else
471 FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH" 575 FREETYPE_CFLAGS="-I$FREETYPE_INCLUDE_PATH"
472 fi 576 fi
473 fi 577 fi
474 578
475 if test "x$FREETYPE_LIBS" = x; then 579 if test "x$FREETYPE_LIBS" = x; then
476 BASIC_FIXUP_PATH(FREETYPE_LIB_PATH) 580 BASIC_FIXUP_PATH(FREETYPE_LIB_PATH)
477 if test "x$OPENJDK_TARGET_OS" = xwindows; then 581 if test "x$OPENJDK_TARGET_OS" = xwindows; then
478 FREETYPE_LIBS="$FREETYPE_LIB_PATH/freetype.lib" 582 FREETYPE_LIBS="$FREETYPE_LIB_PATH/freetype.lib"
479 else 583 else
485 AC_MSG_CHECKING([if we can compile and link with freetype]) 589 AC_MSG_CHECKING([if we can compile and link with freetype])
486 AC_LANG_PUSH(C++) 590 AC_LANG_PUSH(C++)
487 PREV_CXXCFLAGS="$CXXFLAGS" 591 PREV_CXXCFLAGS="$CXXFLAGS"
488 PREV_LIBS="$LIBS" 592 PREV_LIBS="$LIBS"
489 PREV_CXX="$CXX" 593 PREV_CXX="$CXX"
490 CXXFLAGS="$CXXFLAGS $FREETYPE_CFLAGS" 594 CXXFLAGS="$CXXFLAGS $FREETYPE_CFLAGS"
491 LIBS="$LIBS $FREETYPE_LIBS" 595 LIBS="$LIBS $FREETYPE_LIBS"
492 CXX="$FIXPATH $CXX" 596 CXX="$FIXPATH $CXX"
493 AC_LINK_IFELSE([AC_LANG_SOURCE([[ 597 AC_LINK_IFELSE([AC_LANG_SOURCE([[
494 #include<ft2build.h> 598 #include<ft2build.h>
495 #include FT_FREETYPE_H 599 #include FT_FREETYPE_H
503 ], 607 ],
504 [ 608 [
505 AC_MSG_RESULT([no]) 609 AC_MSG_RESULT([no])
506 AC_MSG_NOTICE([Could not compile and link with freetype. This might be a 32/64-bit mismatch.]) 610 AC_MSG_NOTICE([Could not compile and link with freetype. This might be a 32/64-bit mismatch.])
507 AC_MSG_NOTICE([Using FREETYPE_CFLAGS=$FREETYPE_CFLAGS and FREETYPE_LIBS=$FREETYPE_LIBS]) 611 AC_MSG_NOTICE([Using FREETYPE_CFLAGS=$FREETYPE_CFLAGS and FREETYPE_LIBS=$FREETYPE_LIBS])
508 612
509 HELP_MSG_MISSING_DEPENDENCY([freetype]) 613 HELP_MSG_MISSING_DEPENDENCY([freetype])
510 614
511 AC_MSG_ERROR([Can not continue without freetype. $HELP_MSG]) 615 AC_MSG_ERROR([Can not continue without freetype. $HELP_MSG])
512 ] 616 ]
513 ) 617 )
514 CXXCFLAGS="$PREV_CXXFLAGS" 618 CXXCFLAGS="$PREV_CXXFLAGS"
515 LIBS="$PREV_LIBS" 619 LIBS="$PREV_LIBS"

mercurial