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