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

  1. Xref: sparky comp.unix.shell:3802 comp.unix.questions:10685
  2. Newsgroups: comp.unix.shell,comp.unix.questions
  3. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!cs.utexas.edu!convex!news.utdallas.edu!corpgate!bnrgate!bcars267!bmdhh243!agc
  4. From: agc@bmdhh298.bnr.ca (Alan Carter)
  5. Subject: Re: Need help from a make guru
  6. Message-ID: <1992Sep03.105554.10887@bnr.uk>
  7. Sender: news@bnr.uk (News Administrator)
  8. Nntp-Posting-Host: bmdhh298
  9. Organization: BNR-Europe-Limited, Maidenhead, England
  10. References:  <Btytp9.BKs@news.larc.nasa.gov> <1992Sep3.071821.3803@ericsson.se>
  11. Date: Thu, 03 Sep 1992 10:55:54 GMT
  12. Lines: 48
  13.  
  14. In article <Btytp9.BKs@news.larc.nasa.gov>, alan@hal.larc.nasa.gov (alan dare) writes:
  15. |> 
  16. |> In our application we wanted to keep the object and source separate from 
  17. |> each other in a directory structure as shown below:
  18. |> 
  19. |>             <topdir>
  20. |>                |
  21. |>               / \
  22. |>            obj  src
  23. |> 
  24. |> My current makefile does this quite well. It also doesn't require a separate
  25. |> condition for each source. Problem: Several users add modules to a 
  26. |> executive then compile it. It would would be nice if they didn't have to
  27. |> modify the makefile. The makefile would just compile any source file in the
  28. |> current directory. I have taken several stabs at it, but I am not having
  29. |> any luck. All I need for it to work is a variable containing a list of
  30. |> the source and a variable containing the objects with the directory path 
  31. |> "../obj/" prefixed to it.  Below is a makefile that would compile all *.c and
  32. |> create a a.out file. However, I can't get make to execute the shell command
  33. |> correctly on the OBJECTS line correctly (the line is a valid shell command).
  34. |> 
  35. |> OBJDIR = ../obj
  36. |> 
  37. |> SOURCE=*.c
  38. |> OBJECTS=`for i in \`ls *.c |sed 's/\.c/.o/g'\`; do echo "../obj/$i"; done`
  39. |> $(OBJDIR)/a.out:  $(OBJECTS) 
  40. |>     cc -o $@ $(OBJECTS) 
  41. |> 
  42. |> $(OBJECTS) : $SOURCE
  43. |>     cc -c $(OPT)  $(@F:o=c) -o $@ 
  44. |> 
  45. |> Can anybody tell me how I can get the OBJECT variable set correctly?
  46.  
  47. Your problem is that you are trying to nest the stuff in `` command line
  48. substitution braces. This is not allowed. Do it in two steps:
  49.  
  50. TEMP=`ls *.c |sed 's/\.c/.o/g'\`
  51. OBJECTS=`for i in $TEMP; do echo "../obj/$i"; done`
  52.  
  53.    Alan
  54.  
  55. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  56.    Maidenhead itself is too snobby to be pleasant. It is the haunt of the
  57.    river swell and his overdressed female companion. It is the town of showy
  58.    hotels, patronized chiefly by dudes and ballet girls. 
  59.  
  60.    Three Men In A Boat, Jerome K. Jerome, 1889
  61. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62.