]> git.ipfire.org Git - thirdparty/glibc.git/blame - malloc/Makefile
Update.
[thirdparty/glibc.git] / malloc / Makefile
CommitLineData
e8783fd5 1# Copyright (C) 1991-1999,2000,2001,2002,2003 Free Software Foundation, Inc.
f65fd747
UD
2# This file is part of the GNU C Library.
3
4# The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5# modify it under the terms of the GNU Lesser General Public
6# License as published by the Free Software Foundation; either
7# version 2.1 of the License, or (at your option) any later version.
f65fd747
UD
8
9# The GNU C Library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12# Lesser General Public License for more details.
f65fd747 13
41bdb6e2
AJ
14# You should have received a copy of the GNU Lesser General Public
15# License along with the GNU C Library; if not, write to the Free
16# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17# 02111-1307 USA.
f65fd747
UD
18
19#
20# Makefile for malloc routines
21#
33a934a3 22subdir := malloc
f65fd747
UD
23
24all:
25
26dist-headers := malloc.h
bd355af0 27headers := $(dist-headers) obstack.h mcheck.h
fa8d436c
UD
28tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
29 tst-mallocstate
199d6eb0 30test-srcs = tst-mtrace
f65fd747 31
e5874a42 32distribute = thread-m.h mtrace.pl mcheck-init.c stackinfo.h memusage.h \
fa8d436c 33 memusage.sh memusagestat.c tst-mtrace.sh arena.c hooks.c
f65fd747
UD
34
35# Things which get pasted together into gmalloc.c.
36gmalloc-routines := malloc morecore
37# Things to include in the standalone distribution.
6d52618b 38dist-routines = $(gmalloc-routines) mcheck mtrace
f65fd747
UD
39routines = $(dist-routines) obstack
40
6d52618b
UD
41install-lib := libmcheck.a
42non-lib.a := libmcheck.a
43
c8f3e6db 44# Additional library.
e5874a42 45extra-libs = libmemusage
c8f3e6db
UD
46extra-libs-others = $(extra-libs)
47
e5874a42
UD
48libmemusage-routines = memusage
49libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
c8f3e6db 50
6d52618b 51# These should be removed by `make clean'.
469e977f 52extra-objs = mcheck-init.o libmcheck.a
6d52618b 53
a5a0310d 54# Include the cleanup handler.
e8783fd5 55aux := set-freeres thread-freeres
a5a0310d 56
a8a1269d
UD
57include ../Makeconfig
58
3ba06713
UD
59CPPFLAGS-memusagestat = -DNOT_IN_libc
60
eacde9d0 61# The Perl script to analyze the output of the mtrace functions.
a2b08ee5 62ifneq ($(PERL),no)
6c3ebebd 63install-bin-script = mtrace
da2d1bc5 64generated = mtrace
a2b08ee5
UD
65
66# The Perl script will print addresses and to do this nicely we must know
67# whether we are on a 32 or 64 bit machine.
737547be 68ifneq ($(findstring wordsize-32,$(config-sysdirs)),)
a2b08ee5
UD
69address-width=10
70else
71address-width=18
72endif
73endif
74
48d99185
UD
75# Unless we get a test for the availability of libgd which also works
76# for cross-compiling we disable the memusagestat generation in this
77# situation.
78ifneq ($(cross-compiling),yes)
e5874a42 79# If the gd library is available we build the `memusagestat' program.
c8f3e6db 80ifneq ($(LIBGD),no)
6c3ebebd 81install-bin = memusagestat memusage
991dca90 82generated += memusagestat memusage
469e977f 83extra-objs += memusagestat.o
c843e065
RM
84
85# The configure.in check for libgd and its headers did not use $SYSINCLUDES.
86# The directory specified by --with-headers usually contains only the basic
87# kernel interface headers, not something like libgd. So the simplest thing
88# is to presume that the standard system headers will be ok for this file.
89$(objpfx)memusagestat.o: sysincludes = # nothing
c8f3e6db 90endif
48d99185 91endif
c8f3e6db
UD
92
93# Another goal which can be used to override the configure decision.
e5874a42
UD
94.PHONY: do-memusagestat
95do-memusagestat: $(objpfx)memusagestat
c8f3e6db 96
e5874a42
UD
97memusagestat-modules = memusagestat
98$(objpfx)memusagestat: $(memusagestat-modules:%=$(objpfx)%.o)
580ca83f 99 $(LINK.o) -o $@ $^ $(libgd-LDFLAGS) -lgd -lpng -lz -lm
c8f3e6db 100
f65fd747
UD
101include ../Rules
102
6d52618b
UD
103$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
104 -rm -f $@
e7c5513d
UD
105 $(patsubst %/,cd % &&,$(objpfx)) \
106 $(LN_S) $(<F) $(@F)
6d52618b
UD
107
108lib: $(objpfx)libmcheck.a
109
77e4b6fe 110ifeq (no,$(cross-compiling))
02ba6e61 111ifeq (yes,$(build-shared))
9317ba7c 112ifneq ($(PERL),no)
3f36c563
UD
113tests: $(objpfx)tst-mtrace.out
114$(objpfx)tst-mtrace.out: tst-mtrace.sh $(objpfx)tst-mtrace
199d6eb0 115 $(SHELL) -e $< $(common-objpfx)
02ba6e61 116endif
77e4b6fe 117endif
9317ba7c 118endif
199d6eb0 119
831372e7 120# Uncomment this for test releases. For public releases it is too expensive.
fa8d436c 121#CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
a2b08ee5
UD
122
123$(objpfx)mtrace: mtrace.pl
dfd2257a 124 rm -f $@.new
a2b08ee5
UD
125 sed -e 's|@PERL@|$(PERL)|' -e 's|@XXX@|$(address-width)|' \
126 -e 's|@VERSION@|$(version)|' $^ > $@.new \
43fc8f18
UD
127 && rm -f $@ && mv $@.new $@ && chmod +x $@
128
e5874a42 129$(objpfx)memusage: memusage.sh
43fc8f18 130 rm -f $@.new
926de5eb 131 sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
3ebab9ee 132 -e 's|@SLIBDIR@|$(slibdir)|' -e 's|@BINDIR@|$(bindir)|' $^ > $@.new \
43fc8f18
UD
133 && rm -f $@ && mv $@.new $@ && chmod +x $@
134
8f48bfcc
UD
135
136# The implementation uses `dlsym'
e5874a42 137$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so
fa8d436c
UD
138
139# Extra dependencies
140$(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c