Created
September 15, 2016 04:29
-
-
Save YuukiTsuchida/a6a0a93c66ec98735162f88df3eda6f8 to your computer and use it in GitHub Desktop.
Makeのことはじめ ref: http://qiita.com/thaladabar/items/1f72a3359acb5cf7428e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY ターゲット | |
ターゲット: 依存ファイル | |
[実行コマンド] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% make ターゲット |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.cpp.o: | |
コマンド |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: debug | |
debug: main.o sub1.o | |
clang++ main.o sub1.o | |
.cpp.o: | |
clang++ -c -std=c++14 -O3 -g $< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC=clang++ | |
SRCS=main.cpp sub1.cpp | |
EXE_FILE=exe_ | |
CXXFLAGS=-c -std=c++14 | |
OBJS=$(SRCS:.cpp=.o) | |
DEFINE=NDEBUG | |
.PHONY: debug | |
debug: EXE_FILE=exe_debug | |
debug:CXXFLAGS+=-g -O3 -Wall -W | |
debug: build | |
.PHONY: release | |
release: EXE_FILE=exe_release | |
release: CXXFLAGS+=-O0 -DNDEBUG | |
release: build | |
.PHONY: build | |
build: $(OBJS) | |
$(CC) -o $(EXE_FILE) $(OBJS) | |
.cpp.o: | |
$(CC) -c -std=c++14 $(CXXFLAGS) $< | |
.PHONY: clean | |
clean: | |
rm -f $(EXE_FILE)* $(OBJS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clang++ -MMD -std=c++11 -c main.cpp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC=clang++ | |
SRCS=main.cpp sub1.cpp | |
DEPS=$(SRCS:.cpp=.d) | |
EXE_FILE=exe_ | |
CXXFLAGS=-c -std=c++14 | |
OBJS=$(SRCS:.cpp=.o) | |
DEFINE=NDEBUG | |
-include $(DEPS) | |
.PHONY: debug | |
debug: EXE_FILE=exe_debug | |
debug:CXXFLAGS+=-g -O3 -Wall -W | |
debug: build | |
.PHONY: release | |
release: EXE_FILE=exe_release | |
release: CXXFLAGS+=-O0 -DNDEBUG | |
release: build | |
.PHONY: build | |
build: $(OBJS) | |
$(CC) -o $(EXE_FILE) $(OBJS) | |
.cpp.o: | |
$(CC) -c -MMD -MP -std=c++14 $(CXXFLAGS) $< | |
.PHONY: clean | |
clean: | |
rm -f $(EXE_FILE)* $(OBJS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY output | |
output: | |
echo "test" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "test" # makeの出力 | |
test # echoの出力 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: debug | |
debug: main.cpp | |
clang++ -std=c++14 -O3 -g main.cpp | |
.PHONY: release | |
release: main.cpp | |
clang++ -std=c++14 -O0 -DNDEBUG main.cpp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: debug | |
debug: main.cpp sub1.cpp | |
clang++ -std=c++14 -O3 -g main.cpp | |
clang++ -std=c++14 -O3 -g sub1.cpp | |
clang++ -o main main.o sub1.o |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "sub1.hpp" | |
int main(int argc, char const* argv[]) | |
{ | |
std::cout << "make test" << std::endl; | |
sub1(); | |
#ifdef NDEBUG | |
std::cout << "NO DEBUG" << std::endl; | |
#else | |
std::cout << "DEBUG" << std::endl; | |
#endif | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main.o: main.cpp sub1.hpp | |
sub1.hpp: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "sub1.hpp" | |
void sub1() | |
{ | |
std::cout << "sub1" << std::endl; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
void sub1(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment