In the context of a makefile, I see two things.
First, you need a semicolon or newline before the
then. Shell syntax for
if looks like:
if commands... ; then commands... ; fi (where any semicolon here can be replaced with a newline).
make executes a recipe, it runs each individual line of the recipe in a separate shell instance, and stops executing if any single line gives an error. Effectively, it's running:
sh -c 'if [ ! -d upload-api/app-router/ ]; then' &&
sh -c 'git clone someRepo upload-api/app-router/' &&
sh -c 'fi'
...which is a syntax error on the first line, with or without the semicolon, because the
if is never finished.
So for a makefile recipe, you would need to let
make know that it should treat the entire
if ... fi block as one line. For instance, use backslashes for line continuation, and semicolons in the appropriate places since the shell won't see any line breaks.
↦ if [ ! -d upload-api/app-router/ ] ; then \
↦ git clone someRepo upload-api/app-router/ ; \
This gets unwieldy pretty quickly, so my preferred solution is usually to put the shellscript in a separate file, then run that file from your recipe.