home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dbmalloc.zip / Makefile < prev    next >
Makefile  |  1995-04-26  |  9KB  |  333 lines

  1. #
  2. #  (c) Copyright 1990, 1991, 1992 Conor P. Cahill (uunet!virtech!cpcahil).  
  3. #  This software may be distributed freely as long as the following conditions
  4. #  are met:
  5. #          * the distribution, or any derivative thereof, may not be
  6. #           included as part of a commercial product
  7. #         * full source code is provided including this copyright
  8. #         * there is no charge for the software itself (there may be
  9. #           a minimal charge for the copying or distribution effort)
  10. #         * this copyright notice is not modified or removed from any
  11. #           source file
  12. #
  13. #
  14. # $Id: Makefile,v 1.39 1992/08/22 16:27:13 cpcahil Exp $
  15. #
  16. # This is the Makefile for the malloc debugging library
  17. #
  18. # NOTE: while most porting changes are made here, the malloc.h file
  19. #       may require hand editing (mostly the DATATYPE and SIZETYPE
  20. #    typedefs) because of system wierdities.
  21. #
  22. # Usefull targets:
  23. #
  24. #    all        make all programs/libs in the local directory
  25. #    install        install updated programs/libs
  26. #    frcinstall    install all programs/libs
  27. #    tests        build tests
  28. #    runtests    build and run all tests
  29. #    clean        clean up after yourself
  30. #    fullclean    clean up everything (including configure stuff)
  31. #
  32. # NOTE: there are several other targets used by myself for souce code
  33. # maintenance related functions.  These are probably specific to my system
  34. # and may not do what they are supposed to do in a different environment.
  35. # Therefore, unless you know what you are doing, I would suggest not running
  36. # them (hence why they are not documented here).
  37. #
  38. # And now, onto a few definitions that you may need to alter
  39. #
  40. # The following defines may be added as necessary to the CFLAGS definition:
  41. #
  42. # -DANSI_NULLS      if you want to allow passing of NULL pointers to realloc
  43. #            and/or free (as ANSI does) even if the library is
  44. #            compiled by a non-ANSI compiler.
  45. # -DNO_ANSI_NULLS     if you DON'T want to allow passing of NULL pointers to
  46. #            realloc and/or free, even if the library is compiled by
  47. #            an ANSI conforming compiler.
  48. # -DDONT_USE_ASM    don't use ASM speedups when replacing system memcpy
  49. #            and/or memset routines
  50. # -DCTYPE_SUPPORT=x    where x is one of the following
  51. #
  52. #                1 - use plain-jane ctype.h which is only valid
  53. #                    for the ansii character set (DEFAULT)
  54. #                2 - use POSIX setlocal() to setup the character
  55. #                    set definitions
  56. #                3 - use C library islower() & toupper()
  57. #                    functions
  58. #
  59. # NOTE: if you add any flags other than the above to the CFLAGS, you might want
  60. #    to add a similar arguement in the Config.flags file.  However, you
  61. #     should remember that the malloc.h configuration will depend upon these
  62. #    settings and you could have a problem if you attempt to use the file
  63. #    in a compile session that doesn't include these flags.
  64. #
  65. CFLAGS=
  66. #
  67. # Where the code will be installed
  68. #
  69. #    DESTDIR        root for installation directory
  70. #    INSTDIR     installation directory
  71. #    LIBINSTDIR    install directory for library
  72. #    INCINSTDIR    install directory for include files
  73. #    MANINSTDIR    manual installation directory
  74. #    MANINSTNAME    name to install the manual as
  75. #    MANINSTVER    manual install version (use malloc.3 for troff/nroff
  76. #            source and malloc.man for pre-formatted)
  77. #
  78. DESTDIR=
  79. INSTDIR=$(DESTDIR)/usr/local
  80. LIBINSTDIR=$(INSTDIR)/lib
  81. INCINSTDIR=$(INSTDIR)/debug_include
  82. MANINSTDIR=$(INSTDIR)/man/man3
  83. RANLIB=/usr/local/bin/ranlib
  84. MANINSTNAME=dbmalloc.3
  85. MANINSTVER=malloc.3
  86.  
  87. #
  88. # miscellaneous commands
  89. #
  90. # NOTE: if you change CC to a non-K&R compiler be sure to read the 
  91. #       PROBLEMS file first.
  92. #
  93. CC=gcc
  94. CPROTO=/usr/local/bin/cproto
  95. LINT=lint
  96. NROFF=nroff
  97. SHARCMD=makekit -p -m -nmallocshar.
  98. #SHELL=/bin/sh
  99.  
  100. LIB=dbmalloc.a
  101. LINTLIB=llib-ldbmal.ln
  102.  
  103. #
  104. # You shouldn't have to modify anything below this line
  105. #
  106. LIBSRCS=    malloc.c    \
  107.         datams.c    \
  108.         dgmalloc.c    \
  109.         fill.c        \
  110.         free.c        \
  111.         realloc.c    \
  112.         calloc.c    \
  113.         string.c    \
  114.         mcheck.c    \
  115.         mchain.c    \
  116.         memory.c    \
  117.         tostring.c    \
  118.         m_perror.c    \
  119.         m_init.c    \
  120.         mallopt.c    \
  121.         dump.c         \
  122.         stack.c        \
  123.         xmalloc.c    \
  124.         xheap.c        \
  125.         malign.c    \
  126.         size.c        \
  127.         abort.c        \
  128.         leak.c    
  129.  
  130. LIBOBJS=    malloc.o    \
  131.         datams.o    \
  132.         dgmalloc.o    \
  133.         fill.o        \
  134.         free.o        \
  135.         realloc.o    \
  136.         calloc.o    \
  137.         string.o    \
  138.         mcheck.o    \
  139.         mchain.o    \
  140.         memory.o    \
  141.         tostring.o    \
  142.         m_perror.o    \
  143.         m_init.o    \
  144.         mallopt.o    \
  145.         dump.o         \
  146.         stack.o        \
  147.         xmalloc.o    \
  148.         xheap.o        \
  149.         malign.o    \
  150.         size.o        \
  151.         abort.o        \
  152.         leak.o    
  153.  
  154. SRCS=$(LIBSRCS) testmalloc.c testmem.c testerr.c teststack.c cctest.c
  155. HDRS= malloc.h.org mallocin.h debug.h tostring.h
  156.  
  157. BUILDFILES=malloc.man prototypes.h 
  158.  
  159. MANSRCFILES=patchlevel README PROBLEMS CHANGES Buildpatch minipatch Makefile \
  160.     malloc.3 malloc.man $(SRCS) $(HDRS) prototypes.h \
  161.     Configure Config.flags Runtests testerr.base
  162. SRCFILES=MANIFEST $(MANSRCFILES)
  163.  
  164. TESTS=testmalloc.exe testmem.exe testerr.exe teststack.exe
  165.  
  166. all:    $(LIB)
  167.  
  168. install: $(LIBINSTDIR)/$(LIB) $(INCINSTDIR)/malloc.h \
  169.     $(MANINSTDIR)/$(MANINSTNAME)
  170.  
  171. frcinstall: rminstall install
  172.  
  173. rminstall:
  174.     rm -f $(LIBINSTDIR)/$(LIB) $(INCINSTDIR)/malloc.h \
  175.     $(MANINSTDIR)/$(MANINSTNAME)
  176.  
  177. $(LIBINSTDIR)/$(LIB): $(LIB)
  178.     -rm -f $@.old
  179.     -mv -f $@ $@.old
  180.     cp $? $@
  181.     @-if test -s $(RANLIB); then $(RANLIB) $@; \
  182.          else if test -s /bin/ranlib; then /bin/ranlib $@; \
  183.      else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $@; \
  184.      else exit 0; fi; fi; fi
  185.     -chmod 644 $@
  186.     -rm -f $@.old
  187.  
  188. $(INCINSTDIR)/malloc.h: malloc.h
  189.     -rm -f $@.old
  190.     -mv -f $@ $@.old
  191.     cp $? $@
  192.     -chmod 644 $@
  193.     -rm -f $@.old
  194.     
  195. $(MANINSTDIR)/$(MANINSTNAME): $(MANINSTVER)
  196.     -rm -f $@.old
  197.     -mv -f $@ $@.old
  198.     cp $? $@
  199.     -chmod 644 $@
  200.     -rm -f $@.old
  201.  
  202. tests:    $(TESTS)
  203.  
  204. #
  205. # runtests - target for building and running the tests.  Note that we 
  206. # run testmalloc with fill_area disabled.  This is because testmalloc is
  207. # a malloc exerciser and we just want to see if we broke malloc, not verify
  208. # that the test doesn't overwrite memory (since it doesn't).
  209. #
  210. runtests: tests
  211.     @echo "Running all of the test programs.  This may take a while so"
  212.     @echo "please be patient.  Note that you won't see any output unless"
  213.     @echo "a test fails....."
  214.     ./Runtests
  215.  
  216. clean:  
  217.     rm -f $(TESTS) pgm cctest $(LIB) *.o *.ln Runtests.out malloc.h \
  218.         sysdefs.h
  219.  
  220. fullclean: clean
  221.     rm -f .configure .configure.[sO] *.O core cscope.out tags
  222.  
  223. sharfile: $(SRCFILES) CHECKSUMS
  224.     $(SHARCMD)
  225.  
  226. CHECKSUMS: $(SRCFILES)
  227.     echo "SYSV sums:\n" > CHECKSUMS
  228.     sum $(SRCFILES) >> CHECKSUMS
  229.     echo "\nBSD sums (generated using sum -r on SYSV system):\n" >>CHECKSUMS
  230.     sum -r $(SRCFILES) >> CHECKSUMS
  231.  
  232. MANIFEST: $(MANSRCFILES)    
  233.     $(SHARCMD) -x
  234.     chmod -w MANIFEST
  235.     
  236. $(LIB): $(LIBOBJS)
  237.     -rm -f $(LIB)
  238.     ar r $(LIB) $(LIBOBJS)
  239.     ar s $(LIB)
  240.  
  241. $(LINTLIB): $(LIBSRCS)
  242.     $(LINT) -x -v -o dbmal $(LIBSRCS)
  243.  
  244. malloc.h: malloc.h.org Configure
  245.     ./Configure 
  246.  
  247. sysdefs.h: Configure
  248.     ./Configure 
  249.  
  250. #
  251. # stuff for building the nroffed version of the manual page
  252. #
  253. man:    malloc.man
  254.  
  255. malloc.man: malloc.3
  256.     rm -f malloc.man
  257.     $(NROFF) -man malloc.3 | col -b > malloc.man
  258.  
  259. #
  260. # stuff for building the test programs
  261. #
  262. testmalloc.exe:    $(LIB) testmalloc.o
  263.     $(CC) $(CFLAGS) -o $@ testmalloc.o $(LIB)
  264.  
  265. testmem.exe:    $(LIB) testmem.o
  266.     $(CC) $(CFLAGS) -o $@ testmem.o $(LIB)
  267.  
  268. teststack.exe:    $(LIB) teststack.o
  269.     $(CC) $(CFLAGS) -o $@ teststack.o $(LIB)
  270.  
  271. testerr.exe:    $(LIB) testerr.o
  272.     $(CC) $(CFLAGS) -o $@ testerr.o $(LIB)
  273.  
  274. #
  275. # misc stuff for source code maintenance
  276. #
  277. lint:    
  278.     $(LINT) $(CFLAGS) $(SRCS)
  279.  
  280. proto:
  281.     rm -f prototypes.h
  282.     make prototypes.h
  283.  
  284. prototypes.h: $(LIBSRCS) $(HDRS) malloc.h
  285.     @if [ ! -s $(CPROTO) ]; then \
  286.         echo "Need cproto to rebuild prototypes file";\
  287.         exit 1; \
  288.     else \
  289.         exit 0; \
  290.     fi
  291.     -rm -f prototypes.h
  292.     cp /dev/null prototypes.h
  293.     $(CPROTO) -Dforce_cproto_to_use_defines -D__STDC__ \
  294.          -DDONT_USE_ASM -m__stdcargs -f4 $(LIBSRCS) \
  295.          | sed -e "s/const/CONST/g" > prototypes.new
  296.     mv prototypes.new prototypes.h
  297.     chmod -w prototypes.h
  298.     
  299. patch: $(SRCFILES)
  300.     sh Buildpatch $(SRCFILES)
  301.  
  302. srclist:
  303.     @echo $(SRCFILES)
  304.  
  305. rcsclean: $(BUILDFILES)
  306.     -rcsclean -q $(SRCFILES)
  307.     -ls $(SRCFILES) 2>/dev/null > files.list
  308.     -rcs -i -t/dev/null `cat files.list` 2>/dev/null
  309.     @set -e; \
  310.     echo "files to be checked in: `cat files.list`"; \
  311.     echo "\n\tMessage: \c"; \
  312.     read message; \
  313.     echo ""; \
  314.     rcs -q -l `cat files.list`; \
  315.     ci -m"$$message" `cat files.list`; \
  316.     co -u $(SRCFILES)
  317.  
  318. #
  319. # special rules for building datams.o and datamc.o
  320. #
  321. datams.o: datams.c malloc.h mallocin.h sysdefs.h
  322.  
  323. #
  324. # include file dependencies
  325. #
  326. $(LIBOBJS):    malloc.h mallocin.h sysdefs.h
  327.  
  328. testerr.o testmalloc.o testmem.o:    malloc.h sysdefs.h
  329.  
  330. tostring.o malloc.o dump.o:    tostring.h sysdefs.h
  331.