salman khan
salman khan

Reputation: 33

How to write install tag in makefile?

install: bank
if[ -d $(INSTDIR) ];\
then\
cp bank $(INSTDIR);\
echo "Installed in $(INSTDIR)";\
else\
echo "Sorry";\
fi

I am writing this script in install tag and this error is coming. Can anybody suggest what I did wrong,.

error->
if[ -d /home/salman/Desktop ];\
then\
cp bank /home/salman/Desktop;\
echo "Installed in /home/salman/Desktop";\
else\
echo "Sorry";\
fi
/bin/sh: -c: line 6: syntax error near unexpected token `fi'
/bin/sh: -c: line 6: `fi'
make: *** [install] Error 1

Upvotes: 0

Views: 347

Answers (2)

vvvv
vvvv

Reputation: 135

Please try something like this:

install:
        if [ -d $(INCLUDE_INC) ] ; then\
                echo "Is a directory $(INCLUDE_INC)";\
        else\
                echo "Sorry";\
        fi
  1. One tab before the if, else and fi.
  2. Two tabs before the echo statements.
  3. "\" slashes to keep the command in single line.

Upvotes: 0

Wayne
Wayne

Reputation: 651

Add a space between 'if' and '['. The syntax error is due to space missing.

Upvotes: 1

Related Questions