File: ac_dmalloc.m4

package info (click to toggle)
adios 1.3-11
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 7,376 kB
  • sloc: ansic: 48,186; sh: 9,682; cpp: 2,662; f90: 1,390; makefile: 895; python: 372; xml: 301
file content (62 lines) | stat: -rw-r--r-- 1,414 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#
#
# AC_DMALLOC
#
#
#
dnl @synopsis AC_DMALLOC
dnl
dnl This macro test if dmalloc is to be used. 
dnl Use in C code:
dnl     #ifdef DMALLOC
dnl     #include "dmalloc.h"
dnl     #endif
dnl
dnl @version 1.0
dnl @author Norbert Podhorszki, ORNL
dnl
AC_DEFUN([AC_DMALLOC],[

AM_CONDITIONAL(HAVE_DMALLOC,true)

AC_ARG_WITH(dmalloc,
        [  --with-dmalloc=DIR      Location of dmalloc library],
        [DMALLOC_LDFLAGS="-L$withval/lib";
         DMALLOC_CPPFLAGS="-I$withval/include";])

save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
save_LDFLAGS="$LDFLAGS"
LIBS="$LIBS -ldmalloc"
LDFLAGS="$LDFLAGS $DMALLOC_LDFLAGS"
CPPFLAGS="$CPPFLAGS $DMALLOC_CPPFLAGS"

if test -z "${HAVE_DMALLOC_TRUE}"; then
        AC_CHECK_HEADERS(dmalloc.h,
                ,
                [AM_CONDITIONAL(HAVE_DMALLOC,false)])
fi

# Check for the dmalloc library and headers
AC_TRY_COMPILE([#include "dmalloc.h"],
        [char * s; s=malloc(sizeof(char)*10); free(s);],
        [DMALLOC_LIBS="-ldmallocth"],
        [AM_CONDITIONAL(HAVE_DMALLOC,false)])

LIBS="$save_LIBS"
LDFLAGS="$save_LDFLAGS"
CPPFLAGS="$save_CPPFLAGS"

AC_SUBST(DMALLOC_LIBS)
AC_SUBST(DMALLOC_LDFLAGS)
AC_SUBST(DMALLOC_CPPFLAGS)

# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
if test -z "${HAVE_DMALLOC_TRUE}"; then
        ifelse([$1],,[AC_DEFINE(HAVE_DMALLOC,1,[Define if you have DMALLOC.])],[$1])
        :
else
        $2
        :
fi
])dnl AC_DMALLOC