home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / shell / 3777 < prev    next >
Encoding:
Internet Message Format  |  1992-09-02  |  1.9 KB

  1. Xref: sparky comp.unix.shell:3777 comp.unix.questions:10656
  2. Newsgroups: comp.unix.shell,comp.unix.questions
  3. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!news.larc.nasa.gov!hal.larc.nasa.gov!alan
  4. From: alan@hal.larc.nasa.gov (alan dare)
  5. Subject: Need help from a make guru
  6. Message-ID: <Btytp9.BKs@news.larc.nasa.gov>
  7. Originator: alan@hal.larc.nasa.gov
  8. Sender: news@news.larc.nasa.gov (USENET Network News)
  9. Organization: NASA Langley Research Center, Hampton, VA  USA
  10. Date: Wed, 2 Sep 1992 19:19:56 GMT
  11. Lines: 38
  12.  
  13.  
  14. In our application we wanted to keep the object and source separate from 
  15. each other in a directory structure as shown below:
  16.  
  17.             <topdir>
  18.                |
  19.               / \
  20.                obj  src
  21.  
  22. My current makefile does this quite well. It also doesn't require a separate
  23. condition for each source. Problem: Several users add modules to a 
  24. executive then compile it. It would would be nice if they didn't have to
  25. modify the makefile. The makefile would just compile any source file in the
  26. current directory. I have taken several stabs at it, but I am not having
  27. any luck. All I need for it to work is a variable containing a list of
  28. the source and a variable containing the objects with the directory path 
  29. "../obj/" prefixed to it.  Below is a makefile that would compile all *.c and
  30. create a a.out file. However, I can't get make to execute the shell command
  31. correctly on the OBJECTS line correctly (the line is a valid shell command).
  32.  
  33. OBJDIR = ../obj
  34.  
  35. SOURCE=*.c
  36. OBJECTS=`for i in \`ls *.c |sed 's/\.c/.o/g'\`; do echo "../obj/$i"; done`
  37. $(OBJDIR)/a.out:  $(OBJECTS) 
  38.     cc -o $@ $(OBJECTS) 
  39.  
  40. $(OBJECTS) : $SOURCE
  41.     cc -c $(OPT)  $(@F:o=c) -o $@ 
  42.  
  43. Can anybody tell me how I can get the OBJECT variable set correctly?
  44.  
  45. Thanks to any and all.
  46. -- 
  47.  
  48. *********************************************************************
  49. Alan Dare                     |  Internet : alan@hal.larc.nasa.gov
  50. NASA Langley Research Center  | 
  51.