Hi all,
I need to write makefile for my project. I wrote some basic makefiles, and
never used automatic variables. But the makefile that my project needs is a
bit more complex (has to be recursive and few other stuff). I'm learning how
to write such makefiles. While learning I came across the automatic
variables and tried them on a simple code (file name: test.c).... I wrote
the following makefile:
EXEC = test
OBJS = test.o
all : $(EXEC)
$(EXEC) : $(OBJS)
% : %.o
echo "First line\n"
gcc $< -o $@
# %.o : %.c
# echo "This is second line\n"
# gcc -c $<
.PHONY : clean
clean :
-rm -f $(EXEC) $(OBJS)
With the lines that are commented I'm not providing any rule to make the
object files. Hence when I execute make I expected this to give me error,
but this proceeds smoothly with following output:
cc -c -o test.o test.c
echo "First line\n"
First line\n
gcc test.o -o test
does make "know" howto get .o files even with out specifying. Why doesn't
this give me an error as I expected.
Thanks.
-----
"tron"ix
--
View this message in context:
http://old.nabble.com/makefile-automatic-variables-question-tp29135505p29135505.html
Sent from the Gnu - Make - Help mailing list archive at Nabble.com.
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make