[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Makefile macros not working
From: |
Kristof Provost |
Subject: |
Re: Makefile macros not working |
Date: |
Wed, 27 Jun 2007 06:35:34 +0200 |
User-agent: |
Thunderbird 1.5.0.12 (X11/20070604) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
address@hidden wrote:
> I'm trying to use macros in this simple project:
>
> .cpp.obj:
>
> g++ $? -o $@
>
>
> Battle: Battle.obj
>
> g++ $? -o $@
>
>
> all: Battle
>
> But the response of make is :
> make: *** No rule to make target `Battle.obj', needed by `Battle'. Stop.
>
> How can I use macros?
> Thanks
> Daniele
There are a couple of mistakes in your makefile:
- To create the program you have Battle.obj as a prerequisite, but
you don't have a rule to create the prerequisite.
- Your first rule isn't a pattern rule
- Your first rule will also execute the link step because you forgot '-c'
- The all: Battle rule should be the first one, as make uses the
first target as default.
Try this:
all: Battle
%.cpp,obj: %.cpp
g++ -c $< -o $@
Battle: Battle.obj
g++ $^ -o $@
Note the use of %, $< (rather than $?) and $^. You can find them all
in the GNU Make manual.
Kristof
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGgekW/I87bQ13V5YRAnjgAJ9buNf25H8A4CKjyR2udEuyty22iwCfZxq5
iYjQAUsv8OXGS80V/xSWFu8=
=SjED
-----END PGP SIGNATURE-----