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
50 Usage: ./configure [options]...
52 This script configures ${PROJECT} to build on your system.
54 It verifies that dependencies are available, determines flags needed
55 to compile and link against various required libraries, and identifies
56 whether various system functions can be used or if locally-provided
57 replacements will be built instead.
59 Finally, it allows you to control various aspects of the build and
62 First, some common variables can specified via environment variables:
64 CC The C compiler to use
65 CFLAGS Flags to pass to the C compiler
66 LDFLAGS Flags to pass when linking
68 Each of these values can further be controlled by specifying them
69 later on the "make" command line.
71 Additionally, various options can be specified on the configure
74 --prefix=PREFIX Install files in PREFIX [$PREFIX]
76 By default, "make install" will install the resulting program to
77 $PREFIX/bin, documentation to $PREFIX/man, etc. You can
78 specify an installation prefix other than $PREFIX using
79 --prefix, for instance:
81 ./configure --prefix=\$HOME
83 Fine tuning of some installation directories is available:
85 --libdir=DIR Install libraries to DIR [PREFIX/lib]
86 --includedir=DIR Install header files to DIR [PREFIX/include]
87 --mandir=DIR Install man pages to DIR [PREFIX/share/man]
88 --sysconfdir=DIR Read-only single-machine data [PREFIX/etc]
90 Additional options are accepted for compatibility with other
91 configure-script calling conventions, but don't do anything yet:
93 --build=<cpu>-<vendor>-<os> Currently ignored
94 --host=<cpu>-<vendor>-<os> Currently ignored
95 --infodir=DIR Currently ignored
96 --datadir=DIR Currently ignored
97 --localstatedir=DIR Currently ignored
98 --libexecdir=DIR Currently ignored
99 --disable-maintainer-mode Currently ignored
100 --disable-dependency-tracking Currently ignored
105 # Parse command-line options
107 if [ "${option}" = '--help' ] ; then
110 elif [ "${option%%=*}" = '--prefix' ] ; then
111 PREFIX="${option#*=}"
112 elif [ "${option%%=*}" = '--libdir' ] ; then
113 LIBDIR="${option#*=}"
114 elif [ "${option%%=*}" = '--includedir' ] ; then
115 INCLUDEDIR="${option#*=}"
116 elif [ "${option%%=*}" = '--mandir' ] ; then
117 MANDIR="${option#*=}"
118 elif [ "${option%%=*}" = '--sysconfdir' ] ; then
119 SYSCONFDIR="${option#*=}"
120 elif [ "${option%%=*}" = '--build' ] ; then
122 elif [ "${option%%=*}" = '--host' ] ; then
124 elif [ "${option%%=*}" = '--infodir' ] ; then
126 elif [ "${option%%=*}" = '--datadir' ] ; then
128 elif [ "${option%%=*}" = '--localstatedir' ] ; then
130 elif [ "${option%%=*}" = '--libexecdir' ] ; then
132 elif [ "${option}" = '--disable-maintainer-mode' ] ; then
134 elif [ "${option}" = '--disable-dependency-tracking' ] ; then
137 echo "Unrecognized option: ${option}"
145 # We set this value early, (rather than just while printing the
146 # Makefile.config file later like most values), because we need to
147 # actually investigate this value compared to the ldconfig_paths value
149 if [ -z "$LIBDIR" ] ; then
150 libdir_expanded="${PREFIX}/lib"
152 # very non-general variable expansion
153 libdir_expanded=`echo "$LIBDIR" | sed "s|\\${prefix}|${PREFIX}|g; s|\\$prefix/|${PREFIX}/|; s|//*|/|g"`
157 Welcome to ${PROJECT}, ${PROJECT_BLURB}
159 We hope that the process of building and installing ${PROJECT} is quick
162 If anything goes wrong in the configure process, you can override any
163 decisions it makes by manually editing the Makefile.config file that
164 it creates. Also please do as much as you can to figure out what could
165 be different on your machine compared to those of the ${PROJECT}
166 developers. Then, please email those details to the ${PROJECT} developers so
167 that they can hopefully make future versions of ${PROJECT} easier for you to
170 We'll now investigate your system to verify that all required
171 dependencies are available:
177 if pkg-config --version > /dev/null 2>&1; then
183 printf "Checking for talloc development files... "
184 if pkg-config --exists talloc; then
187 talloc_cflags=$(pkg-config --cflags talloc)
188 talloc_ldflags=$(pkg-config --libs talloc)
193 errors=$((errors + 1))
198 printf "Checking which platform we are on... "
200 if [ $uname = "Darwin" ] ; then
203 linker_resolves_library_dependencies=0
204 elif [ $uname = "SunOS" ] ; then
207 linker_resolves_library_dependencies=0
208 elif [ $uname = "FreeBSD" ] ; then
211 linker_resolves_library_dependencies=0
212 elif [ $uname = "OpenBSD" ] ; then
215 linker_resolves_library_dependencies=0
216 elif [ $uname = "Linux" ] || [ $uname = "GNU" ] ; then
219 linker_resolves_library_dependencies=1
221 printf "Checking for $libdir_expanded in ldconfig... "
222 ldconfig_paths=$(/sbin/ldconfig -N -X -v 2>/dev/null | sed -n -e 's,^\(/.*\):\( (.*)\)\?$,\1,p')
223 # Separate ldconfig_paths only on newline (not on any potential
224 # embedded space characters in any filenames). Note, we use a
225 # literal newline in the source here rather than something like:
229 # because the shell's command substitution deletes any trailing newlines.
232 for path in $ldconfig_paths; do
233 if [ "$path" = "$libdir_expanded" ]; then
238 if [ "$libdir_in_ldconfig" = '0' ]; then
239 printf "No (will set RPATH)\n"
247 *** Warning: Unknown platform. ${PROJECT} might or might not build correctly.
252 if [ $errors -gt 0 ]; then
255 *** Error: The dependencies of ${PROJECT} could not be satisfied. You will
256 need to install the following packages before being able to compile
260 if [ $have_talloc -eq 0 ]; then
261 echo " The talloc library (including development files such as headers)"
262 echo " http://talloc.samba.org/"
266 With any luck, you're using a modern, package-based operating system
267 that has all of these packages available in the distribution. In that
268 case a simple command will install everything you need. For example:
270 On Debian and similar systems:
272 sudo apt-get install libtalloc-dev
274 Or on Fedora and similar systems:
276 sudo yum install libtalloc-devel
278 On other systems, similar commands can be used, but the details of the
279 package names may be different.
282 if [ $have_pkg_config -eq 0 ]; then
284 Note: the pkg-config program is not available. This configure script
285 uses pkg-config to find the compilation flags required to link against
286 the various libraries needed by ${PROJECT}. It's possible you simply need
287 to install pkg-config with a command such as:
289 sudo apt-get install pkg-config
291 sudo yum install pkgconfig
293 But if pkg-config is not available for your system, then you will need
294 to modify the configure script to manually set the cflags and ldflags
295 variables to the correct values to link against each library in each
296 case that pkg-config could not be used to determine those values.
301 When you have installed the necessary dependencies, you can run
302 configure again to ensure the packages can be found, or simply run
309 printf "int main(void){return 0;}\n" > minimal.c
312 printf "Checking for available C compiler warning flags... "
313 for flag in -Wall -Wextra -Wmissing-declarations; do
314 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
316 WARN_CFLAGS="${WARN_CFLAGS}${WARN_CFLAGS:+ }${flag}"
319 printf "\n\t${WARN_CFLAGS}\n"
321 rm -f minimal minimal.c
325 All required packages were found. You may now run the following
326 commands to compile and install ${PROJECT}:
333 # construct the Makefile.config
334 cat > Makefile.config <<EOF
335 # This Makefile.config was automatically generated by the ./configure
336 # script of ${PROJECT}. If the configure script identified anything
337 # incorrectly, then you can edit this file to try to correct things,
338 # but be warned that if configure is run again it will destroy your
339 # changes, (and this could happen by simply calling "make" if the
340 # configure script is updated).
342 # The top-level directory for the source, (the directory containing
343 # the configure script). This may be different than the build
344 # directory (the current directory at the time configure was run).
347 configure_options = $@
349 # We use vpath directives (rather than the VPATH variable) since the
350 # VPATH variable matches targets as well as prerequisites, (which is
351 # not useful since then a target left-over from a srcdir build would
352 # cause a target to not be built in the non-srcdir build).
354 # Also, we don't use a single "vpath % \$(srcdir)" here because we
355 # don't want the vpath to trigger for our emacs lisp compilation,
356 # (unless we first find a way to convince emacs to build the .elc
357 # target in a directory other than the directory of the .el
358 # prerequisite). In the meantime, we're actually copying in the .el
359 # files, (which is quite ugly).
361 vpath %.cc \$(srcdir)
363 vpath Makefile.% \$(srcdir)
365 # The C compiler to use
368 # Default FLAGS for C compiler (can be overridden by user such as "make CFLAGS=-g")
371 # Default FLAGS for the linker (can be overridden by user such as "make LDFLAGS=-znow")
374 # Flags to enable warnings when using the C compiler
375 WARN_CFLAGS=${WARN_CFLAGS}
377 # The prefix to which ${PROJECT} should be installed
378 # Note: If you change this value here, be sure to ensure that the
379 # LIBDIR_IN_LDCONFIG value below is still set correctly.
382 # The directory to which libraries should be installed
383 # Note: If you change this value here, be sure to ensure that the
384 # LIBDIR_IN_LDCONFIG value below is still set correctly.
385 libdir = ${LIBDIR:=\$(prefix)/lib}
387 # Whether libdir is in a path configured into ldconfig
388 LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}
390 # The directory to which header files should be installed
391 includedir = ${INCLUDEDIR:=\$(prefix)/include}
393 # The directory to which man pages should be installed
394 mandir = ${MANDIR:=\$(prefix)/share/man}
396 # The directory to which read-only (configuration) files should be installed
397 sysconfdir = ${SYSCONFDIR:=\$(prefix)/etc}
399 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS, FREEBSD, OPENBSD
400 PLATFORM = ${platform}
402 # Whether the linker will automatically resolve the dependency of one
403 # library on another (if not, then linking a binary requires linking
404 # directly against both)
405 LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
407 # Flags needed to compile and link against talloc
408 TALLOC_CFLAGS = ${talloc_cflags}
409 TALLOC_LDFLAGS = ${talloc_ldflags}
411 # Flags needed to have linker link only to necessary libraries
412 AS_NEEDED_LDFLAGS = ${as_needed_ldflags}
414 # Combined flags for compiling and linking against all of the above
415 CONFIGURE_CFLAGS = \$(TALLOC_CFLAGS)
416 CONFIGURE_LDFLAGS = \$(TALLOC_LDFLAGS)