Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can we undefine/unset a variable in makefile

Team,

I have an environment variable which i would like to undefined/unset during the compilation of that particular project and then enable that back..

i have tried using.. the below code..

ifdef ${ENV_VAR_TEST} undefine ${ENV_VAR_TEST} endif

but i still see that its get reflected in the compilation environment... are these correct steps to undefined/unset a variable ?..i am i missing some basics here..

Thanks for your time .

like image 775
satishkumar432 Avatar asked Dec 04 '13 19:12

satishkumar432


People also ask

How do I check if a variable is set in Makefile?

Check if variable is defined in a Makefilecheck_defined = \ $(strip $(foreach 1,$1, \ $(call __check_defined,$1,$(strip $(value 2))))) __check_defined = \ $(if $(value $1),, \ $(error Undefined $1$(if $2, ($2)))) install: $(call check_defined, var1) $(call check_defined, var2) # do stuff here..

How do I use IFEQ in Makefile?

The ifeq directive begins the conditional, and specifies the condition. It contains two arguments, separated by a comma and surrounded by parentheses. Variable substitution is performed on both arguments and then they are compared.


2 Answers

unexport ENV_VAR_TEST

I don't know what the others mean by undefine, which doesn't look like valid make syntax.

Edit: undefine exists indeed, but only in GNU make 3.82 and higher.

like image 152
user2719058 Avatar answered Oct 16 '22 08:10

user2719058


The correct syntax is

undefine ENV_VAR_TEST
like image 27
Mark Galeck Avatar answered Oct 16 '22 09:10

Mark Galeck