imlib.m4 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. # Configure paths for IMLIB
  2. # Frank Belew 98-8-31
  3. # stolen from Manish Singh
  4. # Shamelessly stolen from Owen Taylor
  5. dnl AM_PATH_IMLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  6. dnl Test for IMLIB, and define IMLIB_CFLAGS and IMLIB_LIBS
  7. dnl
  8. AC_DEFUN([AM_PATH_IMLIB],
  9. [dnl
  10. dnl Get the cflags and libraries from the imlib-config script
  11. dnl
  12. AC_ARG_WITH(imlib-prefix,[ --with-imlib-prefix=PFX Prefix where IMLIB is installed (optional)],
  13. imlib_prefix="$withval", imlib_prefix="")
  14. AC_ARG_WITH(imlib-exec-prefix,[ --with-imlib-exec-prefix=PFX Exec prefix where IMLIB is installed (optional)],
  15. imlib_exec_prefix="$withval", imlib_exec_prefix="")
  16. AC_ARG_ENABLE(imlibtest, [ --disable-imlibtest Do not try to compile and run a test IMLIB program],
  17. , enable_imlibtest=yes)
  18. if test x$imlib_exec_prefix != x ; then
  19. imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix"
  20. if test x${IMLIB_CONFIG+set} != xset ; then
  21. IMLIB_CONFIG=$imlib_exec_prefix/bin/imlib-config
  22. fi
  23. fi
  24. if test x$imlib_prefix != x ; then
  25. imlib_args="$imlib_args --prefix=$imlib_prefix"
  26. if test x${IMLIB_CONFIG+set} != xset ; then
  27. IMLIB_CONFIG=$imlib_prefix/bin/imlib-config
  28. fi
  29. fi
  30. AC_PATH_PROG(IMLIB_CONFIG, imlib-config, no)
  31. min_imlib_version=ifelse([$1], ,1.8.2,$1)
  32. AC_MSG_CHECKING(for IMLIB - version >= $min_imlib_version)
  33. no_imlib=""
  34. if test "$IMLIB_CONFIG" = "no" ; then
  35. no_imlib=yes
  36. else
  37. IMLIB_CFLAGS=`$IMLIB_CONFIG $imlibconf_args --cflags`
  38. IMLIB_LIBS=`$IMLIB_CONFIG $imlibconf_args --libs`
  39. imlib_major_version=`$IMLIB_CONFIG $imlib_args --version | \
  40. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  41. imlib_minor_version=`$IMLIB_CONFIG $imlib_args --version | \
  42. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  43. imlib_micro_version=`$IMLIB_CONFIG $imlib_args --version | \
  44. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
  45. if test "x$enable_imlibtest" = "xyes" ; then
  46. ac_save_CFLAGS="$CFLAGS"
  47. ac_save_LIBS="$LIBS"
  48. CFLAGS="$CFLAGS $IMLIB_CFLAGS"
  49. LIBS="$LIBS $IMLIB_LIBS"
  50. dnl
  51. dnl Now check if the installed IMLIB is sufficiently new. (Also sanity
  52. dnl checks the results of imlib-config to some extent
  53. dnl
  54. rm -f conf.imlibtest
  55. AC_TRY_RUN([
  56. #include <stdio.h>
  57. #include <stdlib.h>
  58. #include <string.h>
  59. #include <Imlib.h>
  60. char*
  61. my_strdup (char *str)
  62. {
  63. char *new_str;
  64. if (str)
  65. {
  66. new_str = malloc ((strlen (str) + 1) * sizeof(char));
  67. strcpy (new_str, str);
  68. }
  69. else
  70. new_str = NULL;
  71. return new_str;
  72. }
  73. int main ()
  74. {
  75. int major, minor, micro;
  76. char *tmp_version;
  77. system ("touch conf.imlibtest");
  78. /* HP/UX 9 (%@#!) writes to sscanf strings */
  79. tmp_version = my_strdup("$min_imlib_version");
  80. if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
  81. printf("%s, bad version string\n", "$min_imlib_version");
  82. exit(1);
  83. }
  84. if (($imlib_major_version > major) ||
  85. (($imlib_major_version == major) && ($imlib_minor_version > minor)) ||
  86. (($imlib_major_version == major) && ($imlib_minor_version == minor) &&
  87. ($imlib_micro_version >= micro)))
  88. {
  89. return 0;
  90. }
  91. else
  92. {
  93. printf("\n*** 'imlib-config --version' returned %d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version);
  94. printf("*** of IMLIB required is %d.%d. If imlib-config is correct, then it is\n", major, minor);
  95. printf("*** best to upgrade to the required version.\n");
  96. printf("*** If imlib-config was wrong, set the environment variable IMLIB_CONFIG\n");
  97. printf("*** to point to the correct copy of imlib-config, and remove the file\n");
  98. printf("*** config.cache before re-running configure\n");
  99. return 1;
  100. }
  101. }
  102. ],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  103. CFLAGS="$ac_save_CFLAGS"
  104. LIBS="$ac_save_LIBS"
  105. fi
  106. fi
  107. if test "x$no_imlib" = x ; then
  108. AC_MSG_RESULT(yes)
  109. ifelse([$2], , :, [$2])
  110. else
  111. AC_MSG_RESULT(no)
  112. if test "$IMLIB_CONFIG" = "no" ; then
  113. echo "*** The imlib-config script installed by IMLIB could not be found"
  114. echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in"
  115. echo "*** your path, or set the IMLIB_CONFIG environment variable to the"
  116. echo "*** full path to imlib-config."
  117. else
  118. if test -f conf.imlibtest ; then
  119. :
  120. else
  121. echo "*** Could not run IMLIB test program, checking why..."
  122. CFLAGS="$CFLAGS $IMLIB_CFLAGS"
  123. LIBS="$LIBS $IMLIB_LIBS"
  124. AC_TRY_LINK([
  125. #include <stdio.h>
  126. #include <Imlib.h>
  127. ], [ return 0; ],
  128. [ echo "*** The test program compiled, but did not run. This usually means"
  129. echo "*** that the run-time linker is not finding IMLIB or finding the wrong"
  130. echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your"
  131. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  132. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  133. echo "*** is required on your system"
  134. echo "***"
  135. echo "*** If you have an old version installed, it is best to remove it, although"
  136. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  137. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  138. echo "*** exact error that occured. This usually means IMLIB was incorrectly installed"
  139. echo "*** or that you have moved IMLIB since it was installed. In the latter case, you"
  140. echo "*** may want to edit the imlib-config script: $IMLIB_CONFIG" ])
  141. CFLAGS="$ac_save_CFLAGS"
  142. LIBS="$ac_save_LIBS"
  143. fi
  144. fi
  145. IMLIB_CFLAGS=""
  146. IMLIB_LIBS=""
  147. ifelse([$3], , :, [$3])
  148. fi
  149. AC_SUBST(IMLIB_CFLAGS)
  150. AC_SUBST(IMLIB_LIBS)
  151. rm -f conf.imlibtest
  152. ])
  153. # Check for gdk-imlib
  154. AC_DEFUN(AM_PATH_GDK_IMLIB,
  155. [dnl
  156. dnl Get the cflags and libraries from the imlib-config script
  157. dnl
  158. AC_ARG_WITH(imlib-prefix,[ --with-imlib-prefix=PFX Prefix where IMLIB is installed (optional)],
  159. imlib_prefix="$withval", imlib_prefix="")
  160. AC_ARG_WITH(imlib-exec-prefix,[ --with-imlib-exec-prefix=PFX Exec prefix where IMLIB is installed (optional)],
  161. imlib_exec_prefix="$withval", imlib_exec_prefix="")
  162. AC_ARG_ENABLE(imlibtest, [ --disable-imlibtest Do not try to compile and run a test IMLIB program],
  163. , enable_imlibtest=yes)
  164. if test x$imlib_exec_prefix != x ; then
  165. imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix"
  166. if test x${IMLIB_CONFIG+set} != xset ; then
  167. IMLIB_CONFIG=$imlib_exec_prefix/bin/imlib-config
  168. fi
  169. fi
  170. if test x$imlib_prefix != x ; then
  171. imlib_args="$imlib_args --prefix=$imlib_prefix"
  172. if test x${IMLIB_CONFIG+set} != xset ; then
  173. IMLIB_CONFIG=$imlib_prefix/bin/imlib-config
  174. fi
  175. fi
  176. AC_PATH_PROG(IMLIB_CONFIG, imlib-config, no)
  177. min_imlib_version=ifelse([$1], ,1.8.2,$1)
  178. AC_MSG_CHECKING(for IMLIB - version >= $min_imlib_version)
  179. no_imlib=""
  180. if test "$IMLIB_CONFIG" = "no" ; then
  181. no_imlib=yes
  182. else
  183. GDK_IMLIB_CFLAGS=`$IMLIB_CONFIG $imlibconf_args --cflags-gdk`
  184. GDK_IMLIB_LIBS=`$IMLIB_CONFIG $imlibconf_args --libs-gdk`
  185. imlib_major_version=`$IMLIB_CONFIG $imlib_args --version | \
  186. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
  187. imlib_minor_version=`$IMLIB_CONFIG $imlib_args --version | \
  188. sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
  189. if test "x$enable_imlibtest" = "xyes" ; then
  190. ac_save_CFLAGS="$CFLAGS"
  191. ac_save_LIBS="$LIBS"
  192. CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS"
  193. LIBS="$LIBS $GDK_IMLIB_LIBS"
  194. dnl
  195. dnl Now check if the installed IMLIB is sufficiently new. (Also sanity
  196. dnl checks the results of imlib-config to some extent
  197. dnl
  198. rm -f conf.imlibtest
  199. AC_TRY_RUN([
  200. #include <stdio.h>
  201. #include <stdlib.h>
  202. #include <gdk_imlib.h>
  203. int main ()
  204. {
  205. int major, minor;
  206. char *tmp_version;
  207. system ("touch conf.gdkimlibtest");
  208. /* HP/UX 9 (%@#!) writes to sscanf strings */
  209. tmp_version = g_strdup("$min_imlib_version");
  210. if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2) {
  211. printf("%s, bad version string\n", "$min_imlib_version");
  212. exit(1);
  213. }
  214. if (($imlib_major_version > major) ||
  215. (($imlib_major_version == major) && ($imlib_minor_version >= minor)))
  216. {
  217. return 0;
  218. }
  219. else
  220. {
  221. printf("\n*** 'imlib-config --version' returned %d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version);
  222. printf("*** of IMLIB required is %d.%d. If imlib-config is correct, then it is\n", major, minor);
  223. printf("*** best to upgrade to the required version.\n");
  224. printf("*** If imlib-config was wrong, set the environment variable IMLIB_CONFIG\n");
  225. printf("*** to point to the correct copy of imlib-config, and remove the file\n");
  226. printf("*** config.cache before re-running configure\n");
  227. return 1;
  228. }
  229. }
  230. ],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
  231. CFLAGS="$ac_save_CFLAGS"
  232. LIBS="$ac_save_LIBS"
  233. fi
  234. fi
  235. if test "x$no_imlib" = x ; then
  236. AC_MSG_RESULT(yes)
  237. ifelse([$2], , :, [$2])
  238. else
  239. AC_MSG_RESULT(no)
  240. if test "$IMLIB_CONFIG" = "no" ; then
  241. echo "*** The imlib-config script installed by IMLIB could not be found"
  242. echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in"
  243. echo "*** your path, or set the IMLIB_CONFIG environment variable to the"
  244. echo "*** full path to imlib-config."
  245. else
  246. if test -f conf.gdkimlibtest ; then
  247. :
  248. else
  249. echo "*** Could not run IMLIB test program, checking why..."
  250. CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS"
  251. LIBS="$LIBS $GDK_IMLIB_LIBS"
  252. AC_TRY_LINK([
  253. #include <stdio.h>
  254. #include <gdk_imlib.h>
  255. ], [ return 0; ],
  256. [ echo "*** The test program compiled, but did not run. This usually means"
  257. echo "*** that the run-time linker is not finding IMLIB or finding the wrong"
  258. echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your"
  259. echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  260. echo "*** to the installed location Also, make sure you have run ldconfig if that"
  261. echo "*** is required on your system"
  262. echo "***"
  263. echo "*** If you have an old version installed, it is best to remove it, although"
  264. echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
  265. [ echo "*** The test program failed to compile or link. See the file config.log for the"
  266. echo "*** exact error that occured. This usually means IMLIB was incorrectly installed"
  267. echo "*** or that you have moved IMLIB since it was installed. In the latter case, you"
  268. echo "*** may want to edit the imlib-config script: $IMLIB_CONFIG" ])
  269. CFLAGS="$ac_save_CFLAGS"
  270. LIBS="$ac_save_LIBS"
  271. fi
  272. fi
  273. IMLIB_CFLAGS=""
  274. IMLIB_LIBS=""
  275. ifelse([$3], , :, [$3])
  276. fi
  277. AC_SUBST(GDK_IMLIB_CFLAGS)
  278. AC_SUBST(GDK_IMLIB_LIBS)
  279. rm -f conf.gdkimlibtest
  280. ])