]> git.mxchange.org Git - simgear.git/blobdiff - configure.ac
Convert char* to string to prevent stdup/malloc/free
[simgear.git] / configure.ac
index ac5d8d7f0010bd4baef39353851c4a3acb3c9840..2136625ba2dc490f6d0bdeb4a4733d8b32e79e47 100644 (file)
@@ -1,5 +1,5 @@
-dnl Process this file with aclocal ; automake -a ; autoconf to produce a 
-dnl working configure script.
+dnl Process this file with autoget.sh to produce a working configure
+dnl script.
 dnl
 dnl $Id$
 
@@ -38,7 +38,7 @@ AC_PROG_RANLIB
 AC_PROG_INSTALL
 AC_PROG_LN_S
 
-
+dnl set the $host variable based on local machine/os
 AC_CANONICAL_HOST
 
 dnl Used on the Irix platform
@@ -49,6 +49,7 @@ case "${host}" in
     if test "$CXX" = "CC"; then
         AR="CC -ar"
         ARFLAGS="-o"
+        CXXFLAGS="$CXXFLAGS -I$(top_srcdir)/simgear/compatibility"
     fi
     ;;
 esac
@@ -146,10 +147,44 @@ if test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h
     CXXFLAGS="$CXXFLAGS -D_REENTRANT"
     CFLAGS="$CFLAGS -D_REENTRANT"
 fi
+if test "x$ac_cv_lib_pthread_pthread_exit" != "xyes" -a "x$ac_cv_header_pthread_h" = "xyes"; then
+    dnl FreeBSD: System has pthread.h, but -lpthread library check
+    dnl fails.  See if we need -pthread instead of -lpthread and look
+    dnl for the functions in libc_r.
+    save_CXXFLAGS="$CXXFLAGS"
+    save_CFLAGS="$CFLAGS"
+    CXXFLAGS="-pthread $CXXFLAGS"
+    CFLAGS="-pthread $FLAGS"
+    save_LIBS=$LIBS
+    AC_CHECK_LIB(c_r, pthread_exit)
+    if test "x$ac_cv_lib_c_r_pthread_exit" != "xyes"; then
+       CXXFLAGS=$save_CXXFLAGS
+       CFLAGS=$save_CFLAGS
+    else
+       dnl This is cheating a bit. pthread_exit comes with using -pthread, not -lpthread
+       ac_cv_lib_pthread_pthread_exit="yes"
+    fi
+    LIBS=$save_LIBS
+fi
 AM_CONDITIONAL(HAVE_THREADS, test "x$ac_cv_lib_pthread_pthread_exit" = "xyes" -a "x$ac_cv_header_pthread_h" = "xyes")
 
 AC_CHECK_LIB(socket, socket)
 
+dnl check for glut location
+AC_CHECK_HEADER(GL/glut.h)
+if test "x$ac_cv_header_GL_glut_h" = "xyes"; then
+    AC_DEFINE([GLUT_H], "GL/glut.h", [Define as glut.h include location])
+else
+    AC_CHECK_HEADER(GLUT/glut.h)
+    if test "x$ac_cv_header_GLUT_glut_h" = "xyes"; then
+        AC_DEFINE([GLUT_H], "GLUT/glut.h", [Define as glut.h include location])
+    else
+        echo "Neither GL/glut.h nor GLUT/glut.h found.  Cannot continue"
+        exit
+    fi
+fi
+
+dnl check for OpenGL related libraries
 case "${host}" in
 *-*-cygwin* | *-*-mingw32*)
     dnl CygWin under Windoze.
@@ -164,7 +199,7 @@ case "${host}" in
     dnl add -lwsock32 for mingwin
     case "${host}" in
     *-*-mingw32*)
-        LIBS="$LIBS -lwsock32"
+        base_LIBS="$base_LIBS -lws2_32"
         ;;
     esac
 
@@ -221,20 +256,6 @@ case "${host}" in
 
 esac
 
-dnl check for glut location
-AC_CHECK_HEADER(GL/glut.h)
-if test "x$ac_cv_header_GL_glut_h" = "xyes"; then
-    AC_DEFINE([GLUT_H], "GL/glut.h", [Define as glut.h include location])
-else
-    AC_CHECK_HEADER(GLUT/glut.h)
-    if test "x$ac_cv_header_GLUT_glut_h" = "xyes"; then
-        AC_DEFINE([GLUT_H], "GLUT/glut.h", [Define as glut.h include location])
-    else
-        echo "Neither GL/glut.h nor GLUT/glut.h found.  Cannot continue"
-        exit
-    fi
-fi
-
 opengl_LIBS="$LIBS"
 LIBS="$base_LIBS"
 
@@ -286,31 +307,79 @@ int main() {
   AC_MSG_RESULT(yes)
 )
 
-dnl Check for system installed metakit
+dnl Check for MetaKit
 AC_CHECK_HEADER(mk4.h)
 if test "x$ac_cv_header_mk4_h" != "xyes"; then
-    echo 
-    echo "Metakit not found, you will need to install this first."
-    echo "Please read the README.metakit for more information."
+    echo
+    echo "MetaKit library not found."
+    echo
+    echo "If your OS does not provide an installable package for MetaKit"
+    echo "you will have to compile and install it first yourself.  A copy"
+    echo "of metakit-$(VERSION).tar.gz is included with SimGear.  You will"
+    echo "have to untar this source code, and follow its included instructions"
+    echo "to compile and install on your system."
+    echo
+    echo "configure aborted."
     exit
 fi
 
+AC_MSG_CHECKING([for metakit 2.4.3 or newer])
+saved_LIBS="$LIBS"
+LIBS="$saved_LIBS -lmk4"
+AC_TRY_RUN([
+#include <mk4.h>
+
+#define MIN_MK4_VERSION 243
+
+int main() {
+    int major, minor, micro;
+
+    if ( d4_MetaKitLibraryVersion < MIN_MK4_VERSION ) {
+        return -1;
+    }
+
+    return 0;
+}
+
+],
+  AC_MSG_RESULT(yes),
+  [AC_MSG_RESULT(wrong version);
+   AC_MSG_ERROR([
+
+Install metakit 2.4.3 or later first.
+
+Or, the compiler may not be finding your libmk4.so library.
+Please check the config.log file for specific details of the
+failure if you believe you have the correct metakit version.
+Also, look up this issue in the FlightGear FAQ.])],
+  AC_MSG_RESULT(yes)
+)
+
+LIBS="$saved_LIBS"
+
 AC_LANG_POP
 
 dnl Check for system installed zlib
 AC_CHECK_HEADER(zlib.h)
 if test "x$ac_cv_header_zlib_h" != "xyes"; then
-    echo 
-    echo "zlib not found, you will need to install this first."
-    echo "Please read the README.zlib for more information."
-    exit
+    echo
+    echo "zlib library not found."
+    echo
+    echo "If your OS does not provide an installable package for zlib"
+    echo "you will have to compile and install it first yourself.  A copy"
+    echo "of zlib-1.1.4.tar.gz is included with SimGear.  You will"
+    echo "have to untar this source code, and follow its included instructions"
+    echo "to compile and install on your system."
+    echo
+    echo "configure aborted."
+    echo
 fi
 
 dnl Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS( \
        fcntl.h getopt.h malloc.h memory.h stdint.h stdlib.h sys/param.h \
-       sys/stat.h sys/time.h sys/timeb.h unistd.h winbase.h values.h )
+       sys/stat.h sys/time.h sys/timeb.h unistd.h values.h )
 
 if test "x$ac_cv_header_stdint_h" = "xyes"; then
     AC_DEFINE([HAVE_STDINT_H], 1, [Define if stdint.h exists])
@@ -337,6 +406,7 @@ AC_CONFIG_FILES([ \
        src-libs/Makefile \
        simgear/Makefile \
        simgear/version.h \
+       simgear/compatibility/Makefile \
        simgear/bucket/Makefile \
        simgear/debug/Makefile \
        simgear/ephemeris/Makefile \
@@ -345,11 +415,17 @@ AC_CONFIG_FILES([ \
        simgear/math/Makefile \
        simgear/metar/Makefile \
        simgear/misc/Makefile \
+       simgear/props/Makefile \
        simgear/route/Makefile \
+       simgear/scene/Makefile \
+       simgear/scene/material/Makefile \
+       simgear/scene/model/Makefile \
+       simgear/scene/tgdb/Makefile \
        simgear/screen/Makefile \
        simgear/serial/Makefile \
        simgear/sky/Makefile \
        simgear/sky/clouds3d/Makefile \
+       simgear/sound/Makefile \
        simgear/threads/Makefile \
        simgear/timing/Makefile \
        simgear/xgl/Makefile \
@@ -370,7 +446,7 @@ else
     echo "Debug messages: yes"
 fi
 
-echo -n "Automake version: ($AUTO_MAKE_VERSION) "
+echo -n "Automake version: "
 automake --version | head -1
 
 if test "x$ac_cv_header_GL_glut_h" = "xyes"; then