From b21fd748dc0c8208138cc7d8439bd3b80efc7ade Mon Sep 17 00:00:00 2001
From: "Diogo F. S. Ramos" <diogofsr@gmail.com>
Date: Mon, 29 Jul 2013 04:14:53 -0300
Subject: [PATCH] Fix compilation

* Delete `bootstrap.sh'

There is no need to maintain a separate file to call automake,
autoconf and friends as autoreconf does the job.

For this particular case, `autoreconf -i' will call everything that is
needed, in the correct order.

* Specify guile's version to 1.8

Without specifying guile's version, systems with guile-2.0 installed
will have this version of guile used and the compilation will fail.

* Fix compilation outside the root directory

It's possible now to compile the project outside the root directory.

* Remove warning errors

Some deprecation warnings make the project fail to build.  Remove
`-Werror' to make the project compile.

A ISO C warning makes the project fail to build.  Remove
`-pedantic-errors' to make the project compile.
---
 bootstrap.sh    | 135 --------------------------------------------------------
 configure.ac    |  16 +++----
 src/Makefile.am |  23 +++++-----
 3 files changed, 20 insertions(+), 154 deletions(-)
 delete mode 100755 bootstrap.sh

diff --git a/bootstrap.sh b/bootstrap.sh
deleted file mode 100755
index 19433f7..0000000
--- a/bootstrap.sh
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/bin/sh
-# Run this to generate all the initial makefiles, etc.
-
-DIE=0
-SRCDIR=`dirname $0`
-BUILDDIR=`pwd`
-srcfile=src/main.c
-
-debug ()
-# print out a debug message if DEBUG is a defined variable
-{
-  if [ ! -z "$DEBUG" ]; then
-    echo "DEBUG: $1"
-  fi
-}
-
-version_check ()
-# check the version of a package
-# first argument : complain ('1') or not ('0')
-# second argument : package name (executable)
-# third argument : source download url
-# rest of arguments : major, minor, micro version
-{
-  COMPLAIN=$1
-  PACKAGE=$2
-  URL=$3
-  MAJOR=$4
-  MINOR=$5
-  MICRO=$6
-
-  WRONG=
-
-  debug "major $MAJOR minor $MINOR micro $MICRO"
-  VERSION=$MAJOR
-  if [ ! -z "$MINOR" ]; then VERSION=$VERSION.$MINOR; else MINOR=0; fi
-  if [ ! -z "$MICRO" ]; then VERSION=$VERSION.$MICRO; else MICRO=0; fi
-
-  debug "version $VERSION"
-  echo "+ checking for $PACKAGE >= $VERSION ... " | tr -d '\n'
-
-  ($PACKAGE --version) < /dev/null > /dev/null 2>&1 ||
-  {
-    echo
-    echo "You must have $PACKAGE installed to compile $package."
-    echo "Download the appropriate package for your distribution,"
-    echo "or get the source tarball at $URL"
-    return 1
-  }
-  # the following line is carefully crafted sed magic
-  pkg_version=`$PACKAGE --version|head -n 1|sed 's/([^)]*)//g;s/^[a-zA-Z\.\ \-\/]*//;s/ .*$//'`
-  debug "pkg_version $pkg_version"
-  pkg_major=`echo $pkg_version | cut -d. -f1`
-  pkg_minor=`echo $pkg_version | sed s/[-,a-z,A-Z].*// | cut -d. -f2`
-  pkg_micro=`echo $pkg_version | sed s/[-,a-z,A-Z].*// | cut -d. -f3`
-  [ -z "$pkg_minor" ] && pkg_minor=0
-  [ -z "$pkg_micro" ] && pkg_micro=0
-
-  debug "found major $pkg_major minor $pkg_minor micro $pkg_micro"
-
-  #start checking the version
-  if [ "$pkg_major" -lt "$MAJOR" ]; then
-    WRONG=1
-  elif [ "$pkg_major" -eq "$MAJOR" ]; then
-    if [ "$pkg_minor" -lt "$MINOR" ]; then
-      WRONG=1
-    elif [ "$pkg_minor" -eq "$MINOR" -a "$pkg_micro" -lt "$MICRO" ]; then
-      WRONG=1
-    fi
-  fi
-
-  if [ ! -z "$WRONG" ]; then
-   echo "found $pkg_version, not ok !"
-   if [ "$COMPLAIN" -eq "1" ]; then
-     echo
-     echo "You must have $PACKAGE $VERSION or greater to compile $package."
-     echo "Get the latest version from <$URL>."
-     echo
-   fi
-   return 1
-  else
-    echo "found $pkg_version, ok."
-  fi
-}
-
-version_check 1 "pkg-config" "http://pkgconfig.freedesktop.org/" 0 9 || DIE=1
-version_check 1 "autoconf" "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 56 || DIE=1
-version_check 1 "automake" "ftp://ftp.gnu.org/pub/gnu/automake/" 1 9 || DIE=1
-if [ "$DIE" -eq 1 ]; then
-  exit 1
-fi
-
-
-# Chdir to the srcdir, then run auto* tools.
-cd $SRCDIR
-
-[ -f $srcfile ] || {
-  echo "Are you sure $SRCDIR is a valid source directory?"
-  exit 1
-}
-
-echo "+ running aclocal ..."
-aclocal || {
-  echo
-  echo "aclocal failed - check that all needed development files are present on system"
-  exit 1
-}
-echo "+ running autoheader ... "
-autoheader || {
-  echo
-  echo "autoheader failed"
-  exit 1
-}
-echo "+ running autoconf ... "
-autoconf || {
-  echo
-  echo "autoconf failed"
-  exit 1
-}
-echo "+ running automake ... "
-automake -a -c || {
-  echo
-  echo "automake failed"
-  exit 1
-}
-
-
-# Chdir back to the builddir before the configure step.
-cd $BUILDDIR
-
-# now remove the cache, because it can be considered dangerous in this case
-echo "+ Tidying up"
-rm -rf config.cache config.h.in~ autom4te.cache
-
-exit 0
-
diff --git a/configure.ac b/configure.ac
index 12cfeba..65e2880 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,15 +19,15 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_INIT([GNU Robots], [1.2.0], [brad@brad-smith.co.uk], [gnurobots])
 AC_PREREQ([2.59])
-AM_CONFIG_HEADER([config.h])
 AC_CONFIG_SRCDIR([include/api.h])
-AM_INIT_AUTOMAKE
+AC_CONFIG_AUX_DIR([build-aux])
+
+AM_INIT_AUTOMAKE([-Wall -Werror 1.9])
+AM_CONFIG_HEADER([config.h])
 
 dnl Checks for programs.
 AC_PROG_CC
 
-GUILE_FLAGS
-
 PKG_CHECK_MODULES(GTHREAD2, gthread-2.0 >= 2.4)
 AC_SUBST(GTHREAD2_LIBS)
 AC_SUBST(GTHREAD2_CFLAGS)
@@ -82,11 +82,9 @@ You need openpty to build this program.
 
 ]))
 
-AC_CHECK_LIB(guile, scm_to_locale_string, [], AC_MSG_ERROR([
-
-You need guile 1.8 to build this program.
-
-]))
+PKG_CHECK_MODULES([GUILE], [guile-1.8])
+AC_SUBST([GUILE_LIBS])
+AC_SUBST([GUILE_CFLAGS])
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
diff --git a/src/Makefile.am b/src/Makefile.am
index 75f16de..a059e8b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,18 +17,21 @@
 
 bin_PROGRAMS = gnurobots
 
-AM_CFLAGS = -pedantic-errors -Werror -Wall
+AM_CFLAGS =			\
+	-Wall			\
+	$(GUILE_CFLAGS) 	\
+	$(READLINE_CFLAGS)	\
+	$(GTK2_CFLAGS)		\
+	$(VTE_CFLAGS) 		\
+	$(GTHREAD2_CFLAGS)
 
-INCLUDES = $(GUILE_CFLAGS) $(READLINE_CFLAGS) $(GTK2_CFLAGS) \
-	$(VTE_CFLAGS) $(GTHREAD2_CFLAGS) \
-	-I$(top_builddir)/include \
-   	-DPKGLIBDIR=\"$(pkglibdir)\" \
-   	-DABS_TOP_BUILDDIR=\"$(abs_top_builddir)\" \
-   	-DPKGDATADIR=\"$(pkgdatadir)\" \
-   	-DMAPS_PATH=\"$(mapsdir)\" \
-   	-DSCRIPTS_PATH=\"$(schemedir)\"
+AM_CPPFLAGS = 				\
+	-I$(top_srcdir)/include		\
+	-I$(top_srcdir)			\
+	-DMAPS_PATH=\"$(mapsdir)\"	\
+	-DSCRIPTS_PATH=\"$(schemedir)\"
 
 gnurobots_SOURCES = main.c api.c map.c grobot.c \
 	ui-window.c ui-cmdwin.c ui-arena.c
-gnurobots_LDFLAGS = $(GUILE_LDFLAGS) $(READLINE_LIBS) $(GTHREAD2_LIBS) \
+gnurobots_LDADD = $(GUILE_LIBS) $(READLINE_LIBS) $(GTHREAD2_LIBS) \
 	$(GTK2_LIBS) $(VTE_LIBS) -lutil
-- 
1.8.1.2

