home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / question / 11095 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  2.2 KB

  1. Path: sparky!uunet!cs.utexas.edu!ut-emx!slcs.slb.com!aa.cad.slb.com!bl.cad.slb.com!coach!shibuya
  2. From: shibuya@mailhost.bl.cad.slb.com (Hiroto Shibuya)
  3. Newsgroups: comp.unix.questions
  4. Subject: GNU make 3.62 VPATH question
  5. Message-ID: <SHIBUYA.92Sep15122320@chute.mailhost.bl.cad.slb.com>
  6. Date: 15 Sep 92 17:23:20 GMT
  7. Sender: usenet@mailhost.bl.cad.slb.com (USENET Administrator)
  8. Reply-To: shibuya@mailhost.bl.cad.slb.com
  9. Distribution: comp
  10. Organization: Schlumberger Technologies CAD/CAM Division
  11. Lines: 75
  12.  
  13. Didn't get any response on gnu.util.bugs so try it here.  I don't
  14. think it is Unix question but can't see anywhere more approprite.
  15. Question concerning VPATH, vpath with GNU make 3.62 on
  16. DECstation/Ultrix 4.2.
  17.  
  18. Following is what I want to do.
  19.  
  20.     ./old/foo
  21.              /foo.c
  22.          /foo.o
  23.          /file1.c
  24.              /file1.o
  25.          /file2.c
  26.          /file2.o
  27.              /makefile
  28.         
  29.     ./new/file1.c
  30.          /makefile
  31.  
  32. There is directory ./old and ./new.  ./old contains all old sources
  33. and objects and exectables.  In the separate directory ./new, I want
  34. to copy a file from old directory, modify it and create new "foo" with
  35. the new module.  So I want make to compile new/file1.c and link new/foo
  36. out of old/foo.c, new/file1.o and old/file.o.  I tried the following
  37. simple makefile.
  38.  
  39.     #
  40.     # test VPATH
  41.     #
  42.     VPATH = ../old
  43.  
  44.     OBJ = foo.o file1.o file2.o
  45.  
  46.     foo : $(OBJ)
  47.         cc -o $@ $^
  48.  
  49. With this make file, if I say make, it simply says,
  50.  
  51.     gmake: `../old/foo' is up to date.
  52.  
  53. So I specify abosolute path for the target foo.
  54.         
  55.     VPATH = ../old
  56.     FOO = /xx/xx/xx/new/foo
  57.  
  58.     OBJ = foo.o file1.o file2.o
  59.  
  60.     $(FOO) : $(OBJ)
  61.         cc -o $(FOO) $^
  62.  
  63. Then it make foo as follows.
  64.  
  65.     cc -o /xx/xx/xx/new/foo ../old/main.o \
  66.       ../old/file1.o ../old/file2.o
  67.  
  68. ignoring the new/file1.c. 
  69.  
  70. If I say "gmake file1.o", it says  
  71.  
  72.     gmake: `../old/file1.o' is up to date.
  73.  
  74. If I say "make file1.o" then it compiles file1.c. After new/file1.o is
  75. created.  Then if I say "gmake", it links with the new object.
  76.  
  77.     cc -o /xx/xx/xx/new/foo ../old/main.o \
  78.       file1.o ../old/file2.o
  79.  
  80. It seems that after Gmake finds the target in ../old, it doesn't go
  81. looking for the source in the current directory.  What am I doing
  82. wrong? Or am I misunderstanding VPATH?
  83. --
  84.                 Hiroto Shibuya
  85.             
  86.                 Schlumberger Technologies 
  87.                 CAD/CAM Division
  88.