TDE graphics utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
5.2KB

  1. dnl KDE_FIND_GPHOTO2 - Find gphoto2 libraries and include files
  2. dnl
  3. dnl Adapted from tdebase/nsplugins/configure.in.in
  4. AC_DEFUN([KDE_FIND_GPHOTO2],
  5. [
  6. # Clear working variables
  7. gphoto2_includes=
  8. gphoto2_libraries=
  9. # Process user input to configure
  10. AC_ARG_WITH(kamera,
  11. AC_HELP_STRING([--without-kamera],[do not build kamera (gphoto2 required)]),
  12. [if test "$withval" = "no" ; then
  13. gphoto2_includes=none
  14. gphoto2_libraries=none
  15. fi])dnl
  16. AC_ARG_WITH(gphoto2-includes,
  17. AC_HELP_STRING([--with-gphoto2-includes=DIR],[gphoto2 include files are in DIR]),
  18. gphoto2_includes="$withval")
  19. AC_ARG_WITH(gphoto2-libraries,
  20. AC_HELP_STRING([--with-gphoto2-libraries=DIR],[gphoto2 libraries are in DIR]),
  21. gphoto2_libraries="$withval")
  22. AC_MSG_CHECKING(for gPhoto2)
  23. # the pkg-config way first, if user did not use --with-
  24. AC_CHECK_PROG(gphoto2_config,gphoto2-config,gphoto2-config,no)
  25. AC_CHECK_PROG(gphoto2_port_config,gphoto2-port-config,gphoto2-port-config,no)
  26. if test "$gphoto2_includes" = "" -a "$gphoto2_libraries" = "" -a "$gphoto2_config" != "no" -a "$gphoto2_port_config" != "no"
  27. then
  28. with_kamera="yes"
  29. GPHOTO2_INCS="`$gphoto2_config --cflags` `$gphoto2_port_config --cflags`"
  30. GPHOTO2_LIBS="`$gphoto2_config --libs` `$gphoto2_port_config --libs`"
  31. else
  32. #
  33. # Search for gphoto2 include files.
  34. #
  35. if test "$gphoto2_includes" = ""; then
  36. AC_CACHE_VAL(ac_cv_gphoto2_includes, [
  37. ac_gphoto2_save_LIBS="$LIBS"
  38. LIBS="-lgphoto2 $LIBS"
  39. ac_cv_gphoto2_includes="none"
  40. AC_TRY_COMPILE([#include <gphoto2.h>],[int a;],
  41. [
  42. # gphoto2.h is in the standard search path.
  43. ac_cv_gphoto2_includes=
  44. ],[
  45. # gphoto2.h is not in the standard search path.
  46. # Locate it and put its directory in `gphoto2_includes'
  47. for dir in /usr/include /usr/local/include \
  48. /usr/include/gphoto2 /usr/local/include/gphoto2; do
  49. if test -f "$dir/gphoto2.h"; then
  50. ac_cv_gphoto2_includes="$dir"
  51. break
  52. fi
  53. done
  54. ])
  55. #
  56. LIBS="$ac_gphoto2_save_LIBS"
  57. ])
  58. gphoto2_includes="$ac_cv_gphoto2_includes"
  59. fi
  60. #
  61. # Search for libgphoto2
  62. #
  63. if test "$gphoto2_libraries" = ""; then
  64. AC_CACHE_VAL(ac_cv_gphoto2_libraries,[
  65. ac_gphoto2_save_LIBS="$LIBS"
  66. LIBS="-lgphoto2_port -lgphoto2 $LIBS"
  67. ac_cv_gphoto2_libraries="none"
  68. AC_TRY_LINK([#include <gphoto2.h>],[gp_context_progress_start(0,0,0,0);], [
  69. # libgphoto2 is in the standard search path.
  70. ac_cv_gphoto2_libraries=
  71. ],[
  72. # libgphoto2 is not in the standard search path.
  73. # Locate it and put its directory in `gphoto2_libraries'
  74. for dir in /usr/lib /usr/local/lib; do
  75. if test -d "$dir" && test "`ls $dir/libgphoto2.* 2> /dev/null`" != ""; then
  76. ac_cv_gphoto2_libraries="$dir"
  77. break
  78. fi
  79. done
  80. ])
  81. #
  82. LIBS="$ac_gphoto2_save_LIBS"
  83. ])
  84. #
  85. gphoto2_libraries="$ac_cv_gphoto2_libraries"
  86. fi
  87. # Initialise compiler and linker flag variables for export
  88. if test "$gphoto2_includes" = "none" -o "$gphoto2_libraries" = "none" ; then
  89. with_kamera="no"
  90. else
  91. with_kamera="yes"
  92. if test "$gphoto2_libraries" = "" -o "$gphoto2_libraries" = "none"; then
  93. GPHOTO2_LIBS="-lgphoto2"
  94. else
  95. GPHOTO2_LIBS="-L$gphoto2_libraries -lgphoto2"
  96. fi
  97. if test "$gphoto2_includes" != "" -a "$gphoto2_includes" != "none"; then
  98. GPHOTO2_INCS="-I$gphoto2_includes"
  99. fi
  100. fi
  101. fi
  102. if test "$with_kamera" = "yes" ; then
  103. # Check if it works.
  104. ac_gphoto2_save_LIBS="$LIBS"
  105. ac_gphoto2_save_CFLAGS="$CFLAGS"
  106. LIBS="$LIBS $GPHOTO2_LIBS"
  107. CFLAGS="$CFLAGS $GPHOTO2_INCS"
  108. AC_TRY_LINK([#include <gphoto2.h>],[gp_context_progress_start(0,0,0,0);], [
  109. # It works.
  110. AC_DEFINE(HAVE_GPHOTO2,1,[Define if you have gPhoto2 installed])
  111. ],[
  112. with_kamera="no"
  113. ])
  114. LIBS="$ac_gphoto2_save_LIBS"
  115. CFLAGS="$ac_gphoto2_save_CFLAGS"
  116. fi
  117. dnl **** Check for va_copy ****
  118. AC_CACHE_CHECK([for va_copy], ac_cv_c_va_copy,
  119. AC_TRY_LINK(
  120. [#include <stdarg.h>],
  121. [va_list ap1, ap2;
  122. va_copy(ap1,ap2);
  123. ],
  124. [ac_cv_c_va_copy="yes"],
  125. [ac_cv_c_va_copy="no"])
  126. )
  127. if test "$ac_cv_c_va_copy" = "yes"
  128. then
  129. AC_DEFINE(HAVE_VA_COPY, 1, [Define if we have va_copy])
  130. fi
  131. AC_CACHE_CHECK([for __va_copy], ac_cv_c___va_copy,
  132. AC_TRY_LINK(
  133. [#include <stdarg.h>],
  134. [va_list ap1, ap2;
  135. __va_copy(ap1,ap2);
  136. ],
  137. [ac_cv_c___va_copy="yes"],
  138. [ac_cv_c___va_copy="no"])
  139. )
  140. if test "$ac_cv_c___va_copy" = "yes"
  141. then
  142. AC_DEFINE(HAVE___VA_COPY, 1, [Define if we have __va_copy])
  143. fi
  144. # Export compiler and linker flags for replacement in Makefile
  145. AC_SUBST(GPHOTO2_INCS)
  146. AC_SUBST(GPHOTO2_LIBS)
  147. # Display results of configuration
  148. gphoto2_libraries_result="$gphoto2_libraries"
  149. gphoto2_includes_result="$gphoto2_includes"
  150. test "$gphoto2_libraries" = "" && gphoto2_libraries_result="in default path"
  151. test "$gphoto2_includes" = "" && gphoto2_includes_result="in default path"
  152. test "$gphoto2_libraries" = "none" && gphoto2_libraries_result="(none)"
  153. test "$gphoto2_includes" = "none" && gphoto2_includes_result="(none)"
  154. AC_MSG_RESULT(
  155. [gphoto2 libraries $gphoto2_libraries_result, gphoto2 headers $gphoto2_includes_result])
  156. ]) dnl end of KDE_FIND_GPHOTO2 definition
  157. KDE_FIND_GPHOTO2
  158. if test "$with_kamera" = "no"; then
  159. dnl AC_MSG_WARN([You need to install gphoto 2.0 (or later), e.g. http://gphoto.net/dist/gphoto2-2.0.tar.gz if your distributor doesn't have a package])
  160. DO_NOT_COMPILE="$DO_NOT_COMPILE kamera"
  161. fi