summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 69efc85)
raw | patch | inline | side by side (parent: 69efc85)
author | Steven Grimm <koreth@midwinter.com> | |
Mon, 20 Aug 2007 20:49:05 +0000 (22:49 +0200) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 21 Aug 2007 10:22:27 +0000 (12:22 +0200) |
This is a first cut at building tig using autoconf. With this patch, tig
configures and builds on both Linux (FC4) and OS X.
Signed-off-by: Steven Grimm <koreth@midwinter.com>
Reworked to not use aclocal+automake and external scripts for
bootstrapping. Instead, run `make configure` to generate the configure
script. It will create a config.make file from config.make.in, which
contains variables set by the configure script. Update .gitignore to
list generated files.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
configures and builds on both Linux (FC4) and OS X.
Signed-off-by: Steven Grimm <koreth@midwinter.com>
Reworked to not use aclocal+automake and external scripts for
bootstrapping. Instead, run `make configure` to generate the configure
script. It will create a config.make file from config.make.in, which
contains variables set by the configure script. Update .gitignore to
list generated files.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
.gitignore | patch | blob | history | |
INSTALL | patch | blob | history | |
Makefile | patch | blob | history | |
TODO | patch | blob | history | |
config.make.in | [new file with mode: 0644] | patch | blob |
configure.ac | [new file with mode: 0644] | patch | blob |
tig.c | patch | blob | history |
diff --git a/.gitignore b/.gitignore
index 5627fa82f0e9df50e6b43da63b243a0f9ad4e1a5..4469f10149b14689ee61efdc5893175b9d1eb1bb 100644 (file)
--- a/.gitignore
+++ b/.gitignore
+autom4te.cache
+config.h
+config.h.in
+config.log
+config.make
+config.status
+configure
manual.html-chunked
manual.pdf
manual.toc
index 586878e1389c50141785b1d5071e62cc03e8cc06..db7dcbf636f2f7b27c34170659740fb9c58bf5de 100644 (file)
--- a/INSTALL
+++ b/INSTALL
To install tig simply run:
+ $ sh autoconf.sh
+ $ ./configure
$ make install
To install documentation run:
$ make install-doc
-Edit the Makefile if you need to configure specific compiler or linker flags.
-On FreeBSD for example the c library does not support the iconv interface and
-to compile tig you need to append `-L/usr/local/lib -liconv` to `LDLIBS` and
-`-I/usr/local/include` to the `CFLAGS` variable.
+If you had to install your own copy of libiconv, you'll probably want to pass
+the "--with-libiconv" option to the "configure" script to tell it where to look.
The following tools and packages are needed:
diff --git a/Makefile b/Makefile
index ba42a900748c9355a7d0ce524933dcea9123c763..ff6239002c697c426baa2a474fd5b15744dd1ff6 100644 (file)
--- a/Makefile
+++ b/Makefile
-prefix = $(HOME)
-bindir = $(prefix)/bin
-mandir = $(prefix)/man
-docdir = $(prefix)/share/doc
+## Makefile for tig
+
+# Include setting from the configure script
+-include config.make
+
+prefix ?= $(HOME)
+bindir ?= $(prefix)/bin
+mandir ?= $(prefix)/man
+datarootdir ?= $(prefix)/share
+docdir ?= $(datarootdir)/doc
# DESTDIR=
# Get version either via git or from VERSION file. Allow either
RPM_RELEASE = $(word 2,$(RPM_VERLIST))$(if $(WTDIRTY),.dirty)
LDLIBS = -lcurses
-CFLAGS = -Wall -O2
+CFLAGS ?= -Wall -O2
DFLAGS = -g -DDEBUG -Werror
PROGS = tig
MANDOC = tig.1 tigrc.5
override CFLAGS += '-DVERSION="$(VERSION)"'
+AUTOHEADER ?= autoheader
+AUTOCONF ?= autoconf
+
all: $(PROGS)
all-debug: $(PROGS)
all-debug: CFLAGS += $(DFLAGS)
rpm: dist
rpmbuild -ta $(TARNAME).tar.gz
+configure: configure.ac
+ $(AUTOHEADER)
+ $(AUTOCONF)
+
# Maintainer stuff
release-doc:
git checkout release && \
index d1008ddd0eb17187c667a7810f806fac996d04f5..9ff2b3273a51dea041712ef3545bc5271ce398b0 100644 (file)
--- a/TODO
+++ b/TODO
part of the commit detail information you display on the lower pane
(log/diff view).
- - Use autoconf to check for iconv in libc and how it is declared (the
- 2nd argument is 'const' on FreeBSD / Mac OS X). Maybe also check for
- the AsciiDoc and XmlTo document tools.
+ - Use autoconf to check for the AsciiDoc and XmlTo document tools.
- The autoconf check could also be used to determine whether it is a
newer git so that git-config will be used instead of git-repo-config.
diff --git a/config.make.in b/config.make.in
--- /dev/null
+++ b/config.make.in
@@ -0,0 +1,9 @@
+CFLAGS = @CFLAGS@
+LDFLAGS = @LDFLAGS@
+LDLIBS = @LIBS@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+mandir = @mandir@
+docdir = @docdir@
+datarootdir = @datarootdir@
diff --git a/configure.ac b/configure.ac
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,53 @@
+AC_INIT([tig], [0],
+ [Jonas Fonseca <fonseca@diku.dk>],
+ [tig])
+AC_LANG([C])
+AC_CONFIG_HEADER(config.h)
+AC_CONFIG_SRCDIR(tig.c)
+
+AC_ARG_WITH(libiconv,
+ AC_HELP_STRING([--with-libiconv=DIRECTORY],[base directory for libiconv]))
+if test "$with_libiconv" != ""
+then
+ CFLAGS="$CFLAGS -I$with_libiconv/include"
+ LDFLAGS="$LDFLAGS -L$with_libiconv/lib"
+fi
+
+dnl
+dnl See if we need to link with -liconv to get the iconv() function.
+dnl
+AC_SEARCH_LIBS([wclear], [ncurses curses])
+AC_SEARCH_LIBS([iconv], [iconv])
+
+if test "$ac_cv_search_iconv" = "no"
+then
+ AC_MSG_FAILURE([iconv() not found. Please install libiconv.],[1])
+fi
+
+dnl
+dnl See if iconv() requires a const char ** for the input buffer.
+dnl
+if test "$GCC" = "yes"
+then
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Werror"
+ AC_MSG_CHECKING([whether iconv needs const char **])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <iconv.h>]],
+ [[char **buf;
+ size_t *size;
+ iconv_t cd;
+ iconv(cd, buf, size, buf, size);]])],
+ [AC_DEFINE([ICONV_INBUF_TYPE],[char *],
+ [Type of iconv() input buffer])
+ AC_MSG_RESULT([no])],
+ [AC_DEFINE([ICONV_INBUF_TYPE],[const char *],
+ [Type of iconv() input buffer])
+ AC_MSG_RESULT([yes])])
+ CFLAGS="$OLD_CFLAGS"
+fi
+
+AC_PROG_CC
+
+AC_CONFIG_FILES([config.make])
+AC_OUTPUT
index 49848d67b459a81abf1edaaa8a935dd3535ea44d..1ad92644ebe5efc94d50d72e3f5ce65bb465d022 100644 (file)
--- a/tig.c
+++ b/tig.c
* GNU General Public License for more details.
*/
-#ifndef VERSION
-#define VERSION "unknown-version"
+#ifndef TIG_VERSION
+#define TIG_VERSION "unknown-version"
#endif
#ifndef DEBUG
#include <curses.h>
+#include "config.h"
+
#if __GNUC__ >= 3
#define __NORETURN __attribute__((__noreturn__))
#else
*/
static const char usage[] =
-"tig " VERSION " (" __DATE__ ")\n"
+"tig " TIG_VERSION " (" __DATE__ ")\n"
"\n"
"Usage: tig [options]\n"
" or: tig [options] [--] [git log options]\n"
}
if (check_option(opt, 'v', "version", OPT_NONE)) {
- printf("tig version %s\n", VERSION);
+ printf("tig version %s\n", TIG_VERSION);
return FALSE;
}
line[linelen - 1] = 0;
if (opt_iconv != ICONV_NONE) {
- char *inbuf = line;
+ ICONV_INBUF_TYPE inbuf = line;
size_t inlen = linelen;
char *outbuf = out_buffer;
break;
case REQ_SHOW_VERSION:
- report("tig-%s (built %s)", VERSION, __DATE__);
+ report("tig-%s (built %s)", TIG_VERSION, __DATE__);
return TRUE;
case REQ_SCREEN_RESIZE: