Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8258 was 8061, checked in by bensch, 19 years ago

merged the scriptengine back to the trunk

File size: 10.3 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 ; then
149        QT_LIB_DIRECTORY=${_lib_directory}
150        break
151      fi
152    done
153    if test -n ${QT_LIB_DIRECTORY} ; then
154      echo "Qt-Library Directory is: ${QT_LIB_DIRECTORY}"
155    else
156      AC_MSG_ERROR([Qt LIB not found])
157    fi
158
159## Search in all BINDirectories for QT-executables
160    for _bin_directory in ${QT_COMMON_BIN_DIRECTORIES}
161    do
162      if test -e ${_bin_directory}/moc || test -e  ${_bin_directory}/moc.exe ; then
163        QT_BIN_DIRECTORY=${_bin_directory}
164        break
165      fi
166    done
167    if test -n ${QT_BIN_DIRECTORY} ; then
168        echo "Qt-Bin Directory is: ${QT_BIN_DIRECTORY}"
169    else
170        QT_BIN_DIRECTORY=${QT_PREFIX}/bin
171    fi
172
173## Setting up the Environment Variables.
174    QT_LIBS=""
175    QT_CXXFLAGS="-I${QT_INCLUDE_DIRECTORY}"
176    LDFLAGS="${LDFLAGS} -L${QT_LIB_DIRECTORY} -Wl,-rpath -Wl,${QT_LIB_DIRECTORY}"
177
178    CACHED_CPPFLAG=${CPPFLAGS}
179    CACHED_LDFLAGS=${LDFLAGS}
180
181    LDFLAGS="${LDFLAGS} ${QT_LDFLAGS}"
182    for _lib in $2
183    do
184      AC_CHECK_LIB([$_lib], [main], [_lib_check="yes"], [_lib_check="no"])
185      if test "x$_lib_check" = "xyes" ; then
186        _found_lib=$_lib
187        break
188      fi
189    done
190
191    if [test "x$_lib_check" = "xyes"] ; then
192         QT_LIBS="${QT_LIBS} -l$_found_lib"
193         AX_CHECK_REQUIRED_LIB([QtCore QtCore4], [main],,,[http://www.trolltech.com] )
194         AX_CHECK_REQUIRED_LIB([QtGui QtGui4], [main],,,[http://www.trolltech.com] )
195         AX_CHECK_REQUIRED_LIB([QtOpenGL QtOpenGL4], [main],,,[http://www.trolltech.com] )
196
197         $3
198    else
199         echo "------------------"
200         echo "LIBRARY $2 not found.in $1"
201         echo "please install the $1-LIBRARY-package which can be found at $5"
202         echo "------------------"
203         $4
204         exit -1
205    fi
206
207    echo "QT_LIBS = ${QT_LIBS}"
208    echo "QT_CXXFLAGS = ${QT_CXXFLAGS}"
209    echo "QT_LD_FLAGS = ${QT_LDFLAGS}"
210    echo "QT_BIN_DIRECTORY = ${QT_BIN_DIRECTORY}"
211
212    AC_SUBST([QT_LIBS])
213    AC_SUBST([QT_CXXFLAGS])
214    AC_SUBST([QT_LDFLAGS])
215
216    #----------#
217    # QT - MOC #
218    #----------#
219    AC_PATH_PROGS([QT_MOC], [moc-qt4 moc], [no], ["${QT_BIN_DIRECTORY}:${PATH}"])
220      if test x${QT_MOC} = xno ; then
221         AC_MSG_ERROR([QT MOC not found])
222      fi
223    AC_SUBST([QT_MOC])
224
225    AC_PATH_PROG([QT_UIC], [uic], [no], ["${QT_BIN_DIRECTORY}:${PATH}"])
226 #     if test x${QT_UIC} = xno ; then
227 #       AC_MSG_WARN([QT UIC not found])
228 #     fi
229    AC_SUBST([QT_UIC])
230
231    AC_PATH_PROG([QT_RCC], [rcc], [no], ["${QT_BIN_DIRECTORY}:${PATH}"])
232#      if test x${QT_RCC} = xno ; then
233#        AC_MSG_WARN([QT RCC not found])
234#      fi
235    AC_SUBST([QT_RCC])
236
237
238
239    # Restore Values of CPPFLAGS and LDFLAGS
240    CPPFLAGS=${CACHED_CPPFLAG}
241    LDFLAGS=${CACHED_LDFLAGS}
242])
243
244
245dnl AX_CHECK_LUA([LUA_DIR])
246AC_DEFUN([AX_CHECK_LUA], [
247#dnl checking for LUA.
248LUA_LIBS=
249LUA_INCLUDES=
250dnl Check for Lua.
251
252LUA_INCLUDE_DIRECTORY="/usr/include"
253LUA_COMMON_INCLUDE_DIRECTORIES="
254      `ls -dr $1                       2>/dev/null`
255      /usr/include
256      `ls -dr /usr/include/lua*        2>/dev/null`
257      `ls -dr /usr/lib/lua/include     2>/dev/null`
258      `ls -dr /usr/local/include/lua   2>/dev/null`
259      `ls -dr /opt/lua*/include        2>/dev/null`
260      `ls -dr /Developer/lua*/include  2>/dev/null`
261    "
262
263  for _lua_include_directory in ${LUA_COMMON_INCLUDE_DIRECTORIES}
264    do
265      if test -e ${_lua_include_directory}/lua.h ; then
266        LUA_INCLUDE_DIRECTORY=${_lua_include_directory}
267        CPPFLAGS="${CPPFLAGS} -I${LUA_INCLUDE_DIRECTORY}"
268        break
269      fi
270  done
271    if test -n ${LUA_INCLUDE_DIRECTORY} ; then
272      echo "Lua-Include Directory is: ${LUA_INCLUDE_DIRECTORY}"
273    else
274      AC_MSG_ERROR([Lua Headers not found])
275    fi
276
277
278AC_CHECK_LIB([dl], [dlopen])
279AX_CHECK_REQUIRED_HEADER_LIB([lua.h], [lua lua50], [lua_open],
280dnl libLUA found
281     [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"  AX_CHECK_REQUIRED_HEADER_LIB([lualib.h], [lualib lualib50], [luaopen_base],
282dnl liblualib found
283      [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"],,
284      [http://www.lua.org],, [${LUA_LIBS} -ldl -lm])],
285dnl liblua not found (download it)
286       [AX_GET_INSTALL_NECESSARY_LIB([http://www.lua.org/ftp], [lua-5.0.tar.gz], [lua-5.0], [extern_libs/], [include/*.h lib/*.a])
287       LUA_LIBS="-llualib -llua"  LUA_INCLUDES="-I$(top_build_dir)/extern_libs" ], [http://www.lua.org])
288
289AC_SUBST([LUA_LIBS])
290AC_SUBST([LUA_INCLUDES])
291])
292
293
294
295
296
297dnl AX_GET_INSTALL_NECESSARY_LIB([FTP-DIR], [DIST-FILE], [DIST-DIR], [INSTALL-DIR], [INSTALL-FILES], [CONFIG-FLAGS], [MAKE-OPTS])
298AC_DEFUN([AX_GET_INSTALL_NECESSARY_LIB], [
299
300   _get_install_FTP=$1
301   _get_install_DISTFILE=$2
302   _get_install_DISTDIR=$3
303   _get_install_INSTALLDIR=$4
304   dnl $5 is left out (inegrated bellow)
305   _get_install_CONFIGFLAGS=$6
306   _get_install_MAKEOPTS=$7
307
308dnl DOWNLOADING THE FILE
309   if test -f "${_get_install_DISTFILE}" ; then
310     echo "${_get_install_DISTFILE} already downloaded"
311   else
312     echo "Getting ${_get_install_DISTFILE} from ${_get_install_FTP}/${_get_install_DISTFILE}"
313     echo `wget ${_get_install_FTP}/${_get_install_DISTFILE}`
314   fi
315
316dnl UNCOMPRESS STAGE
317   echo "Uncompressing ${_get_install_DISTFILE}"
318   echo `tar xzvf ${_get_install_DISTFILE}`
319
320dnl ENTER DIRECTORY AND EXECUTE CONFIGURE AND MAKE
321   _get_install_PWD=`pwd`
322   cd ${_get_install_DISTDIR}
323dnl configure
324   if test -x "configure" ; then
325    ./configure ${_get_install_CONFIGFLAGS}
326   fi
327   make ${_get_install_MAKEOPTS}
328   cd ${_get_install_PWD}
329
330dnl INSTALL STAGE
331   echo "Installing Libraries and Headers into ${_get_install_INSTALLDIR} local directory"
332
333   mkdir -p ${_get_install_INSTALLDIR}
334   for _get_install_installfile in $5
335    do
336     echo "copy  ${_get_install_DISTDIR}/${_get_install_installfile} to ${_get_install_INSTALLDIR}/"
337     cp `ls -dr ${_get_install_DISTDIR}/${_get_install_installfile}` "${_get_install_INSTALLDIR}/"
338    done
339
340#cleaning up
341  echo "rm -rf ${_get_install_DISTDIR}"
342  rm -rf ${_get_install_DISTDIR}
343  echo "rm ${_get_install_DISTFILE}"
344  rm ${_get_install_DISTFILE}
345])
Note: See TracBrowser for help on using the repository browser.