View Single Post
  #7   (View Single Post)  
Old 5th May 2013
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,128
Default

make(1) will use environment variables but as you noticed there are subtle differences.

A simple Makefile:
Code:
test:
.ifdef CFLAGS 
        @echo Yes, CFLAGS has been defined: $${CFLAGS}
        env | grep CFLAGS 
.else
        @echo No, CFLAGS has not been defined !!!
.endif


test2:
.ifdef MONKEY  
        @echo Yes, MONKEY has been defined: $${MONKEY}
        env | grep MONKEY 
.else
        @echo No, MONKEY has not been defined !!!
.endif
Some tests with the test2 target:
Code:
$  env MONKEY=gorilla make test2

Yes, MONKEY has been defined: gorilla
env | grep MONKEY 
MONKEY=gorilla

$  make test2 MONKEY=chimp

Yes, MONKEY has been defined: chimp
env | grep MONKEY 
MONKEY=chimp
MAKEFLAGS= MONKEY=chimp

$ make test2
No, MONKEY has not been defined !!!
Note that when setting the environment variable with the env(1) utility, the MAKEFLAGS= MONKEY=chimp does not show in the environment output.

With CFLAGS:
Code:
$ env CFLAGS=-02 make test
Yes, CFLAGS has been defined: -02
env | grep CFLAGS 
CFLAGS=-02

$  make CFLAGS=-O2 test

Yes, CFLAGS has been defined: -O2
env | grep CFLAGS 
MAKEFLAGS= CFLAGS=-O2
CFLAGS=-O2

$ make test

Yes, CFLAGS has been defined:
env | grep CFLAGS 
*** Error 1 in /home/adriaan/TEST (Makefile:4 'test')
According to make(1) CFLAGS is an internal make variable. This explains the output of $ make test where it has been defined but apparently does not have a value assigned yet.

It seems that only when you specify the variable like # make CFLAGS=xxx it is seen as a one of the MAKEFLAGS.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote