Subject: net/tnftp and undefined reference to `strunvis'
To: None <tech-pkg@netbsd.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: tech-pkg
Date: 11/28/2007 18:40:29
Why doesn't net/tnftp use libnbcompat? (I don't know if that would 
immediately fix my problem though.)

Building net/tnftp on my pkglinux fails with:

cc -pipe -g -I/usr/include -L../libedit 
-L/usr/gcc3/lib/gcc-lib/i386-pc-linux-gnu/3.3.5 
-Wl,-R/usr/gcc3/lib/gcc-lib/i386-pc-linux-gnu/3.3.5 -L/usr/gcc3/lib 
-Wl,-R/usr/gcc3/lib -L/usr/lib -Wl,-R/usr/lib -L../libnetbsd -o ftp cmds.o 
cmdtab.o complete.o domacro.o fetch.o ftp.o main.o progressbar.o 
ruserpass.o util.o -ledit -ledit -lncurses  -lnetbsd
../libedit/libedit.a(history.o)(.text+0xc82): In function `history_load':
/scratch2/pkgsrc/net/tnftp/work.puget/tnftp-20070806/libedit/history.c:677: 
undefined reference to `strunvis'


and strvis



This package builds its own libnetbsd and libedit. The libnetbsd/config.h 
is configured with:

/* Define to 1 if you have the `strunvis' function. */
#define HAVE_STRUNVIS 1

/* Define to 1 if you have the `strvis' function. */
#define HAVE_STRVIS 1

/* Define to 1 if you have the <vis.h> header file. */
/* #undef HAVE_VIS_H */


So no header, but the strunvis.c and strvis.c are never compiled.

The configure assumes if functions exist it shouldn't build them. That is 
fine.  But then it doesn't link with the libedit that do contain them. But 
links to tnftp's libedit and libnetbsd instead which do not.

(Notice it has -ledit -ledit twice.)

My installed libedit is libedit-20041207.2.9 from wip/editline (all 
LOCALBASE is /usr).

My workaround is here:

--- ./libedit/Makefile.in.orig	2007-11-28 18:21:08.000000000 -0600
+++ ./libedit/Makefile.in	2007-11-28 18:21:19.000000000 -0600
@@ -12,7 +12,7 @@
 AR	= @AR@
 RANLIB	= @RANLIB@
 
-LIB	= libedit.a
+LIB	= libtnedit.a
 
 SRCS	= chared.c common.c el.c emacs.c fcns.c help.c hist.c key.c map.c \
 	  parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c \

--- ./configure.orig	2007-11-28 18:22:52.000000000 -0600
+++ ./configure	2007-11-28 18:33:21.000000000 -0600
@@ -9533,9 +9533,9 @@
 echo "${ECHO_T}no - using my own" >&6; }
               INCLUDES="-I\${srcdir}/../libedit $INCLUDES"
               LDFLAGS="-L../libedit $LDFLAGS"
-              LIBS="-ledit $LIBS"
-              LIBEDIT=libedit.a
-              LIBDEPENDS="$LIBDEPENDS ../libedit/libedit.a"
+              LIBS="-ltnedit $LIBS"
+              LIBEDIT=libtnedit.a
+              LIBDEPENDS="$LIBDEPENDS ../libedit/libtnedit.a"
 else
   { echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6; }

--- ./Makefile.in.orig	2007-11-28 18:27:05.000000000 -0600
+++ ./Makefile.in	2007-11-28 18:27:24.000000000 -0600
@@ -15,7 +15,7 @@
 ftp:	@LIBEDIT@ @LIBNETBSD@
 	( cd src; ${MAKE} )
 
-libedit.a:
+libtnedit.a:
 	( cd libedit; ${MAKE} )
 
 libnetbsd.a:



And it links with both -ltnedit and -ledit.

(Sorry no configure.ac updated here.)

Long ago, I forced tnftp to use wip/editline which is NetBSD's Editline 
library (libedit). But never committed any of that. This above is not 
using that change.