How to pass an argument with spaces to a make command.

·

1 min read

In this article, I document for my future self how to pass an argument with spaces to a make command.
For context, in my makefile, I have a command that uses alembic to generate migrations for some SQLAlchemy models.
The detail of the command depends on context, but here it is for completeness sake:

make-migration:
    cd src && poetry run alembic revision --autogenerate -m '$(msg)'

where msg is the argument I need to pass in when running the command.
Assuming I have just added a user table, and would like to run the migration for it. The command is as follows:

make msg="add user table" make-migration

Note that msg is is separated by spaces. And for the command to work, the argument in the make-migration has to be surrounded by a space like so: '$(msg)'