Skip to content

Commit

Permalink
Build system updates.
Browse files Browse the repository at this point in the history
- Update configure.ac to work with recent automake.
- Use git-version-gen to generate git revisions.
- Use kernel style compile messages.
- Don't use PKG_CHECK_MODULES macro (ref http://goo.gl/E6Bvi)
- Misc. clean-up.
  • Loading branch information
csete committed Mar 7, 2013
1 parent fb32133 commit daa611c
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 50 deletions.
91 changes: 41 additions & 50 deletions configure.ac
@@ -1,14 +1,17 @@
AC_INIT(src/main.c)

AC_INIT([gpredict],
m4_esyscmd([./git-version-gen .tarball-version]),
[gpredict-discussion@lists.sourceforge.net])
AC_CONFIG_SRCDIR(src/main.c)
AM_CONFIG_HEADER(build-config.h)

AM_INIT_AUTOMAKE(gpredict, 1.4git)
AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip 1.6])

AM_MAINTAINER_MODE
AC_PROG_INTLTOOL([0.21])

# kernel style compile messages
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

dnl check for programs
# check for programs
AC_PROG_CC
AC_ISC_POSIX
AC_HEADER_STDC
Expand All @@ -20,40 +23,40 @@ if test "${ac_cv_c_compiler_gnu}" = "yes"; then
CFLAGS="${CFLAGS} -Wall"
fi

dnl check for libm
# check for libm
AC_CHECK_LIB([m], [sin],, AC_MSG_ERROR([Can't find libm. Check your libc installation]))

dnl check for glib, gtk, and goocanvas libraries
pkg_modules="gtk+-2.0 >= 2.18.0 glib-2.0 >= 2.22.0 gthread-2.0 >= 2.22.0 goocanvas >= 0.15 libcurl >= 7.19.0"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
# check for goocanvas (depends on gtk and glib)
if pkg-config --atleast-version=7.19 libcurl; then
CFLAGS="$CFLAGS `pkg-config --cflags libcurl`"
LIBS="$LIBS `pkg-config --libs libcurl`"
else
AC_MSG_ERROR(Gpredict requires libcurl-dev 7.19 or later)
fi

# check for goocanvas (depends on gtk and glib)
if pkg-config --atleast-version=0.15 goocanvas; then
CFLAGS="$CFLAGS `pkg-config --cflags goocanvas`"
LIBS="$LIBS `pkg-config --libs goocanvas`"
else
AC_MSG_ERROR(Gpredict requires libgoocanvas-dev 0.15 or later)
fi

# check for libgps (optional)
if pkg-config --atleast-version=2.90 libgps; then
CFLAGS="$CFLAGS `pkg-config --cflags libgps`"
LIBS="$LIBS `pkg-config --libs libgps`"
havelibgps=true;
AC_DEFINE(HAS_LIBGPS, 1, [Define if libgps is available])
else
havelibgps=false;
fi

AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)

dnl optional check for libgps
PKG_CHECK_MODULES(LIBGPS, [ libgps >= 2.90 ], [
CFLAGS="$CFLAGS $LIBGPS_CFLAGS";
LIBS="$LIBS $LIBGPS_LIBS";
havelibgps=true;
AC_DEFINE(HAS_LIBGPS, 1, [Define if libgps is available])
], [
havelibgps=false;
])

dnl Hamlib not needed if we go for the TCP based I/F
dnl check for hamlib
dnl PKG_CHECK_MODULES(HAMLIB, hamlib, [
dnl CFLAGS="$CFLAGS $HAMLIB_CFLAGS";
dnl LIBS="$LIBS $HAMLIB_LIBS";
dnl havehamlib=true;
dnl AC_DEFINE(HAVE_HAMLIB, 1, [Define if hamlib is available])
dnl ], [
dnl havehamlib=false;
dnl AC_DEFINE(HAVE_HAMLIB, 0, [Define if hamlib is unvailable])

dnl])

dnl Add the languages which your application supports here.
dnl Note that other progs only have ALL_LINGUAS and AM_GLIB_GNU_GETTEXT
# Add the languages which your application supports here.
# Note that other progs only have ALL_LINGUAS and AM_GLIB_GNU_GETTEXT
ALL_LINGUAS="cs da de en_GB en_US es fi fr it lt ru th uk"
GETTEXT_PACKAGE=gpredict
AC_SUBST(GETTEXT_PACKAGE)
Expand All @@ -63,8 +66,8 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,
"definition of GETTEXT_PACKAGE")


dnl compiler flags to enable generating coverage report
dnl using gcov
# compiler flags to enable generating coverage report
# using gcov
AC_ARG_ENABLE(coverage, [ --enable-coverage enable coverge reports],enable_coerage=yes,enable_coverage=no)
if test "$enable_coverage" = yes ; then
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage";
Expand All @@ -75,8 +78,6 @@ AC_ARG_ENABLE(caches,[ --enable-caches Run update-* to update desktop and ico
AM_CONDITIONAL(UPDATE_CACHES, test x"$enable_caches" = "xyes")




GLIB_V=`pkg-config --modversion glib-2.0`
GIO_V=`pkg-config --modversion gio-2.0`
GTHR_V=`pkg-config --modversion gthread-2.0`
Expand All @@ -87,10 +88,6 @@ CURL_V=`pkg-config --modversion libcurl`
if test "$havelibgps" = true ; then
GPS_V=`pkg-config --modversion libgps`
fi
dnl SQL_V=`pkg-config --modversion sqlite3`
dnl if test "$havehamlib" = true ; then
dnl HAML_V=`pkg-config --modversion hamlib`
dnl fi


AC_SUBST(CFLAGS)
Expand Down Expand Up @@ -129,12 +126,6 @@ echo Libcurl version..... : $CURL_V
if test "$havelibgps" = true ; then
echo Libgps version..... : $GPS_V
fi
dnl echo SQLite version..... : $SQL_V
dnl if test "$havehamlib" = true ; then
dnl echo Hamlib version..... : $HAML_V
dnl else
dnl echo Hamlib version..... : none
dnl fi
dnl echo Enable coverage.... : $enable_coverage
dnl echo
# echo Enable coverage.... : $enable_coverage
# echo

151 changes: 151 additions & 0 deletions git-version-gen
@@ -0,0 +1,151 @@
#!/bin/sh
# Print a version string.
scriptversion=2010-01-28.01

# Copyright (C) 2007-2010 Free Software Foundation, Inc.
#
# This program 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
# (at your option) any later version.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.

# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
# It may be run two ways:
# - from a git repository in which the "git describe" command below
# produces useful output (thus requiring at least one signed tag)
# - from a non-git-repo directory containing a .tarball-version file, which
# presumes this script is invoked like "./git-version-gen .tarball-version".

# In order to use intra-version strings in your project, you will need two
# separate generated version string files:
#
# .tarball-version - present only in a distribution tarball, and not in
# a checked-out repository. Created with contents that were learned at
# the last time autoconf was run, and used by git-version-gen. Must not
# be present in either $(srcdir) or $(builddir) for git-version-gen to
# give accurate answers during normal development with a checked out tree,
# but must be present in a tarball when there is no version control system.
# Therefore, it cannot be used in any dependencies. GNUmakefile has
# hooks to force a reconfigure at distribution time to get the value
# correct, without penalizing normal development with extra reconfigures.
#
# .version - present in a checked-out repository and in a distribution
# tarball. Usable in dependencies, particularly for files that don't
# want to depend on config.h but do want to track version changes.
# Delete this file prior to any autoconf run where you want to rebuild
# files to pick up a version string change; and leave it stale to
# minimize rebuild time after unrelated changes to configure sources.
#
# It is probably wise to add these two files to .gitignore, so that you
# don't accidentally commit either generated file.
#
# Use the following line in your configure.ac, so that $(VERSION) will
# automatically be up-to-date each time configure is run (and note that
# since configure.ac no longer includes a version string, Makefile rules
# should not depend on configure.ac for version updates).
#
# AC_INIT([GNU project],
# m4_esyscmd([build-aux/git-version-gen .tarball-version]),
# [bug-project@example])
#
# Then use the following lines in your Makefile.am, so that .version
# will be present for dependencies, and so that .tarball-version will
# exist in distribution tarballs.
#
# BUILT_SOURCES = $(top_srcdir)/.version
# $(top_srcdir)/.version:
# echo $(VERSION) > $@-t && mv $@-t $@
# dist-hook:
# echo $(VERSION) > $(distdir)/.tarball-version

case $# in
1) ;;
*) echo 1>&2 "Usage: $0 \$srcdir/.tarball-version"; exit 1;;
esac

tarball_version_file=$1
nl='
'

# First see if there is a tarball-only version file.
# then try "git describe", then default.
if test -f $tarball_version_file
then
v=`cat $tarball_version_file` || exit 1
case $v in
*$nl*) v= ;; # reject multi-line output
[0-9]*) ;;
*) v= ;;
esac
test -z "$v" \
&& echo "$0: WARNING: $tarball_version_file seems to be damaged" 1>&2
fi

if test -n "$v"
then
: # use $v
elif
v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \
|| git describe --abbrev=4 HEAD 2>/dev/null` \
&& case $v in
[0-9]*) ;;
v[0-9]*) ;;
*) (exit 1) ;;
esac
then
# Is this a new git that lists number of commits since the last
# tag or the previous older version that did not?
# Newer: v6.10-77-g0f8faeb
# Older: v6.10-g0f8faeb
case $v in
*-*-*) : git describe is okay three part flavor ;;
*-*)
: git describe is older two part flavor
# Recreate the number of commits and rewrite such that the
# result is the same as if we were using the newer version
# of git describe.
vtag=`echo "$v" | sed 's/-.*//'`
numcommits=`git rev-list "$vtag"..HEAD | wc -l`
v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`;
;;
esac

# Change the first '-' to a '.', so version-comparing tools work properly.
# Remove the "g" in git describe's output string, to save a byte.
v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
else
v=UNKNOWN
fi

v=`echo "$v" |sed 's/^v//'`

# Don't declare a version "dirty" merely because a time stamp has changed.
git status > /dev/null 2>&1

dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty=
case "$dirty" in
'') ;;
*) # Append the suffix only if there isn't one already.
case $v in
*-dirty) ;;
*) v="$v-dirty" ;;
esac ;;
esac

# Omit the trailing newline, so that m4_esyscmd can use the result directly.
echo "$v" | tr -d '\012'

# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

0 comments on commit daa611c

Please sign in to comment.