home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16812 < prev    next >
Encoding:
Text File  |  1992-11-19  |  2.3 KB  |  61 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!keinstr!chaplin
  3. From: chaplin@keinstr.uucp (Roger Chaplin)
  4. Subject: Re: How to use make to create two different targets from the same sources
  5. Message-ID: <1992Nov18.130647.3857@keinstr.uucp>
  6. Organization: Keithley Instruments, Cleveland, Ohio
  7. X-Newsreader: TIN [version 1.1 PL6]
  8. References: <1992Nov10.220743.4479@quintro.uucp>
  9. Date: Wed, 18 Nov 1992 13:06:47 GMT
  10. Lines: 49
  11.  
  12. I tried to respond via email, but it bounced . . .
  13.  
  14. Roger E. Benz (reb@quintro.uucp) wrote:
  15.  
  16. In article <1992Nov10.220743.4479@quintro.uucp> Roger E. Benz
  17. (reb@quintro.uucp) wrote:
  18.  
  19. : I would like to setup a Makefile that would allow me to create two
  20. : different targets from the same source files.  Our primary target is
  21. : a 68k embedded system for which we use a cross compiler.  During
  22. : development, however, we find it useful to build test version using
  23. : the native compiler.  Currently, I have to edit my Makefile to switch
  24. : compilers and then run: make clean.  If anyone knows of an easier way to
  25. : accomplish this, I would be most thankful.
  26.  
  27. I'm not sure how to eliminate the `make clean' step, but here's a
  28. sample bit of Makefile, derived from the Makefile I used in a similar
  29. situation (this is formatted with 4-space TAB stops - you probably
  30. already know that make is very picky about having TABs instead of
  31. SPACEs):
  32.  
  33. .primary:=    CC = mcc68k
  34. .primary:=    CFLAGS = -aic -nQ -nKc -g -c
  35.  
  36. .test:=        CC = /usr/bin/cc
  37. .test:=        CFLAGS = -c -O
  38.  
  39. primary:    $(SOURCES)
  40.             $(CC) $(CFLAGS) $(SOURCES)
  41.  
  42. test:        $(SOURCES)
  43.             $(CC) $(CFLAGS) $(SOURCES)
  44.  
  45.  
  46. Notice that since `primary' is the first real target in the Makefile,
  47. just running `make' will build it.  Make will perform the conditional
  48. macro assignments based on the fact that target `primary' is being
  49. built.  On the other hand, running `make test' will build the `test'
  50. target.  In this case, make will perform the conditional macro
  51. assignments in the lines that begin with `test:='.
  52.  
  53. Disclaimer: this is Sun's make; if you have a different make, it may
  54. not have this capability.
  55.  
  56. -- 
  57. Roger Chaplin / Instruments Division Engineering / "This land is your land,
  58. chaplin@keinstr.uucp / CI$: 76307,3506          / This land is my land,
  59. #include <disclaimer.h>                        / One of us has a bogus deed
  60. #include "disclaimer.h" /* cover all bases */ / to this land."  - George Carlin
  61.