]> Dogcows Code - chaz/yoink/blobdiff - configure
build system enhancements
[chaz/yoink] / configure
index 06a303d39c002ec9a9432ca170dd8178f0be31f7..09df45fdf580bdfd3bfddbca3e903027fe9e7db3 100755 (executable)
--- a/configure
+++ b/configure
 # Execute this file to configure the build system.
 #
 
-PACKAGE="Yoink"
-VERSION="0.1"
-BUGREPORT="chaz@dogcows.com"
-
-
-showhelp()
-{
-       cat <<"END"
-
-This script prepares Yoink for building on your system.
-Usage: ./configure [OPTION]... [VAR=VALUE]...
-
-Basic configuration:
-  -h, --help              display this help and exit
-      --host=HOST         cross-compile program to run on HOST
-
-      --prefix=DIR        base directory to install program
-      --bindir=DIR        directory to install executables
-      --libdir=DIR        directory to install libraries
-      --datadir=DIR       directory to install shared data files
-      --mandir=DIR        directory to install manual pages
-
-Program options:
-      --enable-debug      include debugging symbols and code paths
-      --enable-double-precision   use doubles instead of floats
-      --enable-profile    compile in gprof profiling instructions
-      --enable-extra-warnings     make the gcc compiler give more warnings
-      --enable-link-sh    try to decrease the number of direct dependencies
-      --enable-clock_gettime      use clock_gettime() instead of SDL
-      --enable-threads    use threads for concurrency where appropriate
-      --enable-hotloading monitor assets and reload them when they change
-
-      --with-gtk          use gtk2 modal dialogs
-      --with-qt4          use qt4 modal dialogs; overridden by --with-gtk
-
-END
-}
-
-. "build/functions.sh"
-
-
-#
-# Perform a quick sanity check.
-#
-
-test -f configure -a -f Makefile || die <<"END"
-You must `cd' to the project root directory where the Makefile resides.
-END
-
-
-#
-# Define some default values.
-#
-
-CC=""
-CXX=""
-AR=""
-RANLIB=""
-
-CFLAGS="-g -O2"
-CXXFLAGS="$CFLAGS"
-LDFLAGS=""
-LIBS=""
-
-prefix='/usr/local'
-bindir='$prefix/bin'
-libdir='$prefix/lib'
-datadir='$prefix/share/yoink'
-mandir='$prefix/share/man'
-
-host=$(./build/config.guess)
-althost=$(./build/config.sub $host)
-cross_compile="no"
-
-
-#
-# Parse the command-line options.
-#
-
-for opt in "$@"
-do
-       case $opt in
-               -h|--help)
-                       showhelp
-                       exit 0
-                       ;;
-
-               --host=*)
-                       host=$(parse_argument host $opt)
-                       cross_compile="yes"
-                       ;;
-               --prefix=*)
-                       prefix=$(parse_argument prefix $opt)
-                       ;;
-               --bindir=*)
-                       bindir=$(parse_argument bindir $opt)
-                       ;;
-               --libdir=*)
-                       libdir=$(parse_argument libdir $opt)
-                       ;;
-               --datadir=*)
-                       datadir=$(parse_argument datadir $opt)
-                       ;;
-               --mandir=*)
-                       mandir=$(parse_argument mandir $opt)
-                       ;;
-
-               --enable-debug)
-                       cflags="$cflags -O0 -Wall -Wno-uninitialized"
-                       define "DEBUG"
-                       ;;
-               --enable-double-precision)
-                       define "USE_DOUBLE_PRECISION"
-                       ;;
-               --enable-profile)
-                       cflags="$cflags -pg"
-                       define "PROFILING_ENABLED"
-                       ;;
-               --enable-extra-warnings)
-                       cflags="$cflags -Wextra -Wno-unused-parameter"
-                       ;;
-               --enable-link-sh)
-                       link_sh=yes
-                       ;;
-               --enable-clock_gettime)
-                       clock_gettime=yes
-                       ;;
-               --enable-threads)
-                       define "USE_THREADS"
-                       ;;
-               --enable-hotloading)
-                       define "USE_HOTLOADING"
-                       ;;
-               --with-gtk)
-                       gtk=yes
-                       ;;
-               --with-qt4)
-                       qt4=yes
-                       ;;
-               *)
-                       if echo "$opt" | grep -q '^[A-Za-z0-9_]*=.*'
-                       then
-                               export "$opt"
-                       else
-                               echo "warning: unknown option: $opt"
-                       fi
-                       ;;
-       esac
-done
-
-
-#
-# Evaluate any dependent paths.
-#
-
-eval bindir="$bindir"
-eval datadir="$datadir"
-eval libdir="$libdir"
-eval mandir="$mandir"
-
-is_defined "DEBUG" || define "NDEBUG"
-
-export PKG_CONFIG_PATH="$libdir/pkgconfig:$PKG_CONFIG_PATH"
-
-define_string "YOINK_DATADIR" "$datadir"
-
-
-#
-# Determine the target platform.
-#
-
-case $host in
-       *mingw32*) HOST=win32  ;;
-       *netbsd*)  HOST=netbsd ;;
-esac
-
-
-#
-# Define the check functions.
-#
-
-# Run a command and return its exit code.  If the third argument is given,
-# stdin will be read and written to the specified file before the command
-# is executed.  If the command creates any files inside the current
-# directory, they will be removed automatically.
-# $1 The command to run.
-# $2 The arguments to be passed to the command.
-# $3 Optional filename where stdin will be written.
-check_run_command()
-{
-       tmpdir=$(mktemp -d "tmp-XXXXXXXX") || die "could not create temp directory"
-       cd $tmpdir || die "could not enter temp directory"
-
-       if test "x$3" != x
-       then
-               while read line
-               do
-                       echo $line
-               done >$3
-       fi
-
-       saved_ifs=$IFS
-       IFS=:
-       for path in $PATH
-       do
-               if test -x "$path/$1"
-               then
-                       eval "$1 $2" 2>&1 >/dev/null
-                       exit_code=$?
-
-                       cd ..
-                       rm -rf $tmpdir
-                       IFS=$saved_ifs
-                       return $exit_code
-               fi
-       done
-
-       cd ..
-       rm -rf $tmpdir
-       IFS=$saved_ifs
-       return 1
+die () {
+       while read line; do echo $line; done && exit ${1:-127}
 }
 
-
-#
-# Do some common checks.
-#
-
-if test "x$cross_compile" = xno
-then
-       # If we are not cross-compiling, we also want to consider tools without
-       # host prefixes.
-       extra_cc="gcc cc"
-       extra_cxx="g++ c++"
-       extra_ar="ar"
-       extra_ranlib="ranlib"
-       extra_windres="windres"
-fi
-
-for exe in $CC $host-gcc $host-cc $althost-gcc $althost-cc $extra_cc
-do
-       if check_run_command "$exe" "test.c" "test.c" <<"END"
-#include <stdio.h>
-int main()
-{
-       printf("Hello world!\n");
-       return 0;
-}
-END
-       then
-               CC="$exe"
-               break
-       fi
-done
-
-for exe in $CXX $host-g++ $host-c++ $althost-g++ $althost-c++ $extra_cxx
-do
-       if check_run_command "$exe" "test.cpp" "test.cpp" <<"END"
-#include <iostream>
-int main()
-{
-       std::cout << "Hello world!" << std::endl;
-       return 0;
-}
+[ -f build/config.lua ] || die 1 <<"END"
+You must first `cd' to the project directory root where the Makefile is.
+There is no support for out-of-tree builds.
 END
-       then
-               CXX="$exe"
-               break
-       fi
-done
-
-for exe in $AR $host-ar $althost-ar $extra_ar
-do
-       if check_run_command "$exe" "--version"
-       then
-               AR="$exe"
-               break
-       fi
-done
-
-for exe in $RANLIB $host-ranlib $althost-ranlib $extra_ranlib
-do
-       if check_run_command "$exe" "--version"
-       then
-               RANLIB="$exe"
-               break
-       fi
-done
 
-if test x$HOST = xwin32
-then
-       for exe in $WINDRES $host-windres $althost-windres $extra_windres
-       do
-               if check_run_command "$exe" "--version"
-               then
-                       WINDRES="$exe"
-                       break
-               fi
-       done
-fi
-
-if test "x$CC" = x -o "x$CXX" = x -o "x$AR" = x -o "x$RANLIB" = x
-then
-       die <<END
-A working version of one or more of these required tools is missing:
-  CC      = $CC
-  CXX     = $CXX
-  AR      = $AR
-  RANLIB  = $RANLIB
+LUA=${LUA:-lua}
+"$LUA" -v >/dev/null 2>&1 || die 2 <<END
+Can't find a Lua interpreter in your PATH.  Make sure Lua is installed, or
+set the LUA variable in the environment to the path of lua.
 END
-fi
-
-
-#
-# Check for the libraries we need.
-#
-
-deps="sdl gl glu libpng openal vorbisfile lua"
-
-if test x$gtk = xyes
-then
-       deps="$deps gtk+-2.0"
-elif test x$qt4 = xyes
-then
-       deps="$deps QtGui"
-fi
-
-pc_cflags=$(pkg-config --cflags $deps)
-CFLAGS="$CFLAGS $pc_cflags"
-CXXFLAGS="$CXXFLAGS $pc_cflags"
-
-pc_ldflags=$(pkg-config --libs-only-L $deps)
-LDFLAGS="$LDFLAGS $pc_ldflags"
-
-pc_libs=$(pkg-config --libs-only-l $deps)
-LIBS="$LIBS $pc_libs"
-
-# Windows sockets are in libws2_32.
-if test x$HOST = xwin32
-then
-       LIBS="$LIBS -lws2_32"
-       EXEEXT=".exe"
-fi
-
-
-#
-# Find the game resources to install.
-#
-
-#data_files=$(echo $(find . -name "*.lua" \
-                                               #-o -name "*.ogg" \
-                                               #-o -name "*.png" \
-                                               #-o -name "yoinkrc"))
-# FIXME: doesn't work yet
-
-
-#
-# Define version components needed by src/yoink.rc.
-#
-
-vmajor=$(echo $VERSION | cut -d. -f1)
-vminor=$(echo $VERSION | cut -d. -f2)
-vrevis=$(echo $VERSION | cut -d. -f3)
-
-define "VERSION_MAJOR"    "${vmajor:-0}"
-define "VERSION_MINOR"    "${vminor:-0}"
-define "VERSION_REVISION" "${vrevis:-0}"
-
-
-#
-# Determine and define the git revision.
-#
-
-if githead=$(git log -n1 --date=short --pretty=format:"%h (%ad)")
-then
-       define_string "YOINK_GITHEAD" "$githead"
-fi
-
-
-#
-# Finalize the compiler flags, linker flags, and library list.
-#
-
-define_string "PACKAGE"           "$PACKAGE"
-define_string "PACKAGE_NAME"      "$PACKAGE"
-define_string "VERSION"           "$VERSION"
-define_string "PACKAGE_VERSION"   "$VERSION"
-define_string "PACKAGE_STRING"    "$PACKAGE $VERSION"
-define_string "PACKAGE_BUGREPORT" "$BUGREPORT"
-
-CFLAGS=$(echo $CFLAGS $cflags $defines)
-CXXFLAGS=$(echo $CXXFLAGS $cflags $defines)
-LDFLAGS=$(echo $LDFLAGS)
-LIBS=$(echo $LIBS)
-
-
-#
-# All done; output the configuration file.
-#
-
-cat >config.mk <<END
-
-HOST       = $HOST
-
-CC         = $CC
-CXX        = $CXX
-AR         = $AR
-RANLIB     = $RANLIB
-WINDRES    = $WINDRES
-
-CFLAGS     = $CFLAGS
-CXXFLAGS   = $CXXFLAGS
-LDFLAGS    = $LDFLAGS
-LIBS       = $LIBS
-
-prefix     = $prefix
-bindir     = $bindir
-datadir    = $datadir
-libdir     = $libdir
-mandir     = $mandir
-
-EXEEXT     = $EXEEXT
 
+unset MAKEFLAGS
+echo "$@" | grep -w -e --interactive >/dev/null && \
+       ! (cd build && ${MAKE:-make} dialog) && die 3 <<END
+The dialog module cannot be built and so the configure script cannot be
+used interactively.  Run the configure script non-interactively.
 END
 
+export PATH="./build:$PATH"
+exec "$LUA" build/config.lua "$@" -L./build
 
-echo ""
-echo " Configuration complete!  Review your configuration in \`config.mk'":
-echo ""
-cat config.mk | grep -e "^prefix" \
-                                        -e "^datadir" \
-                                        -e "^CXX"  \
-                                        -e "^CXXFLAGS" \
-                                        -e "^LDFLAGS" \
-                                        -e "^LIBS"
-echo ""
-echo " To finish the installation, type:"
-echo "  make"
-echo "  make install"
-echo ""
+# vi:ts=4
 
This page took 0.029892 seconds and 4 git commands to generate.