Ever wondered what the funny-looking vars in the GNU Makefiles are? These two are the most common ones:
@< there are some other are special vars as well.
Here’s what these two mean, and you can look up the rest on the GNU Makefile “Automatic Variables” help page:
$@ -is the name of the target currently being processed.
$< -is the name of the first dependency.
1. So if you have a makefile target that looks like this:
all: clean libs app
@echo 'Building target: $@. First dependency is: $<
Then when you invoke ’make all’ you will see the message:
Building target: all. First dependency is: clean.'
2. It becomes more interesting when the first dependency is a list of several values, e.g.:
OBJS := lib1/src1.c lib1/src2.c lib2/src2.c lib2/src3.c
myapp: $(OBJS) $(USER_OBJS)
@echo 'Building target: $@. First dep: $<'
$(CC) $(USER_FLAGS) -o $@ $(OBJS) $(LIBS)
@echo 'Finished building target: $@'
In this case the first dependency which is the variable OBJS is evaluated. It resolves to a list of values and the first value ‘lib1/src1.c’ will be assigned to the ‘$<’ variable.
So when making ’myapp’ you will see the message:
Building target: myapp. First dependency is: lib1/src1.c.'
One more thing to look for, particularly if you are using echo messages to debug your make process:
Your first dependency may often be another target in the make file! In the first example (all: clean libs app) the dependencies are ‘clean’, ‘libs’ and ‘app’ and by the looks of it these are most likely other targets. Now, what I wanted point out is that if one of these targets prints a message… Then the sequence of the messages you see may not be what you expected! Or worse yet – if one of these pre-requisite targets breaks the build (!) then you may never see your message! Just keep these in mind when debugging your makefiles…
Cloudapt-get audio boot codec compile C programming cups emacs etc FC9 Fedora gcc git global shortcuts grep how to httpd init kernel libc linux linux partition localtime make mount mp3 oracle package package managers partition remove rpm rpmfusion script Ubuntu UTC vbox version control system virtual box vm web server windows partition wordpress xargs xwin