4 PROJECT_BLURB="a program for monitoring performance of OpenGL applications"
6 # Test whether this shell is capable of parameter substring processing.
7 ( option='a/b'; : ${option#*/} ) 2>/dev/null || {
9 The shell interpreting '$0' is lacking some required features.
11 To work around this problem you may try to execute:
20 # Store original IFS value so it can be changed (and restored) in many places.
21 readonly DEFAULT_IFS="$IFS"
23 srcdir=$(dirname "$0")
25 # For a non-srcdir configure invocation (such as ../configure), create
26 # the directory structure and copy Makefiles.
27 if [ "$srcdir" != "." ]; then
29 for dir in . $(grep "^subdirs *=" "$srcdir"/Makefile | sed -e "s/subdirs *= *//"); do
31 cp "$srcdir"/"$dir"/Makefile.local "$dir"
32 cp "$srcdir"/"$dir"/Makefile "$dir"
36 # Set several defaults (optionally specified by the user in
37 # environment variables)
42 # Set the defaults for values the user can specify with command-line
49 Usage: ./configure [options]...
51 This script configures ${PROJECT} to build on your system.
53 It verifies that dependencies are available, determines flags needed
54 to compile and link against various required libraries, and identifies
55 whether various system functions can be used or if locally-provided
56 replacements will be built instead.
58 Finally, it allows you to control various aspects of the build and
61 First, some common variables can specified via environment variables:
63 CC The C compiler to use
64 CFLAGS Flags to pass to the C compiler
65 LDFLAGS Flags to pass when linking
67 Each of these values can further be controlled by specifying them
68 later on the "make" command line.
70 Additionally, various options can be specified on the configure
73 --prefix=PREFIX Install files in PREFIX [$PREFIX]
75 By default, "make install" will install the resulting program to
76 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
77 specify an installation prefix other than $PREFIX using
78 --prefix, for instance:
80 ./configure --prefix=\$HOME
82 Fine tuning of some installation directories is available:
84 --bindir=DIR Install executables to DIR [PREFIX/bin]
85 --libdir=DIR Install libraries to DIR [PREFIX/lib]
86 --mandir=DIR Install man pages to DIR [PREFIX/share/man]
87 --sysconfdir=DIR Read-only single-machine data [PREFIX/etc]
89 Additional options are accepted for compatibility with other
90 configure-script calling conventions, but don't do anything yet:
92 --build=<cpu>-<vendor>-<os> Currently ignored
93 --host=<cpu>-<vendor>-<os> Currently ignored
94 --infodir=DIR Currently ignored
95 --datadir=DIR Currently ignored
96 --localstatedir=DIR Currently ignored
97 --libexecdir=DIR Currently ignored
98 --disable-maintainer-mode Currently ignored
99 --disable-dependency-tracking Currently ignored
104 # Given two absolute paths ("from" and "to"), compute a relative path
105 # from "from" to "to". For example:
107 # relative_path /foo/bar/baz /foo/qux -> ../../qux
110 if [ $# -ne 2 ] ; then
111 echo "Internal error: relative_path requires exactly 2 arguments"
118 # Handle trivial case up-front
119 if [ "$from" = "$to" ] ; then
125 while [ "${to#$shared}" = "$to" ] && [ "$shared" != "." ] ; do
126 shared="$(dirname $shared)"
127 relative="..${relative:+/${relative}}"
130 echo "${relative:-.}${to#$shared}"
134 # Parse command-line options
136 if [ "${option}" = '--help' ] ; then
139 elif [ "${option%%=*}" = '--prefix' ] ; then
140 PREFIX="${option#*=}"
141 elif [ "${option%%=*}" = '--bindir' ] ; then
142 BINDIR="${option#*=}"
143 elif [ "${option%%=*}" = '--libdir' ] ; then
144 LIBDIR="${option#*=}"
145 elif [ "${option%%=*}" = '--mandir' ] ; then
146 MANDIR="${option#*=}"
147 elif [ "${option%%=*}" = '--sysconfdir' ] ; then
148 SYSCONFDIR="${option#*=}"
149 elif [ "${option%%=*}" = '--build' ] ; then
151 elif [ "${option%%=*}" = '--host' ] ; then
153 elif [ "${option%%=*}" = '--infodir' ] ; then
155 elif [ "${option%%=*}" = '--datadir' ] ; then
157 elif [ "${option%%=*}" = '--localstatedir' ] ; then
159 elif [ "${option%%=*}" = '--libexecdir' ] ; then
161 elif [ "${option}" = '--disable-maintainer-mode' ] ; then
163 elif [ "${option}" = '--disable-dependency-tracking' ] ; then
166 echo "Unrecognized option: ${option}"
175 Welcome to ${PROJECT}, ${PROJECT_BLURB}
177 We hope that the process of building and installing ${PROJECT} is quick
180 If anything goes wrong in the configure process, you can override any
181 decisions it makes by manually editing the Makefile.config file that
182 it creates. Also please do as much as you can to figure out what could
183 be different on your machine compared to those of the ${PROJECT}
184 developers. Then, please email those details to the ${PROJECT} developers so
185 that they can hopefully make future versions of ${PROJECT} easier for you to
188 We'll now investigate your system to verify that all required
189 dependencies are available:
195 printf "Checking for pkg-config... "
196 if pkg-config --version > /dev/null 2>&1; then
202 *** Error: This configure script requires pkg-config to find the
203 compilation flags required to link against the various libraries
204 needed by ${PROJECT}. The pkg-config program can be obtained from:
206 http://www.freedesktop.org/wiki/Software/pkg-config/
208 Or you may be able install it with a command such as:
210 sudo apt-get install pkg-config
212 sudo yum install pkgconfig
220 printf "Checking for working C compiler (${CC})... "
221 printf "int main(void){return 42;}\n" > minimal.c
222 if ${CC} -o minimal minimal.c > /dev/null 2>&1
229 *** Error: No functioning C compiler found. Either set the CC environment
230 to a working C compiler, or else install gcc:
234 You may be able to install gcc with a command such as:
236 sudo apt-get install build-essential
238 sudo yum install make automake gcc gcc-c++ kernel-devel
246 printf "Checking for libtalloc... "
247 if pkg-config --exists talloc; then
250 talloc_cflags=$(pkg-config --cflags talloc)
251 talloc_ldflags=$(pkg-config --libs talloc)
256 errors=$((errors + 1))
259 printf "Checking for libelf... "
260 printf "#include <gelf.h>\nint main(void){return elf_version (EV_CURRENT);}\n" > elf-minimal.c
261 if ${CC} -o elf-minimal elf-minimal.c -lelf > /dev/null 2>&1
272 errors=$((errors + 1))
274 rm -f elf-minimal elf-minimal.c
276 printf "Checking for GL/gl.h... "
278 if pkg-config --exists gl; then
281 gl_cflags=$(pkg-config --cflags gl)
282 gl_ldflags=$(pkg-config --libs gl)
284 printf "#include <GL/gl.h>\nint main(void){return 0;}\n" > gl-minimal.c
285 if ${CC} -o gl-minimal gl-minimal.c > /dev/null 2>&1
291 errors=$((errors + 1))
293 rm -f gl-minimal gl-minimal.c
296 printf "Checking for GL window-system-binding headers:\n"
299 printf " Checking for GL/glx.h... "
301 printf "#include <GL/glx.h>\nint main(void){return 0;}\n" > glx-minimal.c
302 if ${CC} -o glx-minimal glx-minimal.c ${gl_cflags} > /dev/null 2>&1
310 rm -f glx-minimal glx-minimal.c
312 printf " Checking for X11... "
314 if pkg-config --exists x11; then
317 x11_cflags=$(pkg-config --cflags x11)
318 x11_ldflags=$(pkg-config --libs x11)
323 printf " Checking for EGL/egl.h... "
325 if pkg-config --exists egl; then
328 egl_cflags=$(pkg-config --cflags egl)
329 egl_ldflags=$(pkg-config --libs egl)
331 printf "#include <EGL/egl.h>\nint main(void){return 0;}\n" > egl-minimal.c
332 if ${CC} -o egl-minimal egl-minimal.c ${gl_cflags} > /dev/null 2>&1
340 rm -f egl-minimal egl-minimal.c
343 if [ $have_gl_winsys -eq 0 ]; then
344 errors=$((errors + 1))
347 printf "int main(void){return 0;}\n" > minimal.c
350 printf "Checking for available C compiler warning flags:\n"
351 for flag in -Wall -Wextra -Wmissing-declarations; do
352 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
354 WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
357 printf "\t${WARN_CFLAGS}\n"
359 rm -f minimal minimal.c
361 printf "#include <features.h>\nint main(void){return 0;}\n" > arch-minimal.c
363 printf "Checking for machine-dependent compiler support:\n"
365 printf " Compiler can create 32-bit binaries... "
367 if ${CC} -m32 -o arch-minimal arch-minimal.c > /dev/null 2>&1
375 printf " Compiler can create 64-bit binaries... "
377 if ${CC} -m64 -o arch-minimal arch-minimal.c > /dev/null 2>&1
385 if [ "$have_m32" = "No" ] || [ "$have_m64" = "No" ]; then
388 * Warning: Cannot create both 32 and 64-bit fips libraries. Fips will not
389 support applications of the non-native size. Fixing this may be
390 as simple as running a command such as:
392 sudo apt-get install gcc-multilib
396 rm -f arch-minimal arch-minimal.c
398 if [ $errors -gt 0 ]; then
401 *** Error: The dependencies of ${PROJECT} could not be satisfied. You will
402 need to install the following packages before being able to compile
406 if [ $have_talloc -eq 0 ]; then
407 echo " The talloc library (including development files such as headers)"
408 echo " http://talloc.samba.org/"
411 if [ $have_libelf -eq 0 ]; then
412 echo " The libelf library (including development files such as headers)"
413 echo " http://http://sourceforge.net/projects/elftoolchain/"
416 if [ $have_gl -eq 0 ]; then
417 echo " Open GL header files (GL/gl.h)"
418 echo " http://www.mesa3d.org/"
421 if [ $have_gl_winsys -eq 0 ]; then
422 echo " OpenGL window-system-bindings header files (GL/glx.h and/or GL/egl.h)"
423 echo " http://www.mesa3d.org/"
427 With any luck, you're using a modern, package-based operating system
428 that has all of these packages available in the distribution. In that
429 case a simple command will install everything you need. For example:
431 On Debian and similar systems:
433 sudo apt-get install libtalloc-dev libelf-dev \\
434 libgl1-mesa-dev libgles2-mesa-dev
436 Or on Fedora and similar systems:
438 sudo yum install libtalloc-devel libelf-devel \\
439 mesa-libGL-devel mesa-libGLES-devel
441 On other systems, similar commands can be used, but the details of the
442 package names may be different.
444 When you have installed the necessary dependencies, you can run
445 configure again to ensure the packages can be found, or simply run
454 All required packages were found.
456 The following OpenGL window-system bindings will be supported:
461 You may now run the following commands to compile and install ${PROJECT}:
468 # construct the Makefile.config
469 cat > Makefile.config <<EOF
470 # This Makefile.config was automatically generated by the ./configure
471 # script of ${PROJECT}. If the configure script identified anything
472 # incorrectly, then you can edit this file to try to correct things,
473 # but be warned that if configure is run again it will destroy your
474 # changes, (and this could happen by simply calling "make" if the
475 # configure script is updated).
477 # The top-level directory for the source, (the directory containing
478 # the configure script). This may be different than the build
479 # directory (the current directory at the time configure was run).
482 configure_options = $@
484 # We use vpath directives (rather than the VPATH variable) since the
485 # VPATH variable matches targets as well as prerequisites, (which is
486 # not useful since then a target left-over from a srcdir build would
487 # cause a target to not be built in the non-srcdir build).
489 # Also, we don't use a single "vpath % \$(srcdir)" here because we
490 # don't want the vpath to trigger for our emacs lisp compilation,
491 # (unless we first find a way to convince emacs to build the .elc
492 # target in a directory other than the directory of the .el
493 # prerequisite). In the meantime, we're actually copying in the .el
494 # files, (which is quite ugly).
496 vpath %.cc \$(srcdir)
498 vpath Makefile.% \$(srcdir)
500 # The C compiler to use
503 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
506 # Default FLAGS for the linker (can be overridden by user such as "make LDFLAGS=-znow")
509 # Flags to enable warnings when using the C compiler
510 WARN_CFLAGS=${WARN_CFLAGS}
512 # The prefix to which ${PROJECT} should be installed
515 # The directory to which executables should be installed
516 bindir = ${BINDIR:=\$(prefix)/bin}
518 # The directory to which libraries should be installed
519 libdir = ${LIBDIR:=\$(prefix)/lib}
521 # The directory to which man pages should be installed
522 mandir = ${MANDIR:=\$(prefix)/share/man}
524 # The directory to which read-only (configuration) files should be installed
525 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
527 # Whether compiler can create 32 or 64-bit binaries
528 COMPILER_SUPPORTS_32 = ${have_m32}
529 COMPILER_SUPPORTS_64 = ${have_m64}
531 # Flags needed to compile and link against talloc
532 TALLOC_CFLAGS = ${talloc_cflags}
533 TALLOC_LDFLAGS = ${talloc_ldflags}
535 # Flags needed to compile and link against libelf
536 LIBELF_CFLAGS = ${libelf_cflags}
537 LIBELF_LDFLAGS = ${libelf_ldflags}
539 # Whether GLX headers are available
540 HAVE_GLX = ${have_glx}
542 # Flags needed to compile and link against libGL
543 GL_CFLAGS = ${gl_cflags}
544 GL_LDFLAGS = ${gl_ldflags}
546 # Wheter X11 headers and library are available
547 HAVE_X11 = ${have_x11}
549 # Flags needs to compile and link against libX11
550 X11_CLFLAGS = ${x11_cflags}
551 X11_LDFLAGS = ${x11_ldflags}
553 # Whether EGL headers are available
554 HAVE_EGL = ${have_egl}
556 # Flags needed to find EGL header files (EGL/egl.h)
557 EGL_CFLAGS = ${egl_cflags}
558 EGL_LDFLAGS = ${egl_ldflags}
560 # Flags needed to have linker link only to necessary libraries
561 AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
566 /* Generated by configure. */
568 /* Relative path from ${bindir} to ${libdir} */
569 #define BINDIR_TO_LIBFIPSDIR "$(relative_path ${BINDIR} ${LIBDIR})/fips"