home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / nethack-3.1 / sys / unix / cpp1.shr / makefile.txt < prev    next >
Encoding:
Makefile  |  1993-01-26  |  3.7 KB  |  137 lines

  1. #
  2. # The redefinition of strchr() and strrchr() are needed for
  3. # Ultrix-32, Unix 4.2 bsd (and maybe some other Unices).
  4. #
  5. BSDDEFINE = -Dstrchr=index -Dstrrchr=rindex
  6. #
  7. # On certain systems, such as Unix System III, you may need to define
  8. # $(LINTFLAGS) in the make command line to set system-specific lint flags.
  9. #
  10. # This Makefile assumes cpp will replace the "standard" preprocessor.
  11. # Delete the reference to -DLINE_PREFIX=\"\" if cpp is used stand-alone.
  12. # LINEFIX is a sed script filter that reinserts #line -- used for testing
  13. # if LINE_PREFIX is set to "".   Note that we must stand on our heads to
  14. # match the # and a line had better not begin with $.  By the way, what
  15. # we really want is
  16. #    LINEFIX = | sed "s/^#/#line/"
  17. #
  18. CPPDEFINE = -DLINE_PREFIX=\"\"
  19. LINEFIX = | sed "s/^[^ !\"%-~]/&line/"
  20. #
  21. # Define OLD_PREPROCESSOR non-zero to make a preprocessor which is
  22. # "as compatible as possible" with the standard Unix V7 or Ultrix
  23. # preprocessors.  This is needed to rebuild 4.2bsd, for example, as
  24. # the preprocessor is used to modify assembler code, rather than C.
  25. # This is not recommended for current development.  OLD_PREPROCESSOR
  26. # forces the following definitions:
  27. #   OK_DOLLAR        FALSE    $ is not allowed in variables
  28. #   OK_CONCAT        FALSE    # cannot concatenate tokens
  29. #   COMMENT_INVISIBLE    TRUE    old-style comment concatenation
  30. #   STRING_FORMAL    TRUE    old-style string expansion
  31. #
  32. OLDDEFINE = -DOLD_PREPROCESSOR=1
  33. #
  34. # DEFINES collects all -D arguments for cc and lint:
  35. # Change DEFINES = $(BSDDEFINE) $(CPPDEFINE) $(OLDDEFINE)
  36. # for an old-style preprocessor.
  37. #
  38. # DEFINES = $(BSDDEFINE) $(CPPDEFINE)
  39. DEFINES = $(CPPDEFINE)
  40.  
  41. CFLAGS = -O $(DEFINES)
  42.  
  43. #
  44. # ** compile cpp
  45. #
  46. SRCS = cpp1.c cpp2.c cpp3.c cpp4.c cpp5.c cpp6.c
  47. OBJS = cpp1.o cpp2.o cpp3.o cpp4.o cpp5.o cpp6.o
  48. cpp: $(OBJS)
  49.     $(CC) $(CFLAGS) $(OBJS) -o cpp
  50.  
  51. #
  52. # ** Test cpp by preprocessing itself, compiling the result,
  53. # ** repeating the process and diff'ing the result.  Note: this
  54. # ** is not a good test of cpp, but a simple verification.
  55. # ** The diff's should not report any changes.
  56. # ** Note that a sed script may be executed for each compile
  57. #
  58. test:
  59.     cpp cpp1.c $(LINEFIX) >old.tmp1.c
  60.     cpp cpp2.c $(LINEFIX) >old.tmp2.c
  61.     cpp cpp3.c $(LINEFIX) >old.tmp3.c
  62.     cpp cpp4.c $(LINEFIX) >old.tmp4.c
  63.     cpp cpp5.c $(LINEFIX) >old.tmp5.c
  64.     cpp cpp6.c $(LINEFIX) >old.tmp6.c
  65.     $(CC) $(CFLAGS) old.tmp[123456].c
  66.     a.out cpp1.c >new.tmp1.c
  67.     a.out cpp2.c >new.tmp2.c
  68.     a.out cpp3.c >new.tmp3.c
  69.     a.out cpp4.c >new.tmp4.c
  70.     a.out cpp5.c >new.tmp5.c
  71.     a.out cpp6.c >new.tmp6.c
  72.     diff old.tmp1.c new.tmp1.c
  73.     diff old.tmp2.c new.tmp2.c
  74.     diff old.tmp3.c new.tmp3.c
  75.     diff old.tmp4.c new.tmp4.c
  76.     diff old.tmp5.c new.tmp5.c
  77.     diff old.tmp6.c new.tmp6.c
  78.     rm a.out old.tmp[123456].* new.tmp[123456].*
  79.  
  80. #
  81. # A somewhat more extensive test is provided by the "clock"
  82. # program (which is not distributed).  Substitute your favorite
  83. # macro-rich program here.
  84. #
  85. clock:    clock.c cpp
  86.     cpp clock.c $(LINEFIX) >temp.cpp.c
  87.     cc temp.cpp.c -lcurses -ltermcap -o clock
  88.     rm temp.cpp.c
  89.  
  90. #
  91. # ** Lint the code
  92. #
  93.  
  94. lint:    $(SRCS)
  95.     lint $(LINTFLAGS) $(DEFINES) $(SRCS)
  96.  
  97. #
  98. # ** Remove unneeded files
  99. #
  100. clean:
  101.     rm -f $(OBJS) cpp
  102.  
  103. #
  104. # ** Rebuild the archive files needed to distribute cpp
  105. # ** Uses the Decus C archive utility.
  106. #
  107.  
  108. archc:    archc.c
  109.     $(CC) $(CFLAGS) archc.c -o archc
  110.  
  111. archx:    archx.c
  112.     $(CC) $(CFLAGS) archx.c -o archx
  113.  
  114. archive: archc
  115.     archc readme.txt cpp.mem archx.c archc.c cpp.rno makefile.txt \
  116.         cpp*.h >cpp1.arc
  117.     archc cpp1.c cpp2.c cpp3.c >cpp2.arc
  118.     archc cpp4.c cpp5.c cpp6.c >cpp3.arc
  119.  
  120. #
  121. # Object module dependencies
  122. #
  123.  
  124. cpp1.o    :    cpp1.c cpp.h cppdef.h
  125.  
  126. cpp2.o    :    cpp2.c cpp.h cppdef.h
  127.  
  128. cpp3.o    :    cpp3.c cpp.h cppdef.h
  129.  
  130. cpp4.o    :    cpp4.c cpp.h cppdef.h
  131.  
  132. cpp5.o    :    cpp5.c cpp.h cppdef.h
  133.  
  134. cpp6.o    :    cpp6.c cpp.h cppdef.h
  135.  
  136.  
  137.