home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / utils / bug / 2098 < prev    next >
Encoding:
Text File  |  1992-11-21  |  2.5 KB  |  87 lines

  1. Newsgroups: gnu.utils.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!jarthur.claremont.edu!jason
  3. From: jason@jarthur.claremont.edu (Jason Merrill)
  4. Subject: Re: (none)
  5. Message-ID: <1992Nov21.232752.22875@muddcs.claremont.edu>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Harvey Mudd College, Claremont, CA 91711
  8. References: <9211180517.AA15811@life.ai.mit.edu>
  9. Distribution: gnu
  10. Date: Sat, 21 Nov 1992 23:27:52 GMT
  11. Approved: bug-gnu-utils@prep.ai.mit.edu
  12. Lines: 73
  13.  
  14. >>>> GSCOTT@manvm1.vnet.ibm.COM writes:
  15.  
  16. >OBJS = lfan_main.o lfan_track.o lfan_bf.o tb_bf.o
  17. >SOURCES = lfan_main.c lfan_track.c lfan_bf.c tb_bf.c
  18.  
  19. >$(OBJS): $(SOURCES) $(INCLUDES)
  20. >    $(CC) $(CFLAGS) -c $<
  21.  
  22. >$ /bin/make -n
  23.  
  24. >gcc -g -Wall -c lfan_main.c
  25. >gcc -g -Wall -c lfan_track.c
  26. >...
  27.  
  28. >$ /usr/local/gnu/make -n
  29.  
  30. >gcc -g -Wall -c lfan_main.c
  31. >gcc -g -Wall -c lfan_main.c
  32. >...
  33.  
  34. This is not a bug in gcc, but rather a documented feature :).  If you look
  35. in the GNU Make manual (make.texi), you will see that $< is always set to
  36. the FIRST dependency, not to the dependency with the same name as the
  37. target.  Consider the line
  38.  
  39. >$(OBJS): $(SOURCES) $(INCLUDES)
  40.  
  41. AIX make is interpreting it one of three ways:
  42.  
  43. If there are multiple targets and multiple dependencies, then a given
  44. target depends on:
  45.  
  46. 1) The dependency at the same index, plus all dependencies to which no
  47.    target corresponds.
  48. 2) The dependency with the same name (minus extension) as the target, plus
  49.    all dependencies to which no target corresponds.
  50.  
  51. Try rearranging the SOURCES line in your makefile and see if AIX make still
  52. does the right thing; that will tell you which rule it is using.
  53.  
  54. GNU make is interpreting it as follows:
  55.  
  56. If there are multiple targets and multiple dependencies, then a given
  57. target depends on ALL of the dependencies.
  58.  
  59. I think that the GNU behavior makes perfect sense.  To make your Makefile
  60. work under GNU make, you must use an implicit rule.  Change the lines
  61.  
  62. >$(OBJS): $(SOURCES) $(INCLUDES)
  63. >    $(CC) $(CFLAGS) -c $<
  64.  
  65. to
  66.  
  67. %.o: %.c $(INCLUDES)
  68.     $(CC) $(CFLAGS) -c $<
  69.  
  70. Of course, this won't work under AIX make.  This will probably work under
  71. both:
  72.  
  73. .c.o: $(INCLUDES)
  74.     $(CC) $(CFLAGS) -c $<
  75.  
  76. >Below is a script of what happens when the files must be retrieved
  77. >with RCS.  Note, it retrieves all of the correct files, but still only
  78. >tries to compile the first file in OBJS
  79.  
  80. Yes, because it is using an implicit rule to retrieve the files from RCS,
  81. but not to compile them.
  82.  
  83. --
  84. Jason Merrill                    jason@jarthur.claremont.edu
  85. This is a self-referential .sig which is not particularly interesting.
  86.  
  87.