ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/ac-tools/CGAL.m4
Revision: 1210
Committed: Wed Jan 23 03:45:33 2008 UTC (17 years, 6 months ago) by gezelter
File size: 13233 byte(s)
Log Message:
Removed older version of openbabel from our code.  We now have a
configure check to see if openbabel is installed and then we link to
the stuff we need.  Conversion to OOPSE's md format is handled by only
one application (atom2md), so most of the work went on there.
ElementsTable still needs some work to function in parallel.

File Contents

# User Rev Content
1 chuckv 1191
2    
3     dnl CHECK CGAL BEGIN
4     dnl This script takes too arguments, the action on success and the action on failure.
5     dnl It first checks if CGAL_MAKEFILE is defined (or a --with-cgalmakefile) value is passed.
6     dnl If that fails, it seaches for CGAL in the standard places.
7     dnl CGAL_CXXFLAGS, CGAL_CPPFLAGS, CGAL_LDFLAGS and CGAL_LIBS are all defined.
8     AC_DEFUN([ACX_CGAL],
9     [
10     acx_cgal_found=no
11     AC_ARG_WITH(cgalmakefile,
12     [AC_HELP_STRING([--with-cgalmakefile=makefile], [Use the following CGAL makefile])])
13     case $with_cgalmakefile in
14     yes | "") ;;
15     no) acx_cgal_found=disable ;;
16     -* | */* | *.a | *.so | *.so.* | *.o) CGAL_MAKEFILE="$with_cgalmakefile" ;;
17     *) CGAL_MAKEFILE="$with_cgalmakefile" ;;
18     esac
19    
20     if test "$acx_cgal_found" == no; then
21     AC_MSG_CHECKING(CGAL_MAKEFILE)
22    
23     if test \! -z "$CGAL_MAKEFILE"; then
24    
25     if test -e "$CGAL_MAKEFILE"; then
26     tname=`mktemp /tmp/cgal_makefile_dsrXXXXXX`
27    
28     cat > $tname << _ACEOF
29     include $CGAL_MAKEFILE
30    
31     cppflags:
32     @echo \$(CGAL_CXXFLAGS)
33    
34     cxxflags:
35     @echo
36     ldflags:
37     @echo \$(CGAL_LDFLAGS)
38     _ACEOF
39     CGAL_CPPFLAGS="`make -s -f $tname cppflags`"
40     CGAL_CXXFLAGS="`make -s -f $tname cxxflags`"
41     CGAL_LDFLAGST="`make -s -f $tname ldflags`"
42     for i in $CGAL_LDFLAGST; do
43     if test `echo $i| grep -c ^-l`; then
44     CGAL_LIBS="$CGAL_LIBS $i"
45     else
46     CGAL_LDFLAGS="$CGAL_LDFLAGS $i"
47     fi
48     done
49     rm -f $tname
50     AC_MSG_RESULT(yes)
51     acx_cgal_found=yes
52     dnl echo CGAL_CPPFLAGS are $CGAL_CPPFLAGS
53     dnl echo CGAL_LDFLAGS are $CGAL_LDFLAGS
54     dnl echo CGAL_LIBS are $CGAL_LIBS
55     else
56     AC_MSG_RESULT(invalid)
57     AC_ERROR([CGAL_MAKEFILE defined, but the makefile does not exist.])
58     fi
59     else
60     AC_MSG_RESULT(not defined)
61     fi
62     fi
63    
64     if test "$acx_cgal_found" == no; then
65     AC_CHECK_HEADER(CGAL/Exact_predicates_inexact_constructions_kernel.h, cgal_have_header=yes, cgal_have_header=no)
66     if test "$cgal_have_header" == yes; then
67     AC_CHECK_LIB(CGAL, main, cgal_have_lib=yes, cgal_have_lib=no)
68     if test "$cgal_have_lib" == no; then
69     save_LIBS="$LIBS"; LIBS="$LIBS -lgmp -lmpfr -lm"
70     AC_CHECK_LIB(CGAL, main, [CGAL_LIBS="-lCGAL -lgmp -lmpfr"
71     cgal_have_lib=yes], cgal_have_lib=no)
72     LIBS="$save_LIBS"
73     else
74     CGAL_LIBS="-lCGAL"
75     AC_CHECK_LIB(mpfr, main, [CGAL_LIBS="$CGAL_LIBS -lmpfr"])
76     AC_CHECK_LIB(gmp, main, [CGAL_LIBS="$CGAL_LIBS -lgmp"])
77     AC_CHECK_LIB(gmpxx, main, [CGAL_LIBS="$CGAL_LIBS -lgmpxx"])
78     fi
79    
80     if test "$cgal_have_lib" == yes; then
81     acx_cgal_found=yes
82     fi
83     fi
84     if test "$acx_cgal_found" == yes; then
85     AC_CHECK_LIB(Core, main, [CGAL_LIBS="$CGAL_LIBS -lCore"])
86     fi
87     fi
88    
89    
90    
91     AC_MSG_CHECKING(CGAL)
92 gezelter 1210 AC_SUBST(CGAL_MAKEFILE)
93     AC_SUBST(CGAL_CXXFLAGS)
94     AC_SUBST(CGAL_CPPFLAGS)
95     AC_SUBST(CGAL_LDFLAGS)
96     AC_SUBST(CGAL_LIBS)
97 chuckv 1191 if test "$acx_cgal_found" == yes; then
98 gezelter 1210 AC_MSG_RESULT(yes)
99 chuckv 1191 $1
100     else
101     AC_MSG_RESULT(no)
102     $2
103     fi])
104    
105    
106     dnl CHECK CGAL END
107    
108    
109    
110    
111    
112    
113    
114    
115     dnl CHECK CGALQt BEGIN
116     dnl This script checks for Qt support in CGAL.
117     dnl It takes two arguments, the action on success and the action on failure.
118     dnl It first checks for a CGAL_MAKEFILE.
119     dnl If not, it looks for CGALQt in the usual places.
120     dnl CGALQT_CXXFLAGS, CGALQT_CPPFLAGS, CGALQT_LDFLAGS and CGALQT_LIBS are all defined.
121     dnl If no CGAL_MAKEFILE is defined, it expects the variable QT_LIBS to be defined.
122     dnl This variable can be defined by ACX_QT (which is below)
123     AC_DEFUN([ACX_CGALQT],
124     [
125     acx_cgalqt_found=no
126    
127     if test "$acx_cgalqt_found" == no; then
128    
129     if test \! -z "$CGAL_MAKEFILE" -a -e "$CGAL_MAKEFILE"; then
130     tname=`mktemp /tmp/cgal_makefile_dsrXXXXXX`
131    
132     cat > $tname << _ACEOF
133     include $CGAL_MAKEFILE
134     cppflags:
135     @echo \$(CGAL_CXXFLAGS)
136    
137     ldflags:
138     @echo \$(CGAL_QT_LDFLAGS)
139     _ACEOF
140     CGALQT_CPPFLAGST="`make -s -f $tname cppflags`"
141     CGALQT_LDFLAGST="`make -s -f $tname ldflags`"
142     if test `echo $CGALQT_CPPFLAGST | grep -c -e -DCGAL_USE_QT` == 1; then
143     for i in $CGALQT_LDFLAGST; do
144     if test `echo $i| grep -c ^-l`; then
145     CGALQT_LIBS="$CGALQT_LIBS $i"
146     else
147     CGALQT_LDFLAGS="$CGALQT_LDFLAGS $i"
148     fi
149     done
150     acx_cgalqt_found=yes
151     fi
152     rm -f $tname
153     fi
154     fi
155    
156     if test "$acx_cgalqt_found" == no; then
157     save_LIBS="$LIBS"; LIBS="$LIBS $CGAL_LIBS $CGAL_LDFLAGS $QT_LIBS"
158     AC_CHECK_LIB(CGALQt, main, [acx_cgalqt_found=yes; CGALQT_LIBS="-lCGALQt"])
159     LIBS="$save_LIBS"
160     fi
161     AC_MSG_CHECKING(Qt support for CGAL)
162     if test "$acx_cgalqt_found" == yes; then
163     AC_MSG_RESULT(yes);
164     $1
165     else
166     AC_MSG_RESULT(no);
167     $2
168     fi
169     ])
170    
171     dnl CHECK CGALQt END
172    
173    
174     dnl This script checks for Qt support in CGAL.
175     dnl It takes two arguments, the action on success and the action on failure.
176     dnl It uses
177     AC_DEFUN([ACX_QT],
178     [
179     gw_CHECK_QT
180    
181     if test "$QT_MAJOR" == 3; then
182     if test "$QT_IS_MT" == "yes"; then
183     QT_LIBS="-lqt-mt"
184     else
185     QT_LIBS="-lqt"
186     fi
187     QT_LDFLAGS="$QT_LDADD"
188     $1
189     else
190     $2
191     fi
192    
193     ])
194    
195    
196    
197    
198     # This is taken from http://autoqt.sourceforge.net/
199     # Copyright (c) 2002, Geoffrey Wossum
200     # All rights reserved.
201    
202     # Redistribution and use in source and binary forms, with or without
203     # modification, are permitted provided that the following conditions are
204     # met:
205    
206     # - Redistributions of source code must retain the above copyright notice,
207     # this list of conditions and the following disclaimer.
208    
209     # - Redistributions in binary form must reproduce the above copyright
210     # notice, this list of conditions and the following disclaimer in the
211     # documentation and/or other materials provided with the distribution.
212    
213     # - Neither the name of Geoffrey Wossum nor the names of its
214     # contributors may be used to endorse or promote products derived from
215     # this software without specific prior written permission.
216    
217    
218     # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
219     # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
220     # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221     # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
222     # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
223     # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
224     # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
225     # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
226     # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
227     # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
228     # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
229    
230    
231     # Check for Qt compiler flags, linker flags, and binary packages
232     AC_DEFUN([gw_CHECK_QT],
233     [
234     AC_REQUIRE([AC_PROG_CXX])
235     AC_REQUIRE([AC_PATH_X])
236    
237     AC_MSG_CHECKING([QTDIR])
238     AC_ARG_WITH([qtdir], [ --with-qtdir=DIR Qt installation directory [default=$QTDIR]], QTDIR=$withval)
239     # Check that QTDIR is defined or that --with-qtdir given
240     if test x"$QTDIR" = x ; then
241     QT_SEARCH="/usr/lib/qt31 /usr/local/qt31 /usr/lib/qt3 /usr/local/qt3 /usr/lib/qt2 /usr/local/qt2 /usr/lib/qt /usr/local/qt"
242     for i in $QT_SEARCH; do
243     if test -f $i/include/qglobal.h -a x$QTDIR = x; then QTDIR=$i; fi
244     done
245     fi
246     if test x"$QTDIR" = x ; then
247     AC_MSG_ERROR([*** QTDIR must be defined, or --with-qtdir option given])
248     fi
249     AC_MSG_RESULT([$QTDIR])
250    
251     # Change backslashes in QTDIR to forward slashes to prevent escaping
252     # problems later on in the build process, mainly for Cygwin build
253     # environment using MSVC as the compiler
254     # TODO: Use sed instead of perl
255     QTDIR=`echo $QTDIR | perl -p -e 's/\\\\/\\//g'`
256    
257     # Figure out which version of Qt we are using
258     AC_MSG_CHECKING([Qt version])
259     QT_VER=`grep 'define.*QT_VERSION_STR\W' $QTDIR/include/qglobal.h | perl -p -e 's/\D//g'`
260     case "${QT_VER}" in
261     2*)
262     QT_MAJOR="2"
263     ;;
264     3*)
265     QT_MAJOR="3"
266     ;;
267     *)
268     AC_MSG_ERROR([*** Don't know how to handle this Qt major version])
269     ;;
270     esac
271     AC_MSG_RESULT([$QT_VER ($QT_MAJOR)])
272    
273     if test \! -z "$MOC"; then
274     if test \! -e "$MOC"; then
275     AC_MSG_ERROR([MOC defined but is not a valid file.])
276     fi
277     fi
278    
279     if test -z "$MOC"; then
280     AC_MSG_CHECKING(QTDIR/bin/moc)
281     if test -e "$QTDIR/bin/moc"; then
282     MOC=$QTDIR/bin/moc
283     AC_MSG_RESULT(yes)
284     else
285     AC_MSG_RESULT(no)
286     fi
287     fi
288    
289     # Check that moc is in path
290     if test -z "$MOC"; then
291     AC_CHECK_PROG(MOC, moc, moc, $PATH)
292     if test x$MOC = x ; then
293     AC_MSG_ERROR([*** moc must be in path])
294     fi
295     fi
296    
297     # uic is the Qt user interface compiler
298     AC_CHECK_PROG(UIC, uic, uic)
299     if test x$UIC = x ; then
300     AC_MSG_ERROR([*** uic must be in path])
301     fi
302    
303     # qembed is the Qt data embedding utility.
304     # It is located in $QTDIR/tools/qembed, and must be compiled and installed
305     # manually, we'll let it slide if it isn't present
306     AC_CHECK_PROG(QEMBED, qembed, qembed)
307    
308    
309     # Calculate Qt include path
310     QT_CXXFLAGS="-I$QTDIR/include"
311    
312     QT_IS_EMBEDDED="no"
313     # On unix, figure out if we're doing a static or dynamic link
314     case "${host}" in
315     *-cygwin)
316     AC_DEFINE_UNQUOTED(WIN32, "", Defined if on Win32 platform)
317     if test -f "$QTDIR/lib/qt.lib" ; then
318     QT_LIB="qt.lib"
319     QT_IS_STATIC="yes"
320     QT_IS_MT="no"
321     elif test -f "$QTDIR/lib/qt-mt.lib" ; then
322     QT_LIB="qt-mt.lib"
323     QT_IS_STATIC="yes"
324     QT_IS_MT="yes"
325     elif test -f "$QTDIR/lib/qt$QT_VER.lib" ; then
326     QT_LIB="qt$QT_VER.lib"
327     QT_IS_STATIC="no"
328     QT_IS_MT="no"
329     elif test -f "$QTDIR/lib/qt-mt$QT_VER.lib" ; then
330     QT_LIB="qt-mt$QT_VER.lib"
331     QT_IS_STATIC="no"
332     QT_IS_MT="yes"
333     fi
334     ;;
335    
336     *)
337     QT_IS_STATIC=`ls $QTDIR/lib/*.a 2> /dev/null`
338     if test "x$QT_IS_STATIC" = x; then
339     QT_IS_STATIC="no"
340     else
341     QT_IS_STATIC="yes"
342     fi
343     if test x$QT_IS_STATIC = xno ; then
344     QT_IS_DYNAMIC=`ls $QTDIR/lib/*.so 2> /dev/null`
345     if test "x$QT_IS_DYNAMIC" = x; then
346     AC_MSG_ERROR([*** Couldn't find any Qt libraries])
347     fi
348     fi
349    
350     if test "x`ls $QTDIR/lib/libqt.* 2> /dev/null`" != x ; then
351     QT_LIB="-lqt"
352     QT_IS_MT="no"
353     elif test "x`ls $QTDIR/lib/libqt-mt.* 2> /dev/null`" != x ; then
354     QT_LIB="-lqt-mt"
355     QT_IS_MT="yes"
356     elif test "x`ls $QTDIR/lib/libqte.* 2> /dev/null`" != x ; then
357     QT_LIB="-lqte"
358     QT_IS_MT="no"
359     QT_IS_EMBEDDED="yes"
360     elif test "x`ls $QTDIR/lib/libqte-mt.* 2> /dev/null`" != x ; then
361     QT_LIB="-lqte-mt"
362     QT_IS_MT="yes"
363     QT_IS_EMBEDDED="yes"
364     fi
365     ;;
366     esac
367     AC_MSG_CHECKING([if Qt is static])
368     AC_MSG_RESULT([$QT_IS_STATIC])
369     AC_MSG_CHECKING([if Qt is multithreaded])
370     AC_MSG_RESULT([$QT_IS_MT])
371     AC_MSG_CHECKING([if Qt is embedded])
372     AC_MSG_RESULT([$QT_IS_EMBEDDED])
373    
374     QT_GUILINK=""
375     QASSISTANTCLIENT_LDADD="-lqassistantclient"
376     case "${host}" in
377     *irix*)
378     QT_LIBS="$QT_LIB"
379     if test $QT_IS_STATIC = yes ; then
380     QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE"
381     fi
382     ;;
383    
384     *linux*)
385     QT_LIBS="$QT_LIB"
386     if test $QT_IS_STATIC = yes && test $QT_IS_EMBEDDED = no; then
387     QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -ldl -ljpeg"
388     fi
389     ;;
390    
391    
392     *osf*)
393     # Digital Unix (aka DGUX aka Tru64)
394     QT_LIBS="$QT_LIB"
395     if test $QT_IS_STATIC = yes ; then
396     QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE"
397     fi
398     ;;
399    
400     *solaris*)
401     QT_LIBS="$QT_LIB"
402     if test $QT_IS_STATIC = yes ; then
403     QT_LIBS="$QT_LIBS -L$x_libraries -lXext -lX11 -lm -lSM -lICE -lresolv -lsocket -lnsl"
404     fi
405     ;;
406    
407    
408     *win*)
409     # linker flag to suppress console when linking a GUI app on Win32
410     QT_GUILINK="/subsystem:windows"
411    
412     if test $QT_MAJOR = "3" ; then
413     if test $QT_IS_MT = yes ; then
414     QT_LIBS="/nodefaultlib:libcmt"
415     else
416     QT_LIBS="/nodefaultlib:libc"
417     fi
418     fi
419    
420     if test $QT_IS_STATIC = yes ; then
421     QT_LIBS="$QT_LIBS $QT_LIB kernel32.lib user32.lib gdi32.lib comdlg32.lib ole32.lib shell32.lib imm32.lib advapi32.lib wsock32.lib winspool.lib winmm.lib netapi32.lib"
422     if test $QT_MAJOR = "3" ; then
423     QT_LIBS="$QT_LIBS qtmain.lib"
424     fi
425     else
426     QT_LIBS="$QT_LIBS $QT_LIB"
427     if test $QT_MAJOR = "3" ; then
428     QT_CXXFLAGS="$QT_CXXFLAGS -DQT_DLL"
429     QT_LIBS="$QT_LIBS qtmain.lib qui.lib user32.lib netapi32.lib"
430     fi
431     fi
432     QASSISTANTCLIENT_LDADD="qassistantclient.lib"
433     ;;
434    
435     esac
436    
437    
438     if test x"$QT_IS_EMBEDDED" = "xyes" ; then
439     QT_CXXFLAGS="-DQWS $QT_CXXFLAGS"
440     fi
441    
442     if test x"$QT_IS_MT" = "xyes" ; then
443     QT_CXXFLAGS="$QT_CXXFLAGS -D_REENTRANT -DQT_THREAD_SUPPORT"
444     fi
445    
446     QT_LDADD="-L$QTDIR/lib $QT_LIBS"
447    
448     if test x$QT_IS_STATIC = xyes ; then
449     OLDLIBS="$LIBS"
450     LIBS="$QT_LDADD"
451     AC_CHECK_LIB(Xft, XftFontOpen, QT_LDADD="$QT_LDADD -lXft")
452     LIBS="$LIBS"
453     fi
454    
455     AC_MSG_CHECKING([QT_CXXFLAGS])
456     AC_MSG_RESULT([$QT_CXXFLAGS])
457     AC_MSG_CHECKING([QT_LDADD])
458     AC_MSG_RESULT([$QT_LDADD])
459    
460     AC_SUBST(QT_CXXFLAGS)
461     AC_SUBST(QT_LDADD)
462     AC_SUBST(QT_GUILINK)
463     AC_SUBST(QASSISTANTCLIENT_LDADD)
464    
465     ])