LoginSignup
0
0

More than 3 years have passed since last update.

[Makefile] 「Hello World!」する方法

Last updated at Posted at 2020-08-29

概要

Makefile を vim で編集し、「Hello World」と表示する方法についてまとめる。

手順

makefile の作成

作業用フォルダー(ここでは、「workspace」)にmakefile を作成

workspace $ touch makefile //makefile の作成

vim で編集

workspace $ vi makefile //vim で makefile を開く

黒い画面が表示されるので「i」をタイプすると、画面下部に「-- INSERT --」と表示され、文字の入力が可能になる
スクリーンショット 2020-08-29 23.05.22.png

makefile に以下のように入力

makefile
message = Hello World!!

helloWorld:
        echo $(message)

入力終了後は [esc] キーで insert モードを終了し、「:wq」(write quit) を入力してターミナルに戻る

makefile の書き方

target名:
        実行するコマンド

コマンドは Unix コマンド
半角スペースではなく、タブを利用する

ターミナルで実行

ターミナル
workspace $ make helloWorld
echo  Hello World!! //実行されたコマンド
Hello World!! //返り値

makefile で指定したターゲットの実行方法

make ターゲット名

参考資料

Makefikeとは
【初心者必見】最強エディタVimの使い方/コマンド30種まとめ

0
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
0
0