This page contains a minimal GNU Make reference, adapted for my use from

Automatic Variables:

Here is a summary of the automatic variables. See Automatic Variables, for full information.

$@    The file name of the target.
$%    The target member name, when the target is an archive member.
$<    The name of the first prerequisite.
$?    The names of all the prerequisites that are newer than the target, with spaces between them.
$+
$^    The names of all the prerequisites, with spaces between them.

The value of $^ omits duplicate prerequisites, while $+ retains them and preserves their order.

Automatic Rules:

  • Compiling C programs
    n.o is made automatically from n.c with a recipe of the form
    $(CC) $(CPPFLAGS) $(CFLAGS) -c
  • Compiling C++ programs
    n.o is made automatically from n.c with a recipe of the form
    $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c
Example:
all: test libtest.so

libtest.so: libtest.o
    $(CC) -shared -o $@ $< -lc

test: test_main.c libtest.o
    $(CC) -o $@ $?

2 Responses to “Make Quick Reference”


  1. 1 Juvenal February 9, 2012 at 6:42 pm

    i hope a lot moms get to read this post, your story is truly itiripansonal.

  2. 2 jggoon February 10, 2012 at 2:10 am

    jMXnY7 zyikswxtzxrc

Leave a Reply