ikeh1024のブログ

ZennやQiitaに書くにはちょっと小粒なネタをこちらに書いています

Makefileで複数行のコマンドを書くときのセミコロン

概要

  • とても難しい。わかるようなわからんような。
  • 一旦シェルスクリプトで考えるといい。

参考

# Standard
for x in 1 2 3
do
    echo $x
done

# 1 line
for x in 1 2 3; do echo $x; done
.PHONY: test
test:
    @for x in 1 2 3;\
    do\
        echo $$x;\
    done
# Standard
if true; then
    echo "hello"
else
    echo "goodbye"
fi

# 1 line
if true; then echo "hello"; else echo "goodbye"; fi
.PHONY: test
test:
    if true; then\
        echo "hello";\
    else\
        echo "goodbye";\
    fi