I have a question: can I use automatic variables $@ or $@F in the dependency of a rule ? When these variables are defined exactly: after then all the dependencies of a rule are resolved or when the processing of a rule is started ?
Is the rule below correct?
CCC=gcc
CPPFLAGS=-DLINUX -UDEBUG -DNDEBUG -O0 -Winline -Wparentheses -c
SRCPATH=${HOME}/project/cpp/
OBJPATH=${HOME}/project/obj/
MAKEFILE=${HOME}/project/makefile
MODULES_CPP_1=module1.cpp module2.cpp module3.cpp
MODULES_CPP_1_O=${MODULES_CPP_1:%.cpp=${OBJPATH}%.o}
${MODULES_CPP_1_O}: ${SRCPATH:=${@F:.o=.cpp}} ${MAKEFILE}
@ echo --- Compile ${@F:.o=.cpp}'->'${@F}
@ ${CCC} ${CPPFLAGS} -o $@ ${SRCPATH:=${@F:.o=.cpp}}
I use GNU Make version 3.79.1, under linux:
GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
Built for i386-redhat-linux-gnu
Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
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.
I tried to use -p option. make printed following information concerning the rule above:
/home/vkc/project/obj/module1.o: /home/vkc/project/cpp/ /home/vkc/project/makefile
# Implicit rule search has not been done.
# Implicit/static pattern stem: `'
# Last modified 2002-03-20 13:13:08
# File has been updated.
# Successfully updated.
# automatic
# ^ := /home/vkc/project/cpp/ /home/vkc/project/makefile
# automatic
# @ := /home/vkc/project/obj/module1.o
# automatic
# + := /home/vkc/project/cpp/ /home/vkc/project/makefile
# automatic
# ? := /home/vkc/project/cpp/
# automatic
# * :=
# automatic
# % :=
# automatic
# < := /home/vkc/project/cpp/
# 7 variables in 23 hash buckets.
# average of 0,3 variables per bucket, max 2 in one bucket.
# commands to execute (from `../Makefile.actions.lib.inc', line 459):
@ echo --- Compile ${@F:.o=.cpp}'->'${@F}
@ ${CCC} ${CPPFLAGS} -o $@ ${SRCPATH:=${$@F:.o=.cpp}}
As I see $@ and $@F are not defined in the dependencies but are defined in the action of a rule. Is it correct behaviour of the make or I ran into a defect ?
Thanks in advance.
--
Best regards, Kovalevich Victor
mailto:[EMAIL PROTECTED]
_______________________________________________ Bug-make mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-make