From: Steven Grimm Date: Mon, 20 Aug 2007 20:49:05 +0000 (+0200) Subject: Add autoconf-based build infrastructure for tig X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=ec31d0d018f14973d7d91084a3582f8bfd53b0ef;p=tig.git Add autoconf-based build infrastructure for tig 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 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 --- diff --git a/.gitignore b/.gitignore index 5627fa8..4469f10 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,10 @@ +autom4te.cache +config.h +config.h.in +config.log +config.make +config.status +configure manual.html-chunked manual.pdf manual.toc diff --git a/INSTALL b/INSTALL index 586878e..db7dcbf 100644 --- a/INSTALL +++ b/INSTALL @@ -8,16 +8,16 @@ available either in the tarballs or in the above repository in the branch named 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 ba42a90..ff62390 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,13 @@ -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 @@ -24,7 +30,7 @@ RPM_VERSION = $(word 1,$(RPM_VERLIST)) 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 @@ -34,6 +40,9 @@ TARNAME = tig-$(RPM_VERSION)-$(RPM_RELEASE) override CFLAGS += '-DVERSION="$(VERSION)"' +AUTOHEADER ?= autoheader +AUTOCONF ?= autoconf + all: $(PROGS) all-debug: $(PROGS) all-debug: CFLAGS += $(DFLAGS) @@ -92,6 +101,10 @@ dist: tig.spec rpm: dist rpmbuild -ta $(TARNAME).tar.gz +configure: configure.ac + $(AUTOHEADER) + $(AUTOCONF) + # Maintainer stuff release-doc: git checkout release && \ diff --git a/TODO b/TODO index d1008dd..9ff2b32 100644 --- a/TODO +++ b/TODO @@ -22,9 +22,7 @@ Features that should be explored. 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 new file mode 100644 index 0000000..aab449b --- /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 new file mode 100644 index 0000000..0e06af5 --- /dev/null +++ b/configure.ac @@ -0,0 +1,53 @@ +AC_INIT([tig], [0], + [Jonas Fonseca ], + [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 ]], + [[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 diff --git a/tig.c b/tig.c index 49848d6..1ad9264 100644 --- a/tig.c +++ b/tig.c @@ -11,8 +11,8 @@ * GNU General Public License for more details. */ -#ifndef VERSION -#define VERSION "unknown-version" +#ifndef TIG_VERSION +#define TIG_VERSION "unknown-version" #endif #ifndef DEBUG @@ -40,6 +40,8 @@ #include +#include "config.h" + #if __GNUC__ >= 3 #define __NORETURN __attribute__((__noreturn__)) #else @@ -390,7 +392,7 @@ get_request(const char *name) */ 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" @@ -516,7 +518,7 @@ parse_options(int argc, char *argv[]) } if (check_option(opt, 'v', "version", OPT_NONE)) { - printf("tig version %s\n", VERSION); + printf("tig version %s\n", TIG_VERSION); return FALSE; } @@ -1926,7 +1928,7 @@ update_view(struct view *view) 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; @@ -2286,7 +2288,7 @@ view_driver(struct view *view, enum request request) 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: