1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247
|
# This Makefile is set up to make a debugging malloc called libmalloc_d.a
# and a non-debugging fast malloc called libmalloc.a.
# Also generates testmalloc, simumalloc, teststomp and maltrace (together
# with _d versions)
#
# 'make veryclean' cleans out lib*.a as well.
#
# 'make .lint' runs lint.
#
# 'make install' puts libmalloc.a and libmalloc_d.a in $LIBDIR and
# puts malloc.h in $INCDIR.
#
srcdir = @srcdir@
VPATH = @srcdir@
@SET_MAKE@
SHELL= /bin/sh
CC= @CC@
COPTS= @CFLAGS@
CPPFLAGS= @CPPFLAGS@
CPPDEP= @CPPDEP@
TOPDIR= ..
DEFS= @DEFS@
RANLIB= @RANLIB@
AR= ar
LIBC_INCL= @GENINCL@
LIBDIR= @libdir@
INSTALL= @INSTALL@
INCDIR= @incdir@
# neutralize SystemV genius
SHELL= /bin/sh
# DEBUGDEFS are set for libmalloc_d.a. Say 'make libmalloc' for nondebug
# version. (DEBUGDEFS=$(FASTDEFS))
#
DEBUGDEFS=-DDEBUG -DTRACE -DPROFILESIZES
# FASTDEFS are used when the 'libmalloc' target is made.
#
# -DTRACE and -DPROFILESIZES shouldn't introduce very much overhead since the
# former is turned off (one 'if'), and the latter is one 'if' + increment.
# So you can keep them even in the fast production version.
# You may want to define -DSVID_MALLOC_0 if you want malloc(0) to
# return NULL, per the SVID. Otherwise, I return a block that
# has zero size so it can then be passed to realloc().
#
FASTDEFS=#-DSVID_MALLOC_0 -DTRACE -DPROFILESIZES
# NORMALDEFS are used for both debugging and non-debugging versions
# -DSHORTNAMES makes sure all internal global symbols are unique within 6
# characters. Avoid defining unless your linker is braindead.
# -DUSESTDIO is to make this use fputs() instead of write() for trace
# and debugging output. write() is preferable since it is unbuffered,
# and does not call malloc() or suchlike. Avoid defining if possible.
# -DSTDHEADERS if you have ANSI standard header files (stdlib.h, string.h)
# This can be defined on Solaris2.1, Irix3.3.x, BSD3.3,
# 386BSD, BSD386 and other sufficiently Posix systems.
# -DHAVE_MMAP should be defined for SunOS4.x and other systems
# that have a general purpose mmap call that allows memory-mapped files.
#
NORMALDEFS= @CFLAGS@
EXTRAINCLUDES=-I$(HOME)/include
LINT=lint
LN= ln -s
AR= ar
ARFLAGS= ruv
TOPDIR= ..
RANLIB= @RANLIB@
LDFLAGS=#-Bstatic
EXT= @MALLOCEXT@
MALLOC= @MALLOC@
# only developers should have to change stuff below this line
PROGS= testmalloc$(EXT) simumalloc$(EXT) teststomp$(EXT) maltrace$(EXT)
DEFINES= $(CPPFLAGS) $(NORMALDEFS) $(DEBUGDEFS)
SPLAYOBJ = splay/sptree.o
SPLAYSRC = splay/sptree.c
SPLAYHDR = splay/sptree.h
SRCS = _emalloc.c _malloc.c _memalign.c \
_strdup.c _strsave.c botch.c \
dumpheap.c emalloc.c getmem.c leak.c \
malloc.c memalign.c setopts.c \
stats.c strdup.c strsave.c verify.c
OBJS = _emalloc.o _malloc.o _memalign.o \
_strdup.o _strsave.o botch.o \
dumpheap.o emalloc.o getmem.o leak.o \
malloc.o memalign.o setopts.o \
stats.o strdup.o strsave.o verify.o
# HDRS, DOCS, TESTS and EXTRAS are used when making distributions.
# so please keep them uptodate.
# bundle is smart enough not to include object files, RCS, executables,
# etc, and does subdirectories right, but there's often other files
# in the development directory...
# globals.c, version.c are included in malloc.c.
HDRS = align.h assert.h defs.h externs.h globals.c globals.h globrename.h \
malloc.h trace.h version.c
DOCS = README NOTE TODO CHANGES malloc.doc Makefile
TESTS = testmalloc.c test.out teststomp.c tests regress \
simumalloc.c
EXTRAS = splay
INCLUDES=-I./splay -I.. $(EXTRAINCLUDES)
CFLAGS= $(COPTS) $(INCLUDES) $(DEFS) $(DEFINES)
zmailer: lib$(MALLOC).a
all: pass clean lib$(MALLOC).a
pass: lib$(MALLOC).a $(PROGS) out$(EXT)
system:
# Nothing to do!
malloc:
$(MAKE) -f Makefile $(MFLAGS) CC="$(CC)" DEBUGDEFS="$(FASTDEFS)" \
EXT="" CDEBUGFLAGS="$(CDEBUGFLAGS)" pass
malloc_d:
$(MAKE) -f Makefile $(MFLAGS) CC="$(CC)" DEBUGDEFS="$(DEBUGDEFS)" \
EXT="_d" CDEBUGFLAGS="$(CDEBUGFLAGS)" pass
testmalloc$(EXT): testmalloc.c .lib$(EXT)
$(CC) $(CFLAGSM) -o $@ testmalloc.c -L. $(LIBMALLOC) ${LDFLAGS}
teststomp$(EXT): teststomp.c .lib$(EXT)
$(CC) $(CFLAGSM) -o $@ teststomp.c -L. $(LIBMALLOC) ${LDFLAGS}
simumalloc$(EXT): simumalloc.c .lib$(EXT)
$(CC) $(CFLAGSM) -DMYMALLOC -o $@ simumalloc.c -L. $(LIBMALLOC) ${LDFLAGS}
maltrace$(EXT): maltrace.c .lib$(EXT)
$(CC) $(CFLAGSM) -DMYMALLOC -o $@ maltrace.c -L. $(LIBMALLOC) ${LDFLAGS}
../libs/lib$(MALLOC).a: lib$(MALLOC).a
lib$(MALLOC).a: $(OBJS) $(SPLAYOBJ)
rm -f lib$(MALLOC).a
$(AR) $(ARFLAGS) lib$(MALLOC).a $(OBJS) $(SPLAYOBJ)
-$(RANLIB) lib$(MALLOC).a
cp -p lib$(MALLOC).a ../libs/lib$(MALLOC).a
-$(RANLIB) ../libs/lib$(MALLOC).a
touch .lib$(EXT)
$(SPLAYOBJ): .foo
cd splay; $(MAKE) $(MFLAGS) DEFINES="$(DEFINES)" DEFS="$(DEFS)" \
LIBMALLOC=$(TOPDIR)/$(LIBMALLOC) COPTS="$(COPTS)" CC="$(CC)"
out$(EXT): $(PROGS)
rm -f out$(EXT)
EXT=$(EXT); export EXT; ./regress > out$(EXT) 2>&1
@echo "Ok to get two core dumps if this is teststomp_d"
-(./teststomp$(EXT) 5; ./teststomp$(EXT) 8) >>out$(EXT) 2>&1
one: onefile.o
onefile.c: $(SRCS) $(SPLAYSRC)
rm -f onefile.c
cat $(SRCS) $(SPLAYSRC) | sed '/RCSID/d' > onefile.c
.lint: $(SRCS)
($(LINT) $(LINTFLAGS) $(DEFINES) $(INCLUDES) $(SRCS); \
$(LINT) $(LINTFLAGS) $(DEFINES) $(INCLUDES) -I$(TOPDIR) $(SPLAYSRC)) \
2>&1 | egrep -v 'pointer alignment|illegal pointer comb'
touch .lint
.foo:
cleanprogs:
-rm -f $(PROGS) $(LIBMALLOC) out$(EXT) trace$(EXT) .lib$(EXT)
clean:
-rm -f *.a *.o \#* *~ core a.out gmon.out mon.out onefile.c *.sL prof.out
cd splay; $(MAKE) clean
distclean veryclean: clean cleanprogs
make EXT= cleanprogs
-rm -f make.log make.out o core simumalloc_* Makefile */Makefile
install:
$(INSTALL) -m 644 libmalloc.a $(LIBDIR)
-$(RANLIB) $(LIBDIR)/libmalloc.a
$(INSTALL) -m 644 libmalloc_d.a $(LIBDIR)
-$(RANLIB) $(LIBDIR)/libmalloc_d.a
$(INSTALL) -m 644 malloc.h $(INCDIR)
.id: $(SRCS)
mkid $(SRCS) $(SPLAYSRC) $(HDRS) $(SPLAYHDR)
touch .id
dist:
@rm -f Makefile.bak
@mv Makefile Makefile.bak;\
sed '/^# DO NOT PUT ANYTHING/,$$d' Makefile.bak > Makefile; \
(bundle -v $(DOCS) $(SRCS) $(HDRS) $(TESTS) $(EXTRAS)); \
mv Makefile.bak Makefile
files:
find * -type f -print | \
egrep -v '(,v|\.o|core|make.log|simumalloc|testmalloc|teststomp)$$' | \
egrep -v '(libmalloc.*\.a|res\..*)$$' > FILES
depend: # An empty target -- manually generated..
.dep: $(SRCS)
$(CC) $(CFLAGSM) -MM $(SRCS) > .dep
# append the contents of .dep after this line.
_emalloc.o : _emalloc.c defs.h externs.h assert.h align.h globals.h globrename.h \
trace.h
_malloc.o : _malloc.c defs.h externs.h assert.h align.h globals.h globrename.h \
trace.h
_memalign.o : _memalign.c defs.h externs.h assert.h align.h globals.h globrename.h \
trace.h
_strdup.o : _strdup.c defs.h externs.h assert.h align.h globals.h globrename.h \
trace.h
_strsave.o : _strsave.c defs.h externs.h assert.h align.h globals.h globrename.h \
trace.h
botch.o : botch.c defs.h externs.h assert.h align.h globals.h globrename.h
dumpheap.o : dumpheap.c defs.h externs.h assert.h align.h globals.h globrename.h
emalloc.o : emalloc.c defs.h externs.h assert.h align.h globals.h globrename.h
getmem.o : getmem.c defs.h externs.h assert.h align.h globals.h globrename.h
leak.o : leak.c defs.h externs.h assert.h align.h globals.h globrename.h ./splay/sptree.h
malloc.o : malloc.c defs.h externs.h assert.h align.h globals.c globrename.h \
version.c
memalign.o : memalign.c defs.h externs.h assert.h align.h globals.h globrename.h
setopts.o : setopts.c defs.h externs.h assert.h align.h globals.h globrename.h
stats.o : stats.c defs.h externs.h assert.h align.h globals.h globrename.h
strdup.o : strdup.c defs.h externs.h assert.h align.h
strsave.o : strsave.c defs.h externs.h assert.h align.h
verify.o : verify.c defs.h externs.h assert.h align.h globals.h globrename.h
|