Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8597 was 8523, checked in by bensch, 18 years ago

trunk: compiles on Windows: DANGER: THE LINUX PORT MAY BE COMPROMISED

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
246dnl AX_CHECK_LUA([LUA_DIR])
247AC_DEFUN([AX_CHECK_LUA], [
248#dnl checking for LUA.
249LUA_LIBS=
250LUA_INCLUDES=
251dnl Check for Lua.
252
253LUA_INCLUDE_DIRECTORY="/usr/include"
254LUA_COMMON_INCLUDE_DIRECTORIES="
255      `ls -dr $1                       2>/dev/null`
256      /usr/include
257      `ls -dr /usr/include/lua*        2>/dev/null`
258      `ls -dr /usr/lib/lua/include     2>/dev/null`
259      `ls -dr /usr/local/include/lua   2>/dev/null`
260      `ls -dr /opt/lua*/include        2>/dev/null`
261      `ls -dr /Developer/lua*/include  2>/dev/null`
262    "
263
264  for _lua_include_directory in ${LUA_COMMON_INCLUDE_DIRECTORIES}
265    do
266      if test -e ${_lua_include_directory}/lua.h ; then
267        LUA_INCLUDE_DIRECTORY=${_lua_include_directory}
268        CPPFLAGS="${CPPFLAGS} -I${LUA_INCLUDE_DIRECTORY}"
269        break
270      fi
271  done
272    if test -n ${LUA_INCLUDE_DIRECTORY} ; then
273      echo "Lua-Include Directory is: ${LUA_INCLUDE_DIRECTORY}"
274    else
275      AC_MSG_ERROR([Lua Headers not found])
276    fi
277
278
279AC_CHECK_LIB([dl], [dlopen])
280AX_CHECK_REQUIRED_HEADER_LIB([lua.h], [lua lua50], [lua_open],,,)
281AX_CHECK_REQUIRED_HEADER_LIB([lualib.h], [lualib lualib50], [luaopen_base])
282#dnl libLUA found
283#     [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"  AX_CHECK_REQUIRED_HEADER_LIB([lualib.h], [lualib lualib50], [luaopen_base],
284dnl liblualib found
285#      [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"],,
286#      [http://www.lua.org],, [${LUA_LIBS} -ldl -lm])],
287#dnl liblua not found (download it)
288#       [AX_GET_INSTALL_NECESSARY_LIB([http://www.lua.org/ftp], [lua-5.0.tar.gz], [lua-5.0], [extern_libs/], [include/*.h lib/*.a])
289#       LUA_LIBS="-llualib -llua"  LUA_INCLUDES="-I$(top_build_dir)/extern_libs" ], [http://www.lua.org])
290
291AC_SUBST([LUA_LIBS])
292AC_SUBST([LUA_INCLUDES])
293])
294
295
296
297
298
299dnl AX_GET_INSTALL_NECESSARY_LIB([FTP-DIR], [DIST-FILE], [DIST-DIR], [INSTALL-DIR], [INSTALL-FILES], [CONFIG-FLAGS], [MAKE-OPTS])
300AC_DEFUN([AX_GET_INSTALL_NECESSARY_LIB], [
301
302   _get_install_FTP=$1
303   _get_install_DISTFILE=$2
304   _get_install_DISTDIR=$3
305   _get_install_INSTALLDIR=$4
306   dnl $5 is left out (inegrated bellow)
307   _get_install_CONFIGFLAGS=$6
308   _get_install_MAKEOPTS=$7
309
310dnl DOWNLOADING THE FILE
311   if test -f "${_get_install_DISTFILE}" ; then
312     echo "${_get_install_DISTFILE} already downloaded"
313   else
314     echo "Getting ${_get_install_DISTFILE} from ${_get_install_FTP}/${_get_install_DISTFILE}"
315     echo `wget ${_get_install_FTP}/${_get_install_DISTFILE}`
316   fi
317
318dnl UNCOMPRESS STAGE
319   echo "Uncompressing ${_get_install_DISTFILE}"
320   echo `tar xzvf ${_get_install_DISTFILE}`
321
322dnl ENTER DIRECTORY AND EXECUTE CONFIGURE AND MAKE
323   _get_install_PWD=`pwd`
324   cd ${_get_install_DISTDIR}
325dnl configure
326   if test -x "configure" ; then
327    ./configure ${_get_install_CONFIGFLAGS}
328   fi
329   make ${_get_install_MAKEOPTS}
330   cd ${_get_install_PWD}
331
332dnl INSTALL STAGE
333   echo "Installing Libraries and Headers into ${_get_install_INSTALLDIR} local directory"
334
335   mkdir -p ${_get_install_INSTALLDIR}
336   for _get_install_installfile in $5
337    do
338     echo "copy  ${_get_install_DISTDIR}/${_get_install_installfile} to ${_get_install_INSTALLDIR}/"
339     cp `ls -dr ${_get_install_DISTDIR}/${_get_install_installfile}` "${_get_install_INSTALLDIR}/"
340    done
341
342#cleaning up
343#  echo "rm -rf ${_get_install_DISTDIR}"
344#  rm -rf ${_get_install_DISTDIR}
345#  echo "rm ${_get_install_DISTFILE}"
346#  rm ${_get_install_DISTFILE}
347])
Note: See TracBrowser for help on using the repository browser.