[C++] 江添亮さんのC++Windowsで入門する方法(MinGW)(64bit Windows11) Make編 

https://ezoeryou.github.io/cpp-intro

に基づいて書いてます。

MinGWに付属する GNU make ですが、ファイル名が mingw32-make.exe となっていると思います。 このままでは使いにくいのでファイルをコピーして make.exe にリネームした方がよいでしょう。

windowsで、timeコマンド touchコマンドをつかうには gitbashが必要だ

(1) https://gitforwindows.org/ にアクセスしてください。

(2) [Download]をクリックしてください。

あとは適当にインストールで。C:\Program Files\Git\git-bash.exe

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$ make
makefile:2: *** missing separator. Stop.

はmakefile の改行のあとが space だから Tab にする。

program : source.cpp
    cat source.cpp > program

source : source01 source02 source03
    cat source01 source02 source03 > source

program : source
	cat source > program

source : source01 source02 source03
	cat source01 source02 source03 > source

うまくいった。

GitBash実行結果


furcr@furcraea_built MINGW64 /
$ cd C:/samples/ehararyu_cpp_sample/cpp

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp
$ cd source010203

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$ make
makefile:2: *** missing separator.  Stop.

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$ ^C

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$ make
cat source01 source02 source03 > source
cat source > program

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$ make
make: 'program' is up to date.

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$ make
cat source > program

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$ make
make: 'program' is up to date.

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$ make
make: 'program' is up to date.

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$ program
bash: program: command not found

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/source010203
$




Makefile

D : A B C
	cat A B C > D

A : a
	cat a > A

B : b
	cat b > B

C : c
	cat c > C

GitBash

furcr@furcraea_built MINGW64 ~
$ cd C:\samples\ehararyu_cpp_sample\cpp~
bash: cd: C:samplesehararyu_cpp_samplecpp~: No such file or directory

furcr@furcraea_built MINGW64 ~
$ cd C:\samples\ehararyu_cpp_sample\cpp
bash: cd: C:samplesehararyu_cpp_samplecpp: No such file or directory

furcr@furcraea_built MINGW64 ~
$ cd C:/samples/ehararyu_cpp_sample/cpp

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp
$ touch source01 source02 source03

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp
$ make
makefile:2: *** missing separator.  Stop.

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp
$ make
makefile:2: *** missing separator.  Stop.

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp
$ make
makefile:2: *** missing separator.  Stop.

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp
$ cd abc

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$ touch a b c

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$ make
Makefile:2: *** missing separator.  Stop.

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$ make
cat A B C > D

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$ touch b

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$ make
cat A B C > D

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$ time make
make: 'D' is up to date.

real    0m0.080s
user    0m0.015s
sys     0m0.000s

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$ ^C

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$

furcr@furcraea_built MINGW64 /c/samples/ehararyu_cpp_sample/cpp/abc
$