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

This is a discussion on what are the differences between = and := in a Makefile? within the Tech Board forums, part of the Community Boards category; I have Code: OBJ = $(wildcard *.c) and Code: OBJ := $(wildcard *.c) Seems the effects are the same. What ...

  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,185
    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,185
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21