-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·178 lines (143 loc) · 5.31 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Example directory structure: ディレクトリ構成例
#
# root/
# |
# + main.cpp (your code)
# |
# + Makefile (your makefile): This file
# |
# + sstd/
# |
# + sstd.hpp (head file that you need to include)
# |
# + Makefile (Makefile that you need to '$ make')
# |
# + make_temp/
# | |
# | + src/
# | |
# | + *.d
# | |
# | + *.o (object files that you need to link "./sstd/make_temp/*.o")
# |
# + src/
# |
# + *.cpp
# |
# + *.hpp
# |
# + *.h
# .o: Objects file
# .d: Depends file
#============================================================
# Please set each item: 各項目を設定してください
# Source files
SRCS = ./main.cpp
# Name of generate file: 生成ファイル名
TARGET = exe
# remove files
RMs = *.stackdump tmp tmpDir
RMs += test_file_c.png
RMs += test_file_c2f.png
RMs += ./sin.png # test file generated by test/c2py
RMs += ./sin_cos.png # test file generated by test/c2py
RMs += ./test_reCombined.png # test file generated by test/c2py
RMs += ./test__writeAll_bin_char.png # test file generated by test/strEdit
RMs += ./test__writeAll_bin_str.png # test file generated by test/strEdit
RMs += ./test_fopen.txt
RMs += ./test_mkdir
# Options: コンパイルオプション
CFLAGS = -L./sstd/lib -I./sstd/include -lsstd # sstd
CFLAGS += -L./googletest-master/build/lib -I./googletest-master/googletest/include -lgtest -pthread # google test
CFLAGS += -std=c++2a # C++ 20
CFLAGS += -Wall
CFLAGS += -O3
CFLAGS += -fopenmp
#============================================================
TEMP_DIR = tmp/make
BACKUP_DIR = ./backup
ALL_FILES = $(wildcard ./*)
TMP_DIRS = $(wildcard ./tmp_*)
LIBS_DIRS = ./googletest-master
BACKUP_FILES = $(filter-out ./$(TARGET) $(TMP_DIRS) $(BACKUP_DIR) $(LIBS_DIRS), $(ALL_FILES))
TIME_STAMP = `date +%Y_%m%d_%H%M`
MULTI_DEF_TEST_FILE = check_multiple_definition
TEST_MULTI_DEF = $(TEMP_DIR)/multiple_definition/$(MULTI_DEF_TEST_FILE).o
# when you need to check the change of files in lib, you need to change file name to a not-existing name like "FORCE_XXX".
LIB_SSTD = FORCE_TO_MAKE_SSTD
#LIB_GOOGLETEST = FORCE_TO_MAKE_GOOGLETEST
#LIB_SSTD = ./sstd/lib/libsstd.a
LIB_GOOGLETEST = ./googletest-master/build/lib/libgtest.a
LIB_GTEST_PARALLEL = ./gtest_parallel/gtest_parallel.hpp
LIB_GTEST_PARALLEL_MAIN = ./gtest_parallel/test_main.hpp
TEST_EXES = FORCE_TO_MAKE_TEST_EXE
.PHONY: all
all: $(LIB_SSTD) $(LIB_GOOGLETEST) $(TEST_MULTI_DEF) $(TEST_EXES) $(SRCS) $(TARGET)
.PHONY: all_mp
all_mp:
@(make clean)
@(make -j)
$(TARGET): $(SRCS) $(LIB_GTEST_PARALLEL)
@echo "\n============================================================"
@echo "Build begin: exe\n"
@echo "SRCS: \n$(SRCS)\n"
@echo "CFLAGS: \n$(CFLAGS)"
# $(CXX) -o $(TARGET) $(SRCS) $(CFLAGS) $(TEST_MULTI_DEF)
@`/usr/bin/time -f "Build time: %e sec ($@)" $(CXX) -o $(TARGET) $(SRCS) $(CFLAGS) $(TEST_MULTI_DEF);`
@echo "\n Build end: exe"
@echo "============================================================\n"
$(LIB_SSTD):
@echo "\n============================================================"
@echo "Build begin: SSTD\n"
@(cd ./sstd; make -j)
@echo "\n Build end: SSTD"
@echo "============================================================\n"
$(LIB_GOOGLETEST):
@echo "\n============================================================"
@echo "Build begin: GoogleTest\n"
@tar -zxvf googletest-release-1.12.1.tar.gz
@mv googletest-release-1.12.1 googletest-master
@(cd ./googletest-master; mkdir -p build; cd build; cmake ..; make)
# @unzip -n googletest-master.zip
# @(cd ./googletest-master; mkdir -p build; cd build; cmake ..; make)
@echo "\n Build end: GoogleTest"
@echo "============================================================\n"
$(TEST_MULTI_DEF):
@mkdir -p $(TEMP_DIR)/multiple_definition
$(CXX) ./test/multiple_definition/$(MULTI_DEF_TEST_FILE).cpp -c $(CFLAGS) -o $(TEST_MULTI_DEF)
$(TEST_EXES):
@echo "\n============================================================"
@echo "Build begin: TEST_EXES\n"
@(cd ./test; make -j)
@echo "\n Build end: TEST_EXES"
@echo "============================================================\n"
patch := *.stackdump
patch_txt_exists := $(shell find -name $(patch))
.PHONY: clean
clean:
-rm -rf $(TARGET)
@(cd ./sstd; make clean)
-rm -rf googletest-master
@(find . -name "__pycache__" -type d | xargs rm -rf)
$(if $(patch_txt_exists) ,$(rm *.stackdump))
-rm -rf $(RMs)
-rm -rf test__write_bin_char.png
-rm -rf test__write_bin_str.png
-rm -rf $(TEMP_DIR)
.PHONY: steps
steps: $(SRCS) $(PYFILES_t) $(TEST_PY)
@(cd ./sstd; make steps)
@(cd ./test; make steps)
@echo ""
@echo ./test/multiple_definition/$(MULTI_DEF_TEST_FILE).cpp ./test/multiple_definition/$(MULTI_DEF_TEST_FILE).hpp | xargs wc -l
.PHONY: zip
zip:
@mkdir -p $(BACKUP_DIR)
zip -r $(BACKUP_DIR)/${TIME_STAMP}$(m).zip $(BACKUP_FILES)
.PHONY: backup
backup:
@(make clean)
@(make zip)
@(make)
# when you need comments for backup, just type
# $ make backup m=_comment_will_be_inserted_after_the_date