Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/script_engine/acinclude.m4 @ 7906

Last change on this file since 7906 was 7648, checked in by bensch, 19 years ago

script_engine: link again

File size: 4.9 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
60
61dnl AX_CHECK_LUA([LUA_DIR])
62AC_DEFUN([AX_CHECK_LUA], [
63#dnl checking for LUA.
64LUA_LIBS=
65LUA_INCLUDES=
66dnl Check for Lua.
67
68LUA_INCLUDE_DIRECTORY="/usr/include"
69LUA_COMMON_INCLUDE_DIRECTORIES="
70      `ls -dr $1                       2>/dev/null`
71      /usr/include
72      `ls -dr /usr/include/lua*        2>/dev/null`
73      `ls -dr /usr/lib/lua/include     2>/dev/null`
74      `ls -dr /usr/local/include/lua   2>/dev/null`
75      `ls -dr /opt/lua*/include        2>/dev/null`
76      `ls -dr /Developer/lua*/include  2>/dev/null`
77    "
78
79  for _lua_include_directory in ${LUA_COMMON_INCLUDE_DIRECTORIES}
80    do
81      if test -e ${_lua_include_directory}/lua.h ; then
82        LUA_INCLUDE_DIRECTORY=${_lua_include_directory}
83        CPPFLAGS="${CPPFLAGS} -I${LUA_INCLUDE_DIRECTORY}"
84        break
85      fi
86  done
87    if test -n ${LUA_INCLUDE_DIRECTORY} ; then
88      echo "Lua-Include Directory is: ${LUA_INCLUDE_DIRECTORY}"
89    else
90      AC_MSG_ERROR([Lua Headers not found])
91    fi
92
93
94AC_CHECK_LIB([dl], [dlopen])
95AX_CHECK_REQUIRED_HEADER_LIB([lua.h], [lua lua50], [lua_open],
96dnl libLUA found
97     [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"  AX_CHECK_REQUIRED_HEADER_LIB([lualib.h], [lualib lualib50], [luaopen_base],
98dnl liblualib found
99      [LUA_LIBS="${LUA_LIBS} -l${LAST_FOUND_LIB}"],,
100      [http://www.lua.org],, [${LUA_LIBS} -ldl -lm])],
101dnl liblua not found (download it)
102       [AX_GET_INSTALL_NECESSARY_LIB([http://www.lua.org/ftp], [lua-5.0.tar.gz], [lua-5.0], [extern_libs/], [include/*.h lib/*.a])
103       LUA_LIBS="-llualib -llua"  LUA_INCLUDES="-I$(top_build_dir)/extern_libs" ], [http://www.lua.org])
104
105AC_SUBST([LUA_LIBS])
106AC_SUBST([LUA_INCLUDES])
107])
108
109
110
111
112
113dnl AX_GET_INSTALL_NECESSARY_LIB([FTP-DIR], [DIST-FILE], [DIST-DIR], [INSTALL-DIR], [INSTALL-FILES], [CONFIG-FLAGS], [MAKE-OPTS])
114AC_DEFUN([AX_GET_INSTALL_NECESSARY_LIB], [
115
116   _get_install_FTP=$1
117   _get_install_DISTFILE=$2
118   _get_install_DISTDIR=$3
119   _get_install_INSTALLDIR=$4
120   dnl $5 is left out (inegrated bellow)
121   _get_install_CONFIGFLAGS=$6
122   _get_install_MAKEOPTS=$7
123
124dnl DOWNLOADING THE FILE
125   if test -f "${_get_install_DISTFILE}" ; then
126     echo "${_get_install_DISTFILE} already downloaded"
127   else
128     echo "Getting ${_get_install_DISTFILE} from ${_get_install_FTP}/${_get_install_DISTFILE}"
129     echo `wget ${_get_install_FTP}/${_get_install_DISTFILE}`
130   fi
131
132dnl UNCOMPRESS STAGE
133   echo "Uncompressing ${_get_install_DISTFILE}"
134   echo `tar xzvf ${_get_install_DISTFILE}`
135
136dnl ENTER DIRECTORY AND EXECUTE CONFIGURE AND MAKE
137   _get_install_PWD=`pwd`
138   cd ${_get_install_DISTDIR}
139dnl configure
140   if test -x "configure" ; then
141    ./configure ${_get_install_CONFIGFLAGS}
142   fi
143   make ${_get_install_MAKEOPTS}
144   cd ${_get_install_PWD}
145
146dnl INSTALL STAGE
147   echo "Installing Libraries and Headers into ${_get_install_INSTALLDIR} local directory"
148
149   mkdir -p ${_get_install_INSTALLDIR}
150   for _get_install_installfile in $5
151    do
152     echo "copy  ${_get_install_DISTDIR}/${_get_install_installfile} to ${_get_install_INSTALLDIR}/"
153     cp `ls -dr ${_get_install_DISTDIR}/${_get_install_installfile}` "${_get_install_INSTALLDIR}/"
154    done
155
156#cleaning up
157  echo "rm -rf ${_get_install_DISTDIR}"
158  rm -rf ${_get_install_DISTDIR}
159  echo "rm ${_get_install_DISTFILE}"
160  rm ${_get_install_DISTFILE}
161])
Note: See TracBrowser for help on using the repository browser.