List Info

Thread: include directory




include directory
user name
2008-03-25 02:54:33
Hello
 
I have a problem.
 
My makefile is:
----------------
 ;
depend : main.c
  ;           $(CC) -M $(CPPFLAGS) $^ > $
 
include depend
------------------
 
I type in command line:
 
>>make -f myMakefile
cc -M main.c > depend
make: 'depend' is up to date.
 
I assumed that above make produce main.o, but it did. why?
 
If I now the include directive add the dependencies of main.c to make file and
according to implicit rule( %.o : %.c ) make must produce main.o. I am right?
 
Re: include directory
user name
2008-03-25 13:51:09
Vad,

On Tue, Mar 25, 2008 at 1:54 AM, Vad N <vadimidgmail.com> wrote:
> depend : main.c
>              $(CC) -M $(CPPFLAGS) $^ > $
>
> include depend
> ------------------
>
> I type in command line:
>
> >>make -f myMakefile
> cc -M main.c > depend
> make: 'depend' is up to date.
>
> I assumed that above make produce main.o, but it did.
why?

Make only builds the first target specified in the Makefile,
unless
you provide a command line target. Try this, for example,
with your
Makefile:

$ make main.o

This will build main.o because you specified it as your
desired
target. Otherwise make will only build depend because it's
the first
target in the Makefile. If you want to have main.o be the
primary
target, move your include statement above the rule for
building it:

include depend
depend : main.c
        $(CC) -M $(CPPFLAGS) $^ > $

$ make
Makefile:6: depend: No such file or directory
cc -M  main.c > depend
cc    -c -o main.o main.c

This has the unfortunate side-effect of generating a warning
that
there's no such file as depend, but it doesn't matter
because GNU make
is smart enough to re-run itself on the same Makefile
_after_
generating the file from specified rules, so all your
targets get
built. To remove this warning, you can add a dash to the
front of the
include line:

-include depend
depend : main.c
        $(CC) -M $(CPPFLAGS) $^ > $

This causes make to ignore the fact that depend can't be
found on the
first pass. The first pass will build depend, then the
second pass
will work fine because depend is now there.

Regards,
John


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )