src/3rdparty/ptmalloc/Makefile
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 # Makefile for ptmalloc, version 3
       
     2 # by Wolfram Gloger 1996-1999, 2001-2005, 2006
       
     3 
       
     4 DIST_FILES0 = ChangeLog malloc-2.8.3.h malloc.c \
       
     5  malloc-private.h ptmalloc3.c \
       
     6  sysdeps \
       
     7  #tst-mallocstate.c tst-mstats.c
       
     8 DIST_FILES1 = COPYRIGHT README Makefile \
       
     9  $(DIST_FILES0) \
       
    10  lran2.h t-test.h t-test1.c t-test2.c \
       
    11  tst-independent-alloc.c \
       
    12  #debian
       
    13 DIST_FILES2 = $(DIST_FILES1) \
       
    14  m-test1.c \
       
    15  RCS/*,v
       
    16 
       
    17 TAR_FLAGS = --numeric-owner --exclude "*~" --exclude "debian/tmp*"
       
    18 
       
    19 #CC = /pkg/gcc-2.95.2-wg/bin/gcc
       
    20 CC = gcc
       
    21 
       
    22 SYS_FLAGS  =
       
    23 OPT_FLAGS  = -g -O2 #-O # -O2
       
    24 WARN_FLAGS = -Wall -Wstrict-prototypes
       
    25 SH_FLAGS   = -shared -fpic
       
    26 
       
    27 INC_FLAGS  = -Isysdeps/generic
       
    28 
       
    29 # Flags for the test programs
       
    30 T_FLAGS   = -DUSE_MALLOC=1 -DTEST=1
       
    31 
       
    32 # Flags for the compilation of malloc.c
       
    33 M_FLAGS   = -DTHREAD_STATS=1 #-DMALLOC_DEBUG=1 -DDEBUG=1
       
    34 
       
    35 # Thread flags.
       
    36 # See the platform-specific targets below.
       
    37 THR_FLAGS = -DUSE_TSD_DATA_HACK -D_REENTRANT
       
    38 THR_LIBS  = -lpthread
       
    39 
       
    40 RM        = rm -f
       
    41 AR        = ar
       
    42 RANLIB    = ranlib
       
    43 
       
    44 MALLOC_OBJ = ptmalloc3.o malloc.o
       
    45 LIB_MALLOC = libptmalloc3.a
       
    46 
       
    47 T_SUF =
       
    48 TESTS = t-test1$(T_SUF) t-test2$(T_SUF) \
       
    49 	tst-independent-alloc$(T_SUF)
       
    50         #m-test1$(T_SUF) tst-mallocstate$(T_SUF) tst-mstats$(T_SUF)
       
    51 
       
    52 CFLAGS = $(SYS_FLAGS) $(OPT_FLAGS) $(WARN_FLAGS) $(THR_FLAGS) $(INC_FLAGS)
       
    53 
       
    54 .c.o:
       
    55 	$(CC) -c $(CFLAGS) $<
       
    56 
       
    57 all: $(LIB_MALLOC) 
       
    58 
       
    59 ptmalloc3.o: ptmalloc3.c malloc-2.8.3.h
       
    60 	$(CC) -c $(CFLAGS) $(M_FLAGS) -DMSPACES=1 $<
       
    61 
       
    62 malloc.o: malloc.c
       
    63 	$(CC) -c $(CFLAGS) $(M_FLAGS) -DONLY_MSPACES -DUSE_LOCKS=0 $<
       
    64 
       
    65 #malloc-stats.o: malloc-stats.c malloc.h
       
    66 #	$(CC) -c $(CFLAGS) $(M_FLAGS) $<
       
    67 
       
    68 libptmalloc3.a: $(MALLOC_OBJ)
       
    69 	$(AR) cr $@ $(MALLOC_OBJ)
       
    70 	$(RANLIB) $@
       
    71 
       
    72 libptmalloc3.so: $(MALLOC_OBJ)
       
    73 	$(CC) $(SH_FLAGS) $(CFLAGS) $(M_FLAGS) $(MALLOC_OBJ) -o $@
       
    74 
       
    75 again:
       
    76 	$(RM) $(TESTS)
       
    77 	$(MAKE) $(TESTS)
       
    78 
       
    79 clean:
       
    80 	$(RM) $(MALLOC_OBJ) libptmalloc3.a libptmalloc3.so $(TESTS) \
       
    81          core core.[0-9]*
       
    82 
       
    83 m-test1$(T_SUF): m-test1.c $(LIB_MALLOC)
       
    84 	$(CC) $(CFLAGS) $(T_FLAGS) m-test1.c $(LIB_MALLOC) $(THR_LIBS) -o $@
       
    85 
       
    86 t-test1$(T_SUF): t-test1.c t-test.h $(LIB_MALLOC)
       
    87 	$(CC) $(CFLAGS) $(T_FLAGS) t-test1.c $(LIB_MALLOC) $(THR_LIBS) -o $@
       
    88 
       
    89 t-test2$(T_SUF): t-test2.c t-test.h $(LIB_MALLOC)
       
    90 	$(CC) $(CFLAGS) $(T_FLAGS) t-test2.c $(LIB_MALLOC) $(THR_LIBS) -o $@
       
    91 
       
    92 tst-mallocstate$(T_SUF): tst-mallocstate.c $(LIB_MALLOC)
       
    93 	$(CC) $(CFLAGS) $(T_FLAGS) tst-mallocstate.c $(LIB_MALLOC) \
       
    94 	 $(THR_LIBS) -o $@
       
    95 
       
    96 tst-mstats$(T_SUF): tst-mstats.c $(LIB_MALLOC)
       
    97 	$(CC) $(CFLAGS) $(T_FLAGS) tst-mstats.c $(LIB_MALLOC) \
       
    98 	 $(THR_LIBS) -o $@
       
    99 
       
   100 tst-independent-alloc$(T_SUF): tst-independent-alloc.c $(LIB_MALLOC)
       
   101 	$(CC) $(CFLAGS) $(T_FLAGS) tst-independent-alloc.c $(LIB_MALLOC) \
       
   102 	 $(THR_LIBS) -o $@
       
   103 
       
   104 ############################################################################
       
   105 # Platform-specific targets. The ones ending in `-libc' are provided
       
   106 # to enable comparison with the standard malloc implementation from
       
   107 # the system's native C library.  The option USE_TSD_DATA_HACK is now
       
   108 # the default for pthreads systems, as most (Irix 6, Solaris 2) seem
       
   109 # to need it.  Try with USE_TSD_DATA_HACK undefined only if you're
       
   110 # confident that your systems's thread specific data functions do _not_
       
   111 # use malloc themselves.
       
   112 
       
   113 # posix threads with TSD data hack
       
   114 posix:
       
   115 	$(MAKE) THR_FLAGS='-DUSE_TSD_DATA_HACK -D_REENTRANT' \
       
   116  OPT_FLAGS='$(OPT_FLAGS)' SYS_FLAGS='$(SYS_FLAGS)' CC='$(CC)' \
       
   117  INC_FLAGS='-Isysdeps/pthread -Isysdeps/generic -I.'
       
   118  THR_LIBS=-lpthread
       
   119 
       
   120 # posix threads with explicit initialization.  Known to be needed on HPUX.
       
   121 posix-explicit:
       
   122 	$(MAKE) THR_FLAGS='-D_REENTRANT -DUSE_TSD_DATA_HACK -DUSE_STARTER=2' \
       
   123 	 THR_LIBS=-lpthread \
       
   124 	 OPT_FLAGS='$(OPT_FLAGS)' SYS_FLAGS='$(SYS_FLAGS)' CC='$(CC)' \
       
   125 	 INC_FLAGS='-Isysdeps/pthread -Isysdeps/generic -I.' \
       
   126 	 M_FLAGS='$(M_FLAGS)'
       
   127 
       
   128 # posix threads without TSD data hack -- not known to work
       
   129 posix-with-tsd:
       
   130 	$(MAKE) THR_FLAGS='-D_REENTRANT' THR_LIBS=-lpthread \
       
   131 	INC_FLAGS='-Isysdeps/pthread -Isysdeps/generic -I.' \
       
   132 	M_FLAGS='$(M_FLAGS)'
       
   133 
       
   134 posix-libc:
       
   135 	$(MAKE) THR_FLAGS='-D_REENTRANT' THR_LIBS=-lpthread \
       
   136 	INC_FLAGS='-Isysdeps/pthread -Isysdeps/generic -I.' \
       
   137 	M_FLAGS='$(M_FLAGS)' LIB_MALLOC= T_FLAGS= T_SUF=-libc
       
   138 
       
   139 linux-pthread:
       
   140 	$(MAKE) SYS_FLAGS='-D_GNU_SOURCE=1' \
       
   141  WARN_FLAGS='-Wall -Wstrict-prototypes' \
       
   142  OPT_FLAGS='$(OPT_FLAGS)' THR_FLAGS='-DUSE_TSD_DATA_HACK' \
       
   143  INC_FLAGS='-Isysdeps/pthread -Isysdeps/generic -I.' M_FLAGS='$(M_FLAGS)' \
       
   144  TESTS='$(TESTS)'
       
   145 
       
   146 linux-shared:
       
   147 	$(MAKE) SYS_FLAGS='-D_GNU_SOURCE=1 -fpic' \
       
   148  WARN_FLAGS='-Wall -Wstrict-prototypes' \
       
   149  OPT_FLAGS='$(OPT_FLAGS)' THR_FLAGS='-DUSE_TSD_DATA_HACK' \
       
   150  INC_FLAGS='-Isysdeps/pthread -Isysdeps/generic -I.' M_FLAGS='$(M_FLAGS)' \
       
   151  LIB_MALLOC=libptmalloc3.so
       
   152 
       
   153 sproc:
       
   154 	$(MAKE) THR_FLAGS='' THR_LIBS='' OPT_FLAGS='$(OPT_FLAGS)' CC='$(CC)' \
       
   155 	INC_FLAGS='-Isysdeps/sproc -Isysdeps/generic -I.' \
       
   156 	M_FLAGS='$(M_FLAGS) -Dmalloc_getpagesize=4096'
       
   157 
       
   158 sproc-shared:
       
   159 	$(MAKE) THR_FLAGS='' THR_LIBS= \
       
   160 	 SH_FLAGS='-shared -check_registry /usr/lib/so_locations' \
       
   161 	 INC_FLAGS='-Isysdeps/sproc -Isysdeps/generic -I.' \
       
   162 	  LIB_MALLOC=libptmalloc3.so M_FLAGS='$(M_FLAGS)'
       
   163 
       
   164 sproc-libc:
       
   165 	$(MAKE) THR_FLAGS='' THR_LIBS= LIB_MALLOC= T_FLAGS= \
       
   166 	 INC_FLAGS='-Isysdeps/sproc -Isysdeps/generic -I.' \
       
   167 	 T_SUF=-libc M_FLAGS='$(M_FLAGS)'
       
   168 
       
   169 solaris:
       
   170 	$(MAKE) THR_FLAGS='-D_REENTRANT' OPT_FLAGS='$(OPT_FLAGS)' \
       
   171 	 INC_FLAGS='-Isysdeps/solaris -Isysdeps/generic -I.' \
       
   172 	THR_LIBS=-lthread M_FLAGS='$(M_FLAGS)'
       
   173 
       
   174 solaris-libc:
       
   175 	$(MAKE) THR_FLAGS='-D_REENTRANT' OPT_FLAGS='$(OPT_FLAGS)' \
       
   176 	 INC_FLAGS='-Isysdeps/solaris -Isysdeps/generic -I.' \
       
   177  THR_LIBS=-lthread LIB_MALLOC= T_FLAGS= T_SUF=-libc M_FLAGS='$(M_FLAGS)'
       
   178 
       
   179 nothreads:
       
   180 	$(MAKE) OPT_FLAGS='$(OPT_FLAGS)' SYS_FLAGS='$(SYS_FLAGS)' \
       
   181 	 INC_FLAGS='-Isysdeps/generic -I.' \
       
   182  THR_FLAGS='' THR_LIBS='' M_FLAGS='$(M_FLAGS)'
       
   183 
       
   184 gcc-nothreads:
       
   185 	$(MAKE) CC='gcc' WARN_FLAGS='-Wall' OPT_FLAGS='$(OPT_FLAGS)' \
       
   186 	 INC_FLAGS='-Isysdeps/generic -I.' \
       
   187  SYS_FLAGS='$(SYS_FLAGS)' THR_FLAGS='' THR_LIBS='' M_FLAGS='$(M_FLAGS)'
       
   188 
       
   189 linux-nothreads:
       
   190 	$(MAKE) CC='gcc' WARN_FLAGS='-Wall' OPT_FLAGS='$(OPT_FLAGS)' \
       
   191 	 INC_FLAGS='-Isysdeps/generic -I.' \
       
   192  SYS_FLAGS='-D_GNU_SOURCE' THR_FLAGS='' THR_LIBS='' M_FLAGS='$(M_FLAGS)'
       
   193 
       
   194 ############################################################################
       
   195 
       
   196 check: $(TESTS)
       
   197 	./t-test1
       
   198 	./t-test2
       
   199 	#./tst-mallocstate || echo "Test mallocstate failed!"
       
   200 	#./tst-mstats || echo "Test mstats failed!"
       
   201 
       
   202 snap:
       
   203 	cd ..; tar $(TAR_FLAGS) -c -f - $(DIST_FILES1:%=ptmalloc3/%) | \
       
   204 	 gzip -9 >ptmalloc3-current.tar.gz
       
   205 
       
   206 dist:
       
   207 	cd ..; tar $(TAR_FLAGS) -c -f - $(DIST_FILES2:%=ptmalloc3/%) | \
       
   208 	 gzip -9 >ptmalloc3.tar.gz
       
   209 
       
   210 # dependencies
       
   211 ptmalloc3.o: malloc-private.h