home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / share / aclocal / ac_find_motif.m4 next >
Encoding:
M4 Source File  |  2005-06-09  |  7.3 KB  |  260 lines

  1. dnl
  2. dnl $Header: /cvsroot/lesstif/lesstif/scripts/autoconf/ac_find_motif.m4,v 1.8 2004/02/01 15:55:07 dannybackx Exp $
  3. dnl
  4. dnl AC_FIND_MOTIF : find OSF/Motif or LessTif, and provide variables
  5. dnl    to easily use them in a Makefile.
  6. dnl
  7. dnl Adapted from a macro by Andreas Zeller.
  8. dnl
  9. dnl The variables provided are :
  10. dnl    link_motif        (e.g. -L/usr/lesstif/lib -lXm)
  11. dnl    include_motif        (e.g. -I/usr/lesstif/lib)
  12. dnl    motif_libraries        (e.g. /usr/lesstif/lib)
  13. dnl    motif_includes        (e.g. /usr/lesstif/include)
  14. dnl
  15. dnl The link_motif and include_motif variables should be fit to put on
  16. dnl your application's link line in your Makefile.
  17. dnl
  18. dnl Oleo CVS Id: motif.m4,v 1.9 1999/04/09 11:46:49 danny
  19. dnl LessTif CVS $Id: ac_find_motif.m4,v 1.8 2004/02/01 15:55:07 dannybackx Exp $
  20. dnl
  21. AC_DEFUN([AC_FIND_MOTIF],
  22. [
  23.  
  24. AC_REQUIRE([AC_PATH_XTRA])
  25. AC_REQUIRE([AC_FIND_LIBXP])
  26.  
  27. motif_includes=
  28. motif_libraries=
  29.  
  30. dnl AC_ARG_WITH(motif,
  31. dnl [  --without-motif         do not use Motif widgets])
  32. dnl Treat --without-motif like
  33. dnl --without-motif-includes --without-motif-libraries.
  34. dnl if test "$with_motif" = "no"
  35. dnl then
  36. dnl   motif_includes=none
  37. dnl   motif_libraries=none
  38. dnl fi
  39.  
  40. AC_ARG_WITH(motif-includes,
  41. [  --with-motif-includes=DIR    Motif include files are in DIR],
  42. motif_includes="$withval")
  43.  
  44. AC_ARG_WITH(motif-libraries,
  45. [  --with-motif-libraries=DIR   Motif libraries are in DIR],
  46. motif_libraries="$withval")
  47.  
  48. AC_MSG_CHECKING(for Motif)
  49.  
  50. #
  51. #
  52. # Search the include files.
  53. #
  54. if test "$motif_includes" = ""; then
  55. AC_CACHE_VAL(ac_cv_motif_includes,
  56. [
  57. ac_motif_save_LIBS="$LIBS"
  58. ac_motif_save_INCLUDES="$INCLUDES"
  59. ac_motif_save_CPPFLAGS="$CPPFLAGS"
  60. ac_motif_save_LDFLAGS="$LDFLAGS"
  61. #
  62. LIBS="$X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS $LIBS"
  63. INCLUDES="$X_CFLAGS $INCLUDES"
  64. CPPFLAGS="$X_CFLAGS $CPPFLAGS"
  65. LDFLAGS="$X_LIBS $LDFLAGS"
  66. #
  67. ac_cv_motif_includes="none"
  68. AC_TRY_COMPILE([#include <Xm/Xm.h>],[int a;],
  69. [
  70. # Xm/Xm.h is in the standard search path.
  71. ac_cv_motif_includes=
  72. ],
  73. [
  74. # Xm/Xm.h is not in the standard search path.
  75. # Locate it and put its directory in `motif_includes'
  76. #
  77. # /usr/include/Motif* are used on HP-UX (Motif).
  78. # /usr/include/X11* are used on HP-UX (X and Athena).
  79. # /usr/dt is used on Solaris (Motif).
  80. # /usr/openwin is used on Solaris (X and Athena).
  81. # Other directories are just guesses.
  82. for dir in "$x_includes" "${prefix}/include" /usr/include /usr/local/include \
  83.            /usr/include/Motif2.1 /usr/include/Motif2.0 /usr/include/Motif1.2  \
  84.            /usr/include/X11 /usr/include/X11R6 /usr/include/X11R5 \
  85.            /usr/X11/include /usr/X11R6/include /usr/X11R5/include \
  86.            /usr/dt/include /usr/openwin/include \
  87.            /usr/dt/*/include /opt/*/include /usr/include/Motif* \
  88.            "${prefix}"/*/include /usr/*/include /usr/local/*/include \
  89.            "${prefix}"/include/* /usr/include/* /usr/local/include/*; do
  90. if test -f "$dir/Xm/Xm.h"; then
  91. ac_cv_motif_includes="$dir"
  92. break
  93. fi
  94. done
  95. ])
  96. #
  97. LIBS="$ac_motif_save_LIBS"
  98. INCLUDES="$ac_motif_save_INCLUDES"
  99. CPPFLAGS="$ac_motif_save_CPPFLAGS"
  100. LDFLAGS="$ac_motif_save_LDFLAGS"
  101. ])
  102. motif_includes="$ac_cv_motif_includes"
  103. fi
  104. #
  105. #
  106. # Now for the libraries.
  107. #
  108. if test "$motif_libraries" = ""; then
  109. AC_CACHE_VAL(ac_cv_motif_libraries,
  110. [
  111. ac_motif_save_LIBS="$LIBS"
  112. ac_motif_save_INCLUDES="$INCLUDES"
  113. ac_motif_save_CPPFLAGS="$CPPFLAGS"
  114. ac_motif_save_LDFLAGS="$LDFLAGS"
  115. #
  116. LIBS="$X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS $LIBS"
  117. INCLUDES="$X_CFLAGS $INCLUDES"
  118. CPPFLAGS="$X_CFLAGS $CPPFLAGS"
  119. LDFLAGS="$X_LIBS $LDFLAGS"
  120. #
  121. ac_cv_motif_libraries="none"
  122. AC_TRY_LINK([#include <Xm/Xm.h>],[XtToolkitInitialize();],
  123. [
  124. # libXm.a is in the standard search path.
  125. ac_cv_motif_libraries=
  126. ],
  127. [
  128. # libXm.a is not in the standard search path.
  129. # Locate it and put its directory in `motif_libraries'
  130. #
  131. # /usr/lib/Motif* are used on HP-UX (Motif).
  132. # /usr/lib/X11* are used on HP-UX (X and Athena).
  133. # /usr/dt is used on Solaris (Motif).
  134. # /usr/lesstif is used on Linux (Lesstif).
  135. # /usr/openwin is used on Solaris (X and Athena).
  136. # Other directories are just guesses.
  137. for dir in "$x_libraries" "${prefix}/lib" /usr/lib /usr/local/lib \
  138.            /usr/lib/Motif2.1 /usr/lib/Motif2.0 /usr/lib/Motif1.2 \
  139.            /usr/lib/X11 /usr/lib/X11R6 /usr/lib/X11R5 \
  140.            /usr/X11/lib /usr/X11R6/lib /usr/X11R5/lib \
  141.            /usr/dt/lib /usr/openwin/lib \
  142.            /usr/dt/*/lib /opt/*/lib /usr/lib/Motif* \
  143.            /usr/lesstif*/lib /usr/lib/Lesstif* \
  144.            "${prefix}"/*/lib /usr/*/lib /usr/local/*/lib \
  145.            "${prefix}"/lib/* /usr/lib/* /usr/local/lib/*; do
  146. if test -d "$dir" && test "`ls $dir/libXm.* 2> /dev/null`" != ""; then
  147. ac_cv_motif_libraries="$dir"
  148. break
  149. fi
  150. done
  151. ])
  152. #
  153. LIBS="$ac_motif_save_LIBS"
  154. INCLUDES="$ac_motif_save_INCLUDES"
  155. CPPFLAGS="$ac_motif_save_CPPFLAGS"
  156. LDFLAGS="$ac_motif_save_LDFLAGS"
  157. ])
  158. #
  159. motif_libraries="$ac_cv_motif_libraries"
  160. fi
  161. #
  162. # Provide an easier way to link
  163. #
  164. if test "$motif_includes" = "none" -o "$motif_libraries" = "none"; then
  165.         with_motif="no"
  166. else
  167.         with_motif="yes"
  168. fi
  169.  
  170. AC_FIND_LIBXP
  171. if test "$LT_HAVE_XP" = "yes"; then
  172.     XPLIB="-lXp -lXext"
  173. else
  174.     XPLIB=""
  175. fi
  176.  
  177. if test "$with_motif" != "no"; then
  178.         if test "$motif_libraries" = ""; then
  179.                 link_motif="-lXm $XPLIB"
  180.                 MOTIF_LIBS="-lXm $XPLIB"
  181.         else
  182.                 link_motif="-L$motif_libraries -lXm $XPLIB"
  183.                 MOTIF_LIBS="-L$motif_libraries -lXm $XPLIB"
  184.         fi
  185.         if test "$motif_includes" != ""; then
  186.                 include_motif="-I$motif_includes"
  187.                 MOTIF_CFLAGS="-I$motif_includes"
  188.         fi
  189.     AC_DEFINE(HAVE_MOTIF)
  190. else
  191.         with_motif="no"
  192. fi
  193. #
  194. AC_SUBST(link_motif)
  195. AC_SUBST(include_motif)
  196. AC_SUBST(MOTIF_CFLAGS)
  197. AC_SUBST(MOTIF_LIBS)
  198. #
  199. #
  200. #
  201. motif_libraries_result="$motif_libraries"
  202. motif_includes_result="$motif_includes"
  203. test "$motif_libraries_result" = "" && motif_libraries_result="in default path"
  204. test "$motif_includes_result" = "" && motif_includes_result="in default path"
  205. test "$motif_libraries_result" = "none" && motif_libraries_result="(none)"
  206. test "$motif_includes_result" = "none" && motif_includes_result="(none)"
  207. AC_MSG_RESULT(
  208.   [libraries $motif_libraries_result, headers $motif_includes_result])
  209. ])dnl
  210.  
  211. dnl
  212. dnl Check for libXp
  213. dnl In fact this check ensures that
  214. dnl  - <X11/extensions/Print.h> and
  215. dnl  - both libXp libXext
  216. dnl are in place
  217. dnl Note that a simpler check only for the libraries would not
  218. dnl be sufficient perhaps.
  219. dnl If the test succeeds it defines Have_Libxp within our
  220. dnl Makefiles. Perhaps one should immediately add those libs
  221. dnl to link commands which include libXm version2.1?!
  222. dnl
  223. AC_DEFUN([AC_FIND_LIBXP],
  224. [AC_REQUIRE([AC_PATH_X])
  225. AC_CACHE_CHECK(whether libXp is available, lt_cv_libxp,
  226. [lt_save_CFLAGS="$CFLAGS"
  227. lt_save_CPPFLAGS="$CPPFLAGS"
  228. lt_save_LIBS="$LIBS"
  229. LIBS="$X_LIBS -lXp -lXext -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
  230. CFLAGS="$X_CFLAGS $CFLAGS"
  231. CPPFLAGS="$X_CFLAGS $CPPFLAGS"
  232. AC_TRY_LINK([
  233. #include <X11/Intrinsic.h>
  234. #include <X11/extensions/Print.h>
  235. ],[
  236. int main() {
  237. Display *display=NULL;
  238. short   major_version, minor_version;
  239. Status rc;
  240. rc=XpQueryVersion(display, &major_version, &minor_version);
  241. exit(0);
  242. }
  243. ],
  244. lt_cv_libxp=yes,
  245. lt_cv_libxp=no)
  246. ])
  247. if test "$lt_cv_libxp" = "yes"; then
  248.   AC_DEFINE(HAVE_LIB_XP)
  249.   LT_HAVE_XP="yes"
  250. else
  251.   LT_HAVE_XP="no"
  252. fi
  253. AM_CONDITIONAL(Have_Libxp, test "$lt_cv_libxp" = "yes")
  254. AC_SUBST(LT_HAVE_XP)
  255. CFLAGS="$lt_save_CFLAGS"
  256. CPPFLAGS="$lt_save_CPPFLAGS"
  257. LIBS="$lt_save_LIBS"
  258. ])
  259.  
  260.