[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: One Makefile for more object files
From: |
Paul Smith |
Subject: |
Re: One Makefile for more object files |
Date: |
Tue, 09 Nov 2010 09:23:23 -0500 |
On Tue, 2010-11-09 at 07:38 +0100, Csanyi Pal wrote:
> I'm trying to compile 16 sourcefiles to get 16 executable objectfiles
> with one Makefile, but without success. Is this possyble?
>
> All source files are in the same directory.
>
> The makefile is here:
> http://pastebin.com/N1WLUJEk
>
> but when I run 'make' I get only the first executable: DPResetBit0
> $ make
> gcc -ggdb DPResetBit0.c -o DPResetBit0
>
> and the others won't to be compiled.
>
> I'm trying to understand GNU make reading GNU `make' here:
> http://www.gnu.org/software/make/manual/make.html
>
> but can't figure out what to do to achieve my goal?
>
> Any advices will be appreciated!
Check the start of Chapter 4: Writing Rules:
The order of rules is not significant, except for determining the
"default goal": the target for `make' to consider, if you do not
otherwise specify one. The default goal is the target of the first
rule in the first makefile. If the first rule has multiple targets,
only the first target is taken as the default. There are two
exceptions: a target starting with a period is not a default unless it
contains one or more slashes, `/', as well; and, a target that defines
a pattern rule has no effect on the default goal. (*Note Defining and
Redefining Pattern Rules: Pattern Rules.)
Therefore, we usually write the makefile so that the first rule is
the one for compiling the entire program or all the programs described
by the makefile (often with a target called `all'). *Note Arguments to
Specify the Goals: Goals.
Does that help?
Make will always (unless you specify otherwise on the command line)
build only the first target it finds (subject to a few special cases as
above).
If you want more than one target built by default, declare a "fake"
target like "all" (traditional) as the first target, and make all your
real targets prerequisites of that one.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.mad-scientist.net
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist