In Linux Makefiles, you will often see a notation which looks like this:
This is called "expansion assignment".
So what's the difference between expansion assignment and ordinary variable assignment (=)? Let's get straight into a coding example:
So what's the difference between expansion assignment and ordinary variable assignment (=)? Let's get straight into a coding example:
So nothing unexpected or unusual here! But lets try the same thing using expansion assignment ( := ):
Oh no! It appears that we have a frog instead of the porcupine we wanted. So what happened?
When using the equals sign the variable is only expanded when used. In other words, when we run test.
When using the equals sign the variable is only expanded when used. In other words, when we run test.
In the second example we used ":=". This means that the variable is expanded at the time of assignment. If we want to see PORCUPINE again in the second example, we need to make a slight modification to it:
No comments:
Post a Comment