home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10657 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.9 KB  |  74 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!minyos.xx.rmit.oz.au!s902113
  3. From: s902113@minyos.xx.rmit.oz.au (Luke Mewburn)
  4. Subject: evaluation of shell stuff in Makefiles
  5. Organization: RMIT Computer Centre, Melbourne Australia.
  6. Date: Thu, 3 Sep 1992 01:42:48 EST
  7. Message-ID: <1992Sep3.014248.16259@minyos.xx.rmit.oz.au>
  8. Lines: 64
  9.  
  10.  
  11. I have this slight problem with a Makefile. I have a shell expression
  12. which I use to extract the version number of the program from a header
  13. file, but make evaluates this expression everywhere the variable is
  14. used, which slows things down a bit... Is there a way I can get make
  15. to evaluate it once???
  16.  
  17. An extract of the makefile is below. The output of make tar is something
  18. like: (wrapped for clarity)
  19.  
  20. --
  21.     mkdir flon-`/bin/sed -ne 's/.*VERSION."\(.*\)".*/\1/p;/VERSION/q'
  22. lon.h`
  23.     cp Makefile lon.h getfile.c main.c init.c print.c flon.nro
  24. Installation eg.friends tags Notes flon-`/bin/sed -ne
  25. 's/.*VERSION."\(.*\)".*/\1/p;/VERSION/q' lon.h`
  26.     tar -cf flon-`/bin/sed -ne 's/.*VERSION."\(.*\)".*/\1/p;/VERSION/q'
  27. lon.h`.tar flon-`/bin/sed -ne 's/.*VERSION."\(.*\)".*/\1/p;/VERSION/q' lon.h`
  28.     compress flon-`/bin/sed -ne 's/.*VERSION."\(.*\)".*/\1/p;/VERSION/q'
  29. lon.h`.tar
  30.     rm -rf flon-`/bin/sed -ne 's/.*VERSION."\(.*\)".*/\1/p;/VERSION/q'
  31. lon.h`
  32. --
  33.  
  34. As you can see, this would be slow (and messy too :). So, any suggestions
  35. how to clean this up?
  36.  
  37.  
  38. Thanx in advance,
  39. Luke.
  40.  
  41.  
  42. -- extract from Makefile --
  43. #[...]
  44.  
  45. #
  46. # Version number
  47. #
  48. VERSION=`/bin/sed -ne 's/.*VERSION."\(.*\)".*/\1/p;/VERSION/q' lon.h`
  49.  
  50. #
  51. # Executable name
  52. #
  53. EXEC=flon
  54.  
  55. #
  56. # Archive name
  57. #
  58. ARCNAM=$(EXEC)-$(VERSION)
  59.  
  60. # [...] 
  61. tar:
  62.     mkdir $(ARCNAM)
  63.     cp $(ALLF) $(ARCNAM)
  64.     tar -cf $(ARCNAM).tar $(ARCNAM)
  65.     compress $(ARCNAM).tar
  66.     rm -rf $(ARCNAM)
  67.  
  68. shar:
  69.     mkdir $(ARCNAM)
  70.     cp $(ALLF) $(ARCNAM)
  71.     shar $(ARCNAM) > $(ARCNAM).shar
  72.     rm -rf $(ARCNAM)
  73. -- end extract --
  74.