[OTR-dev] compilation on NetBSD too hard, but gaim plugin seems to work

Greg Troxel gdt at ir.bbn.com
Sat Dec 18 10:18:14 EST 2004

On a NetBSD/i386 2.0ish system with gaim and libgrcrypt installed, I
donwloaded OTR 1.0.1 and tried to build it.  I had a number of build
issues, all of which were trivial for me to fix, but probably would
have stopped mere "users".  After fixing them, I was able to run the
plugin and talk to myself from two jabber accounts on different

I enclose a diff, parts of which you certainly won't want to apply,
but I'll explain the issues and make two suggestions of how to deal
with this.

1) The makefiles require GNU make, and fail with BSD make.  This is
   fine (but should be noted in the README), but the makefiles use
   'make' to invoke make again.  On NetBSD, make is BSD make and GNU
   make is installed as gmake.  Changing to ${MAKE} invokes the
   current make again.  [I suggest just taking this change.]

2) Finding gcrypt: On NetBSD, it's usually in /usr/pkg/lib, and
   includes in /usr/pkg/include.  gcrypt does not have a pkgconfig
   file.  I just patched the makefiles; obviously this is

3) -R for the plugin.  On NetBSD, gtk/gaim/gcrypt libs are in
    /usr/pkg/lib, so I added -R so the plugin could resolve those
    libs.  Before doing this, the plugin silently failed to appear in
    the list.  Arguably gaim should notify the user of plugin loading
    failure - I even watched stdout/stderr.

4) Installation paths.  I want this in /usr/pkg, not /usr.

I can see two ways to address these issues:

a) add a Makefile.inc at top-level that sets variables for
GAIM_MODULE_LDFLAGS (for -R), and similarly for gaim.

Define PREFIX (defaulting to /usr) and then define BINDIR, MANDIR,
etc. based on PREFIX.  (While system man pages are in /usr/share/man,
pkgsrc man pages are in /urs/pkg/man.)

b) Use autoconf/automake/libtool.  This is probably not very hard,
especially if one is willing to install the shlib version of the
library, since that's what is natural.

It looks like the utilities could use a library for themselves,
perhaps static and not installed so it won't impact the binaries.
Or, such facilities might belong in the toolkit.

Thank you very much for writing and releasing this code - I'm trying
to be helpful, not griping....

diff -ur gaim-otr-1.0.1/Makefile gaim-otr-1.0.1-netbsd/Makefile
--- gaim-otr-1.0.1/Makefile	2004-12-01 18:57:01.000000000 -0500
+++ gaim-otr-1.0.1-netbsd/Makefile	2004-12-18 09:31:42.000000000 -0500
@@ -1,4 +1,4 @@
 all install clean distclean:
-	make -C libotr $@
-	make -C gaim-otr $@
-	make -C tools $@
+	${MAKE} -C libotr $@
+	${MAKE} -C gaim-otr $@
+	${MAKE} -C tools $@
diff -ur gaim-otr-1.0.1/gaim-otr/Makefile gaim-otr-1.0.1-netbsd/gaim-otr/Makefile
--- gaim-otr-1.0.1/gaim-otr/Makefile	2004-12-09 13:51:38.000000000 -0500
+++ gaim-otr-1.0.1-netbsd/gaim-otr/Makefile	2004-12-18 09:41:01.000000000 -0500
@@ -1,5 +1,5 @@
 # Replace this with the path to the GAIM headers
-GAIM_SOURCE ?= /usr/include/gaim
+GAIM_SOURCE ?= /usr/pkg/include/gaim
 # If you don't have pkg-config, put the appropriate -I entry on the next line
 GTK_HDRS ?= `pkg-config --cflags glib-2.0 gtk+-2.0`
@@ -10,8 +10,10 @@
 # The target
 TARGET = ../gaim-otr.so
+GCRYPT_LD=-R/usr/pkg/lib -L/usr/pkg/lib -lgcrypt
 # Install directory
-INSTALLDIR = $(DESTDIR)/usr/lib/gaim
+INSTALLDIR = $(DESTDIR)/usr/pkg/lib/gaim
 CC ?= gcc
 override CFLAGS += -g -Wall -I$(GAIM_SOURCE) $(GTK_HDRS) -I$(LIBOTR_DIR) -fPIC
@@ -19,10 +21,10 @@
 all: $(TARGET)
 $(TARGET): otr-plugin.o ui.o dialogs.o $(LIBOTR_DIR)/libotr.a
-	$(CC) -g -shared -module -avoid-version $^ -o $@ -lgcrypt
+	$(CC) -g -shared -module -avoid-version $^ -o $@ ${GCRYPT_LD}
 $(LIBOTR_DIR)/libotr.a: FORCE
-	make -C $(LIBOTR_DIR) libotr.a
+	${MAKE} -C $(LIBOTR_DIR) libotr.a
 install: all
 	install -d $(INSTALLDIR)
diff -ur gaim-otr-1.0.1/libotr/Makefile gaim-otr-1.0.1-netbsd/libotr/Makefile
--- gaim-otr-1.0.1/libotr/Makefile	2004-12-09 13:51:38.000000000 -0500
+++ gaim-otr-1.0.1-netbsd/libotr/Makefile	2004-12-18 09:31:12.000000000 -0500
@@ -1,6 +1,6 @@
 CC ?= gcc
-override CFLAGS += -g -Wall -fPIC
-LDFLAGS ?= -lgcrypt -g
+CFLAGS += -I/usr/pkg/include -g -Wall -fPIC
+LDFLAGS ?= -L/usr/pkg/lib -lgcrypt -g
 all: libotr.a
diff -ur gaim-otr-1.0.1/tools/Makefile gaim-otr-1.0.1-netbsd/tools/Makefile
--- gaim-otr-1.0.1/tools/Makefile	2004-12-09 13:51:38.000000000 -0500
+++ gaim-otr-1.0.1-netbsd/tools/Makefile	2004-12-18 09:36:23.000000000 -0500
@@ -5,11 +5,13 @@
 # Install dirs
-INSTALLMANDIR = $(DESTDIR)/usr/share/man/man1
+INSTALLMANDIR = $(DESTDIR)/usr/pkg/man/man1
 CC ?= gcc
-override CFLAGS += -g -Wall -I$(LIBOTR_DIR) -fPIC
+CFLAGS += -I/usr/pkg/include -g -Wall -I$(LIBOTR_DIR) -fPIC
+GCRYPT_LD=-L/usr/pkg/lib -lgcrypt
 TARGETS = $(TARGET_DIR)/otr_parse \
           $(TARGET_DIR)/otr_sesskeys \
@@ -21,25 +23,25 @@
 all: $(TARGETS)
 $(TARGET_DIR)/otr_parse: otr_parse.o readotr.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) -g $^ -o $@ -lgcrypt
+	$(CC) -g $^ -o $@ ${GCRYPT_LD}
 $(TARGET_DIR)/otr_sesskeys: otr_sesskeys.o sesskeys.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) -g $^ -o $@ -lgcrypt
+	$(CC) -g $^ -o $@ ${GCRYPT_LD}
 $(TARGET_DIR)/otr_mackey: otr_mackey.o sesskeys.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) -g $^ -o $@ -lgcrypt
+	$(CC) -g $^ -o $@ ${GCRYPT_LD}
 $(TARGET_DIR)/otr_readforge: otr_readforge.o readotr.o sesskeys.o parse.o sha1hmac.o aes.o ctrmode.o $(LIBOTR_DIR)/libotr.a
-	$(CC) -g $^ -o $@ -lgcrypt
+	$(CC) -g $^ -o $@ ${GCRYPT_LD}
 $(TARGET_DIR)/otr_modify: otr_modify.o readotr.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) -g $^ -o $@ -lgcrypt
+	$(CC) -g $^ -o $@ ${GCRYPT_LD}
 $(TARGET_DIR)/otr_remac: otr_remac.o parse.o sha1hmac.o $(LIBOTR_DIR)/libotr.a
-	$(CC) -g $^ -o $@ -lgcrypt
+	$(CC) -g $^ -o $@ ${GCRYPT_LD}
 $(LIBOTR_DIR)/libotr.a: FORCE
-	make -C $(LIBOTR_DIR) libotr.a
+	${MAKE} -C $(LIBOTR_DIR) libotr.a
 install: all
 	install -d $(INSTALLBINDIR)

More information about the OTR-dev mailing list