On Saturday 28 January 2006 15:50, Morten Gulbrandsen wrote:
>
> make -v
> GNU Make 3.80
> Copyright (C) 2002  Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.
> There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.
>
>
>
> make
> cc -c -o helloworld.o helloworld.c
> cc    -o helloworld helloworld.o
>
>
>
> ####### Unexpected result #####$
>
> according to the manual
>
> http://www.gnu.org/software/make/manual/html_chapter/make_3.html#SEC13
>
> then you would expect to see this output:
>
>
>
> name1 = Makefile
> name2 = inc.mk
>
>
> cat  inc.mk
> helloworld: helloworld.o
>         cc    -o $@ $<
>
> helloworld.o: helloworld.c
>         cc -c -o $@ $<
>
> .PHONY: clean
> clean:
>         -rm -f helloworld helloworld.o
>
>
> cat Makefile
> name1 := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
>
> include inc.mk
>
> name2 := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
>
> all:
>         @echo name1 = $(name1)
>         @echo name2 = $(name2)
>
>
>
> what can I do ?
>
> Am I doing  something wrong or is the manual
> not up to date ?
>
>

Your include file, inc.mk contains targets. When you run make without 
out explicit targets, the first target (implicit target) in your make 
file is used. In this case, the first target due to the include 
statement is helloworld.  If you create an empty inc.mk or explicitly 
call the "all" target, ("make all") then the code will work as you 
might have expected.

  --Eric


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to