The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

makefile

Hi guys,

I created a makefile for my ISV product. At the command line, I just need to type

make build_retail=0

it builds the demo version under the DEMO directory. If I type

make build_retail=1

it builds the full version under the RETAIL directory.

Since I always build both versions at the same time, I'd like to change it to building both versions by simply typing

make

In addition to that, I also want to build demo and retail version separately by typing

make demo

or

make retail

How should I reorganize the make file to achieve the goal?
makefile newbie
Thursday, September 07, 2006
 
 
all: retail demo

retail: common stuff retail stuff

demo: common stuff demo stuff

common stuff: x y z
son of parnas
Thursday, September 07, 2006
 
 
sop,

the problem is that the demo build shares most stuff with retail build, with just a couple of differences.

For example, one is the output directory $(OUTDIR). Previously I can write

if (eq(build_retail, 1) )
OUTDIR = Retail
else
OUTDIR = Demo
endif

I can not write something like

demo :
    $(OUTDIR)=Demo
    ...

retail :
    $(OUTDIR)=Retail
    ...

It is not allowed to assign a variable within the command section.
makefile newbie
Thursday, September 07, 2006
 
 
Which make are you using? Gmake should be able to do this.
son of parnas
Thursday, September 07, 2006
 
 
I am using GNUMake. No you can not set the variable inside the command section.
makefile newbie
Thursday, September 07, 2006
 
 
Will something like this work:

demo : OUTDIR = demo
son of parnas
Thursday, September 07, 2006
 
 
You can recursively invoke make:

demo:
    make product retail_version=RETAIL

retail:
    make product retail_version=DEMO

product: x y z
    cc $(OBJ) -o ${retail_version}/bin/prod

etc.
David Jones Send private email
Thursday, September 07, 2006
 
 
>>Will something like this work:
>>demo : OUTDIR = demo

No. That line can only hold dependents.
makefile newbie
Thursday, September 07, 2006
 
 
Not in GNU Make.  With GNU Make I can set target specified variables.

mytarget: CFLAGS = -DBLAH
mytarget: mytarget.c
    ....
Jason Send private email
Thursday, September 07, 2006
 
 
Or you can make with a shell script to do the two makes sequentially.
dot for this one
Thursday, September 07, 2006
 
 
Finally I got it worked. It involves heavy use of ifeq statement.

None of the posts above work with my Gmake 3.80, unfortunately.
makefile newbie
Friday, September 08, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz