-
Notifications
You must be signed in to change notification settings - Fork 5
/
makefile
220 lines (163 loc) · 5.81 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# makefile for building samples for udgcd
# author: S. Kramm, 2015-2023
# see https://github.com/skramm/udgcd
# Linux only, probably.
COLOR_1=-e "\e[1;33m"
COLOR_2=-e "\e[1;34m"
COLOR_OFF="\e[0m"
# don't delete intermediate files
.SECONDARY:
# disable implicit rules
.SUFFIXES:
.PHONY: clearlogfile svg all help runsam doc clean cleanout diff
#--------------------------------
# general compiler flags
# -Wno-unused-result is to avoid the warning on call to std::system() when calling dot (see void CallDot() )
CFLAGS = -std=c++11 -Wall -O2 -Iinclude -Wno-unused-result
# test_m4ri.cpp: wrapper_m4ri.hpp
# remove if no need to compare the output ti some ground truth
#CFLAGS += -DUDGCD_NORMALIZE_CYCLES
ifeq "$(PRINT_STEPS)" "Y"
CFLAGS += -DUDGCD_PRINT_STEPS
endif
ifeq "$(DEVMODE)" "Y"
CFLAGS += -DUDGCD_DEV_MODE
endif
ifeq "$(DEBUG)" "Y"
CFLAGS += -g
LDFLAGS += -g
else
LDFLAGS += -s
endif
ifeq "$(M4RI)" "Y"
CFLAGS += -DUDGCD_USE_M4RI
LDFLAGS +=-lm4ri
endif
SHELL=/bin/bash
# files and folders
SRC_DIR=demo
APP=udgcd.hpp
HEADER=udgcd.hpp
HEADERS = $(wildcard *.h*)
HEADERS += $(wildcard demo/*.h*)
BIN_DIR=build/bin
OBJ_DIR=build/obj
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES))
EXEC_FILES = $(patsubst $(SRC_DIR)/%.cpp,$(BIN_DIR)/%,$(SRC_FILES))
SAMPLE_FILES = $(wildcard samples/*.txt)
GEN_GSAMPLE_FILES = $(wildcard out/gen_graph_*.txt)
GEN_GSAMPLES_OUTPUT = $(patsubst out/%.txt,out/stdout_%.txt,$(GEN_GSAMPLE_FILES))
GEN_SAMPLE_TXT_FILES = $(wildcard samples/graph_*.txt)
GEN_SAMPLE_DOT_FILES = $(wildcard samples/graph_*.dot)
GEN_SAMPLES_OUTPUT = $(patsubst samples/graph_%.txt,out/stdout_graph_%.txt,$(GEN_SAMPLE_TXT_FILES))
GEN_SAMPLES_OUTPUT += $(patsubst samples/graph_%.dot,out/stdout_graph_%.txt,$(GEN_SAMPLE_DOT_FILES))
#GEN_SAMPLES_PLOT = $(patsubst samples/%.txt,out/sample_%.svg,$(GEN_SAMPLE_FILES))
DOT_FILES=$(wildcard out/*.dot)
SVG_FILES=$(patsubst out/%.dot,out/svg/%_dot.svg,$(DOT_FILES))
SVG_FILES+=$(patsubst out/%.dot,out/svg/%_neato.svg,$(DOT_FILES))
help:
@echo "Available targets:"
@echo " -run: runs once all the produced binaries"
@echo " -runsam: runs cycle detection process on all provided samples"
@echo " -svg: build svg renderings of all the samples produced by target 'runsam', with cycles as colored edges (see folder 'out')"
@echo " -clean: erase obj files"
@echo " -cleanout: erase produced output"
@echo " -cleandoc: erase produced (doxygen-build) documentation"
@echo " -cleanall: all of the above \"clean\" targets"
@echo " -doc: builds documentation form source, using doxygen"
@echo "Available options"
@echo " -PRINT_STEPS={Y|N} (default: N) : logs some steps to stdout"
@echo " -DEVMODE={Y|N} (default: N) : lots of additional logging on stdout (useless for end user)"
all: $(EXEC_FILES)
@echo "- Done target $@"
# runs once all the produced binaries
run: all
$(addsuffix ;,$(EXEC_FILES))
@echo "- Done target $@"
# runs on all generated samples
rungen: $(GEN_GSAMPLES_OUTPUT) $(BIN_DIR)/read_graph
@echo "- Done target $@"
# runs cycle detection process on all provided samples
runsam: clearlogfile $(GEN_SAMPLES_OUTPUT) $(BIN_DIR)/read_graph
@echo "- Done target $@"
clearlogfile: makefile
@echo "Running make target 'runsam', results:" > build/runsam.log
# this one for .txt input files
out/stdout_graph_%.txt: samples/graph_%.txt $(BIN_DIR)/read_graph makefile
@echo "processing file $<"
@-$(BIN_DIR)/read_graph $< > $@;\
STATUS=$$?; echo "file $<: exit with $$STATUS" >> build/runsam.log
# this one for .dot input files
out/stdout_graph_%.txt: samples/graph_%.dot $(BIN_DIR)/read_graph makefile
@echo "processing file $<"
@-$(BIN_DIR)/read_graph $< > $@;\
STATUS=$$?; echo "file $<: exit with $$STATUS" >> build/runsam.log
create_svg:
mkdir -p out/svg/
out/svg/%_dot.svg: out/%.dot create_svg
@echo "generating $@"
@dot -Tsvg -Nfontsize=24 $< >out/svg/$(notdir $(basename $@))_dot.svg
out/svg/%_neato.svg: out/%.dot create_svg
@echo "generating $@"
@neato -Tsvg -Nfontsize=24 -Elen=2.0 $< >out/svg/$(notdir $(basename $@))_neato.svg
show: $(SRC_FILES)
@echo SRC_FILES=$(SRC_FILES)
@echo OBJ_FILES=$(OBJ_FILES)
@echo EXEC_FILES=$(EXEC_FILES)
@echo SAMPLE_FILES=$(SAMPLE_FILES)
@echo GEN_GSAMPLE_FILES=$(GEN_GSAMPLE_FILES)
@echo GEN_GSAMPLES_OUTPUT=$(GEN_GSAMPLES_OUTPUT)
@echo GEN_SAMPLE_TXT_FILES=$(GEN_SAMPLE_TXT_FILES)
@echo GEN_SAMPLE_DOT_FILES=$(GEN_SAMPLE_DOT_FILES)
@echo GEN_SAMPLES_OUTPUT=$(GEN_SAMPLES_OUTPUT)
@echo GEN_SAMPLES_PLOT =$(GEN_SAMPLES_PLOT)
@echo DOT_FILES =$(DOT_FILES)
@echo SVG_FILES =$(SVG_FILES)
doc:
doxygen misc/doxyfile 1>build/doxygen.stdout 2>build/doxygen.stderr
xdg-open build/html/index.html
doc2:
make runsam -j4
make svg -j4
make doc
clean:
@-rm $(OBJ_DIR)/*
@-rm $(BIN_DIR)/*
@-rm build/doxygen.*
@-rm *.layout
cleanout:
@-rm out/*
@-rm out/svg/*
cleanall: clean cleandoc cleanout
@-rm $(EXEC_FILES)
cleandoc:
@-rm -r build/html/*
# @-rmdir html
svg: $(SVG_FILES)
@echo "target $@ done"
diff:
git diff --color-words | aha > $(OBJ_DIR)/diff.html
xdg-open $(OBJ_DIR)/diff.html
# needs 'sudo'
install:
-cp $(APP) /usr/local/include/$(APP)
# generic compile rule
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(HEADERS) wrapper_m4ri.hpp
@echo $(COLOR_2) " - Compiling app file $<." $(COLOR_OFF)
$(CXX) -o $@ -c $< $(CFLAGS)
# linking
# -s option: strip symbol (don't add if debugging)
$(BIN_DIR)/%: $(OBJ_DIR)/%.o
@echo $(COLOR_1) " - Link demo $@." $(COLOR_OFF)
$(CXX) -o $@ $< $(LDFLAGS)
# $(L)$(CXX) -o $@ $< $(LDFLAGS)
#$(BIN_DIR)/test_catch: $(OBJ_DIR)/test_catch.o
# $(CXX) -o bin/test_catch $(OBJ_DIR)/test_catch.o -s
# @echo "done target $@"
$(BIN_DIR)/test_catch: udgcd.hpp test_catch.cpp
$(CXX) -o $(BIN_DIR)/test_catch test_catch.cpp -s $(CFLAGS)
@echo "done target $@"
# -s option: also shows successful test results
test: $(BIN_DIR)/test_catch
$(BIN_DIR)/test_catch