2

I am using an M1 powered mac. I am trying to use makefile in a project and to my surprise, no matter what I do it ends being a missing separator error. my Makefile below won't run no matter what. I have used textedit, vscode and IntelliJ. Same result. I have event picked a tutorial online copy pasted their makefile content (the hello example)https://tutorialedge.net/golang/makefiles-for-go-developers/ hoping that I am the one not conversant with the syntax.

hello:
echo "Something"

#build:
#.   go build -o bin/apigateway
#run: build
#.   ./bin/apigateway
#test:
#.   go test -v ./..

I checked the version and bellow is the response

make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

I am actually really confused . What am I possibly missing?

1
  • 1
    This is not the syntax for a makefile.
    – harrymc
    Commented Jul 29, 2023 at 16:12

1 Answer 1

2

The basic syntax of a makefile is:

target: dependency
<tab>command

The MUST be a tab-character, not four spaces or something like that. It may be, that some editors convert tabs to spaces. These editors are useless for creating Makefiles. It may also be that the cut-and-paste did put in the spaces.

Try:

cat > Makefile
hello:
<tab>echo something
<control-D>
make hello
1
  • This helped a lot. So using terminal (vim) , a tab looks like 2 tabs actually. After getting it to work with the terminal using your example, I replicated the same with Intellij but using 2 tabs instead. Commented Jul 29, 2023 at 21:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .