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