[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make: puzzeling make behaviour ?

From: Henrik Carlqvist
Subject: Re: Make: puzzeling make behaviour ?
Date: Tue, 20 Feb 2007 08:01:53 +0100
User-agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)

B Thomas <> wrote:

> I changed the build rule to 
> build:  $(PROGRAMS)
>       $(CC) $(CFLAGS) $(LDFLAGS) -o "$<" "$<".c
> Shouldn't this work ? However I still have
> the same problem. 

The problem remains because make thinks like this:

1) It wants to create a file named "build". To create the file "build" it
thinks it has a command line which you have specified.

2) Before it can create "build" it will have to create $(PROGRAMS). There
is no rule that specifies how to create $(PROGRAMS) so it uses a built in

> This make file rule or something else results in :
> gcc -I/home/bt/include   -L/usr/X11R6/lib -lX11 -lGL -lGLU -lm
> -L/home/bt/lib -lgltk  Hello_World.c   -o Hello_World

So make has a built in rule on how to build a program from a C source. If
you still want to call your target "build" the right way to do this would
be something like:

build:  $(PROGRAMS)

%: %.c
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<

Above "build" depends on $(PROGRAMS) and a custom rule has been specified
how programs are built from C source. The fact that no file named "build"
is created is no problem. This is how Makefiles are usually written.
However, the de-facto standard for the default rule is usually "all"
instead of "build", but you are free to call the rule whatever you want.

> Output of nm/ar  commands is as follows :

Your output from nm and ar looks fine, once you get the right command done
by make the library will probably be usable.

regards Henrik
The address in the header is only to prevent spam. My real address is:
hc1(at) Examples of addresses which go to spammers:
root@localhost postmaster@localhost

reply via email to

[Prev in Thread] Current Thread [Next in Thread]