home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!keinstr!chaplin
- From: chaplin@keinstr.uucp (Roger Chaplin)
- Subject: Re: How to use make to create two different targets from the same sources
- Message-ID: <1992Nov18.130647.3857@keinstr.uucp>
- Organization: Keithley Instruments, Cleveland, Ohio
- X-Newsreader: TIN [version 1.1 PL6]
- References: <1992Nov10.220743.4479@quintro.uucp>
- Date: Wed, 18 Nov 1992 13:06:47 GMT
- Lines: 49
-
- I tried to respond via email, but it bounced . . .
-
- Roger E. Benz (reb@quintro.uucp) wrote:
-
- In article <1992Nov10.220743.4479@quintro.uucp> Roger E. Benz
- (reb@quintro.uucp) wrote:
-
- : I would like to setup a Makefile that would allow me to create two
- : different targets from the same source files. Our primary target is
- : a 68k embedded system for which we use a cross compiler. During
- : development, however, we find it useful to build test version using
- : the native compiler. Currently, I have to edit my Makefile to switch
- : compilers and then run: make clean. If anyone knows of an easier way to
- : accomplish this, I would be most thankful.
-
- I'm not sure how to eliminate the `make clean' step, but here's a
- sample bit of Makefile, derived from the Makefile I used in a similar
- situation (this is formatted with 4-space TAB stops - you probably
- already know that make is very picky about having TABs instead of
- SPACEs):
-
- .primary:= CC = mcc68k
- .primary:= CFLAGS = -aic -nQ -nKc -g -c
-
- .test:= CC = /usr/bin/cc
- .test:= CFLAGS = -c -O
-
- primary: $(SOURCES)
- $(CC) $(CFLAGS) $(SOURCES)
-
- test: $(SOURCES)
- $(CC) $(CFLAGS) $(SOURCES)
-
-
- Notice that since `primary' is the first real target in the Makefile,
- just running `make' will build it. Make will perform the conditional
- macro assignments based on the fact that target `primary' is being
- built. On the other hand, running `make test' will build the `test'
- target. In this case, make will perform the conditional macro
- assignments in the lines that begin with `test:='.
-
- Disclaimer: this is Sun's make; if you have a different make, it may
- not have this capability.
-
- --
- Roger Chaplin / Instruments Division Engineering / "This land is your land,
- chaplin@keinstr.uucp / CI$: 76307,3506 / This land is my land,
- #include <disclaimer.h> / One of us has a bogus deed
- #include "disclaimer.h" /* cover all bases */ / to this land." - George Carlin
-