configure.ac revision e7980a23
1# Copyright © 2011 Intel Corporation
2#
3# Permission is hereby granted, free of charge, to any person obtaining a
4# copy of this software and associated documentation files (the "Software"),
5# to deal in the Software without restriction, including without limitation
6# the rights to use, copy, modify, merge, publish, distribute, sublicense,
7# and/or sell copies of the Software, and to permit persons to whom the
8# Software is furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice (including the next
11# paragraph) shall be included in all copies or substantial portions of the
12# Software.
13#
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20# IN THE SOFTWARE.
21
22AC_PREREQ([2.60])
23AC_INIT([glu],
24        [9.0.2],
25        [https://gitlab.freedesktop.org/mesa/glu/issues])
26AC_CONFIG_SRCDIR([Makefile.am])
27AC_CANONICAL_HOST
28
29AM_INIT_AUTOMAKE([dist-xz foreign subdir-objects])
30
31LT_PREREQ([2.2])
32LT_INIT
33
34dnl Check for progs
35AC_PROG_CPP
36AC_PROG_CC
37AC_PROG_CXX
38
39dnl Enable quiet compiles on automake 1.11.
40m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
41
42AC_ARG_ENABLE(debug,
43              AS_HELP_STRING([--enable-debug],
44                [Enable debugging information]),
45              [if test x$enableval = xyes; then
46               CFLAGS="$CFLAGS -g -O0 -DDEBUG"
47               CXXFLAGS="$CXXFLAGS -g -O0 -DDEBUG"; else
48               CFLAGS="$CFLAGS -DNDEBUG"
49               CXXFLAGS="$CXXFLAGS -DNDEBUG"; fi],
50              [CFLAGS="$CFLAGS -DNDEBUG"
51               CXXFLAGS="$CXXFLAGS -DNDEBUG"])
52
53dnl Make sure the pkg-config macros are defined
54m4_ifndef([PKG_PROG_PKG_CONFIG],
55    [m4_fatal([Could not locate the pkg-config autoconf macros.
56  These are usually located in /usr/share/aclocal/pkg.m4. If your macros
57  are in a different location, try setting the environment variable
58  ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])])
59PKG_PROG_PKG_CONFIG()
60
61AC_ARG_ENABLE(libglvnd,
62              AS_HELP_STRING([--enable-libglvnd],
63                [Enable use of libglvnd]),
64              [LIBGLVND="$enableval"],
65              [LIBGLVND=no])
66
67AC_ARG_ENABLE(osmesa,
68              AS_HELP_STRING([--enable-osmesa],
69                [Enable use of OSMesa instead of libGL]),
70              [OSMESA="$enableval"],
71              [OSMESA=no])
72
73dnl Get the pkg-config definitions for libglvnd/OSMesa/libGL.  We include a
74dnl fallback path for implementations that don't provide a .pc file
75AS_IF([test "x$LIBGLVND" = "xyes"], [
76    GLU_REQUIRES="libglvnd"
77    PKG_CHECK_MODULES(LIBGLVND, [opengl], [], [
78        AC_CHECK_HEADER([GL/gl.h],
79                        [],
80                        AC_MSG_ERROR([libglvnd GL not found]))
81        AC_CHECK_LIB([OpenGL],
82                     [glBegin],
83                     [GL_LIBS=-lOpenGL],
84                     AC_MSG_ERROR([libglvnd libOpenGL required]))
85    ])
86], [test "x$OSMESA" = "xyes"], [
87    GLU_REQUIRES="osmesa"
88    PKG_CHECK_MODULES(OSMESA, [osmesa], [], [
89        AC_CHECK_LIB([OSMesa],
90                     [glBegin],
91                     [OSMESA_LIBS=-lOSMesa],
92                     AC_MSG_ERROR([OSMesa required]))
93    ])
94], [
95    GLU_REQUIRES="gl"
96    PKG_CHECK_MODULES(GL, [gl], [], [
97        AC_CHECK_HEADER([GL/gl.h],
98                        [],
99                        AC_MSG_ERROR([GL not found]))
100        AC_CHECK_LIB([GL],
101                     [glBegin],
102                     [GL_LIBS=-lGL],
103                     AC_MSG_ERROR([GL required]))
104    ])
105])
106
107AC_SUBST([GLU_REQUIRES])
108
109dnl Set up C warning and visibility flags.
110if test "x$GCC" = xyes; then
111    WARNCFLAGS="-Wall"
112
113    # Enable -fvisibility=hidden if using a gcc that supports it
114    save_CFLAGS="$CFLAGS"
115    AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
116    VISIBILITY_CFLAGS="-fvisibility=hidden"
117    CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
118    AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
119                   [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
120
121    # Restore CFLAGS; VISIBILITY_CFLAGS are added to it where needed.
122    CFLAGS=$save_CFLAGS
123
124    if test "x$GXX" = xyes; then
125        WARNCXXFLAGS="-Wall"
126
127        # Enable -fvisibility=hidden if using a gcc that supports it
128        save_CXXFLAGS="$CXXFLAGS"
129        AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
130        VISIBILITY_CXXFLAGS="-fvisibility=hidden"
131        CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
132        AC_LANG_PUSH([C++])
133        AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
134                       [VISIBILITY_CXXFLAGS=""; AC_MSG_RESULT([no])]);
135        AC_LANG_POP([C++])
136
137        # Restore CXXFLAGS; VISIBILITY_CXXFLAGS are added to it where needed.
138        CXXFLAGS=$save_CXXFLAGS
139    fi
140else
141    AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
142    if test "x$SUNCC" = "xyes"; then
143        WARNCFLAGS="-v"
144        WARNCXXFLAGS="-v"
145    fi
146fi
147AC_SUBST([WARNCFLAGS])
148AC_SUBST([WARNCXXFLAGS])
149AC_SUBST([VISIBILITY_CFLAGS])
150AC_SUBST([VISIBILITY_CXXFLAGS])
151
152AC_OUTPUT([
153    Makefile
154    glu.pc
155])
156