forked from guicattani/cg-guide-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
104 lines (81 loc) · 2.71 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
#
# Cross Platform Makefile
# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X
#
# You will need GLFW (http://www.glfw.org):
# Linux:
# apt-get install libglfw-dev
# Mac OS X:
# brew install glfw
# MSYS2:
# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw
#
#CXX = g++
#CXX = clang++
EXE = main
SOURCES = ./src/main.cpp
SOURCES += ./src/callbacks.cpp ./src/shaders.cpp ./src/interface.cpp
SOURCES += ./libs/tiny_obj_loader/tiny_obj_loader.cpp
SOURCES += ./libs/imgui/imgui_impl_glfw.cpp ./libs/imgui/imgui_impl_opengl3.cpp
SOURCES += ./libs/imgui/imgui.cpp ./libs/imgui/imgui_demo.cpp ./libs/imgui/imgui_draw.cpp ./libs/imgui/imgui_widgets.cpp
OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES))))
UNAME_S := $(shell uname -s)
INCLUDE := include
LIB := libs
CXXFLAGS = -I./libs/imgui -I./libs/tiny_obj_loader -I./libs/KHR/
CXXFLAGS += -g -Wall -Wformat -Wno-unknown-pragmas
LIBS =
##---------------------------------------------------------------------
## OPENGL LOADER
##---------------------------------------------------------------------
## Using OpenGL loader: gl3w [default]
SOURCES += ./libs/gl3w/GL/gl3w.c
CXXFLAGS += -I./libs/gl3w
## Using OpenGL loader: glew
## (This assumes a system-wide installation)
CXXFLAGS += -lGLEW -DIMGUI_IMPL_OPENGL_LOADER_GLEW
##---------------------------------------------------------------------
## BUILD FLAGS PER PLATFORM
##---------------------------------------------------------------------
ifeq ($(UNAME_S), Linux) #LINUX
ECHO_MESSAGE = "Linux"
LIBS += -lGL `pkg-config --static --libs glfw3`
CXXFLAGS += `pkg-config --cflags glfw3`
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(UNAME_S), Darwin) #APPLE
ECHO_MESSAGE = "Mac OS X"
LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
LIBS += -L/usr/local/lib -L/opt/local/lib
#LIBS += -lglfw3
LIBS += -lglfw
CXXFLAGS += -I/usr/local/include -I/opt/local/include
CFLAGS = $(CXXFLAGS)
endif
ifeq ($(findstring MINGW,$(UNAME_S)),MINGW)
ECHO_MESSAGE = "MinGW"
LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32
CXXFLAGS += `pkg-config --cflags glfw3`
CFLAGS = $(CXXFLAGS)
endif
##---------------------------------------------------------------------
## BUILD RULES
##---------------------------------------------------------------------
%.o:./src/%.cpp
$(CXX) $(CXXFLAGS) -I$(INCLUDE) -c -o $@ $<
%.o:./libs/imgui/%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
%.o:./libs/tiny_obj_loader/%.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
%.o:./libs/gl3w/GL/%.c
$(CC) $(CFLAGS) -c -o $@ $<
all: $(EXE)
mv $(OBJS) ./bin/
mv $(EXE) ./bin/
@echo Build complete for $(ECHO_MESSAGE)
$(EXE): $(OBJS)
$(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS)
run: all
cd ./bin; ./$(EXE);
clean:
cd ./bin; rm -rf $(EXE) $(OBJS);