aboutsummaryrefslogtreecommitdiff
path: root/m4/nx-macros.m4
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-07-21 12:31:09 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-08-25 10:06:49 +0200
commitc350873c7c977efe5210484f04160be45f84ba7e (patch)
tree717d33eb315f4def1307d65108d14715696cd5cf /m4/nx-macros.m4
parent1472e7e37838f17b7ed948fa206e8c3434a9d346 (diff)
downloadnx-libs-c350873c7c977efe5210484f04160be45f84ba7e.tar.gz
nx-libs-c350873c7c977efe5210484f04160be45f84ba7e.tar.bz2
nx-libs-c350873c7c977efe5210484f04160be45f84ba7e.zip
Convert nx-X11/lib/ build flow from imake to autotools.
Diffstat (limited to 'm4/nx-macros.m4')
-rw-r--r--m4/nx-macros.m447
1 files changed, 47 insertions, 0 deletions
diff --git a/m4/nx-macros.m4 b/m4/nx-macros.m4
index 61acfb58a..b40f628b0 100644
--- a/m4/nx-macros.m4
+++ b/m4/nx-macros.m4
@@ -304,6 +304,53 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])],
[AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
]) # NX_DEFAULT_OPTIONS
+# NX_CHECK_MALLOC_ZERO
+# ----------------------
+# Minimum version: 1.0.0
+#
+# Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if
+# malloc(0) returns NULL. Packages should add one of these cflags to
+# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
+AC_DEFUN([NX_CHECK_MALLOC_ZERO],[
+AC_ARG_ENABLE(malloc0returnsnull,
+ AS_HELP_STRING([--enable-malloc0returnsnull],
+ [malloc(0) returns NULL (default: auto)]),
+ [MALLOC_ZERO_RETURNS_NULL=$enableval],
+ [MALLOC_ZERO_RETURNS_NULL=auto])
+
+AC_MSG_CHECKING([whether malloc(0) returns NULL])
+if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([
+#include <stdlib.h>
+],[
+ char *m0, *r0, *c0, *p;
+ m0 = malloc(0);
+ p = malloc(10);
+ r0 = realloc(p,0);
+ c0 = calloc(0,10);
+ exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1);
+])],
+ [MALLOC_ZERO_RETURNS_NULL=yes],
+ [MALLOC_ZERO_RETURNS_NULL=no],
+ [MALLOC_ZERO_RETURNS_NULL=yes])
+fi
+AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL])
+
+if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then
+ MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL"
+ XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS
+ XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC"
+else
+ MALLOC_ZERO_CFLAGS=""
+ XMALLOC_ZERO_CFLAGS=""
+ XTMALLOC_ZERO_CFLAGS=""
+fi
+
+AC_SUBST([MALLOC_ZERO_CFLAGS])
+AC_SUBST([XMALLOC_ZERO_CFLAGS])
+AC_SUBST([XTMALLOC_ZERO_CFLAGS])
+]) # NX_CHECK_MALLOC_ZERO
+
dnl Check to see if we're running under Cygwin32.