On Mon, 2014-10-06 at 13:44 +0100, Jonathan McDowell wrote: > On Mon, Oct 06, 2014 at 01:29:41PM +0200, Svante Signell wrote: > > > Currently onak fails to build from source due to missing linkage of > > libpthread in the db4 backend test. The previously successfully built > > version is 0.4.2-1. The attached patch rules.patch fixes this problem. > > Firstly this is a problem that would have existed in 0.4.2-1 - the more > recent versions switch the build system to dh which is then running the > upstream tests and catching the fact that although everything compiled > fine the db4 backend is not functional on hurd. > > Secondly I don't feel that patching the debian/rules is the right way to > fix this; that doesn't help anyone compiling upstream on Hurd directly > themselves. The requirement for pthread is coming via the db5.3 library, > so the autoconf checks for that probably need to be expanded to include > picking up -lpthread when necessary. I don't really like the fact that > I'm then expected to know that pulling in a library might then need me > to check for pthreads when I'm not using them, but perhaps there are > examples of suitable autoconf snippets to do this correctly and > generically?
The only executable needing to be linked with libpthread is onak itself on GNU/Hurd. The attached patches configure.ac.patch and Makefile.in.patch solves this problem leaving the other systems unaffected. One problem is that -gnu* (i586-gnu in this case) has to be last in order not to be triggered by e.g. i586-kfreebsd-gnu or x86_64-linux-gnu. Build tested on kFreeBSD (i386) and Linux (x86_64) in addition to Hurd (i386). I don't claim this to be the best solution, it would be better to link onak with libpthread on GNU/Hurd only if the db4 backend is used. Such a solution could be achieved by moving the configure.ac patch into the detection part of the db4 backend. Thanks!
Index: onak-0.4.5/configure.ac =================================================================== --- onak-0.4.5.orig/configure.ac +++ onak-0.4.5/configure.ac @@ -85,6 +85,16 @@ then backend="$enable_backend" fi +case $build in + *-linux* | *-k*bsd-gnu*) + pthreadlibs ="" + ;; + *-gnu*) + pthreadlibs="-lpthread" + ;; +esac + +AC_SUBST(PTHREADLIBS,$pthreadlibs) AC_SUBST(DBTYPE, $enable_backend) AC_SUBST(DB4LIBS, $db4libs) AC_SUBST(KEYD, $enable_keyd)
Index: onak-0.4.5/Makefile.in =================================================================== --- onak-0.4.5.orig/Makefile.in +++ onak-0.4.5/Makefile.in @@ -11,6 +11,7 @@ DBTYPE = @DBTYPE@ # LIBS = @LIBS@ @NETTLE_LIBS@ DB4LIBS = @DB4LIBS@ +PTHREADLIBS = @PTHREADLIBS@ CURLLIBS = @LIBCURL@ #MAKEDEPEND = makedepend -f- -- MAKEDEPEND = $(CC) -MM @@ -139,7 +140,7 @@ add: add.o cleankey.o $(CORE_OBJS) $(KEY onak: onak.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ) $(CC) $(LDFLAGS) -o onak onak.o cleankey.o \ - $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA) + $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA) $(PTHREADLIBS) onak-conf.o: onak-conf.c onak-conf.h $(CC) $(CFLAGS) -DCONFIGFILE=\"@sysconfdir@/onak.conf\" \

