Skip to content

Instantly share code, notes, and snippets.

@raidoz
Created December 7, 2016 14:46
Show Gist options
  • Save raidoz/a4b15bf24ba51c293a8a6367be7994d1 to your computer and use it in GitHub Desktop.
Save raidoz/a4b15bf24ba51c293a8a6367be7994d1 to your computer and use it in GitHub Desktop.
Makefile user interaction
# Make the clean target work without having to specify anything
ifneq ($(filter clean,$(MAKECMDGOALS)),)
IMPORTANT_PARAMETER=none
endif
ifndef IMPORTANT_PARAMETER
INTERACT_WITH_USER=1
endif
ifeq ($(INTERACT_WITH_USER),1)
$(info IMPORTANT_PARAMETER not specified, use defaults(none)?)
USER_AGREES := $(shell read -p "Use defaults? [Y/n]: " REPLY ; echo $$REPLY)
ifeq ($(strip $(USER_AGREES)),)
USER_AGREES = y
endif
ifneq ($(filter Y y, $(USER_AGREES)),)
IMPORTANT_PARAMETER ?= none
else
$(error Build stopped!)
endif
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment