-2

When I executed command make, I got an error message

Makefile:4: *** missing separator. Stop.

The command in Makefile is:

$(shell ./makejce common/jce jce)

What's wrong with it?

-------makejce---------

#!/bin/bash
FLAGS=""
local_protoc=""
dir0=`pwd`
dir=`pwd`
......

if [ $# -gt 1 ]
then
    mkdir -p $2
    cd $2
    dir=`pwd`
    cd $dir0
fi

cd $1
jce_dir=`pwd`

#sub dir
for d in `ls -d */`
do
    if [ -d $d ]
    then
            cd $d
            for f in `find . -name '*.jce'`
            do  
                    ${local_protoc} ${FLAGS} --dir=${dir} $f
            done
            cd $jce_dir
    fi
done

#current dir
for f in `ls *.jce`
do
    ${local_protoc} ${FLAGS} --dir=${dir} $f
done

cd $dir0

-----makefile------

......
$(shell ./makejce common/jce jce)
......
herbertluo
  • 59
  • 10

1 Answers1

2

With so little info it looks extremely bizarre (why are you running all the build steps in a shell script then invoking that script with a shell makefile function? The entire point of a makefile is to manage the build steps...) but without more information I'll just answer your specific question:

The make shell function works like backticks or $(...) in shell scripts: that is it runs the command in a shell and expands to the stdout of the command.

In your makefile if you have:

$(shell echo hi)

then it runs the shell command echo hi and expands to the stdout (i.e., hi). Then make will attempt to interpret that as some makefile text, because that's where you have put the function invocation (on a line all by itself). That's a syntax error because make doesn't know what to do with the string hi.

If you want to run a shell function then either (a) redirect its output so it doesn't output anything:

$(shell ...command... >/dev/null 2>&1)

or (b) capture the output somewhere that it won't bother make, such as in a variable like this:

_dummy := $(shell ...command...)

(by using := here we ensure the shell function is evaluated when the makefile is parsed).

MadScientist
  • 92,819
  • 9
  • 109
  • 136