summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 1567380a865b5300186894741b5d8ecf1b60ba27 (plain)
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
EXE := fsisotool

CXX := c++
CXXFLAGS := -std=c++11 -Isrc -Isrc/imgui -Isrc/implot -Isrc/imgui/backends -Isrc/armadillo/include # -I src/slycot
CXXFLAGS += -g -Wall -Wformat
LIBS :=

# FOR := gfortran
# FORFLAGS := -lstdc++ -static-libgfortran

SOURCES_CPP := src/main.cpp \
	src/control.h \
	src/control.cpp \
	$(wildcard src/implot/*.cpp) \
	$(wildcard src/implot/*.h) \
	$(wildcard src/imgui/*.cpp) \
	$(wildcard src/imgui/*.h) \
	src/imgui/backends/imgui_impl_opengl3.h \
	src/imgui/backends/imgui_impl_glfw.h \
	src/imgui/backends/imgui_impl_glfw.cpp \
	src/imgui/backends/imgui_impl_opengl3_loader.h \
	src/imgui/backends/imgui_impl_opengl3.cpp \
	$(wildcard src/armadillo/*.cpp)
	# $(wildcard src/slycot/*.cpp) \
	# $(wildcard src/slycot/*.h) \

# SOURCES_F := $(wildcard src/slycot/*.f)

OBJS := $(subst src, build, $(addsuffix .o, $(basename $(filter %.cpp, $(SOURCES_CPP)))))
# OBJS += $(subst src, build, $(addsuffix .o, $(basename $(filter %.f, $(SOURCES_F)))))

UNAME_S := $(shell uname -s)
LINUX_GL_LIBS = -lGL

ifeq ($(UNAME_S), Linux) #LINUX
	ECHO_MESSAGE = "Linux"
	LIBS += $(LINUX_GL_LIBS) `pkg-config --static --libs glfw3 lapack`
	CXXFLAGS += `pkg-config --cflags glfw3 lapack`
endif

ifeq ($(UNAME_S), Darwin) #APPLE
	ECHO_MESSAGE = "Mac OS X"
	LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -framework Accelerate
	LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib # -L/opt/homebrew/lib/gcc/current
	LIBS += -lglfw -llapack # -lgfortran
	CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include
endif

ifeq ($(OS), Windows_NT)
	ECHO_MESSAGE = "MinGW"
	LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
	CXXFLAGS += `pkg-config --cflags glfw3`
endif

.PHONY: all dir clean
all: $(EXE)
	@echo Build complete for $(ECHO_MESSAGE)

dir:
	mkdir -p build/imgui/backends
	mkdir -p build/implot
	mkdir -p build/armadillo
	# mkdir -p build/slycot

clean:
	rm -rdf $(EXE) $(OBJS) build

build/%.o:src/%.cpp | dir
	$(CXX) $(CXXFLAGS) -c -o $@ $<

# build/%.o:src/%.f | dir
# 	$(FOR) $(FORFLAGS) -c -o $@ $<

$(EXE): $(OBJS)
	$(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)