ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/ac-tools/CGAL.m4
Revision: 1191
Committed: Thu Dec 6 19:39:00 2007 UTC (17 years, 8 months ago) by chuckv
File size: 13119 byte(s)
Log Message:
Added configure for CGAL.

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