---
 configure.ac    |    6 +++++-
 src/Makefile.am |    4 +++-
 2 files changed, 8 insertions(+), 2 deletions(-)

Index: libedit/configure.ac
===================================================================
--- libedit.orig/configure.ac
+++ libedit/configure.ac
@@ -126,7 +126,7 @@ AC_PROG_GCC_TRADITIONAL
 #AC_FUNC_REALLOC
 AC_TYPE_SIGNAL
 AC_FUNC_STAT
-AC_CHECK_FUNCS([endpwent isascii memchr memset re_comp regcomp strcasecmp strchr strcspn strdup strerror strrchr strstr strtol issetugid wcsdup getline __secure_getenv secure_getenv])
+AC_CHECK_FUNCS([endpwent isascii memchr memset re_comp regcomp strcasecmp strchr strcspn strdup strerror strrchr strstr strtol issetugid getline __secure_getenv secure_getenv])
 
 # fgetln
 AC_CHECK_FUNCS(fgetln, found_fgetln=yes, found_fgetln=no)
@@ -148,6 +148,10 @@ AM_CONDITIONAL(HAVE_VIS, [test "x$found_
 AC_CHECK_FUNCS(unvis, found_unvis=yes, found_unvis=no)
 AM_CONDITIONAL(HAVE_UNVIS, [test "x$found_unvis" = xyes])
 
+# wcsdup
+AC_CHECK_FUNCS(wcsdup, found_wcsdup=yes, found_wcsdup=no)
+AM_CONDITIONAL(HAVE_WCSDUP, [test "x$found_wcsdup" = xyes])
+
 
 EL_GETPW_R_POSIX
 EL_GETPW_R_DRAFT
Index: libedit/src/Makefile.am
===================================================================
--- libedit.orig/src/Makefile.am
+++ libedit/src/Makefile.am
@@ -27,7 +27,6 @@ CLEANFILES = $(BUILT_SOURCES)
 lib_LTLIBRARIES    = libedit.la
 libedit_la_SOURCES = chared.c common.c el.c eln.c emacs.c hist.c keymacro.c map.c chartype.c parse.c \
 							prompt.c read.c refresh.c search.c sig.c terminal.c tty.c vi.c \
-							wcsdup.c \
 							tokenizer.c tokenizern.c \
 							history.c historyn.c \
 							filecomplete.c readline.c chared.h literal.c el.h hist.h \
@@ -35,6 +34,9 @@ libedit_la_SOURCES = chared.c common.c e
 							search.h sig.h sys.h terminal.h tty.h vis.h filecomplete.h \
 							editline/readline.h literal.h
 
+if !HAVE_WCSDUP
+libedit_la_SOURCES += wcsdup.c
+endif
 if !HAVE_STRLCPY
 libedit_la_SOURCES += strlcpy.c
 endif
