summaryrefslogtreecommitdiff
path: root/src/configure
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-10-02 00:00:32 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-10-02 00:00:32 +0000
commit621c7f4acf2ce36db5dcae2de1d013f7de2f2cf8 (patch)
treed51cc5299a535929923fb45edd88ac5731b7e66e /src/configure
parentadded initial svn dirs (diff)
inital checkin (base daemon should be running)
git-svn-id: https://svn.spreadspace.org/gcsd/trunk@2 ac14a137-c7f1-4531-abe0-07747231d213
Diffstat (limited to 'src/configure')
-rwxr-xr-xsrc/configure294
1 files changed, 294 insertions, 0 deletions
diff --git a/src/configure b/src/configure
new file mode 100755
index 0000000..58926b0
--- /dev/null
+++ b/src/configure
@@ -0,0 +1,294 @@
+#!/bin/sh
+#
+# gcsd
+#
+# gcsd the generic command sequencer daemon can be used to serialize
+# commands sent over various paralell communication channels to a
+# single command output. It can be seen as a multiplexer for any
+# kind of communication between a single resource and various clients
+# which want to submit commands to it or query information from it.
+# gcsd is written in C and Lua. The goal is to provide an easy to
+# understand high level API based on Lua which can be used to
+# implement the business logic of the so formed multiplexer daemon.
+#
+#
+# Copyright (C) 2009-2010 Markus Grueneis <gimpf@spreadspace.org>
+# Christian Pointner <equinox@spreadspace.org>
+#
+# This file is part of gcsd.
+#
+# gcsd is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# any later version.
+#
+# gcsd is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with gcsd. If not, see <http://www.gnu.org/licenses/>.
+#
+
+TARGET=`uname -s`
+EBUILD_COMPAT=0
+
+CFLAGS='-g -O2'
+LDFLAGS='-g -Wall -O2 -lm'
+
+LUA_DIR=''
+LUA=''
+LUAC=''
+
+PREFIX='/usr/local'
+SBINDIR=''
+ETCDIR=''
+MANDIR=''
+INSTALLMANPAGE=1
+EXAMPLESDIR=''
+INSTALLEXAMPLES=1
+
+print_usage() {
+ echo "configure --help print this"
+ echo " --target=<TARGET> build target i.e. Linux (default: autodetect)"
+ echo " --prefix=<PREFIX> the installation prefix (default: /usr/local)"
+ echo " --sbindir=<DIR> the path to the sbin directory (default: $PREFIX/sbin)"
+ echo " --sysconfdir=<DIR> the path to the system configuration directory (default: $PREFIX/etc"
+ echo " --mandir=<DIR> the path to the system man pages (default: $PREFIX/share/man)"
+ echo " --no-manpage dont't install manpage"
+ echo " --examplesdir=<DIR> the path to the examples files (default: $PREFIX/share/examples)"
+ echo " --no-examples dont't install example files"
+ echo " --with-lua=<DIR> use this lua tree instead of system default"
+}
+
+for arg
+do
+ case $arg in
+ --target=*)
+ TARGET=${arg#--target=}
+ ;;
+ --prefix=*)
+ PREFIX=${arg#--prefix=}
+ ;;
+ --sbindir=*)
+ SBINDIR=${arg#--sbindir=}
+ ;;
+ --sysconfdir=*)
+ ETCDIR=${arg#--sysconfdir=}
+ ;;
+ --mandir=*)
+ MANDIR=${arg#--mandir=}
+ ;;
+ --no-manpage)
+ INSTALLMANPAGE=0
+ ;;
+ --examplesdir=*)
+ EXAMPLESDIR=${arg#--examplesdir=}
+ ;;
+ --no-examples)
+ INSTALLEXAMPLES=0
+ ;;
+ --with-lua=*)
+ LUA_DIR=${arg#--with-lua=}
+ ;;
+ --ebuild-compat)
+ EBUILD_COMPAT=1
+ ;;
+ --help)
+ print_usage
+ exit 0
+ ;;
+ *)
+ ERRORS="$ERRORS $arg"
+ ;;
+ esac
+done
+
+if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then
+ for error in $ERRORS; do
+ echo "Unknown argument: $error"
+ done
+
+ print_usage
+ exit 1
+fi
+
+rm -f version.h
+rm -f include.mk
+case $TARGET in
+ Linux)
+ LDFLAGS=$LDFLAGS' -ldl'
+ ;;
+ OpenBSD|FreeBSD|NetBSD|GNU/kFreeBSD)
+ CFLAGS=$CFLAGS' -I/usr/local/include'
+ LDFLAGS=$LDFLAGS' -L/usr/local/lib'
+ ;;
+ MINGW*)
+ CFLAGS=$CFLAGS' -DWINVER=0x501 -D_WIN32_WINNT -D_WIN32'
+ LDFLAGS=$LDFLAGS' -lwsock32'
+ TARGET=mingw
+ if [ -z "$LUA_DIR" ]; then
+ echo "No Lua tree specified, use --with-lua"
+ exit 1
+ fi
+ echo "WARNING: don't use install target on this platform"
+ ;;
+ *)
+ echo "platform not supported"
+ exit 1;
+ ;;
+esac
+
+
+test_lua_version()
+{
+ LUA_VERSION=`cat $1 | grep "#define LUA_VERSION[ ]" | cut -f2- | tr -d '"' | sed -e 's/Lua \([0-9][0-9.]*\)/\1/'`
+ LUA_VERSION_NUM=`cat $1 | grep "#define LUA_VERSION_NUM" | awk '{ print $3 }'`
+ LUA_RELEASE=`cat $1 | grep "#define LUA_RELEASE[ ]" | cut -f2-`
+
+ if [ $LUA_VERSION_NUM -ge 501 ]; then
+ return 1;
+ else
+ return 0;
+ fi
+}
+
+if [ -z "$LUA_DIR" ]; then
+ for prefix in /usr /usr/local; do
+ if [ -e $prefix/include/lua.h ]; then
+ test_lua_version $prefix/include/lua.h
+ if [ $? -eq 1 ]; then
+ echo "using Lua $LUA_VERSION ($LUA_RELEASE) found at $prefix/include"
+ CFLAGS="$CFLAGS -I'$prefix/include'"
+ LDFLAGS="$LDFLAGS -L'$prefix/lib' -llua"
+ LUA=$prefix/lua
+ LUAC=$prefix/luac
+ break
+ fi
+ else
+ for dir in `ls -d $prefix/include/lua* 2> /dev/null`; do
+ if [ -e $dir/lua.h ]; then
+ test_lua_version $dir/lua.h
+ if [ $? -eq 1 ]; then
+ echo "using Lua $LUA_VERSION ($LUA_RELEASE) found at $dir"
+ CFLAGS="$CFLAGS -I$dir"
+ if [ -x "$prefix/bin/lua$LUA_VERSION" ]; then
+ LDFLAGS="$LDFLAGS -L'$prefix/lib' -llua$LUA_VERSION"
+ LUA=$prefix/bin/lua$LUA_VERSION
+ LUAC=$prefix/bin/luac$LUA_VERSION
+ elif [ -x "$prefix/bin/lua-$LUA_VERSION" ]; then
+ LDFLAGS="$LDFLAGS -L'$prefix/lib' -llua-$LUA_VERSION"
+ LUA=$prefix/bin/lua-$LUA_VERSION
+ LUAC=$prefix/bin/luac-$LUA_VERSION
+ else
+ echo "ERROR: found lua.h at $dir/lua.h but no matching lua and luac"
+ return 1
+ fi
+ break
+ fi
+ fi
+ done
+ if [ -n "$LUAC" ]; then
+ break
+ fi
+ fi
+ done
+
+ if [ -z "$LUAC" ]; then
+ echo "ERROR: no suitable lua found .. please install lua 5.1 or higher or use --with-lua"
+ return 1
+ fi
+
+else
+ CFLAGS="$CFLAGS -I'$LUA_DIR/include'"
+ LDFLAGS="$LDFLAGS '$LUA_DIR/lib/liblua.a'"
+ LUA=$LUA_DIR/bin/lua
+ LUAC=$LUA_DIR/bin/luac
+fi
+
+if [ -z "$SBINDIR" ]; then
+ SBINDIR=$PREFIX/sbin
+fi
+
+if [ -z "$ETCDIR" ]; then
+ ETCDIR=$PREFIX/etc
+fi
+
+if [ -z "$MANDIR" ]; then
+ MANDIR=$PREFIX/share/man
+fi
+
+if [ -z "$EXAMPLESDIR" ]; then
+ EXAMPLESDIR=$PREFIX/share/examples
+fi
+
+cat >> include.mk <<EOF
+# this file was created automatically
+# do not edit this file directly
+# use ./configure instead
+
+TARGET := '$TARGET'
+CC := gcc
+CFLAGS := $CFLAGS
+LDFLAGS := $LDFLAGS
+LUA := '$LUA'
+LUAC := '$LUAC'
+STRIP := strip
+INSTALL := install
+
+PREFIX := '$PREFIX'
+SBINDIR := '$SBINDIR'
+ETCDIR := '$ETCDIR'
+EOF
+
+if [ "$TARGET" != "mingw" ]; then
+ if [ $INSTALLMANPAGE -eq 1 ]; then
+ echo "MANDIR := '$MANDIR'" >> include.mk
+ echo "installing manpage"
+ else
+ echo "not installing manpage"
+ fi
+
+ if [ $INSTALLEXAMPLES -eq 1 ]; then
+ echo "EXAMPLESDIR := '$EXAMPLESDIR'" >> include.mk
+ echo "installing example files"
+ else
+ echo "not installing example files"
+ fi
+
+ VERSION=`cat ../version`
+ if which svn >/dev/null; then
+ SVN_REV=`svn info 2> /dev/null | grep "^Revision: " | awk '{print($2)}'`
+ if [ -n "$SVN_REV" ]; then
+ VERSION="$VERSION (svn$SVN_REV)"
+ fi
+ fi
+
+else
+ VERSION=`cat ../version`
+fi
+
+HOSTNAME=`hostname`
+DATE=`date +"%d.%m.%Y %H:%M:%S %Z"`
+
+cat >> version.h <<EOF
+/*
+ * gcsd version info
+ *
+ * this file was created automatically
+ * do not edit this file directly
+ * use ./configure instead
+ */
+
+#ifndef GCSD_version_h_INCLUDED
+#define GCSD_version_h_INCLUDED
+
+#define VERSION_STRING_0 "gcsd version $VERSION"
+#define VERSION_STRING_1 "built on $HOSTNAME, $DATE"
+
+#endif
+
+EOF
+
+exit 0