home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d523 / bmake.lha / BMake / source.lzh / TEST-Makefile < prev    next >
Makefile  |  1991-06-11  |  3KB  |  115 lines

  1. #    Just for testing
  2. #
  3. #    To debug, run the resulting make utility with the following arguments
  4. #        bmake -a -d -n -v9 +l -f TEST-Makefile
  5. #    the log file make.log will contain a detailed account of what the
  6. #    program attempted to do.
  7. #
  8.  
  9. .jj.k: ; echo "jj to k suffix rule"
  10.  
  11. .SUFFIXES: .jj .k
  12.  
  13. aaaaaa = 1
  14. A = aaa
  15. B := $(A)$(A)
  16. C := $($(B))
  17.  
  18. #    This one is cool.
  19. SRCS := $(wildcard #?.c)
  20. OBJS := $(subst .c,.o,$(SRCS))
  21. LIBS := -lben
  22.  
  23. #    Test some of the function calls
  24. SSRC := $(filter s%,$(SRCS))
  25. WILD := $(wildcard #?.c)
  26. BASE := $(basename $(WILD))
  27. ASUF := $(addsuffix .x,$(BASE))
  28. APRE := $(addprefix foo-,$(BASE))
  29. NAPRE := $(words $(APRE))
  30.  
  31. # test nested conditionals
  32. ifndef (DOIT)
  33. ifdef (undefined)
  34.     undefined := $(strip $(undefined))
  35. else
  36.     undefined := undefined
  37. endif
  38.     DOIT = $(undefined)
  39. endif
  40.  
  41. doodah:
  42.     @echo "$$ $C $$"
  43.     @echo "SOURCES:"
  44.     @echo "$(SRCS)"
  45.     @echo ""
  46.     @echo "OBJECTS:"
  47.     @echo "$(OBJS)"
  48.     @echo ""
  49.     @echo "SOURCES starting in s:"
  50.     @echo "$(SSRC)"
  51.     @echo ""
  52.     @echo "replacing ee with EE:"
  53.     @echo "$(subst ee,EE,feet on the street)"
  54.     @echo ""
  55.     @echo "$$(wildcard #?.c)"
  56.     @echo "$(WILD)"
  57.     @echo ""
  58.     @echo "basenames of the above filenames"
  59.     @echo "$(BASE)"
  60.     @echo ""
  61.     @echo "add suffix .x to the above basenames"
  62.     @echo "$(ASUF)"
  63.     @echo ""
  64.     @echo "add prefix foo- to the above basenames"
  65.     @echo "$(APRE)"
  66.     @echo "find the first word in the above foo-list"
  67.     @echo "$(firstword $(APRE))
  68.     @echo "find the last word in the above foo-list"
  69.     @echo "$(word $(NAPRE),$(APRE))
  70.     @echo "sorted list of filenames"
  71.     @echo "$(sort $(WILD))"
  72.  
  73. FILES := soft:ugly soft:butt/ugly soft:butt/ugly/slime
  74. DIRS := $(dir $(FILES))
  75. NOTDIRS := $(notdir $(FILES))
  76. JOIN := $(join $(DIRS),$(NOTDIRS))
  77.  
  78. testdir:
  79.     @echo "$(FILES)"
  80.     @echo "$(DIRS)"
  81.     @echo "$(NOTDIRS)"
  82.     @echo "$(JOIN)"
  83.     cd subdir
  84.     list
  85.  
  86. LIST1 := a.a b.b c.c d.d e.e f.f g.g h.h i.i j.j k.k
  87. LIST2 := $(suffix $(LIST1))
  88. LIST3 := $(join $(BASE),$(LIST2))
  89.  
  90. testlist:
  91.     @echo "$(LIST2)"
  92.     @echo "$(LIST3)"
  93.  
  94. finger := my toe      hurts
  95. bleh:
  96. #    test a conditional
  97. if eq($(DOIT),yes)
  98.     @echo "DOIT=yes; hurray!"
  99. else
  100.     @echo "DOIT=$(DOIT)"
  101. endif
  102.     echo "$(ugh) $(findstring hello,my hello) $(strip $(finger))"
  103.  
  104. MONSTER := a.b a.c b.b b.c
  105. BEES := $(filter %.b,$(MONSTER))
  106. CEES := $(filter %.c,$(MONSTER))
  107. NOTB := $(filter-out %.b,$(MONSTER))
  108. NOTC := $(filter-out %.c,$(MONSTER))
  109.  
  110. #    Now for a real-live generic rule that will make a.out
  111. #    from any .c files in your current directory!  Neat huh?
  112. #    Just change a.out to your favourite file name for the binary.
  113. a.out: $(OBJS)
  114.     $(CC) -o $@ $(CFLAGS) $(OBJS) $(LIBS)
  115.