Multiline commands in makefiles

Using multiline commands in make is usually a pain, I’ve tried so many ways and still you either have to use arcane extensions or just use a separate file that can be called from the makefile.

A pretty easy way to still achieve what you probably want to do is to use define:

define JSON_TODO (1)
curl -X 'POST' \
  'http://localhost:8080/todo' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "description": "string",
  "done": true,
  "dueDate": {
    "due": "2021-05-07",
    "start": "2021-05-07"
  },
  "title": "string"
}'
endef
export JSON_TODO (2)

todo:
	@echo $$JSON_TODO | bash (3)
1 This defines the variable JSON_TODO and sets the followed content separated by semicolons.
2 The export is required to make this accessible to the shell.
3 And this finally pipes the content of the variable through a bash shell.