Skip to content

Instantly share code, notes, and snippets.

@linki
Created March 3, 2011 16:43
Show Gist options
  • Save linki/853064 to your computer and use it in GitHub Desktop.
Save linki/853064 to your computer and use it in GitHub Desktop.
diff --git a/Makefile.am b/Makefile.am
index 5efcea7..23f8311 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,8 @@ SUBDIRS = src unittest bin
EXTRA_DIST = README ChangeLog AUTHORS COPYING INSTALL NEWS sumo.doxyconf
+ACLOCAL_AMFLAGS = -I m4
+
doc:
tools/build/makeDoc.py -o docs/sumo-user.html -p docs/sumo-user.pdf
diff --git a/configure.ac b/configure.ac
index 5ae5aba..ef760a4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,6 +9,7 @@ AC_CONFIG_HEADER(src/config.h)
dnl enable automake-support
AM_INIT_AUTOMAKE([gnu dist-zip tar-ustar])
+AC_CONFIG_MACRO_DIR([m4])
dnl the debug check has to be made before the program checks
dnl because it modifies CXXFLAGS
@@ -33,7 +34,7 @@ AC_PROG_MAKE_SET
dnl enable libtool-support
dnl gives a deprecated warning for RANLIB with newer libtools
-AC_PROG_RANLIB
+AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL
@@ -336,8 +337,8 @@ dnl ... for includes
fi
AM_CONDITIONAL([WITH_GUI], [test x"$with_fox_includes" != x && test x"$with_fox_libraries" != x])
if test x"$with_fox_includes" != x && test x"$with_fox_libraries" != x; then
- AC_CHECK_HEADERS([GL/gl.h GL/glu.h],,
- [AC_MSG_ERROR([Fox was found but no GL includes. Please either disable Fox or install the GL headers.])])
+ AX_CHECK_GL
+ AX_CHECK_GLU
ac_enabled="$ac_enabled GUI"
else
ac_disabled="$ac_disabled GUI"
diff --git a/m4/ax_check_gl.m4 b/m4/ax_check_gl.m4
new file mode 100644
index 0000000..b557ea7
--- /dev/null
+++ b/m4/ax_check_gl.m4
@@ -0,0 +1,134 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ax_check_gl.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_GL
+#
+# DESCRIPTION
+#
+# Check for an OpenGL implementation. If GL is found, the required
+# compiler and linker flags are included in the output variables
+# "GL_CFLAGS" and "GL_LIBS", respectively. If no usable GL implementation
+# is found, "no_gl" is set to "yes".
+#
+# If the header "GL/gl.h" is found, "HAVE_GL_GL_H" is defined. If the
+# header "OpenGL/gl.h" is found, HAVE_OPENGL_GL_H is defined. These
+# preprocessor definitions may not be mutually exclusive.
+#
+# LICENSE
+#
+# Copyright (c) 2009 Braden McDaniel <[email protected]>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 8
+
+AC_DEFUN([AX_CHECK_GL],
+[AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([AC_PATH_X])dnl
+AC_REQUIRE([AX_PTHREAD])dnl
+
+AC_LANG_PUSH([C])
+AX_LANG_COMPILER_MS
+AS_IF([test X$ax_compiler_ms = Xno],
+ [GL_CFLAGS="${PTHREAD_CFLAGS}"; GL_LIBS="${PTHREAD_LIBS} -lm"])
+
+#
+# Use x_includes and x_libraries if they have been set (presumably by
+# AC_PATH_X).
+#
+AS_IF([test "X$no_x" != "Xyes"],
+ [AS_IF([test -n "$x_includes"],
+ [GL_CFLAGS="-I${x_includes} ${GL_CFLAGS}"])]
+ AS_IF([test -n "$x_libraries"],
+ [GL_LIBS="-L${x_libraries} -lX11 ${GL_LIBS}"]))
+
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+AC_CHECK_HEADERS([GL/gl.h OpenGL/gl.h])
+CPPFLAGS="${ax_save_CPPFLAGS}"
+
+AC_CHECK_HEADERS([windows.h])
+
+m4_define([AX_CHECK_GL_PROGRAM],
+ [AC_LANG_PROGRAM([[
+# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
+# include <windows.h>
+# endif
+# ifdef HAVE_GL_GL_H
+# include <GL/gl.h>
+# elif defined(HAVE_OPENGL_GL_H)
+# include <OpenGL/gl.h>
+# else
+# error no gl.h
+# endif]],
+ [[glBegin(0)]])])
+
+AC_CACHE_CHECK([for OpenGL library], [ax_cv_check_gl_libgl],
+[ax_cv_check_gl_libgl="no"
+case $host_cpu in
+ x86_64) ax_check_gl_libdir=lib64 ;;
+ *) ax_check_gl_libdir=lib ;;
+esac
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+ax_save_LIBS="${LIBS}"
+LIBS=""
+ax_check_libs="-lopengl32 -lGL"
+for ax_lib in ${ax_check_libs}; do
+ AS_IF([test X$ax_compiler_ms = Xyes],
+ [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
+ [ax_try_lib="${ax_lib}"])
+ LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
+AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
+ [ax_cv_check_gl_libgl="${ax_try_lib}"; break],
+ [ax_check_gl_nvidia_flags="-L/usr/${ax_check_gl_libdir}/nvidia" LIBS="${ax_try_lib} ${ax_check_gl_nvidia_flags} ${GL_LIBS} ${ax_save_LIBS}"
+AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
+ [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_nvidia_flags}"; break],
+ [ax_check_gl_dylib_flag='-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib' LIBS="${ax_try_lib} ${ax_check_gl_dylib_flag} ${GL_LIBS} ${ax_save_LIBS}"
+AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
+ [ax_cv_check_gl_libgl="${ax_try_lib} ${ax_check_gl_dylib_flag}"; break])])])
+done
+
+AS_IF([test "X$ax_cv_check_gl_libgl" = Xno -a "X$no_x" = Xyes],
+[LIBS='-framework OpenGL'
+AC_LINK_IFELSE([AX_CHECK_GL_PROGRAM],
+ [ax_cv_check_gl_libgl="$LIBS"])])
+
+LIBS=${ax_save_LIBS}
+CPPFLAGS=${ax_save_CPPFLAGS}])
+
+AS_IF([test "X$ax_cv_check_gl_libgl" = Xno],
+ [no_gl=yes; GL_CFLAGS=""; GL_LIBS=""],
+ [GL_LIBS="${ax_cv_check_gl_libgl} ${GL_LIBS}"])
+AC_LANG_POP([C])
+
+AC_SUBST([GL_CFLAGS])
+AC_SUBST([GL_LIBS])
+])dnl
diff --git a/m4/ax_check_glu.m4 b/m4/ax_check_glu.m4
new file mode 100644
index 0000000..30cae54
--- /dev/null
+++ b/m4/ax_check_glu.m4
@@ -0,0 +1,152 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ax_check_glu.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_GLU
+#
+# DESCRIPTION
+#
+# Check for GLU. If GLU is found, the required preprocessor and linker
+# flags are included in the output variables "GLU_CFLAGS" and "GLU_LIBS",
+# respectively. If no GLU implementation is found, "no_glu" is set to
+# "yes".
+#
+# If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined. If the
+# header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined. These
+# preprocessor definitions may not be mutually exclusive.
+#
+# Some implementations (in particular, some versions of Mac OS X) are
+# known to treat the GLU tesselator callback function type as "GLvoid
+# (*)(...)" rather than the standard "GLvoid (*)()". If the former
+# condition is detected, this macro defines "HAVE_VARARGS_GLU_TESSCB".
+#
+# LICENSE
+#
+# Copyright (c) 2009 Braden McDaniel <[email protected]>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 7
+
+AC_DEFUN([AX_CHECK_GLU],
+[AC_REQUIRE([AX_CHECK_GL])dnl
+AC_REQUIRE([AC_PROG_CXX])dnl
+GLU_CFLAGS="${GL_CFLAGS}"
+
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+AC_CHECK_HEADERS([GL/glu.h OpenGL/glu.h])
+CPPFLAGS="${ax_save_CPPFLAGS}"
+
+m4_define([AX_CHECK_GLU_PROGRAM],
+ [AC_LANG_PROGRAM([[
+# if defined(HAVE_WINDOWS_H) && defined(_WIN32)
+# include <windows.h>
+# endif
+# ifdef HAVE_GL_GLU_H
+# include <GL/glu.h>
+# elif defined(HAVE_OPENGL_GLU_H)
+# include <OpenGL/glu.h>
+# else
+# error no glu.h
+# endif]],
+ [[gluBeginCurve(0)]])])
+
+AC_CACHE_CHECK([for OpenGL Utility library], [ax_cv_check_glu_libglu],
+[ax_cv_check_glu_libglu="no"
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GL_CFLAGS} ${CPPFLAGS}"
+ax_save_LIBS="${LIBS}"
+
+#
+# First, check for the possibility that everything we need is already in
+# GL_LIBS.
+#
+LIBS="${GL_LIBS} ${ax_save_LIBS}"
+#
+# libGLU typically links with libstdc++ on POSIX platforms.
+# However, setting the language to C++ means that test program
+# source is named "conftest.cc"; and Microsoft cl doesn't know what
+# to do with such a file.
+#
+AC_LANG_PUSH([C++])
+AS_IF([test X$ax_compiler_ms = Xyes],
+ [AC_LANG_PUSH([C])])
+AC_LINK_IFELSE(
+[AX_CHECK_GLU_PROGRAM],
+[ax_cv_check_glu_libglu=yes],
+[LIBS=""
+ax_check_libs="-lglu32 -lGLU"
+for ax_lib in ${ax_check_libs}; do
+ AS_IF([test X$ax_compiler_ms = Xyes],
+ [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
+ [ax_try_lib="${ax_lib}"])
+ LIBS="${ax_try_lib} ${GL_LIBS} ${ax_save_LIBS}"
+ AC_LINK_IFELSE([AX_CHECK_GLU_PROGRAM],
+ [ax_cv_check_glu_libglu="${ax_try_lib}"; break])
+done
+])
+AS_IF([test X$ax_compiler_ms = Xyes],
+ [AC_LANG_POP([C])])
+AC_LANG_POP([C++])
+
+LIBS=${ax_save_LIBS}
+CPPFLAGS=${ax_save_CPPFLAGS}])
+AS_IF([test "X$ax_cv_check_glu_libglu" = Xno],
+ [no_glu=yes; GLU_CFLAGS=""; GLU_LIBS=""],
+ [AS_IF([test "X$ax_cv_check_glu_libglu" = Xyes],
+ [GLU_LIBS="$GL_LIBS"],
+ [GLU_LIBS="${ax_cv_check_glu_libglu} ${GL_LIBS}"])])
+AC_SUBST([GLU_CFLAGS])
+AC_SUBST([GLU_LIBS])
+
+#
+# Some versions of Mac OS X include a broken interpretation of the GLU
+# tesselation callback function signature.
+#
+AS_IF([test "X$ax_cv_check_glu_libglu" != Xno],
+[AC_CACHE_CHECK([for varargs GLU tesselator callback function type],
+ [ax_cv_varargs_glu_tesscb],
+[ax_cv_varargs_glu_tesscb=no
+ax_save_CFLAGS="$CFLAGS"
+CFLAGS="$GL_CFLAGS $CFLAGS"
+AC_COMPILE_IFELSE(
+[AC_LANG_PROGRAM([[
+# ifdef HAVE_GL_GLU_H
+# include <GL/glu.h>
+# else
+# include <OpenGL/glu.h>
+# endif]],
+ [[GLvoid (*func)(...); gluTessCallback(0, 0, func)]])],
+[ax_cv_varargs_glu_tesscb=yes])
+CFLAGS="$ax_save_CFLAGS"])
+AS_IF([test X$ax_cv_varargs_glu_tesscb = Xyes],
+ [AC_DEFINE([HAVE_VARARGS_GLU_TESSCB], [1],
+ [Use nonstandard varargs form for the GLU tesselator callback])])])
+])
diff --git a/m4/ax_check_glut.m4 b/m4/ax_check_glut.m4
new file mode 100644
index 0000000..7e3ab0a
--- /dev/null
+++ b/m4/ax_check_glut.m4
@@ -0,0 +1,115 @@
+# ===========================================================================
+# http://www.nongnu.org/autoconf-archive/ax_check_glut.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_GLUT
+#
+# DESCRIPTION
+#
+# Check for GLUT. If GLUT is found, the required compiler and linker flags
+# are included in the output variables "GLUT_CFLAGS" and "GLUT_LIBS",
+# respectively. If GLUT is not found, "no_glut" is set to "yes".
+#
+# If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined. If the
+# header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined. These
+# preprocessor definitions may not be mutually exclusive.
+#
+# LICENSE
+#
+# Copyright (c) 2009 Braden McDaniel <[email protected]>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 7
+
+AC_DEFUN([AX_CHECK_GLUT],
+[AC_REQUIRE([AX_CHECK_GLU])dnl
+AC_REQUIRE([AC_PATH_XTRA])dnl
+
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GLU_CFLAGS} ${CPPFLAGS}"
+AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h])
+CPPFLAGS="${ax_save_CPPFLAGS}"
+
+GLUT_CFLAGS=${GLU_CFLAGS}
+GLUT_LIBS=${GLU_LIBS}
+
+m4_define([AX_CHECK_GLUT_PROGRAM],
+ [AC_LANG_PROGRAM([[
+# if HAVE_WINDOWS_H && defined(_WIN32)
+# include <windows.h>
+# endif
+# ifdef HAVE_GL_GLUT_H
+# include <GL/glut.h>
+# elif defined(HAVE_GLUT_GLUT_H)
+# include <GLUT/glut.h>
+# else
+# error no glut.h
+# endif]],
+ [[glutMainLoop()]])])
+
+#
+# If X is present, assume GLUT depends on it.
+#
+AS_IF([test X$no_x != Xyes],
+ [GLUT_LIBS="${X_PRE_LIBS} -lXmu -lXi ${X_EXTRA_LIBS} ${GLUT_LIBS}"])
+
+AC_CACHE_CHECK([for GLUT library], [ax_cv_check_glut_libglut],
+[ax_cv_check_glut_libglut="no"
+AC_LANG_PUSH(C)
+ax_save_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="${GLUT_CFLAGS} ${CPPFLAGS}"
+ax_save_LIBS="${LIBS}"
+LIBS=""
+ax_check_libs="-lglut32 -lglut"
+for ax_lib in ${ax_check_libs}; do
+ AS_IF([test X$ax_compiler_ms = Xyes],
+ [ax_try_lib=`echo $ax_lib | sed -e 's/^-l//' -e 's/$/.lib/'`],
+ [ax_try_lib="${ax_lib}"])
+ LIBS="${ax_try_lib} ${GLUT_LIBS} ${ax_save_LIBS}"
+ AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
+ [ax_cv_check_glut_libglut="${ax_try_lib}"; break])
+done
+
+AS_IF([test "X$ax_cv_check_glut_libglut" = Xno -a "X$no_x" = Xyes],
+[LIBS='-framework GLUT'
+AC_LINK_IFELSE([AX_CHECK_GLUT_PROGRAM],
+ [ax_cv_check_glut_libglut="$LIBS"])])
+
+CPPFLAGS="${ax_save_CPPFLAGS}"
+LIBS="${ax_save_LIBS}"
+AC_LANG_POP(C)])
+
+AS_IF([test "X$ax_cv_check_glut_libglut" = Xno],
+ [no_glut="yes"; GLUT_CFLAGS=""; GLUT_LIBS=""],
+ [GLUT_LIBS="${ax_cv_check_glut_libglut} ${GLUT_LIBS}"])
+
+AC_SUBST([GLUT_CFLAGS])
+AC_SUBST([GLUT_LIBS])
+])dnl
diff --git a/m4/ax_lang_compiler_ms.m4 b/m4/ax_lang_compiler_ms.m4
new file mode 100644
index 0000000..1c85d77
--- /dev/null
+++ b/m4/ax_lang_compiler_ms.m4
@@ -0,0 +1,41 @@
+# -*- mode: autoconf -*-
+#
+# Check whether the compiler for the current language is Microsoft.
+#
+# This macro is modeled after _AC_LANG_COMPILER_GNU in the GNU Autoconf
+# implementation.
+#
+# version: 1.0
+# author: Braden McDaniel <[email protected]>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception, the you may copy, distribute and modify the
+# configure scripts that are the output of Autoconf when processing
+# the Macro. You need not follow the terms of the GNU General Public
+# License when using or distributing such scripts.
+#
+AC_DEFUN([AX_LANG_COMPILER_MS],
+[AC_CACHE_CHECK([whether we are using the Microsoft _AC_LANG compiler],
+ [ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms],
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef _MSC_VER
+ choke me
+#endif
+]])],
+ [ax_compiler_ms=yes],
+ [ax_compiler_ms=no])
+ax_cv_[]_AC_LANG_ABBREV[]_compiler_ms=$ax_compiler_ms
+])])
diff --git a/m4/pkg.m4 b/m4/pkg.m4
new file mode 100644
index 0000000..9bb3e06
--- /dev/null
+++ b/m4/pkg.m4
@@ -0,0 +1,157 @@
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+# serial 1 (pkg-config-0.24)
+#
+# Copyright © 2004 Scott James Remnant <[email protected]>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG=""
+ fi
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists. Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+# only at the first occurence in configure.ac, so if the first place
+# it's called might be skipped (such as if it is within an "if", you
+# have to call PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+ m4_default([$2], [:])
+m4_ifvaln([$3], [else
+ $3])dnl
+fi])
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+ pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+ PKG_CHECK_EXISTS([$3],
+ [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+ [pkg_failed=yes])
+ else
+ pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+ AC_MSG_RESULT([no])
+ _PKG_SHORT_ERRORS_SUPPORTED
+ if test $_pkg_short_errors_supported = yes; then
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$2" 2>&1`
+ else
+ $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$2" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+ m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])dnl
+ ])
+elif test $pkg_failed = untried; then
+ AC_MSG_RESULT([no])
+ m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old. Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])dnl
+ ])
+else
+ $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+ $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+ AC_MSG_RESULT([yes])
+ $3
+fi[]dnl
+])# PKG_CHECK_MODULES
diff --git a/src/Makefile.am b/src/Makefile.am
index 36c4877..cb44e95 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -80,7 +80,7 @@ $(PROJ_LIBS)
if WITH_GUI
sumo_gui_SOURCES = guisim_main.cpp
-sumo_gui_LDFLAGS = $(FOX_LDFLAGS) $(sumo_LDFLAGS) $(X_LDFLAGS)
+sumo_gui_LDFLAGS = $(FOX_LDFLAGS) $(sumo_LDFLAGS) $(X_LDFLAGS) $(GL_LIBS) $(GLU_LIBS)
sumo_gui_LDADD = ./gui/libgui.a \
./guinetload/libguinetload.a \
diff --git a/src/foreign/polyfonts/pfPSansBold16.c b/src/foreign/polyfonts/pfPSansBold16.c
index 1ae6b44..91b4d85 100644
--- a/src/foreign/polyfonts/pfPSansBold16.c
+++ b/src/foreign/polyfonts/pfPSansBold16.c
@@ -30,7 +30,11 @@ before using this file.
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
/* =========================================================================
* compiler pragmas
diff --git a/src/foreign/polyfonts/polyfonts.c b/src/foreign/polyfonts/polyfonts.c
index b24a4c7..3693217 100644
--- a/src/foreign/polyfonts/polyfonts.c
+++ b/src/foreign/polyfonts/polyfonts.c
@@ -45,7 +45,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
//#include "SDL.h"
//#include "sgl.h"
diff --git a/src/foreign/rtree/SUMORTree.h b/src/foreign/rtree/SUMORTree.h
index ce07a23..9315642 100644
--- a/src/foreign/rtree/SUMORTree.h
+++ b/src/foreign/rtree/SUMORTree.h
@@ -33,7 +33,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <utils/gui/globjects/GUIGlObject.h>
#include <utils/gui/settings/GUIVisualizationSettings.h>
diff --git a/src/gui/GUITLLogicPhasesTrackerWindow.cpp b/src/gui/GUITLLogicPhasesTrackerWindow.cpp
index a2e3aa3..4116070 100644
--- a/src/gui/GUITLLogicPhasesTrackerWindow.cpp
+++ b/src/gui/GUITLLogicPhasesTrackerWindow.cpp
@@ -45,7 +45,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#ifdef CHECK_MEMORY_LEAKS
#include <foreign/nvwa/debug_new.h>
diff --git a/src/gui/GUIViewTraffic.cpp b/src/gui/GUIViewTraffic.cpp
index ce1fc5e..35dbbed 100644
--- a/src/gui/GUIViewTraffic.cpp
+++ b/src/gui/GUIViewTraffic.cpp
@@ -63,8 +63,13 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
#include <GL/gl.h>
#include <GL/glu.h>
+#endif
#ifdef CHECK_MEMORY_LEAKS
#include <foreign/nvwa/debug_new.h>
diff --git a/src/gui/GUIViewTraffic.h b/src/gui/GUIViewTraffic.h
index b2d4331..68d3fc3 100644
--- a/src/gui/GUIViewTraffic.h
+++ b/src/gui/GUIViewTraffic.h
@@ -41,7 +41,12 @@
#ifdef _WIN32
#include <windows.h>
#endif
+
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// ===========================================================================
diff --git a/src/gui/dialogs/GUIDialog_GLObjChooser.cpp b/src/gui/dialogs/GUIDialog_GLObjChooser.cpp
index 3d31c64..88e5894 100644
--- a/src/gui/dialogs/GUIDialog_GLObjChooser.cpp
+++ b/src/gui/dialogs/GUIDialog_GLObjChooser.cpp
@@ -51,7 +51,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#ifdef CHECK_MEMORY_LEAKS
#include <foreign/nvwa/debug_new.h>
diff --git a/src/guisim/GUIBusStop.cpp b/src/guisim/GUIBusStop.cpp
index a13fa8f..b5ca59c 100644
--- a/src/guisim/GUIBusStop.cpp
+++ b/src/guisim/GUIBusStop.cpp
@@ -31,7 +31,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <string>
#include <utils/common/MsgHandler.h>
diff --git a/src/guisim/GUIE3Collector.cpp b/src/guisim/GUIE3Collector.cpp
index 98fc0c3..d7c7b3a 100644
--- a/src/guisim/GUIE3Collector.cpp
+++ b/src/guisim/GUIE3Collector.cpp
@@ -38,7 +38,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#ifdef CHECK_MEMORY_LEAKS
#include <foreign/nvwa/debug_new.h>
diff --git a/src/guisim/GUIEdge.h b/src/guisim/GUIEdge.h
index e71bbc1..dcf880e 100644
--- a/src/guisim/GUIEdge.h
+++ b/src/guisim/GUIEdge.h
@@ -43,7 +43,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// ===========================================================================
diff --git a/src/guisim/GUIEmitter.cpp b/src/guisim/GUIEmitter.cpp
index c2ff130..f744214 100644
--- a/src/guisim/GUIEmitter.cpp
+++ b/src/guisim/GUIEmitter.cpp
@@ -29,7 +29,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <string>
#include <utils/common/MsgHandler.h>
diff --git a/src/guisim/GUIInductLoop.cpp b/src/guisim/GUIInductLoop.cpp
index 3be608e..bafc1e8 100644
--- a/src/guisim/GUIInductLoop.cpp
+++ b/src/guisim/GUIInductLoop.cpp
@@ -42,7 +42,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#ifdef CHECK_MEMORY_LEAKS
#include <foreign/nvwa/debug_new.h>
diff --git a/src/guisim/GUILaneSpeedTrigger.cpp b/src/guisim/GUILaneSpeedTrigger.cpp
index e09e5ed..2f3d824 100644
--- a/src/guisim/GUILaneSpeedTrigger.cpp
+++ b/src/guisim/GUILaneSpeedTrigger.cpp
@@ -29,7 +29,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <string>
#include <utils/common/MsgHandler.h>
diff --git a/src/guisim/GUINet.h b/src/guisim/GUINet.h
index f7b6f16..10dc25a 100644
--- a/src/guisim/GUINet.h
+++ b/src/guisim/GUINet.h
@@ -45,7 +45,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// ===========================================================================
diff --git a/src/guisim/GUITriggeredRerouter.cpp b/src/guisim/GUITriggeredRerouter.cpp
index cfa0986..733a328 100644
--- a/src/guisim/GUITriggeredRerouter.cpp
+++ b/src/guisim/GUITriggeredRerouter.cpp
@@ -31,7 +31,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <string>
#include <utils/common/MsgHandler.h>
diff --git a/src/guisim/GUIVehicle.h b/src/guisim/GUIVehicle.h
index 457e3da..271b142 100644
--- a/src/guisim/GUIVehicle.h
+++ b/src/guisim/GUIVehicle.h
@@ -33,7 +33,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include <vector>
#include <set>
diff --git a/src/guisim/GUIVehicleControl.h b/src/guisim/GUIVehicleControl.h
index 2089f76..63265d8 100644
--- a/src/guisim/GUIVehicleControl.h
+++ b/src/guisim/GUIVehicleControl.h
@@ -36,7 +36,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
diff --git a/src/guisim/GUI_E2_ZS_Collector.cpp b/src/guisim/GUI_E2_ZS_Collector.cpp
index 9b1e579..2ee6503 100644
--- a/src/guisim/GUI_E2_ZS_Collector.cpp
+++ b/src/guisim/GUI_E2_ZS_Collector.cpp
@@ -41,7 +41,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#ifdef CHECK_MEMORY_LEAKS
#include <foreign/nvwa/debug_new.h>
diff --git a/src/utils/gui/div/GLHelper.cpp b/src/utils/gui/div/GLHelper.cpp
index c108293..e942544 100644
--- a/src/utils/gui/div/GLHelper.cpp
+++ b/src/utils/gui/div/GLHelper.cpp
@@ -31,7 +31,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#include "GLHelper.h"
#include <utils/geom/GeomHelper.h>
diff --git a/src/utils/gui/div/GUIDialog_GLChosenEditor.cpp b/src/utils/gui/div/GUIDialog_GLChosenEditor.cpp
index 11e0576..97c62f8 100644
--- a/src/utils/gui/div/GUIDialog_GLChosenEditor.cpp
+++ b/src/utils/gui/div/GUIDialog_GLChosenEditor.cpp
@@ -46,7 +46,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#ifdef CHECK_MEMORY_LEAKS
#include <foreign/nvwa/debug_new.h>
diff --git a/src/utils/gui/div/GUISelectedStorage.h b/src/utils/gui/div/GUISelectedStorage.h
index 819f5e5..1fb1777 100644
--- a/src/utils/gui/div/GUISelectedStorage.h
+++ b/src/utils/gui/div/GUISelectedStorage.h
@@ -39,7 +39,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// ===========================================================================
diff --git a/src/utils/gui/globjects/GUIGlObject.h b/src/utils/gui/globjects/GUIGlObject.h
index bed26e0..ef19209 100644
--- a/src/utils/gui/globjects/GUIGlObject.h
+++ b/src/utils/gui/globjects/GUIGlObject.h
@@ -39,7 +39,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// ===========================================================================
diff --git a/src/utils/gui/globjects/GUIGlObjectStorage.h b/src/utils/gui/globjects/GUIGlObjectStorage.h
index 7aa0874..df2292e 100644
--- a/src/utils/gui/globjects/GUIGlObjectStorage.h
+++ b/src/utils/gui/globjects/GUIGlObjectStorage.h
@@ -37,7 +37,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// ===========================================================================
diff --git a/src/utils/gui/globjects/GUIPolygon2D.cpp b/src/utils/gui/globjects/GUIPolygon2D.cpp
index c5d01a1..c5796c7 100644
--- a/src/utils/gui/globjects/GUIPolygon2D.cpp
+++ b/src/utils/gui/globjects/GUIPolygon2D.cpp
@@ -41,10 +41,17 @@
#ifdef WIN32
#include <windows.h>
+#else
+#define APIENTRY
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
#include <GL/gl.h>
#include <GL/glu.h>
+#endif
// ===========================================================================
diff --git a/src/utils/gui/images/GUITexturesHelper.cpp b/src/utils/gui/images/GUITexturesHelper.cpp
index 71bc018..faaf4a4 100644
--- a/src/utils/gui/images/GUITexturesHelper.cpp
+++ b/src/utils/gui/images/GUITexturesHelper.cpp
@@ -37,7 +37,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#ifdef CHECK_MEMORY_LEAKS
#include <foreign/nvwa/debug_new.h>
diff --git a/src/utils/gui/images/GUITexturesHelper.h b/src/utils/gui/images/GUITexturesHelper.h
index 61daf77..10df770 100644
--- a/src/utils/gui/images/GUITexturesHelper.h
+++ b/src/utils/gui/images/GUITexturesHelper.h
@@ -35,7 +35,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// ===========================================================================
diff --git a/src/utils/gui/settings/GUIColorer.h b/src/utils/gui/settings/GUIColorer.h
index f15aadf..8e6b718 100644
--- a/src/utils/gui/settings/GUIColorer.h
+++ b/src/utils/gui/settings/GUIColorer.h
@@ -37,7 +37,12 @@
#ifdef _WIN32
#include <windows.h>
#endif
+
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
// ===========================================================================
diff --git a/src/utils/gui/tracker/GUIParameterTracker.cpp b/src/utils/gui/tracker/GUIParameterTracker.cpp
index 9f72348..8f28074 100644
--- a/src/utils/gui/tracker/GUIParameterTracker.cpp
+++ b/src/utils/gui/tracker/GUIParameterTracker.cpp
@@ -47,7 +47,11 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#else
#include <GL/gl.h>
+#endif
#ifdef CHECK_MEMORY_LEAKS
#include <foreign/nvwa/debug_new.h>
diff --git a/src/utils/gui/windows/GUISUMOAbstractView.cpp b/src/utils/gui/windows/GUISUMOAbstractView.cpp
index 97bf522..5b95c92 100644
--- a/src/utils/gui/windows/GUISUMOAbstractView.cpp
+++ b/src/utils/gui/windows/GUISUMOAbstractView.cpp
@@ -70,8 +70,14 @@
#include <windows.h>
#endif
+#ifdef __APPLE__
+#include <OpenGL/gl.h>
+#include <OpenGL/glu.h>
+#else
#include <GL/gl.h>
#include <GL/glu.h>
+#endif
+
#include <utils/foxtools/FXSingleEventThread.h>
#ifdef CHECK_MEMORY_LEAKS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment