LoginSignup
2
0

More than 3 years have passed since last update.

Makeのhelpコマンドでターゲットの一覧を出す。

Posted at

Makeファイルを便利なタスクランナーとして使ってると、ターゲットがいっぱい増えてきて、何がなんだかわからなくなっちゃうので、簡単なhelpコマンドを作ると良い。

Makefile
#: ヘルプコマンド
help:
    @grep -A1 -E "^#:" Makefile \
    | grep -v -- -- \
    | sed 'N;s/\n/###/' \
    | sed -n 's/^#: \(.*\)###\(.*\):.*/\2###\1/p' \
    | column -t  -s '###'

#: ビルド
build:
    buid command

Makefileに↑こんな感じで、helpコマンドを実装。
ターゲットの1行上に#: に続けてコメントを書いておくと、

$ make help
help                  ヘルプコマンド
build                 ビルド

こんなかんじで、一覧を出力してくれる。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0