Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/acinclude.m4 @ 10118

Last change on this file since 10118 was 9883, checked in by bensch, 18 years ago

trunk: completely doxygened and finalized IniParser

File size: 10.5 KB
Line 
1
2
3dnl AX_CHECK_HEADER_LIB([HEADER-NAME], [LIBRARY-NAME], [FUNCTION-IN-LIB], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [LIB-WEB-PAGE])
4AC_DEFUN([AX_CHECK_HEADER_LIB], [
5    _header_check=""
6    _lib_check=""
7
8    AC_CHECK_HEADER([$1], [_header_check="yes"], [_header_check="no"])
9    AC_CHECK_LIB([$2], [$3], [_lib_check="yes"], [_lib_check="no"])
10    if [test "x$_header_check" = "xyes" && test "x$_lib_check" = "xyes"] ; then
11         LIBS="$LIBS -l$2"
12         $4
13    else
14         echo "no Support for $2"
15         $5
16    fi
17])
18
19
20
21dnl AX_CHECK_REQUIRED_HEADER_LIB([HEADER-NAME], [LIBRARY-NAME], [FUNCTION-IN-LIB], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [LIB-WEB-PAGE], [CFLAGS], [OTHER_LIBS])
22AC_DEFUN([AX_CHECK_REQUIRED_HEADER_LIB], [
23    _header_check=""
24    _lib_check=""
25    LAST_FOUND_LIB=""
26
27    _lib_USED=""
28    _header_USED=""
29
30    for _header in $1
31    do
32      AC_CHECK_HEADER([${_header}], [_header_check="yes" ; _header_USED=${_header}], [_header_check="no"], $7)
33      if  test "x${_header_check}" = "xyes" ; then
34        break
35      fi
36    done
37    for _check_library in $2
38    do
39      AC_CHECK_LIB([${_check_library}], [$3], [_lib_check="yes"; _lib_USED=${_check_library}], [_lib_check="no"], $8)
40      if test "x${_lib_check}" = "xyes" ; then
41        LAST_FOUND_LIB=${_lib_USED}
42        break
43      fi
44    done
45    if [test "x${_header_check}" = "xyes" && test "x${_lib_check}" = "xyes"] ; then
46        m4_ifval([$4], [$4], [
47         LIBS="${LIBS} -l${_lib_USED}"])
48    else
49        m4_ifval([$5], [$5], [
50         echo "------------------"
51         echo "LIBRARY $2 not found."
52         echo "please install the $2-LIBRARY-package which can be found at $6"
53         echo "------------------"
54         exit -1])
55    fi
56])
57
58
59
60dnl AX_CHECK_REQUIRED_LIB([LIBRARY-NAME], [FUNCTION-IN-LIB], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [LIB-WEB-PAGE])
61AC_DEFUN([AX_CHECK_REQUIRED_LIB], [
62    _lib_check=""
63    _found_lib=""
64
65
66    for _lib in $1
67    do
68      AC_CHECK_LIB([$_lib], [$2], [_lib_check="yes"], [_lib_check="no"])
69      if test "x$_lib_check" = "xyes" ; then
70        _found_lib=$_lib
71        break
72      fi
73    done
74
75    if [test "x$_lib_check" = "xyes"] ; then
76         LIBS="$LIBS -l$_found_lib"
77         $3
78    else
79         echo "------------------"
80         echo "LIBRARY $1 not found."
81         echo "please install the $1-LIBRARY-package which can be found at $5"
82         echo "------------------"
83         $4
84         exit -1
85    fi
86])
87
88
89
90
91dnl AX_CHECK_QT([QTDIR], [LIBRARIES], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [LIB-WEB-PAGE])
92AC_DEFUN([AX_CHECK_QT], [
93    _lib_check=""
94    _found_lib=""
95    QT_PREFIX="$1"
96    QT_INCLUDE_DIRECTORY=""
97    QT_LIB_DIRECTORY=""
98    QT_BIN_DIRECTORY=""
99
100    QT_COMMON_INCLUDE_DIRECTORIES="
101      `ls -dr ${QT_PREFIX}/include     2>/dev/null`
102      /usr/include
103      `ls -dr /usr/include/qt*         2>/dev/null`
104      `ls -dr /usr/lib/qt*/include     2>/dev/null`
105      `ls -dr /usr/local/qt*/include   2>/dev/null`
106      `ls -dr /opt/qt*/include         2>/dev/null`
107      `ls -dr /Developer/qt*/include   2>/dev/null`
108      `ls -dr /c/Qt/*/include          2>/dev/null`
109    "
110
111    QT_COMMON_LIB_DIRECTORIES="
112      `ls -dr ${QT_PREFIX}/lib         2>/dev/null`
113      /usr/lib
114      `ls -dr /usr/lib/qt*             2>/dev/null`
115      `ls -dr /usr/local/qt*/lib       2>/dev/null`
116      `ls -dr /opt/qt*/lib             2>/dev/null`
117      `ls -dr /Developer/qt*/lib       2>/dev/null`
118      `ls -dr /c/Qt/*/lib              2>/dev/null`
119    "
120
121    QT_COMMON_BIN_DIRECTORIES="
122      `ls -dr ${QT_PREFIX}/bin         2>/dev/null`
123      /usr/bin
124      `ls -dr /usr/bin/qt*             2>/dev/null`
125      `ls -dr /usr/local/qt*/bin       2>/dev/null`
126      `ls -dr /opt/qt*/bin             2>/dev/null`
127      `ls -dr /Developer/qt*/bin       2>/dev/null`
128      `ls -dr /c/Qt/*/bin              2>/dev/null`
129    "
130
131## Search in all IncludeDirectories for QT-includes
132    for _qt_include_directory in ${QT_COMMON_INCLUDE_DIRECTORIES}
133    do
134      if test -e ${_qt_include_directory}/QtCore/QCoreApplication ; then
135        QT_INCLUDE_DIRECTORY="${_qt_include_directory}"
136        break
137      fi
138    done
139    if test -n ${QT_INCLUDE_DIRECTORY} ; then
140      echo "Qt-Include Directory is: ${QT_INCLUDE_DIRECTORY}"
141    else
142      AC_MSG_ERROR([Qt Headers not found])
143    fi
144
145## Search in all LibraryDirectories for QT-includes
146    for _lib_directory in ${QT_COMMON_LIB_DIRECTORIES}
147    do
148      if test -e ${_lib_directory}/libQtCore.so || test -e ${_lib_directory}/libQtCore4.a || \
149                        test -e ${_lib_directory}/QtCore.framework ; then
150        QT_LIB_DIRECTORY=${_lib_directory}
151        break
152          fi
153    done
154    if test -n ${QT_LIB_DIRECTORY} ; then
155      echo "Qt-Library Directory is: ${QT_LIB_DIRECTORY}"
156    else
157      AC_MSG_ERROR([Qt LIB not found])
158    fi
159
160## Search in all BINDirectories for QT-executables
161    for _bin_directory in ${QT_COMMON_BIN_DIRECTORIES}
162    do
163      if test -e ${_bin_directory}/moc || test -e  ${_bin_directory}/moc.exe ; then
164        QT_BIN_DIRECTORY=${_bin_directory}
165        break
166      fi
167    done
168    if test -n ${QT_BIN_DIRECTORY} ; then
169        echo "Qt-Bin Directory is: ${QT_BIN_DIRECTORY}"
170    else
171        QT_BIN_DIRECTORY=${QT_PREFIX}/bin
172    fi
173
174## Setting up the Environment Variables.
175    QT_LIBS=""
176    QT_CXXFLAGS="-I${QT_INCLUDE_DIRECTORY}"
177    LDFLAGS="${LDFLAGS} -L${QT_LIB_DIRECTORY} -Wl,-rpath -Wl,${QT_LIB_DIRECTORY}"
178
179    CACHED_CPPFLAG=${CPPFLAGS}
180    CACHED_LDFLAGS=${LDFLAGS}
181
182    LDFLAGS="${LDFLAGS} ${QT_LDFLAGS}"
183    for _lib in $2
184    do
185      AC_CHECK_LIB([$_lib], [main], [_lib_check="yes"], [_lib_check="no"])
186      if test "x$_lib_check" = "xyes" ; then
187        _found_lib=$_lib
188        break
189      fi
190    done
191
192    if [test "x$_lib_check" = "xyes"] ; then
193         QT_LIBS="${QT_LIBS} -l$_found_lib"
194         AX_CHECK_REQUIRED_LIB([QtCore QtCore4], [main],,,[http://www.trolltech.com] )
195         AX_CHECK_REQUIRED_LIB([QtGui QtGui4], [main],,,[http://www.trolltech.com] )
196         AX_CHECK_REQUIRED_LIB([QtOpenGL QtOpenGL4], [main],,,[http://www.trolltech.com] )
197
198         $3
199    else
200         echo "------------------"
201         echo "LIBRARY $2 not found.in $1"
202         echo "please install the $1-LIBRARY-package which can be found at $5"
203         echo "------------------"
204         $4
205         exit -1
206    fi
207
208    echo "QT_LIBS          = ${QT_LIBS}"
209    echo "QT_CXXFLAGS      = ${QT_CXXFLAGS}"
210    echo "QT_LD_FLAGS      = ${QT_LDFLAGS}"
211    echo "QT_BIN_DIRECTORY = ${QT_BIN_DIRECTORY}"
212
213    AC_SUBST([QT_LIBS])
214    AC_SUBST([QT_CXXFLAGS])
215    AC_SUBST([QT_LDFLAGS])
216
217    #----------#
218    # QT - MOC #
219    #----------#
220    AC_PATH_PROGS([QT_MOC], [moc-qt4 moc], [no], ["${QT_BIN_DIRECTORY}:${PATH}"])
221      if test x${QT_MOC} = xno ; then
222         AC_MSG_ERROR([QT MOC not found])
223      fi
224    AC_SUBST([QT_MOC])
225
226    AC_PATH_PROG([QT_UIC], [uic], [no], ["${QT_BIN_DIRECTORY}:${PATH}"])
227 #     if test x${QT_UIC} = xno ; then
228 #       AC_MSG_WARN([QT UIC not found])
229 #     fi
230    AC_SUBST([QT_UIC])
231
232    AC_PATH_PROG([QT_RCC], [rcc], [no], ["${QT_BIN_DIRECTORY}:${PATH}"])
233#      if test x${QT_RCC} = xno ; then
234#        AC_MSG_WARN([QT RCC not found])
235#      fi
236    AC_SUBST([QT_RCC])
237
238
239
240    # Restore Values of CPPFLAGS and LDFLAGS
241    CPPFLAGS=${CACHED_CPPFLAG}
242    LDFLAGS=${CACHED_LDFLAGS}
243])
244
245
246
247
248
249
250dnl AX_CHECK_LUA([LUA_DIR])
251AC_DEFUN([AX_CHECK_LUA], [
252#dnl checking for LUA.
253LUA_LIBS=
254LUA_INCLUDES=
255dnl Check for Lua.
256
257LUA_INCLUDE_DIRECTORY="/usr/include"
258LUA_COMMON_INCLUDE_DIRECTORIES="
259      `ls -dr $1                       2>/dev/null`
260      /usr/include
261      `ls -dr /usr/include/lua*        2>/dev/null`
262      `ls -dr /usr/lib/lua/include     2>/dev/null`
263      `ls -dr /usr/local/include/lua   2>/dev/null`
264      `ls -dr /opt/lua*/include        2>/dev/null`
265      `ls -dr /Developer/lua*/include  2>/dev/null`
266    "
267
268  for _lua_include_directory in ${LUA_COMMON_INCLUDE_DIRECTORIES}
269    do
270      if test -e ${_lua_include_directory}/lua.h ; then
271        LUA_INCLUDE_DIRECTORY=${_lua_include_directory}
272        CPPFLAGS="${CPPFLAGS} -I${LUA_INCLUDE_DIRECTORY}"
273        break
274      fi
275  done
276    if test -n ${LUA_INCLUDE_DIRECTORY} ; then
277      echo "Lua-Include Directory is: ${LUA_INCLUDE_DIRECTORY}"
278    else
279      AC_MSG_ERROR([Lua Headers not found])
280    fi
281
282
283AC_CHECK_LIB([dl], [dlopen])
284AX_CHECK_REQUIRED_HEADER_LIB([lua.h], [lua lua50], [lua_open],
285dnl libLUA found
286     [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"  AX_CHECK_REQUIRED_HEADER_LIB([lualib.h], [lualib lualib50], [luaopen_base],
287dnl liblualib found
288      [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"], [LUA_LIBS="${LUA_LIBS} -llualib"],
289      [http://www.lua.org],, [-llua ${LUA_LIBS} -ldl -lm])],
290dnl liblua not found (download it)
291       [AX_GET_INSTALL_NECESSARY_LIB([http://switch.dl.sourceforge.net/sourceforge/gtksql], [lua-5.0.tar.gz], [lua-5.0], [extern_libs/], [include/*.h lib/*.a])
292       LUA_LIBS="-llualib -llua"  LUA_INCLUDES="-I$(top_build_dir)/extern_libs" ], [http://www.lua.org])
293
294AC_SUBST([LUA_LIBS])
295AC_SUBST([LUA_INCLUDES])
296])
297
298
299
300
301
302
303
304
305
306dnl AX_GET_INSTALL_NECESSARY_LIB([FTP-DIR], [DIST-FILE], [DIST-DIR], [INSTALL-DIR], [INSTALL-FILES], [CONFIG-FLAGS], [MAKE-OPTS])
307AC_DEFUN([AX_GET_INSTALL_NECESSARY_LIB], [
308
309   _get_install_FTP=$1
310   _get_install_DISTFILE=$2
311   _get_install_DISTDIR=$3
312   _get_install_INSTALLDIR=$4
313   dnl $5 is left out (inegrated bellow)
314   _get_install_CONFIGFLAGS=$6
315   _get_install_MAKEOPTS=$7
316
317dnl DOWNLOADING THE FILE
318   if test -f "${_get_install_DISTFILE}" ; then
319     echo "${_get_install_DISTFILE} already downloaded"
320   else
321     echo "Getting ${_get_install_DISTFILE} from ${_get_install_FTP}/${_get_install_DISTFILE}"
322     echo `wget ${_get_install_FTP}/${_get_install_DISTFILE}`
323   fi
324
325dnl UNCOMPRESS STAGE
326   echo "Uncompressing ${_get_install_DISTFILE}"
327   echo `tar xzvf ${_get_install_DISTFILE}`
328
329dnl ENTER DIRECTORY AND EXECUTE CONFIGURE AND MAKE
330   _get_install_PWD=`pwd`
331   cd ${_get_install_DISTDIR}
332dnl configure
333   if test -x "configure" ; then
334    ./configure ${_get_install_CONFIGFLAGS}
335   fi
336   make ${_get_install_MAKEOPTS}
337   cd ${_get_install_PWD}
338
339dnl INSTALL STAGE
340   echo "Installing Libraries and Headers into ${_get_install_INSTALLDIR} local directory"
341
342   mkdir -p ${_get_install_INSTALLDIR}
343   for _get_install_installfile in $5
344    do
345     echo "copy  ${_get_install_DISTDIR}/${_get_install_installfile} to ${_get_install_INSTALLDIR}/"
346     cp `ls -dr ${_get_install_DISTDIR}/${_get_install_installfile}` "${_get_install_INSTALLDIR}/"
347    done
348
349#cleaning up
350  echo "rm -rf ${_get_install_DISTDIR}"
351  rm -rf ${_get_install_DISTDIR}
352  echo "rm ${_get_install_DISTFILE}"
353  rm ${_get_install_DISTFILE}
354])
Note: See TracBrowser for help on using the repository browser.