OBJS+= ${SRCS:.c=.o}
-# This is for NetBSD which has two dynamic linkers and we need to
-# use the right one.
+# This is for NetBSD which has a different libc in /lib which we need
+# to link to if installing in /
+_RPATH_SH= if test "${PREFIX}" = "" -o "${PREIX}" = "/"; then \
+ echo "-Wl,-rpath=${PREFIX}/${LIBNAME}"; \
+ else \
+ echo ""; \
+ fi
+_RPATH!= ${_RPATH_SH}
+LDFLAGS+= ${_RPATH}$(shell ${_RPATH_SH})
+
+# This is for NetBSD which has different dynamic linker in /lib which we need
+# to use to if installing in /
_DYNLINK_SH= if test "${PREFIX}" = "" -o "${PREFIX}" = "/" && test -e /libexec/ld.elf_so; then \
echo "-Wl,-dynamic-linker=/libexec/ld.elf_so"; \
else \
INSTALL?= install
SED?= sed
+
+_LIBNAME_SH= case `readlink /lib` in "") echo "lib";; *) basename `readlink /lib`;; esac
+_LIBNAME!= ${_LIBNAME_SH}
+LIBNAME?= ${_LIBNAME}$(shell ${_LIBNAME_SH})