source: trunk/FACT++/.macro_dir/ac_find_motif.m4@ 18350

Last change on this file since 18350 was 10456, checked in by tbretz, 14 years ago
Renamed conditional to HAS_LIBXP
File size: 7.5 KB
Line 
1dnl
2dnl AC_FIND_MOTIF : find OSF/Motif or LessTif, and provide variables
3dnl to easily use them in a Makefile.
4dnl
5dnl Adapted from a macro by Andreas Zeller.
6dnl
7dnl The variables provided are :
8dnl MOTIF_LDFLAGS (e.g. -L/usr/lesstif/lib -lXm)
9dnl MOTIF_INCL (e.g. -I/usr/lesstif/lib)
10dnl motif_libraries (e.g. /usr/lesstif/lib)
11dnl motif_includes (e.g. /usr/lesstif/include)
12dnl
13dnl The MOTIF_LDFLAGS and MOTIF_INCL variables should be fit to put on
14dnl your application's link line in your Makefile.
15dnl
16dnl Oleo CVS Id: motif.m4,v 1.9 1999/04/09 11:46:49 danny
17dnl LessTif CVS $Id: ac_find_motif.m4,v 1.3 2004/11/30 16:30:33 paul Exp $
18dnl
19AC_DEFUN([AC_FIND_MOTIF],
20[
21AC_REQUIRE([AC_PATH_XTRA])
22AC_REQUIRE([AC_FIND_LIBXP])
23
24motif_includes=
25motif_libraries=
26
27dnl AC_ARG_WITH(motif,
28dnl [ --without-motif do not use Motif widgets])
29dnl Treat --without-motif like
30dnl --without-motif-includes --without-motif-libraries.
31dnl if test "$with_motif" = "no"
32dnl then
33dnl motif_includes=none
34dnl motif_libraries=none
35dnl fi
36
37AC_ARG_WITH(motif-includes,
38[ --with-motif-includes=DIR Motif include files are in DIR],
39motif_includes="$withval")
40
41AC_ARG_WITH(motif-libraries,
42[ --with-motif-libraries=DIR Motif libraries are in DIR],
43motif_libraries="$withval")
44
45AC_MSG_CHECKING(for Motif)
46
47#
48#
49# Search the include files.
50#
51if test "$motif_includes" = ""; then
52AC_CACHE_VAL(ac_cv_motif_includes,
53[
54ac_motif_save_LIBS="$LIBS"
55ac_motif_save_INCLUDES="$INCLUDES"
56ac_motif_save_CPPFLAGS="$CPPFLAGS"
57ac_motif_save_LDFLAGS="$LDFLAGS"
58#
59LIBS="$X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS $LIBS"
60INCLUDES="$X_CFLAGS $INCLUDES"
61CPPFLAGS="$X_CFLAGS $CPPFLAGS"
62LDFLAGS="$X_LIBS $LDFLAGS"
63#
64ac_cv_motif_includes="none"
65AC_TRY_COMPILE([#include <Xm/Xm.h>],[int a;],
66[
67# Xm/Xm.h is in the standard search path.
68ac_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.
80for 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
89if test -f "$dir/Xm/Xm.h"; then
90ac_cv_motif_includes="$dir"
91break
92fi
93done
94])
95#
96LIBS="$ac_motif_save_LIBS"
97INCLUDES="$ac_motif_save_INCLUDES"
98CPPFLAGS="$ac_motif_save_CPPFLAGS"
99LDFLAGS="$ac_motif_save_LDFLAGS"
100])
101motif_includes="$ac_cv_motif_includes"
102fi
103#
104#
105# Now for the libraries.
106#
107if test "$motif_libraries" = ""; then
108AC_CACHE_VAL(ac_cv_motif_libraries,
109[
110ac_motif_save_LIBS="$LIBS"
111ac_motif_save_INCLUDES="$INCLUDES"
112ac_motif_save_CPPFLAGS="$CPPFLAGS"
113ac_motif_save_LDFLAGS="$LDFLAGS"
114#
115LIBS="$X_PRE_LIBS -lXm -lXt -lX11 $X_EXTRA_LIBS $LIBS"
116INCLUDES="$X_CFLAGS $INCLUDES"
117CPPFLAGS="$X_CFLAGS $CPPFLAGS"
118LDFLAGS="$X_LIBS $LDFLAGS"
119#
120ac_cv_motif_libraries="none"
121AC_TRY_LINK([#include <Xm/Xm.h>],[XtToolkitInitialize();],
122[
123# libXm.a is in the standard search path.
124ac_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.
137for 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
147if test -d "$dir" && test "`ls $dir/libXm.* 2> /dev/null`" != ""; then
148ac_cv_motif_libraries="$dir"
149break
150fi
151done
152])
153#
154LIBS="$ac_motif_save_LIBS"
155INCLUDES="$ac_motif_save_INCLUDES"
156CPPFLAGS="$ac_motif_save_CPPFLAGS"
157LDFLAGS="$ac_motif_save_LDFLAGS"
158])
159#
160motif_libraries="$ac_cv_motif_libraries"
161fi
162#
163# Provide an easier way to link
164#
165if test "$motif_includes" = "none" -o "$motif_libraries" = "none"; then
166 with_motif="no"
167else
168 with_motif="yes"
169fi
170
171AC_FIND_LIBXP
172if test "$LT_HAVE_XP" = "yes"; then
173 XPLIB="-lXp -lXext"
174else
175 XPLIB=""
176fi
177
178if 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)
193else
194 with_motif="no"
195fi
196#
197AC_SUBST(MOTIF_LDFLAGS)
198AC_SUBST(MOTIF_INCL)
199AC_SUBST(MOTIF_CFLAGS)
200AC_SUBST(MOTIF_LIBS)
201#
202#
203#
204motif_libraries_result="$motif_libraries"
205motif_includes_result="$motif_includes"
206test "$motif_libraries_result" = "" && motif_libraries_result="in default path"
207test "$motif_includes_result" = "" && motif_includes_result="in default path"
208test "$motif_libraries_result" = "none" && motif_libraries_result="(none)"
209test "$motif_includes_result" = "none" && motif_includes_result="(none)"
210AC_MSG_RESULT(
211 [libraries $motif_libraries_result, headers $motif_includes_result])
212])dnl
213
214dnl
215dnl Check for libXp
216dnl In fact this check ensures that
217dnl - <X11/extensions/Print.h> and
218dnl - both libXp libXext
219dnl are in place
220dnl Note that a simpler check only for the libraries would not
221dnl be sufficient perhaps.
222dnl If the test succeeds it defines Have_Libxp within our
223dnl Makefiles. Perhaps one should immediately add those libs
224dnl to link commands which include libXm version2.1?!
225dnl
226AC_DEFUN([AC_FIND_LIBXP],
227[AC_REQUIRE([AC_PATH_X])
228AC_CACHE_CHECK(whether libXp is available, lt_cv_libxp,
229[lt_save_CFLAGS="$CFLAGS"
230lt_save_CPPFLAGS="$CPPFLAGS"
231lt_save_LIBS="$LIBS"
232LIBS="$X_LIBS -lXp -lXext -lXt $X_PRE_LIBS -lX11 $X_EXTRA_LIBS $LIBS"
233CFLAGS="$X_CFLAGS $CFLAGS"
234CPPFLAGS="$X_CFLAGS $CPPFLAGS"
235AC_TRY_LINK([
236#include <X11/Intrinsic.h>
237#include <X11/extensions/Print.h>
238],[
239int main() {
240Display *display=NULL;
241short major_version, minor_version;
242Status rc;
243rc=XpQueryVersion(display, &major_version, &minor_version);
244exit(0);
245}
246],
247lt_cv_libxp=yes,
248lt_cv_libxp=no)
249])
250if 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"
255else
256 LT_HAVE_XP="no"
257fi
258AM_CONDITIONAL(HAS_LIBXP, test "$lt_cv_libxp" = "yes")
259AC_SUBST(LT_HAVE_XP)
260CFLAGS="$lt_save_CFLAGS"
261CPPFLAGS="$lt_save_CPPFLAGS"
262LIBS="$lt_save_LIBS"
263])
Note: See TracBrowser for help on using the repository browser.