source: branches/libc-0.6/src/libctests/glibc/malloc/Makefile

Last change on this file was 2036, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1# Copyright (C) 1991-1999, 2000, 2001, 2002, 2003, 2005
2# Free Software Foundation, Inc.
3# This file is part of the GNU C Library.
4
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.
9
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.
14
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.
19
20#
21# Makefile for malloc routines
22#
23subdir := malloc
24
25all:
26
27dist-headers := malloc.h
28headers := $(dist-headers) obstack.h mcheck.h
29tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
30 tst-mallocstate tst-mcheck
31test-srcs = tst-mtrace
32
33distribute = thread-m.h mtrace.pl mcheck-init.c stackinfo.h memusage.h \
34 memusage.sh memusagestat.c tst-mtrace.sh arena.c hooks.c
35
36# Things which get pasted together into gmalloc.c.
37gmalloc-routines := malloc morecore
38# Things to include in the standalone distribution.
39dist-routines = $(gmalloc-routines) mcheck mtrace
40routines = $(dist-routines) obstack
41
42install-lib := libmcheck.a
43non-lib.a := libmcheck.a
44
45# Additional library.
46extra-libs = libmemusage
47extra-libs-others = $(extra-libs)
48
49libmemusage-routines = memusage
50libmemusage-inhibit-o = $(filter-out .os,$(object-suffixes))
51
52# These should be removed by `make clean'.
53extra-objs = mcheck-init.o libmcheck.a
54
55# Include the cleanup handler.
56aux := set-freeres thread-freeres
57
58include ../Makeconfig
59
60CPPFLAGS-memusagestat = -DNOT_IN_libc
61
62# The Perl script to analyze the output of the mtrace functions.
63ifneq ($(PERL),no)
64install-bin-script = mtrace
65generated = mtrace
66
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.
69ifneq ($(findstring wordsize-32,$(config-sysdirs)),)
70address-width=10
71else
72address-width=18
73endif
74endif
75
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.
79ifneq ($(cross-compiling),yes)
80# If the gd library is available we build the `memusagestat' program.
81ifneq ($(LIBGD),no)
82install-bin = memusagestat
83install-bin-script += memusage
84generated += memusagestat memusage
85extra-objs += memusagestat.o
86
87# The configure.in check for libgd and its headers did not use $SYSINCLUDES.
88# The directory specified by --with-headers usually contains only the basic
89# kernel interface headers, not something like libgd. So the simplest thing
90# is to presume that the standard system headers will be ok for this file.
91$(objpfx)memusagestat.o: sysincludes = # nothing
92endif
93endif
94
95# Another goal which can be used to override the configure decision.
96.PHONY: do-memusagestat
97do-memusagestat: $(objpfx)memusagestat
98
99memusagestat-modules = memusagestat
100$(objpfx)memusagestat: $(memusagestat-modules:%=$(objpfx)%.o)
101 $(LINK.o) -o $@ $^ $(libgd-LDFLAGS) -lgd -lpng -lz -lm
102
103include ../Rules
104
105CFLAGS-mcheck-init.c = $(PIC-ccflag)
106
107$(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
108 -rm -f $@
109 $(patsubst %/,cd % &&,$(objpfx)) \
110 $(LN_S) $(<F) $(@F)
111
112lib: $(objpfx)libmcheck.a
113
114ifeq (no,$(cross-compiling))
115ifeq (yes,$(build-shared))
116ifneq ($(PERL),no)
117tests: $(objpfx)tst-mtrace.out
118$(objpfx)tst-mtrace.out: tst-mtrace.sh $(objpfx)tst-mtrace
119 $(SHELL) -e $< $(common-objpfx)
120endif
121endif
122endif
123
124tst-mcheck-ENV = MALLOC_CHECK_=3
125
126# Uncomment this for test releases. For public releases it is too expensive.
127#CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
128
129$(objpfx)mtrace: mtrace.pl
130 rm -f $@.new
131 sed -e 's|@PERL@|$(PERL)|' -e 's|@XXX@|$(address-width)|' \
132 -e 's|@VERSION@|$(version)|' $^ > $@.new \
133 && rm -f $@ && mv $@.new $@ && chmod +x $@
134
135$(objpfx)memusage: memusage.sh
136 rm -f $@.new
137 sed -e 's|@BASH@|$(BASH)|' -e 's|@VERSION@|$(version)|' \
138 -e 's|@SLIBDIR@|$(slibdir)|' -e 's|@BINDIR@|$(bindir)|' $^ > $@.new \
139 && rm -f $@ && mv $@.new $@ && chmod +x $@
140
141
142# The implementation uses `dlsym'
143$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so
144
145# Extra dependencies
146$(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c
Note: See TracBrowser for help on using the repository browser.