简体   繁体   中英

Makefile:1: *** missing separator. (I use tab, not spaces)

I know this question have been asked a lot of times, but I can't fix my error anyway.

I'm doing a Makefile with this content:

if [ -d "$HOME/.local/share/nvim/site/autoload/" ]; then
        mkdir -p $HOME/.local/share/nvim/site/autoload/ 
fi

When I run it, I get

Makefile:1: *** missing separator.  Stop.

In order to check if the script has spaces instead of tab, I type on the prompt

cat -t Makefile

so I get

if [ -d "$HOME/.local/share/nvim/site/autoload/" ]; then
^Imkdir -p $HOME/.local/share/nvim/site/autoload/
fi

What's the problem?

GNU make is not bash , it has its own syntax. Your code would be like this:

ifeq ($(wildcard $(HOME)/.local/share/nvim/site/autoload/),)
  MKDIR_OUTPUT:=$(shell mkdir -p $(HOME)/.local/share/nvim/site/autoload/)
endif

No tabs needed here since it is not a recipe.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM