Configure fixes and enhancements, ported from branch-1.3.

- Abort configure if Xft was requested explicitly, but not found.
- Set config.h HAVE_* variables only if both library and header found.
- Replace deprecated configure macros with recommended ones.
- Improve indenting (clarify macro arguments).
- Remove all autoconf warnings (see autoconf --warnings=all).
- Normalize indenting with tabs+spaces.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11999 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2016-09-30 21:44:04 +00:00
parent 6b278da83d
commit 7e273a9fd3

View File

@ -5,7 +5,7 @@ dnl "$Id$"
dnl
dnl Configuration script for the Fast Light Tool Kit (FLTK).
dnl
dnl Copyright 1998-2015 by Bill Spitzak and others.
dnl Copyright 1998-2016 by Bill Spitzak and others.
dnl
dnl This library is free software. Distribution and use rights are outlined in
dnl the file "COPYING" which should have been included with this file. If this
@ -22,7 +22,8 @@ dnl We need at least autoconf 2.50...
AC_PREREQ([2.50])
dnl Required file in package...
AC_INIT(src/Fl.cxx)
AC_INIT
AC_CONFIG_SRCDIR([src/Fl.cxx])
AC_CANONICAL_HOST
@ -159,7 +160,6 @@ AC_SUBST(CAIROLIBS)
AC_SUBST(LINKFLTKCAIRO)
AC_SUBST(FLTKCAIROOPTION)
AC_SUBST(FLLIBNAME)
AC_SUBST(GLDEMOS)
AC_SUBST(GLLIBNAME)
@ -206,7 +206,6 @@ if test x$enable_cp936 = xyes; then
CFLAGS="$CFLAGS -DCP936"
fi
AC_ARG_ENABLE(gl, [ --enable-gl turn on OpenGL support [[default=yes]]])
AC_ARG_ENABLE(shared, [ --enable-shared turn on shared libraries [[default=no]]])
@ -282,13 +281,13 @@ if test x$enable_shared = xyes; then
ac_cv_cxx_fvisibility, [
OLDCXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE(,,
ac_cv_cxx_fvisibility=yes,
ac_cv_cxx_fvisibility=no)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[ac_cv_cxx_fvisibility=yes],
[ac_cv_cxx_fvisibility=no])
CXXFLAGS="$OLDCXXFLAGS"
AC_LANG_RESTORE
AC_LANG_POP([])
])
if test x"$ac_cv_cxx_fvisibility" = xyes; then
OPTIM="$OPTIM -fvisibility=hidden"
@ -299,13 +298,13 @@ if test x$enable_shared = xyes; then
ac_cv_cxx_fvisibility_inlines, [
OLDCXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE(,,
ac_cv_cxx_fvisibility_inlines=yes,
ac_cv_cxx_fvisibility_inlines=no)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[ac_cv_cxx_fvisibility_inlines=yes],
[ac_cv_cxx_fvisibility_inlines=no])
CXXFLAGS="$OLDCXXFLAGS"
AC_LANG_RESTORE
AC_LANG_POP([])
])
if test x"$ac_cv_cxx_fvisibility_inlines" = xyes; then
CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
@ -480,17 +479,19 @@ esac
dnl Does the C++ compiler support the bool type?
AC_CACHE_CHECK(whether the compiler recognizes bool as a built-in type,
ac_cv_cxx_bool,[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
int f(int x){return 1;}
int f(char x){return 1;}
int f(bool x){return 1;}
],[
]], [[
bool b = true;
return f(b);
], ac_cv_cxx_bool=yes, ac_cv_cxx_bool=no)
AC_LANG_RESTORE
]])],
[ac_cv_cxx_bool=yes],
[ac_cv_cxx_bool=no])
AC_LANG_POP([])
])
if test "$ac_cv_cxx_bool" != yes; then
@ -499,22 +500,24 @@ fi
dnl Standard headers and functions...
AC_HEADER_DIRENT
AC_CHECK_HEADER(sys/select.h,AC_DEFINE(HAVE_SYS_SELECT_H))
AC_CHECK_HEADER(sys/stdtypes.h,AC_DEFINE(HAVE_SYS_SELECT_H))
AC_CHECK_HEADERS([sys/select.h sys/stdtypes.h])
dnl Do we have the POSIX compatible scandir() prototype?
AC_CACHE_CHECK([whether we have the POSIX compatible scandir() prototype],
ac_cv_cxx_scandir_posix,[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([
#include <dirent.h>
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <dirent.h>
int func (const char *d, dirent ***list, void *sort) {
int n = scandir(d, list, 0, (int(*)(const dirent **, const dirent **))sort);
return n;
}
],[
], ac_cv_cxx_scandir_posix=yes, ac_cv_cxx_scandir_posix=no)
AC_LANG_RESTORE
]], [[
]])],
[ac_cv_cxx_scandir_posix=yes],
[ac_cv_cxx_scandir_posix=no])
AC_LANG_POP([])
])
dnl Define both HAVE_SCANDIR... macros, if the POSIX compatible function is
@ -561,10 +564,10 @@ AC_CHECK_FUNC(snprintf,[
AC_DEFINE(HAVE_SNPRINTF)
;;
esac])
AC_CHECK_HEADER(strings.h, AC_DEFINE(HAVE_STRINGS_H))
AC_CHECK_HEADERS(strings.h)
AC_CHECK_FUNCS(strcasecmp strlcat strlcpy)
AC_CHECK_HEADER(locale.h, AC_DEFINE(HAVE_LOCALE_H))
AC_CHECK_HEADERS(locale.h)
AC_CHECK_FUNCS(localeconv)
dnl FLTK library uses math library functions...
@ -593,9 +596,11 @@ AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
[if test "$GCC" = yes; then
ac_cv_c_long_long=yes
else
AC_TRY_COMPILE(,[long long int i;],
ac_cv_c_long_long=yes,
ac_cv_c_long_long=no)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]],
[[long long int i;]])],
[ac_cv_c_long_long=yes],
[ac_cv_c_long_long=no])
fi])
if test $ac_cv_c_long_long = yes; then
@ -789,7 +794,7 @@ case $host_os in
esac
if test "x$enable_threads" != xno -a x$check_pthread = xyes; then
AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
AC_CHECK_HEADERS(pthread.h)
if test x$ac_cv_header_pthread_h = xyes; then
dnl Check various threading options for the platforms we support
@ -797,10 +802,12 @@ if test "x$enable_threads" != xno -a x$check_pthread = xyes; then
AC_MSG_CHECKING([for pthread_create using $flag])
SAVELIBS="$LIBS"
LIBS="$flag $LIBS"
AC_TRY_LINK([#include <pthread.h>],
[pthread_create(0, 0, 0, 0);],
have_pthread=yes,
LIBS="$SAVELIBS")
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <pthread.h>]],
[[pthread_create(0, 0, 0, 0);]])],
[have_pthread=yes],
[LIBS="$SAVELIBS"])
AC_MSG_RESULT([$have_pthread])
if test $have_pthread = yes; then
@ -844,7 +851,6 @@ case $host_os_gui in
LDFLAGS="-mwindows $LDFLAGS"
DSOFLAGS="-mwindows $DSOFLAGS"
LIBS="$LIBS -lole32 -luuid -lcomctl32"
#BUILD_GDI="Yes"
BUILD="WIN"
if test "x$with_optim" = x; then
dnl Avoid -Os optimization on Cygwin/MinGW
@ -882,7 +888,6 @@ case $host_os_gui in
darwin*)
AC_DEFINE(__APPLE_QUARTZ__)
#USEMMFILES="Yes"
BUILD="OSX"
# MacOS X uses Cocoa for graphics.
@ -942,7 +947,6 @@ case $host_os_gui in
LDFLAGS="$X_LIBS $LDFLAGS"
DSOFLAGS="$X_LIBS $DSOFLAGS"
AC_DEFINE(USE_X11)
#BUILD_X11="Yes"
BUILD="X11"
if test "x$x_includes" != x; then
ac_cpp="$ac_cpp -I$x_includes"
@ -954,12 +958,16 @@ case $host_os_gui in
if test x$enable_gl != xno; then
AC_SEARCH_LIBS(dlopen, dl)
AC_CHECK_HEADER(GL/gl.h,
AC_CHECK_LIB(GL, glXMakeCurrent, AC_DEFINE(HAVE_GL) GLLIB="-lGL",
AC_CHECK_LIB(MesaGL,glXMakeCurrent, AC_DEFINE(HAVE_GL) GLLIB=" -lMesaGL",,
-lm),
-lm)
AC_CHECK_LIB(GL, glXMakeCurrent,
[AC_DEFINE(HAVE_GL)
GLLIB="-lGL"],
AC_CHECK_LIB(MesaGL, glXMakeCurrent,
[AC_DEFINE(HAVE_GL)
GLLIB="-lMesaGL"],,
[-lm]),
[-lm])
AC_CHECK_LIB(GL, glXGetProcAddressARB,
AC_DEFINE(HAVE_GLXGETPROCADDRESSARB),, -lm)
AC_DEFINE(HAVE_GLXGETPROCADDRESSARB),, [-lm])
)
AC_CHECK_HEADER(GL/glu.h,
AC_DEFINE(HAVE_GL_GLU_H)
@ -987,17 +995,20 @@ case $host_os_gui in
dnl Check for Xinerama support unless disabled...
AC_ARG_ENABLE(xinerama, [ --enable-xinerama turn on Xinerama support [[default=yes]]])
xinerama_found=no
if test x$enable_xinerama != xno; then
AC_CHECK_LIB(Xinerama,XineramaIsActive,
AC_DEFINE(HAVE_XINERAMA)
LIBS="-lXinerama $LIBS")
AC_CHECK_LIB(Xinerama, XineramaIsActive,
[AC_DEFINE(HAVE_XINERAMA)
LIBS="-lXinerama $LIBS"
xinerama_found=yes])
fi
dnl Check for the Xft library unless disabled...
AC_ARG_ENABLE(xft, [ --enable-xft turn on Xft support [[default=yes]]])
xft_found=no
if test x$enable_xft != xno; then
AC_PATH_PROG(FTCONFIG,freetype-config)
AC_PATH_PROG(FTCONFIG, freetype-config)
if test "x$FTCONFIG" != x; then
CPPFLAGS="`$FTCONFIG --cflags` $CPPFLAGS"
@ -1007,51 +1018,81 @@ case $host_os_gui in
AC_CHECK_LIB(fontconfig, FcPatternCreate)
AC_CHECK_HEADER(X11/Xft/Xft.h,
AC_CHECK_LIB(Xft, XftDrawCreate,
AC_DEFINE(USE_XFT)
#BUILD_XFT="Yes"
[AC_DEFINE(USE_XFT)
LIBS="-lXft $LIBS"
BUILD="XFT"
LIBS="-lXft $LIBS"))
xft_found=yes]))
fi
fi
dnl Issue a warning message if Xft was not found, abort configure
dnl if Xft was requested explicitly (but not found)
if test x$enable_xft != xno -a x$xft_found != xyes; then
AC_MSG_WARN([could not find the required Xft headers and/or libraries.])
AC_MSG_NOTICE([please install Xft headers and libraries or use 'configure --disable-xft'.])
if test x$enable_xft = xyes; then
AC_MSG_ERROR([Aborting.])
fi
fi
dnl Check for the Xdbe extension unless disabled...
AC_ARG_ENABLE(xdbe, [ --enable-xdbe turn on Xdbe support [[default=yes]]])
xdbe_found=no
if test x$enable_xdbe != xno; then
AC_CHECK_HEADER(X11/extensions/Xdbe.h, AC_DEFINE(HAVE_XDBE),,
AC_CHECK_HEADER(
[X11/extensions/Xdbe.h],
[AC_CHECK_LIB(Xext, XdbeQueryExtension,
[AC_DEFINE(HAVE_XDBE)
LIBS="-lXext $LIBS"
xdbe_found=yes])],
[],
[#include <X11/Xlib.h>])
AC_CHECK_LIB(Xext, XdbeQueryExtension,
LIBS="-lXext $LIBS")
fi
dnl Check for the Xfixes extension unless disabled...
AC_ARG_ENABLE(xfixes, [ --enable-xfixes turn on Xfixes support [[default=yes]]])
xfixes_found=no
if test x$enable_xfixes != xno; then
AC_CHECK_HEADER(X11/extensions/Xfixes.h, AC_DEFINE(HAVE_XFIXES),,
AC_CHECK_HEADER(
[X11/extensions/Xfixes.h],
[AC_CHECK_LIB(Xfixes, XFixesQueryExtension,
[AC_DEFINE(HAVE_XFIXES)
LIBS="-lXfixes $LIBS"
xfixes_found=yes])],
[],
[#include <X11/Xlib.h>])
AC_CHECK_LIB(Xfixes, XFixesQueryExtension,
LIBS="-lXfixes $LIBS")
fi
dnl Check for the Xcursor library unless disabled...
AC_ARG_ENABLE(xcursor, [ --enable-xcursor turn on Xcursor support [[default=yes]]])
xcursor_found=no
if test x$enable_xcursor != xno; then
AC_CHECK_HEADER(X11/Xcursor/Xcursor.h, AC_DEFINE(HAVE_XCURSOR),,
AC_CHECK_HEADER(
[X11/Xcursor/Xcursor.h],
[AC_CHECK_LIB(Xcursor, XcursorImageCreate,
[AC_DEFINE(HAVE_XCURSOR)
LIBS="-lXcursor $LIBS"
xcursor_found=yes])],
[],
[#include <X11/Xlib.h>])
AC_CHECK_LIB(Xcursor, XcursorImageCreate,
LIBS="-lXcursor $LIBS")
fi
dnl Check for the Xrender library unless disabled...
AC_ARG_ENABLE(xrender, [ --enable-xrender turn on Xrender support [[default=yes]]])
xrender_found=no
if test x$enable_xrender != xno; then
AC_CHECK_HEADER(X11/extensions/Xrender.h, AC_DEFINE(HAVE_XRENDER),,
AC_CHECK_HEADER(
[X11/extensions/Xrender.h],
[AC_CHECK_LIB(Xrender, XRenderQueryVersion,
[AC_DEFINE(HAVE_XRENDER)
LIBS="-lXrender $LIBS"
xrender_found=yes])],
[],
[#include <X11/Xlib.h>])
AC_CHECK_LIB(Xrender, XRenderQueryVersion,
LIBS="-lXrender $LIBS")
fi
dnl Check for the X11/Xregion.h header file...
@ -1224,42 +1265,45 @@ if test -n "$GCC"; then
AC_MSG_CHECKING([if GCC supports -fno-exceptions])
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-exceptions"
AC_TRY_COMPILE(,,
OPTIM="$OPTIM -fno-exceptions"
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[OPTIM="$OPTIM -fno-exceptions"
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
CFLAGS="$OLDCFLAGS"
# See if GCC supports -fno-strict-aliasing...
AC_MSG_CHECKING([if GCC supports -fno-strict-aliasing])
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-strict-aliasing"
AC_TRY_COMPILE(,,
OPTIM="$OPTIM -fno-strict-aliasing"
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[OPTIM="$OPTIM -fno-strict-aliasing"
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
CFLAGS="$OLDCFLAGS"
dnl Experimental (as of 17 Feb 2015):
dnl Make sure that shared libraries don't have undefined references
# See if ld supports -no-undefined...
AC_MSG_CHECKING([if ld supports -no-undefined])
OLDLDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,-no-undefined"
AC_TRY_LINK(,,
[DSOFLAGS="$DSOFLAGS -Wl,-no-undefined"]
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[DSOFLAGS="$DSOFLAGS -Wl,-no-undefined"
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
LDFLAGS="$OLDLDFLAGS"
# See if ld supports -Bsymbolic-functions...
AC_MSG_CHECKING([if ld supports -Bsymbolic-functions])
OLDLDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions"
AC_TRY_LINK(,,
[DSOFLAGS="$DSOFLAGS -Wl,-Bsymbolic-functions"]
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[DSOFLAGS="$DSOFLAGS -Wl,-Bsymbolic-functions"
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
LDFLAGS="$OLDLDFLAGS"
# See if toolchain supports a sectioned build...
@ -1268,11 +1312,12 @@ dnl Make sure that shared libraries don't have undefined references
OLDCFLAGS="$CFLAGS"
LDFLAGS="$LDFLAGS -Wl,-gc-sections"
CFLAGS="$CFLAGS -ffunction-sections -fdata-sections"
AC_TRY_LINK(,,
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[DSOFLAGS="$DSOFLAGS -Wl,-gc-sections"
OPTIM="$OPTIM -ffunction-sections -fdata-sections"]
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no]))
OPTIM="$OPTIM -ffunction-sections -fdata-sections"
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
LDFLAGS="$OLDLDFLAGS"
CFLAGS="$OLDCFLAGS"
@ -1289,11 +1334,12 @@ dnl Make sure that shared libraries don't have undefined references
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fpermissive"
AC_TRY_COMPILE(,,
CXXFLAGS="$CXXFLAGS -fpermissive"
AC_MSG_RESULT([yes]),
CFLAGS="$OLDCFLAGS"
AC_MSG_RESULT([no]))
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]], [[]])],
[CXXFLAGS="$CXXFLAGS -fpermissive"
AC_MSG_RESULT(yes)],
[CFLAGS="$OLDCFLAGS"
AC_MSG_RESULT(no)])
;;
esac
else
@ -1437,14 +1483,23 @@ case $host_os_gui in
;;
*)
graphics="X11"
if test x$enable_xft != xno; then
graphics="$graphics+Xft"
if test x$xft_found = xyes; then
graphics="$graphics + Xft"
fi
if test x$enable_xdbe != xno; then
graphics="$graphics+Xdbe"
if test x$xdbe_found = xyes; then
graphics="$graphics + Xdbe"
fi
if test x$enable_xinerama != xno; then
graphics="$graphics+Xinerama"
if test x$xfixes_found = xyes; then
graphics="$graphics + Xfixes"
fi
if test x$xinerama_found = xyes; then
graphics="$graphics + Xinerama"
fi
if test x$xcursor_found = xyes; then
graphics="$graphics + Xcursor"
fi
if test x$xrender_found = xyes; then
graphics="$graphics + Xrender"
fi
;;
esac
@ -1486,7 +1541,6 @@ if test x$enable_cairoext = xyes; then
echo " CAIRO=internal_use"
fi
if test x$enable_largefile != xno; then
echo " Large Files: YES"
else
@ -1512,7 +1566,8 @@ AC_SUBST(BINARY_DIR)
dnl Write all of the files...
AC_CONFIG_HEADER(config.h:configh.in)
AC_CONFIG_HEADER(FL/abi-version.h:abi-version.in)
AC_OUTPUT(makeinclude fltk.list fltk-config fltk.spec FL/Makefile)
AC_CONFIG_FILES([makeinclude fltk.list fltk-config fltk.spec FL/Makefile])
AC_OUTPUT
dnl Make sure the fltk-config script is executable...
chmod +x fltk-config