←back to thread

Be Aware of the Makefile Effect

(blog.yossarian.net)
431 points thunderbong | 3 comments | | HN request time: 0.521s | source
1. silasdavis ◴[] No.42668536[source]
Someone remind me, is it $@ or $< ?
replies(2): >>42668582 #>>42669227 #
2. pwdisswordfishz ◴[] No.42668582[source]
For what?
3. spc476 ◴[] No.42669227[source]
In a given rule:

    foo.o : foo.c
            $(CC) $(CFLAGS) -o $@ $<
The "$@" is the output (or target, think of @ as a bullseye on a target), and the "$<" is the input (think redirection). The only other commonly used variable is "$^":

    foo : foo.o util.o other.o
            $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
In this case, "$^" means "all inputs".