Monthly Archives: April 2015

Using boolean operators in makefiles

Sometimes when crafting makefiles, one is forced to use various conditional operators, like boolean AND or boolean OR between various flags. This is how it can be done, by using the shell to do it for us: (in this case if the ARCH parameter passed is not one of win32,win64,linux or android, we exit the build process with an error):


ifneq ($(shell if [ $(ARCH) = "win32" ] || \
     [ $(ARCH) = "win64" ] || \
     [ $(ARCH) = "linux" ] || \
     [ $(ARCH) = "android" ]; \
     then echo true;else echo false;fi),true)

$(error \
	please specify a valid architecture by passing ARCH= parameter   \
	Valid architectures are win32, win64, linux, android \