On Linux, define _GNU_SOURCE so that GNU libc exposes the wcwidth()
[mmh] / configure.in
index 3b9f44c..e113860 100644 (file)
@@ -444,6 +444,25 @@ AC_SUBST(MAIL_SPOOL_GRP)dnl
 dnl ------------------
 dnl CHECK HEADER FILES
 dnl ------------------
+
+dnl On glibc we need to define at least the '_XOPEN_SOURCE' level of features,
+dnl or wchar.h doesn't declare a prototype for wcwidth(). But if we only define
+dnl that level then db.h won't compile. So we define _GNU_SOURCE which turns
+dnl on everything. Perhaps other OSes need some feature switch set to get wcwidth()
+dnl declared; if so they should have an entry added to this case statement.
+dnl NB that we must define this on the compiler command line, not in config.h,
+dnl because it must be set before any system header is included and there's no
+dnl portable way to make sure that files generated by lex include config.h
+dnl before system header files.
+
+case "$target_os" in
+  linux*)
+    # Like DEFS, but doesn't get stomped on by configure when using config.h:
+    OURDEFS="$OURDEFS -D_GNU_SOURCE"
+    ;;
+esac
+AC_SUBST(OURDEFS)
+
 AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_HEADER_TIME
@@ -984,6 +1003,7 @@ target os                  : ${target}
 compiler                   : ${CC}
 compiler flags             : ${CFLAGS}
 linker flags               : ${LDFLAGS}
+definitions                : ${OURDEFS}
 source code location       : ${srcdir}
 binary install path        : ${nmhbin2}
 libary install path        : ${nmhlib2}