From: Ole Streicher <debian@liska.ath.cx>
Date: Tue, 25 Oct 2016 21:52:53 +0200
Subject: Link the executables against libfuntools.so

and link libfuntools.so against the needed libs.
---
 Makefile.in  | 6 +++---
 configure.ac | 4 +---
 mklib        | 1 -
 3 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index f935b9d..d5a0536 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -160,7 +160,7 @@ LIB =		@LIB@
 
 # this is used in the link line
 # LLIB =	$(LIB)
-LLIB =		@LLIB@
+LLIB =		-L. -lfuntools
 
 # libraries containing main as subroutines
 MAINLIB =	lib$(PACKAGE)MainLib.a
@@ -228,7 +228,7 @@ shlib:		sublib $(LIBOBJS)
 		@(rm -rf $(PACKAGE)tmp; mkdir $(PACKAGE)tmp; \
 		(cd $(PACKAGE)tmp && ar x ../$(LIB)); \
 		CC='$(CC)' CXX=$(CXX) \
-		./mklib -o $(PACKAGE) $(PACKAGE)tmp/*.o; \
+		./mklib -o $(PACKAGE) -ldl $(WCS_LIBS) -lm -lz $(PACKAGE)tmp/*.o; \
 		rm -rf $(PACKAGE)tmp;)
 
 mainlib:	$(MAINLIBOBJS) funmainlib.o lex.calc.o
@@ -462,7 +462,7 @@ install-binaries: lib $(PROGS) $(SCRIPTS) $(DS9HELPERS)
 install-man:
 	@if [ ! -d $(MAN_INSTALL_DIR) ] ; then \
 	    echo "Making directory $(MAN_INSTALL_DIR)"; \
-	    mkdir $(MAN_INSTALL_DIR); \
+	    mkdir -p $(MAN_INSTALL_DIR); \
 	    chmod 755 $(MAN_INSTALL_DIR); \
 	    else true; \
 	fi;
diff --git a/configure.ac b/configure.ac
index f0a0dfc..4a1ecd8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,7 @@ AC_SUBST(DEFLIB)
 
 AC_MSG_CHECKING(for external zlib)
 AC_ARG_WITH(zlib, [ --with-zlib=LIB  library name],
-	zlib=yes EXTRA_LIBS="$EXTRA_LIBS $withval", zlib=no)
+	zlib=yes, zlib=no)
 AC_MSG_RESULT($zlib)
 
 AC_MSG_CHECKING(for external wcslib)
@@ -99,7 +99,6 @@ if test "$fun_ok" != "no"; then
     if test "$have_dl" = yes; then
       using_shlib="yes"
       fpic="yes"
-      EXTRA_LIBS="$EXTRA_LIBS -ldl"  
       if test `$CC -v -rdynamic 2>&1 | grep -c unrecognized` = "0" ; then
         LDFLAGS="$LDFLAGS -rdynamic"
       fi
@@ -136,7 +135,6 @@ if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
     if test "$have_dl" = yes; then
       USE_DL="-DUSE_DL=1"
       fpic="yes"
-      EXTRA_LIBS="$EXTRA_LIBS -ldl"  
       if test `$CC -v -rdynamic 2>&1 | grep -c unrecognized` = "0" ; then
         LDFLAGS="$LDFLAGS -rdynamic"
       fi
diff --git a/mklib b/mklib
index c900b3e..2f99336 100755
--- a/mklib
+++ b/mklib
@@ -34,7 +34,6 @@ MINOR=0
 PATCH=""
 DEPS=""
 LINK=""
-LDFLAGS=""
 CPLUSPLUS=0
 STATIC=0
 DLOPEN=0
