1dnl $Id: xdt-depends.m4 2273 2005-01-31 19:38:09Z benny $ 2dnl 3dnl Copyright (c) 2002-2005 4dnl The Xfce development team. All rights reserved. 5dnl 6dnl Written for Xfce by Benedikt Meurer <benny@xfce.org>. 7dnl 8dnl xdt-depends 9dnl ----------- 10dnl Contains M4 macros to check for software dependencies. 11dnl Partly based on prior work of the XDG contributors. 12dnl 13 14 15 16dnl We need recent a autoconf version 17AC_PREREQ([2.53]) 18 19 20 21dnl XDT_PROG_PKG_CONFIG() 22dnl 23dnl Checks for the freedesktop.org pkg-config 24dnl utility and sets the PKG_CONFIG environment 25dnl variable to the full path if found. 26dnl 27AC_DEFUN([XDT_PROG_PKG_CONFIG], 28[ 29 # minimum supported version of pkg-config 30 xdt_cv_PKG_CONFIG_MIN_VERSION=0.9.0 31 32 # lookup pkg-config utility 33 if test x"$PKG_CONFIG" = x""; then 34 AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no]) 35 36 if test x"$PKG_CONFIG" = x"no"; then 37 echo "*** The pkg-config utility could not be found on your system." 38 echo "*** Make sure it is in your path, or set the PKG_CONFIG" 39 echo "*** environment variable to the full path to pkg-config." 40 echo "*** You can download pkg-config from the freedesktop.org" 41 echo "*** software repository at" 42 echo "***" 43 echo "*** http://www.freedesktop.org/software/pkgconfig" 44 echo "***" 45 exit 1 46 fi 47 48 # check pkg-config version 49 AC_MSG_CHECKING([for pkg-config >= $xdt_cv_PKG_CONFIG_MIN_VERSION]) 50 if $PKG_CONFIG --atleast-pkgconfig-version $xdt_cv_PKG_CONFIG_MIN_VERSION; then 51 xdt_cv_PKG_CONFIG_VERSION=`$PKG_CONFIG --version` 52 AC_MSG_RESULT([$xdt_cv_PKG_CONFIG_VERSION]) 53 else 54 xdt_cv_PKG_CONFIG_VERSION=`$PKG_CONFIG --version` 55 AC_MSG_RESULT([$xdt_cv_PKG_CONFIG_VERSION]) 56 echo "*** Your version of pkg-config is too old. You need atleast" 57 echo "*** pkg-config $xdt_cv_PKG_CONFIG_MIN_VERSION or newer. You can download pkg-config " 58 echo "*** from the freedesktop.org software repository at" 59 echo "***" 60 echo "*** http://www.freedesktop.org/software/pkgconfig" 61 echo "***" 62 exit 1 63 fi 64 fi 65]) 66 67 68 69dnl XDT_CHECK_PACKAGE(varname, package, version, [action-if], [action-if-not]) 70dnl 71dnl Checks if "package" >= "version" is installed on the 72dnl target system, using the pkg-config utility. If the 73dnl dependency is met, "varname"_CFLAGS, "varname"_LIBS, 74dnl "varname"_VERSION and "varname"_REQUIRED_VERSION 75dnl will be set and marked for substition. 76dnl 77dnl "varname"_REQUIRED_VERSION will be set to the value of 78dnl "version". This is mostly useful to automatically 79dnl place the correct version information into the RPM 80dnl .spec file. 81dnl 82dnl In addition, if the dependency is met, "action-if" will 83dnl be executed if given. 84dnl 85dnl If the package check fails, "action-if-not" will be 86dnl executed. If this parameter isn't specified, a diagnostic 87dnl message will be printed and the configure script will 88dnl be terminated with exit code 1. 89dnl 90AC_DEFUN([XDT_CHECK_PACKAGE], 91[ 92 XDT_PROG_PKG_CONFIG() 93 94 AC_MSG_CHECKING([for $2 >= $3]) 95 if $PKG_CONFIG "--atleast-version=$3" "$2" >/dev/null 2>&1; then 96 $1_VERSION=`$PKG_CONFIG --modversion "$2"` 97 AC_MSG_RESULT([$$1_VERSION]) 98 99 AC_MSG_CHECKING([$1_CFLAGS]) 100 $1_CFLAGS=`$PKG_CONFIG --cflags "$2"` 101 AC_MSG_RESULT([$$1_CFLAGS]) 102 103 AC_MSG_CHECKING([$1_LIBS]) 104 $1_LIBS=`$PKG_CONFIG --libs "$2"` 105 AC_MSG_RESULT([$$1_LIBS]) 106 107 $1_REQUIRED_VERSION=$3 108 109 AC_SUBST([$1_VERSION]) 110 AC_SUBST([$1_CFLAGS]) 111 AC_SUBST([$1_LIBS]) 112 AC_SUBST([$1_REQUIRED_VERSION]) 113 114 ifelse([$4], , , [$4]) 115 elif $PKG_CONFIG --exists "$2" >/dev/null 2>&1; then 116 xdg_cv_version=`$PKG_CONFIG --modversion "$2"` 117 AC_MSG_RESULT([found, but $xdt_cv_version]) 118 119 ifelse([$5], , 120 [ 121 echo "*** The required package $2 was found on your system," 122 echo "*** but the installed version ($xdt_cv_version) is too old." 123 echo "*** Please upgrade $2 to atleast version $3, or adjust" 124 echo "*** the PKG_CONFIG_PATH environment variable if you installed" 125 echo "*** the new version of the package in a nonstandard prefix so" 126 echo "*** pkg-config is able to find it." 127 exit 1 128 ], [$5]) 129 else 130 AC_MSG_RESULT([not found]) 131 132 ifelse([$5], , 133 [ 134 echo "*** The required package $2 was not found on your system." 135 echo "*** Please install $2 (atleast version $3) or adjust" 136 echo "*** the PKG_CONFIG_PATH environment variable if you" 137 echo "*** installed the package in a nonstandard prefix so that" 138 echo "*** pkg-config is able to find it." 139 exit 1 140 ], [$5]) 141 fi 142]) 143 144 145 146dnl XDT_CHECK_OPTIONAL_PACKAGE(varname, package, version, optionname, helpstring, [default]) 147dnl 148dnl Checks for an optional dependency on "package" >= "version". "default" 149dnl can be "yes" or "no" (defaults to "yes" if not specified) and controls 150dnl whether configure should check this dependency by default, or only if 151dnl the user explicitly enables it using a command line switch. 152dnl 153dnl This macro automatically adds a commandline switch based on the "optionname" 154dnl parameter (--enable-optionname/--disable-optionname), which allows the 155dnl user to explicitly control whether this optional dependency should be 156dnl enabled or not. The "helpstring" parameter gives a brief(!) description 157dnl about this dependency. 158dnl 159dnl If the user chose to enable this dependency and the required package 160dnl was found, this macro defines the variable "varname"_FOUND and sets it 161dnl to the string "yes", in addition to the 4 variables set by XDT_CHECK_PACKAGE. 162dnl But "varname"_FOUND will not be marked for substition. Furthermore, 163dnl a CPP define HAVE_"varname" will be placed in config.h (or added to 164dnl the cc command line, depending on your configure.ac) and set to 165dnl 1. 166dnl 167AC_DEFUN([XDT_CHECK_OPTIONAL_PACKAGE], 168[ 169 AC_REQUIRE([XDT_PROG_PKG_CONFIG]) 170 171 AC_ARG_ENABLE([$4], 172AC_HELP_STRING([--enable-$4], [Enable checking for $5 (default=m4_default([$6], [yes]))]) 173AC_HELP_STRING([--disable-$4], [Disable checking for $5]), 174 [xdt_cv_$1_check=$enableval], [xdt_cv_$1_check=m4_default([$6], [yes])]) 175 176 if test x"$xdt_cv_$1_check" = x"yes"; then 177 if $PKG_CONFIG --exists "$2 >= $3" >/dev/null 2>&1; then 178 XDT_CHECK_PACKAGE([$1], [$2], [$3], 179 [ 180 AC_DEFINE([HAVE_$1], [1], [Define if $2 >= $3 present]) 181 $1_FOUND="yes" 182 ]) 183 else 184 AC_MSG_CHECKING([for optional package $2 >= $3]) 185 AC_MSG_RESULT([not found]) 186 fi 187 else 188 AC_MSG_CHECKING([for optional package $2]) 189 AC_MSG_RESULT([disabled]) 190 fi 191 192 AM_CONDITIONAL([HAVE_$1], [test x"$$1_FOUND" = x"yes"]) 193]) 194 195 196 197dnl BM_DEPEND(varname, package, version) 198dnl 199dnl Simple wrapper for XDT_CHECK_PACKAGE("varname", "package", "version"). Kept 200dnl for backward compatibility. Will be removed in the future. 201dnl 202AC_DEFUN([BM_DEPEND], 203[ 204 XDT_CHECK_PACKAGE([$1], [$2], [$3]) 205]) 206 207 208 209dnl BM_DEPEND_CHECK(var, pkg, version, name, helpstring, default) 210dnl 211dnl Simple wrapper for XDT_CHECK_OPTIONAL_PACKAGE(). Kept for backward 212dnl compatibility. Will be removed in the future. 213dnl 214AC_DEFUN([BM_DEPEND_CHECK], 215[ 216 XDT_CHECK_OPTIONAL_PACKAGE([$1], [$2], [$3], [$4], [$5], [$6]) 217]) 218 219 220 221dnl XDT_CHECK_LIBX11() 222dnl 223dnl Executes various checks for X11. Sets LIBX11_CFLAGS, LIBX11_LDFLAGS 224dnl and LIBX11_LIBS (and marks them for substitution). In addition 225dnl HAVE_LIBX11 is set to 1 in config.h, if the X window system and 226dnl the development files are detected on the target system. 227dnl 228AC_DEFUN([XDT_CHECK_LIBX11], 229[ 230 AC_REQUIRE([AC_PATH_XTRA]) 231 232 LIBX11_CFLAGS= LIBX11_LDFLAGS= LIBX11_LIBS= 233 if test x"$no_x" != x"yes"; then 234 AC_CHECK_LIB([X11], [main], 235 [ 236 AC_DEFINE([HAVE_LIBX11], [1], [Define if libX11 is available]) 237 LIBX11_CFLAGS="$X_CFLAGS" 238 for option in $X_PRE_LIBS $X_EXTRA_LIBS $X_LIBS; do 239 case "$option" in 240 -L*) 241 path=`echo $option | sed 's/^-L//'` 242 if test x"$path" != x""; then 243 LIBX11_LDFLAGS="$LIBX11_LDFLAGS -L$path" 244 fi 245 ;; 246 *) 247 LIBX11_LIBS="$LIBX11_LIBS $option" 248 ;; 249 esac 250 done 251 if ! echo $LIBX11_LIBS | grep -- '-lX11' >/dev/null; then 252 LIBX11_LIBS="$LIBX11_LIBS -lX11" 253 fi 254 ], [], [$X_CFLAGS $X_PRE_LIBS $X_EXTRA_LIBS $X_LIBS]) 255 fi 256 AC_SUBST([LIBX11_CFLAGS]) 257 AC_SUBST([LIBX11_LDFLAGS]) 258 AC_SUBST([LIBX11_LIBS]) 259]) 260 261 262 263dnl XDT_CHECK_LIBX11_REQUIRE() 264dnl 265dnl Similar to XDT_CHECK_LIBX11(), but terminates with an error if 266dnl the X window system and development files aren't detected on the 267dnl target system. 268dnl 269AC_DEFUN([XDT_CHECK_LIBX11_REQUIRE], 270[ 271 AC_REQUIRE([XDT_CHECK_LIBX11]) 272 273 if test x"$no_x" = x"yes"; then 274 AC_MSG_ERROR([X Window system libraries and header files are required]) 275 fi 276]) 277 278 279 280dnl XDT_CHECK_LIBSM() 281dnl 282dnl Checks whether the session management library is present on the 283dnl target system, and sets LIBSM_CFLAGS, LIBSM_LDFLAGS and LIBSM_LIBS 284dnl properly. In addition, HAVE_LIBSM will be set to 1 in config.h 285dnl if libSM is detected. 286dnl 287AC_DEFUN([XDT_CHECK_LIBSM], 288[ 289 AC_REQUIRE([XDT_CHECK_LIBX11]) 290 291 LIBSM_CFLAGS= LIBSM_LDFLAGS= LIBSM_LIBS= 292 if test x"$no_x" != x"yes"; then 293 AC_CHECK_LIB([SM], [SmcSaveYourselfDone], 294 [ 295 AC_DEFINE([HAVE_LIBSM], [1], [Define if libSM is available]) 296 LIBSM_CFLAGS="$LIBX11_CFLAGS" 297 LIBSM_LDFLAGS="$LIBX11_LDFLAGS" 298 LIBSM_LIBS="$LIBX11_LIBS" 299 if ! echo $LIBSM_LIBS | grep -- '-lSM' >/dev/null; then 300 LIBSM_LIBS="$LIBSM_LIBS -lSM -lICE" 301 fi 302 ], [], [$LIBX11_CFLAGS $LIBX11_LDFLAGS $LIBX11_LIBS -lICE]) 303 fi 304 AC_SUBST([LIBSM_CFLAGS]) 305 AC_SUBST([LIBSM_LDFLAGS]) 306 AC_SUBST([LIBSM_LIBS]) 307]) 308 309 310 311dnl XDT_CHECK_LIBXPM() 312dnl 313dnl Checks if the Xpm library is present on the target system, and 314dnl sets LIBXPM_CFLAGS, LIBXPM_LDFLAGS and LIBXPM_LIBS. In addition, 315dnl HAVE_LIBXPM will be set to 1 in config.h if libXpm is detected. 316dnl 317AC_DEFUN([XDT_CHECK_LIBXPM], 318[ 319 AC_REQUIRE([XDT_CHECK_LIBX11]) 320 321 LIBXPM_CFLAGS= LIBXPM_LDFLAGS= LIBXPM_LIBS= 322 if test "$no_x" != "yes"; then 323 AC_CHECK_LIB([Xpm], [main], 324 [ 325 AC_DEFINE([HAVE_LIBXPM], [1], [Define if libXpm is available]) 326 LIBXPM_CFLAGS="$LIBX11_CFLAGS" 327 LIBXPM_LDFLAGS="$LIBX11_LDFLAGS" 328 LIBXPM_LIBS="$LIBX11_LIBS" 329 if ! echo $LIBXPM_LIBS | grep -- '-lXpm' >/dev/null; then 330 LIBXPM_LIBS="$LIBXPM_LIBS -lXpm" 331 fi 332 ], [], [$LIBX11_CFLAGS $LIBX11_LDFLAGS $LIBX11_LIBS -lXpm]) 333 fi 334 AC_SUBST([LIBXPM_CFLAGS]) 335 AC_SUBST([LIBXPM_LDFLAGS]) 336 AC_SUBST([LIBXPM_LIBS]) 337]) 338 339 340 341dnl XDT_CHECK_LIBXPM_REQUIRE() 342dnl 343dnl Similar to XDT_CHECK_LIBXPM(), but fails if the Xpm library isn't 344dnl present on the target system. 345dnl 346AC_DEFUN([XDT_CHECK_LIBXPM_REQUIRE], 347[ 348 AC_REQUIRE([XDT_CHECK_LIBX11_REQUIRE]) 349 AC_REQUIRE([XDT_CHECK_LIBXPM]) 350 351 if test x"$LIBXPM_LIBS" = x""; then 352 AC_MSG_ERROR([The Xpm library was not found on your system]) 353 fi 354]) 355 356 357 358dnl BM_LIBX11() 359dnl 360dnl Simple wrapper for XDT_CHECK_LIBX11. Kept for backward 361dnl compatibility. Will be removed in the future. 362dnl 363AC_DEFUN([BM_LIBX11], 364[ 365 AC_REQUIRE([XDT_CHECK_LIBX11]) 366]) 367 368 369 370dnl BM_LIBX11_REQUIRE() 371dnl 372dnl Simple wrapper for XDT_CHECK_LIBX11_REQUIRE. Kept for backward 373dnl compatibility. Will be removed in the future. 374dnl 375AC_DEFUN([BM_LIBX11_REQUIRE], 376[ 377 AC_REQUIRE([XDT_CHECK_LIBX11_REQUIRE]) 378]) 379 380 381 382dnl BM_LIBSM() 383dnl 384dnl Simple wrapper for XDT_CHECK_LIBSM. Kept for backward 385dnl compatibility. Will be removed in the future. 386dnl 387AC_DEFUN([BM_LIBSM], 388[ 389 AC_REQUIRE([XDT_CHECK_LIBSM]) 390]) 391 392 393 394dnl BM_LIBXPM 395dnl 396dnl Simple wrapper for XDT_CHECK_LIBXPM. Kept for backward 397dnl compatibility. Will be removed in the future. 398dnl 399AC_DEFUN([BM_LIBXPM], 400[ 401 AC_REQUIRE([XDT_CHECK_LIBXPM]) 402]) 403 404 405 406dnl BM_LIBXPM_REQUIRE 407dnl 408dnl Simple wrapper for XDT_CHECK_LIBXPM_REQUIRE. Kept for 409dnl backward compatibility. Will be removed in the future. 410dnl 411AC_DEFUN([BM_LIBXPM_REQUIRE], 412[ 413 AC_REQUIRE([XDT_CHECK_LIBXPM_REQUIRE]) 414]) 415 416