-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
51 lines (40 loc) · 1.55 KB
/
Makefile
File metadata and controls
51 lines (40 loc) · 1.55 KB
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
UNAME := $(shell uname)
PYBIND_INCLUDE = $(shell python3 -m pybind11 --includes)
OUTFILE = MinCompSpin$(shell python-config --extension-suffix)
CFLAGS = -Wall -Wextra -O3 -std=c++11
# -fvisibility=hidden see:
# https://pybind11.readthedocs.io/en/stable/faq.html#someclass-declared-with-greater-visibility-than-the-type-of-its-field-someclass-member-wattributes
CFLAGS_PYBIND_COMP = -IMinCompSpin_Greedy/Libraries -fvisibility=hidden
CFLAGS_PYBIND_LINK = -shared
ifeq ($(OS), Windows_NT) # Windows
# I don't know what to do here but from what I saw online
# it looks like it's the same as on linux.
CFLAGS_PYBIND_COMP += -fPIC -U__STRICT_ANSI__
else ifeq ($(UNAME), Darwin) # Mac
CFLAGS_PYBIND_LINK += -undefined dynamic_lookup
else ifeq ($(UNAME), Linux) # Linux
CFLAGS_PYBIND_COMP += -fPIC
else
$(error Couldn't find OS: $(UNAME))
endif
MCM_GREEDY_TARGET = MinCompSpin_Greedy/MCM_Greedy.out
MCM_GREEDY_BUILD_PATH = MinCompSpin_Greedy
CC = g++
CXXFLAGS = ERROR NO DEFAULT RULE
all: $(OUTFILE)
perf: $(MCM_GREEDY_TARGET) perf.o
$(CC) $(CFLAGS) -o perf $(MCM_GREEDY_TARGET) perf.o
./perf
perf.o: perf.cpp
$(CC) $(CFLAGS) -o perf.o -c perf.cpp
$(OUTFILE): $(MCM_GREEDY_TARGET) library.o
$(CC) $(CFLAGS) $(CFLAGS_PYBIND_LINK) -o $(OUTFILE) $(MCM_GREEDY_TARGET) library.o
library.o: library.cpp
$(CC) $(CFLAGS) $(CFLAGS_PYBIND_COMP) $(PYBIND_INCLUDE) -o library.o -c library.cpp
$(MCM_GREEDY_TARGET):
cd $(MCM_GREEDY_BUILD_PATH) && $(MAKE)
clean:
rm $(OUTFILE) || true
rm library.o || true
(cd $(MCM_GREEDY_BUILD_PATH) && $(MAKE) clean) || true
.PHONY: all perf