Skip to content
Advertisement

Makefile error: syntax error: unexpected word (expecting “fi”)

I have a problem with the following section of a Makefile:

if [ -d "$(MODLOOP_FIRMWARE_EXTERNAL)" ]; then 
    if [ ! -e "$(MODLOOP_DIR)"/lib/firmware ]; then 
        mkdir -p "$(MODLOOP_DIR)"/lib/firmware; 
    fi 
    cp -r "$(MODLOOP_FIRMWARE_EXTERNAL)"/* "$(MODLOOP_DIR)"/lib/firmware/; 
fi

make SHELL='sh -x':

if [ -d "/mnt/firmware" ]; then 
    if [ ! -e "/mnt/build-env"/lib/firmware ]; then 
        mkdir -p "/mnt/build-env"/lib/firmware; 
    fi 
    cp -r "/mnt/firmware"/* "/mnt/build-env"/lib/firmware/; 
fi
sh: syntax error: unexpected word (expecting "fi")

If I remove the line:

cp -r "/mnt/firmware"/* "/mnt/build-env"/lib/firmware/;

it will work, but I can’t see what the problem is.

What am I doing wrong?

Advertisement

Answer

You should add ; after this fi in the fourth line.

Advertisement