* sysdeps/unix/sysv/linux/getcwd.c (__getcwd): Use larger of PATH_MAX
[glibc.git] / malloc / Makefile
blobc479da39b71ed9db204e638b4c94f6c2a5a54e0f
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.
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
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 install-bin = memusagestat
83 install-bin-script += memusage
84 generated += memusagestat memusage
85 extra-objs += memusagestat.o
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
92 endif
93 endif
95 # Another goal which can be used to override the configure decision.
96 .PHONY: do-memusagestat
97 do-memusagestat: $(objpfx)memusagestat
99 memusagestat-modules = memusagestat
100 $(objpfx)memusagestat: $(memusagestat-modules:%=$(objpfx)%.o)
101 $(LINK.o) -o $@ $^ $(libgd-LDFLAGS) -lgd -lpng -lz -lm
103 include ../Rules
105 CFLAGS-mcheck-init.c = $(PIC-ccflag)
107 $(objpfx)libmcheck.a: $(objpfx)mcheck-init.o
108 -rm -f $@
109 $(patsubst %/,cd % &&,$(objpfx)) \
110 $(LN_S) $(<F) $(@F)
112 lib: $(objpfx)libmcheck.a
114 ifeq (no,$(cross-compiling))
115 ifeq (yes,$(build-shared))
116 ifneq ($(PERL),no)
117 tests: $(objpfx)tst-mtrace.out
118 $(objpfx)tst-mtrace.out: tst-mtrace.sh $(objpfx)tst-mtrace
119 $(SHELL) -e $< $(common-objpfx)
120 endif
121 endif
122 endif
124 tst-mcheck-ENV = MALLOC_CHECK_=3
126 # Uncomment this for test releases. For public releases it is too expensive.
127 #CPPFLAGS-malloc.o += -DMALLOC_DEBUG=1
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 $@
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 $@
142 # The implementation uses `dlsym'
143 $(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so $(elfobjdir)/ld.so
145 # Extra dependencies
146 $(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c