1 # Copyright (C) 1991-1999, 2000, 2001, 2002, 2003, 2005, 2006
2 # Free Software Foundation, Inc.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, write to the Free
17 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 # Makefile for malloc routines
27 dist-headers
:= malloc.h
28 headers
:= $(dist-headers
) obstack.h mcheck.h
29 tests
:= mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
30 tst-mallocstate tst-mcheck tst-mallocfork
31 test-srcs
= tst-mtrace
33 distribute
= thread-m.h mtrace.pl mcheck-init.c stackinfo.h memusage.h \
34 memusage.sh memusagestat.c tst-mtrace.sh arena.c hooks.c
36 # Things which get pasted together into gmalloc.c.
37 gmalloc-routines
:= malloc morecore
38 # Things to include in the standalone distribution.
39 dist-routines
= $(gmalloc-routines
) mcheck mtrace
40 routines
= $(dist-routines
) obstack
42 install-lib
:= libmcheck.a
43 non-lib.a
:= libmcheck.a
46 extra-libs
= libmemusage
47 extra-libs-others
= $(extra-libs
)
49 libmemusage-routines
= memusage
50 libmemusage-inhibit-o
= $(filter-out .os
,$(object-suffixes
))
52 # These should be removed by `make clean'.
53 extra-objs
= mcheck-init.o libmcheck.a
55 # Include the cleanup handler.
56 aux
:= set-freeres thread-freeres
60 CPPFLAGS-memusagestat
= -DNOT_IN_libc
62 # The Perl script to analyze the output of the mtrace functions.
64 install-bin-script
= mtrace
67 # The Perl script will print addresses and to do this nicely we must know
68 # whether we are on a 32 or 64 bit machine.
69 ifneq ($(findstring wordsize-32
,$(config-sysdirs
)),)
76 # Unless we get a test for the availability of libgd which also works
77 # for cross-compiling we disable the memusagestat generation in this
79 ifneq ($(cross-compiling
),yes
)
80 # If the gd library is available we build the `memusagestat' program.
82 others
: $(objpfx
)memusage
83 install-bin
= memusagestat
84 install-bin-script
+= memusage
85 generated
+= memusagestat memusage
86 extra-objs
+= memusagestat.o
88 # The configure.in check for libgd and its headers did not use $SYSINCLUDES.
89 # The directory specified by --with-headers usually contains only the basic
90 # kernel interface headers, not something like libgd. So the simplest thing
91 # is to presume that the standard system headers will be ok for this file.
92 $(objpfx
)memusagestat.o
: sysincludes
= # nothing
96 # Another goal which can be used to override the configure decision.
97 .PHONY
: do-memusagestat
98 do-memusagestat
: $(objpfx
)memusagestat
100 memusagestat-modules
= memusagestat
101 $(objpfx
)memusagestat
: $(memusagestat-modules
:%=$(objpfx
)%.o
)
102 $(LINK.o
) -o
$@
$^
$(libgd-LDFLAGS
) -lgd
-lpng
-lz
-lm
106 CFLAGS-mcheck-init.c
= $(PIC-ccflag
)
108 $(objpfx
)libmcheck.a
: $(objpfx
)mcheck-init.o
110 $(patsubst %/,cd
% &&,$(objpfx
)) \
113 lib
: $(objpfx
)libmcheck.a
115 ifeq (no
,$(cross-compiling
))
116 ifeq (yes
,$(build-shared
))
118 tests
: $(objpfx
)tst-mtrace.out
119 $(objpfx
)tst-mtrace.out
: tst-mtrace.sh
$(objpfx
)tst-mtrace
120 $(SHELL
) -e
$< $(common-objpfx
)
125 tst-mcheck-ENV
= MALLOC_CHECK_
=3
127 # Uncomment this for test releases. For public releases it is too expensive.
128 #CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
130 sLIBdir
:= $(shell echo
$(slibdir
) | sed
's,lib\(\|64\)$$,\\\\$$LIB,')
132 $(objpfx
)mtrace
: mtrace.pl
134 sed
-e
's|@PERL@|$(PERL)|' -e
's|@XXX@|$(address-width)|' \
135 -e
's|@VERSION@|$(version)|' $^
> $@.new \
136 && rm -f
$@
&& mv
$@.new
$@
&& chmod
+x
$@
138 $(objpfx
)memusage
: memusage.sh
140 sed
-e
's|@BASH@|$(BASH)|' -e
's|@VERSION@|$(version)|' \
141 -e
's|@SLIBDIR@|$(sLIBdir)|' -e
's|@BINDIR@|$(bindir)|' $^
> $@.new \
142 && rm -f
$@
&& mv
$@.new
$@
&& chmod
+x
$@
145 # The implementation uses `dlsym'
146 $(objpfx
)libmemusage.so
: $(common-objpfx
)dlfcn
/libdl.so
$(elfobjdir
)/ld.so
149 $(foreach o
,$(all-object-suffixes
),$(objpfx
)malloc
$(o
)): arena.c hooks.c