mercredi 13 janvier 2021

makefile: toggle value of variable based on boolean env var

I have an env var INTEGRATION that is set to true or false.

I would like to set the values of variables based on whether INTEGRATION is set to true or false.

I have tried:

ifeq ($(INTEGRATION),false)
  PRODUCTION_URL="production" 
else
  PRODUCTION_URL="integration"
endif

and also

if [ ${SNOOTY_INTEGRATION} == false ]; then \
    echo "HIT THE TRUTH"; \
    PRODUCTION_URL="https://docs.mongodb.com"; \
fi

after running

export INTEGRATION=true
make help

in terminal, I run make help:

help:
    echo "prod url ${PRODUCTION_URL}";

in the first case, it print prod url integration and in the second case, it prints prod url -- when the desired behavior is for it to print, prod url production

Aucun commentaire:

Enregistrer un commentaire