What are double-colon rules in a Makefile for?

Each :: rule is processed independently, so it can be simpler. For example, the single rule:

libxxx.a : sub1.o sub2.o
    ar rv libxxx.a sub1.o
    ar rv libxxx.a sub2.o

can be replaced with two simpler rules:

libxxx.a :: sub1.o
    ar rv libxxx.a sub1.o

libxxx.a :: sub2.o
    ar rv libxxx.a sub2.o

Utilities like AutoMake have an easier time spitting out many simple rules than a few complex ones.

A great answer with more examples was posted, then taken down, then found here:

https://web.archive.org/web/20180122002430/http://owen.sj.ca.us/~rk/howto/slides/make/slides/makecolon.html

Thanks to R.K. Owen for writing it, and Edward Minnix for finding it again!

Leave a Comment