2.12.90-20
[glibc.git] / malloc / Makefile
blobe7ec1abf93c4fe1fe69b88fece40df9b2c1ca970
1 # Copyright (C) 1991-1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2009
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
18 # 02111-1307 USA.
21 # Makefile for malloc routines
23 subdir := malloc
25 all:
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 tst-trim1
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
45 # Additional library.
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
58 include ../Makeconfig
60 CPPFLAGS-memusagestat = -DNOT_IN_libc
62 # The Perl script to analyze the output of the mtrace functions.
63 ifneq ($(PERL),no)
64 install-bin-script = mtrace
65 generated = 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)),)
70 address-width=10
71 else
72 address-width=18
73 endif
74 endif
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
78 # situation.
79 ifneq ($(cross-compiling),yes)
80 # If the gd library is available we build the `memusagestat' program.
81 ifneq ($(LIBGD),no)
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
93 endif
94 endif
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
104 include ../Rules
106 CFLAGS-mcheck-init.c = $(PIC-ccflag)
107 CFLAGS-obstack.c = $(uses-callbacks)
109 $(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
110 -rm -f $@
111 $(patsubst %/,cd % &&,$(objpfx)) \
112 $(LN_S) $(<F) $(@F)
114 lib: $(objpfx)libmcheck.a
116 ifeq (no,$(cross-compiling))
117 ifeq (yes,$(build-shared))
118 ifneq ($(PERL),no)
119 tests: $(objpfx)tst-mtrace.out
120 $(objpfx)tst-mtrace.out: tst-mtrace.sh $(objpfx)tst-mtrace
121 $(SHELL) -e $< $(common-objpfx)
122 endif
123 endif
124 endif
126 tst-mcheck-ENV = MALLOC_CHECK_=3
128 ifeq ($(experimental-malloc),yes)
129 CPPFLAGS-malloc.c += -DPER_THREAD -DATOMIC_FASTBINS
130 endif
131 # Uncomment this for test releases. For public releases it is too expensive.
132 #CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
134 sLIBdir := $(shell echo $(slibdir) | sed 's,lib\(\|64\)$$,\\\\$$LIB,')
136 $(objpfx)mtrace: mtrace.pl
137 rm -f $@.new
138 sed -e 's|@PERL@|$(PERL)|' -e 's|@XXX@|$(address-width)|' \
139 -e 's|@VERSION@|$(version)|' $^ > $@.new \
140 && rm -f $@ && mv $@.new $@ && chmod +x $@
142 $(objpfx)memusage: memusage.sh
143 rm -f $@.new
144 sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
145 -e 's|@SLIBDIR@|$(sLIBdir)|' -e 's|@BINDIR@|$(bindir)|' $^ > $@.new \
146 && rm -f $@ && mv $@.new $@ && chmod +x $@
149 # The implementation uses `dlsym'
150 $(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so $(elfobjdir)/ld.so
152 # Extra dependencies
153 $(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c