[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Detect unset variables in gnu make
From: |
Rakesh Sharma |
Subject: |
Detect unset variables in gnu make |
Date: |
Tue, 8 Apr 2014 22:39:45 -0700 |
Hello GNU Makers,
Is there a way to find out if a variable is unset in a Makefile? The `ifdef'
condtional directive appears to do something different from what it's name
suggests.
Take for example this make snippet below:
ifdef DEBUG
# debug:=> /\S/
$(info DEBUG=[$(DEBUG)] debug mode ON.)
else
# debug:=> unset || /^$/ || /^\s+$/
$(info DEBUG=[$(DEBUG)] debug mode OFF.)
endif
Using GNU make version 4.0 we see that even if the variable is containing
spaces or is null
the ifdef else portion is executed.
My goal was to trigger the DEBUG evaluation in Makefile based on the state of
the DEBUG variable. This can make from the environment (by way of: setenv
DEBUG), from the command line (make DEBUG= goal), as defined inside the
Makefile (DEBUG := 1 ).
--Rakesh
- Detect unset variables in gnu make,
Rakesh Sharma <=