Thread: what are the differences between = and := in a Makefile?

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    284

    what are the differences between = and := in a Makefile?

    I have

    Code:
    OBJ = $(wildcard *.c)
    and
    Code:
    OBJ := $(wildcard *.c)
    Seems the effects are the same. What are their differences? I have seen many people adopt := ?!

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Have you read the manual? (As I recall, := means expand now, and = means expand later, but I might have that backwards.)

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    284
    Yes, according to manual, you are right. But I did a test and it shows that
    Code:
    OBJ = $(wildcard *.c)
    expends now.

    Quote Originally Posted by tabstop View Post
    Have you read the manual? (As I recall, := means expand now, and = means expand later, but I might have that backwards.)

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Did you look at the example on page 59 of the (gnu pdf) manual? Does that not work for you when you tested it?

Popular pages Recent additions subscribe to a feed