[PATCH weston 03/11] configure.ac: Correctly check for functions and libraries

Ander Conselvan de Oliveira conselvan2 at gmail.com
Mon Dec 9 02:28:17 PST 2013


On 12/08/2013 08:45 PM, Quentin Glidic wrote:
> From: Quentin Glidic <sardemff7+git at sardemff7.net>
>
> AC_SEARCH_LIBS is preferred over AC_CHECK_FUNC and AC_CHECK_LIB

Why is it preferred?


>
> Signed-off-by: Quentin Glidic <sardemff7+git at sardemff7.net>
> ---
>   configure.ac | 37 +++++++++++++++++++++----------------
>   1 file changed, 21 insertions(+), 16 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 40ae145..c169311 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -41,9 +41,13 @@ AC_ARG_VAR([WESTON_SHELL_CLIENT],
>
>   PKG_PROG_PKG_CONFIG()
>
> -AC_CHECK_FUNC([dlopen], [],
> -              AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
> -AC_SUBST(DLOPEN_LIBS)
> +AC_SEARCH_LIBS([dlopen], [dl])
> +case "$ac_cv_search_dlopen" in
> +	no) AC_MSG_ERROR([dlopen support required for Weston]) ;;
> +	"none required") ;;
> +	*) DLOPEN_LIBS="$ac_cv_search_dlopen" ;;
> +esac
> +AC_SUBST([DLOPEN_LIBS])
>
>   AC_CHECK_DECL(SFD_CLOEXEC,[],
>   	      [AC_MSG_ERROR("SFD_CLOEXEC is needed to compile weston")],
> @@ -258,13 +262,13 @@ fi
>   AM_CONDITIONAL(ENABLE_VAAPI_RECORDER, test "x$have_libva" = xyes)
>
>
> -AC_CHECK_LIB([jpeg], [jpeg_CreateDecompress], have_jpeglib=yes)
> -if test x$have_jpeglib = xyes; then
> -  JPEG_LIBS="-ljpeg"
> -else
> -  AC_ERROR([libjpeg not found])
> -fi
> -AC_SUBST(JPEG_LIBS)
> +AC_SEARCH_LIBS([jpeg_CreateDecompress], [jpeg])
> +case "$ac_cv_search_pam_open_session" in

Copy & paste error, you got pam_open_session instead of 
jpeg_CreateDecompress.

> +	no) AC_MSG_ERROR([libjpeg required but not found]) ;;
> +	"none required") ;;
> +	*) JPEG_LIBS="$ac_cv_search_jpeg_CreateDecompress" ;;
> +esac
> +AC_SUBST([JPEG_LIBS])

Anyway, this seems like a change for the worse IMO. Now you're typing 
jpeg_CreateDecompress three times instead of just one. Ideally this 
could be just a one-liner, since this construct has to be repeated a few 
times.

Cheers,
Ander

>
>   PKG_CHECK_MODULES(CAIRO, [cairo])
>
> @@ -334,12 +338,13 @@ AS_IF([test "x$have_systemd_login_209" = "xyes"],
>   AC_ARG_ENABLE(weston-launch, [  --enable-weston-launch],, enable_weston_launch=yes)
>   AM_CONDITIONAL(BUILD_WESTON_LAUNCH, test x$enable_weston_launch == xyes)
>   if test x$enable_weston_launch == xyes; then
> -  AC_CHECK_LIB([pam], [pam_open_session], [have_pam=yes], [have_pam=no])
> -  if test x$have_pam == xno; then
> -    AC_ERROR([weston-launch requires pam])
> -  fi
> -  PAM_LIBS=-lpam
> -  AC_SUBST(PAM_LIBS)
> +	AC_SEARCH_LIBS([pam_open_session], [pam])
> +	case "$ac_cv_search_pam_open_session" in
> +		no) AC_MSG_ERROR([pam support required for weston-launch]) ;;
> +		"none required") ;;
> +		*) PAM_LIBS="$ac_cv_search_pam_open_session" ;;
> +	esac
> +	AC_SUBST([PAM_LIBS])
>   fi
>
>   if test x$enable_egl = xyes; then
>



More information about the wayland-devel mailing list