[OTR-dev] autoconf/automake/libtool support for libotr

Greg Troxel gdt at ir.bbn.com
Fri Jan 21 16:55:32 EST 2005


The following patch against libotr-1.0.3 adds
autoconf/automake/libtool support, and bumps the version to 1.0.4.
With this, 'make dist' seems to work.

See the file NETBSD (doesn't belong in releases) for how to bootstrap
the auto* tools.  It's probably just 'autoreconf -s -i;./configure'
for most of you.

The problem with this change is that it breaks mingw support.  The
original makefiles could be retained, or it should be possible to add
an --enable-mingw configure option that sets some variables (such as
CC to the mingw cross-compiler).
If you have mingw installed so that there is /usr/pkg/mingw/bin which
has cc, ld, etc., you could perhaps do PATH=/usr/pkg/mingw/bin:$PATH
./configure and it might just pick it up.
autoconf is said to have cross support; I'm not wicked familiar with it.

Note that this patch removes the original 'Makefile' files, and adds
Makefile.am.

autoconf support will make it easier to make BSD packages, because the
Linux install paths won't be hard-coded.  Plus, a shared library is
built, and that should work on a.out and ELF on various OSes.

Ian: please disregard previous patch in private mail; this iss a fresh
diff against 1.0.3.


Index: AUTHORS
===================================================================
RCS file: AUTHORS
diff -N AUTHORS
Index: ChangeLog
===================================================================
RCS file: ChangeLog
diff -N ChangeLog
Index: Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
--- Makefile	18 Jan 2005 18:44:32 -0000	1.1.1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,3 +0,0 @@
-all install clean distclean:
-	$(MAKE) -C src $@
-	$(MAKE) -C toolkit $@
Index: Makefile.am
===================================================================
RCS file: Makefile.am
diff -N Makefile.am
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Makefile.am	21 Jan 2005 21:39:46 -0000	1.2
@@ -0,0 +1,14 @@
+# -*- Makefile -*-
+# $Id: Makefile.am,v 1.2 2005/01/21 21:39:46 gdt Exp $
+
+SUBDIRS = src toolkit
+
+EXTRA_DIST = Protocol \
+	packaging/debian/changelog \
+	packaging/debian/compat \
+	packaging/debian/control \
+	packaging/debian/copyright \
+	packaging/debian/docs \
+	packaging/debian/rules \
+	packaging/debian/watch
+
Index: NETBSD
===================================================================
RCS file: NETBSD
diff -N NETBSD
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ NETBSD	21 Jan 2005 18:59:37 -0000	1.1
@@ -0,0 +1,3 @@
+autoreconf -i -s
+CPPFLAGS="-I/usr/pkg/include" LDFLAGS="-R/usr/pkg/lib -L/usr/pkg/lib" ./configure --prefix=/usr/pkg
+gmake
Index: NEWS
===================================================================
RCS file: NEWS
diff -N NEWS
Index: configure.ac
===================================================================
RCS file: configure.ac
diff -N configure.ac
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ configure.ac	21 Jan 2005 21:39:46 -0000	1.3
@@ -0,0 +1,16 @@
+dnl Process this file with autoconf to produce configure.
+
+AC_INIT(toolkit/parse.c)
+
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(libotr, 1.0.4)
+
+AC_PROG_CC
+
+AM_PROG_LIBTOOL
+
+AC_CHECK_LIB(gpg-error, gpg_strerror)
+AM_PATH_LIBGCRYPT
+
+AC_OUTPUT([Makefile src/Makefile toolkit/Makefile])
+
Index: src/Makefile
===================================================================
RCS file: src/Makefile
diff -N src/Makefile
--- src/Makefile	18 Jan 2005 18:44:08 -0000	1.1.1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,40 +0,0 @@
-ifdef WIN32
-CC = i586-mingw32msvc-gcc
-INCINSTALLDIR = /usr/i586-mingw32msvc/include
-LIBINSTALLDIR = /usr/i586-mingw32msvc/lib
-else
-FPIC = -fPIC
-INCINSTALLDIR = /usr/include
-LIBINSTALLDIR = /usr/lib
-endif
-
-INCINSTDIR = $(DESTDIR)$(INCINSTALLDIR)/libotr
-LIBINSTDIR = $(DESTDIR)$(LIBINSTALLDIR)
-
-override CFLAGS += -g -Wall $(FPIC)
-TARGET = libotr.a
-
-HEADERS = b64.h context.h dh.h mem.h message.h privkey.h proto.h version.h
-
-all: $(TARGET)
-
-$(TARGET): privkey.o context.o proto.o b64.o dh.o mem.o message.o
-	rm -f $@
-ifdef WIN32
-	i586-mingw32msvc-ar rcs $@ $^
-	i586-mingw32msvc-ranlib $@
-else
-	ar rcs $@ $^
-endif
-
-install: all
-	install -d $(INCINSTDIR)
-	install -d $(LIBINSTDIR)
-	install -m 0644 $(TARGET) $(LIBINSTDIR)
-	install -m 0644 $(HEADERS) $(INCINSTDIR)
-
-clean:
-	rm -f *.o
-	rm -f $(TARGET)
-
-distclean: clean
Index: src/Makefile.am
===================================================================
RCS file: src/Makefile.am
diff -N src/Makefile.am
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/Makefile.am	21 Jan 2005 19:19:30 -0000	1.2
@@ -0,0 +1,13 @@
+# -*- Makefile -*-
+
+INCLUDES = @LIBGCRYPT_CFLAGS@
+
+lib_LTLIBRARIES = libotr.la
+libotr_la_LDFLAGS = -version 0:0:0
+
+libotr_la_SOURCES = privkey.c context.c proto.c b64.c dh.c mem.c message.c
+libotr_la_LDFLAGS = @LIBS@ @LIBGCRYPT_LDFLAGS@
+
+otrincdir = $(includedir)/libotr
+
+otrinc_HEADERS = b64.h context.h dh.h mem.h message.h privkey.h proto.h version.h
Index: toolkit/Makefile
===================================================================
RCS file: toolkit/Makefile
diff -N toolkit/Makefile
--- toolkit/Makefile	18 Jan 2005 22:47:18 -0000	1.1.1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,72 +0,0 @@
-# The location of the libotr directory
-LIBOTR_DIR = ../src
-
-# The target dir
-TARGET_DIR = ..
-
-ifdef WIN32
-CC = i586-mingw32msvc-gcc
-SUFFIX = .exe
-LDLIBS = -lgcrypt -lgpg-error
-else
-# Install dirs
-INSTALLBINDIR = $(DESTDIR)/usr/bin
-INSTALLMANDIR = $(DESTDIR)/usr/share/man/man1
-
-FPIC = -fPIC
-LDLIBS = -lgcrypt
-endif
-
-override CFLAGS += -g -Wall -I$(LIBOTR_DIR) $(FPIC)
-override LDFLAGS += -g
-
-TARGETS = $(TARGET_DIR)/otr_parse$(SUFFIX) \
-          $(TARGET_DIR)/otr_sesskeys$(SUFFIX) \
-	  $(TARGET_DIR)/otr_mackey$(SUFFIX) \
-	  $(TARGET_DIR)/otr_readforge$(SUFFIX) \
-	  $(TARGET_DIR)/otr_modify$(SUFFIX) \
-	  $(TARGET_DIR)/otr_remac$(SUFFIX)
-
-all: $(TARGETS)
-
-$(TARGET_DIR)/otr_parse$(SUFFIX): otr_parse.o readotr.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
-
-$(TARGET_DIR)/otr_sesskeys$(SUFFIX): otr_sesskeys.o sesskeys.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
-
-$(TARGET_DIR)/otr_mackey$(SUFFIX): otr_mackey.o sesskeys.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
-
-$(TARGET_DIR)/otr_readforge$(SUFFIX): otr_readforge.o readotr.o sesskeys.o parse.o sha1hmac.o aes.o ctrmode.o $(LIBOTR_DIR)/libotr.a
-	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
-
-$(TARGET_DIR)/otr_modify$(SUFFIX): otr_modify.o readotr.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
-
-$(TARGET_DIR)/otr_remac$(SUFFIX): otr_remac.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)
-
-$(LIBOTR_DIR)/libotr.a: FORCE
-	$(MAKE) -C $(LIBOTR_DIR) libotr.a
-
-install: all
-ifndef WIN32
-	install -d $(INSTALLBINDIR)
-	install -d $(INSTALLMANDIR)
-	install -m 0755 $(TARGETS) $(INSTALLBINDIR)
-	install -m 0644 otr_toolkit.1 $(INSTALLMANDIR)/otr_parse.1
-	ln -nsf otr_parse.1 $(INSTALLMANDIR)/otr_sesskeys.1
-	ln -nsf otr_parse.1 $(INSTALLMANDIR)/otr_mackey.1
-	ln -nsf otr_parse.1 $(INSTALLMANDIR)/otr_readforge.1
-	ln -nsf otr_parse.1 $(INSTALLMANDIR)/otr_modify.1
-	ln -nsf otr_parse.1 $(INSTALLMANDIR)/otr_remac.1
-endif
-
-clean:
-	rm -f *.o
-	rm -f $(TARGETS)
-
-distclean: clean
-
-FORCE:
Index: toolkit/Makefile.am
===================================================================
RCS file: toolkit/Makefile.am
diff -N toolkit/Makefile.am
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ toolkit/Makefile.am	21 Jan 2005 21:39:46 -0000	1.2
@@ -0,0 +1,43 @@
+# -*- Makefile -*-
+
+INCLUDES = -I$(includedir) -I../src
+
+noinst_HEADERS = aes.h ctrmode.h parse.h sesskeys.h readotr.h sha1hmac.h
+
+bin_PROGRAMS = otr_parse otr_sesskeys otr_mackey otr_readforge \
+	otr_modify otr_remac
+
+COMMON_S = parse.c sha1hmac.c
+COMMON_LD = ../src/libotr.la @LIBS@ @LIBGCRYPT_LIBS@
+
+otr_parse_SOURCES = otr_parse.c readotr.c $(COMMON_S)
+otr_parse_LDADD = $(COMMON_LD)
+
+otr_sesskeys_SOURCES = otr_sesskeys.c sesskeys.c $(COMMON_S)
+otr_sesskeys_LDADD = $(COMMON_LD)
+
+otr_mackey_SOURCES = otr_mackey.c sesskeys.c $(COMMON_S)
+otr_mackey_LDADD = $(COMMON_LD)
+
+otr_readforge_SOURCES = otr_readforge.c readotr.c sesskeys.c \
+	aes.c ctrmode.c $(COMMON_S)
+otr_readforge_LDADD = $(COMMON_LD)
+
+otr_modify_SOURCES = otr_modify.c readotr.c $(COMMON_S)
+otr_modify_LDADD = $(COMMON_LD)
+
+otr_remac_SOURCES = otr_remac.c $(COMMON_S)
+otr_remac_LDADD = $(COMMON_LD)
+
+
+man_MANS = otr_toolkit.1
+EXTRA_DIST = otr_toolkit.1
+
+# XXX This assumes what automake will do, but there does not
+# seem to be an install-man -hook or -local.
+install-man: install-man1 install-links
+
+install-links:
+	(cd $(DESTDIR)$(man1dir) && \
+	for f in otr_parse.1 otr_sesskeys.1 otr_mackey.1 otr_readforge.1 otr_modify.1 otr_remac.1; do \
+	ln -sf otr_toolkit.1 $$f; done)

-- 
        Greg Troxel <gdt at ir.bbn.com>



More information about the OTR-dev mailing list