forked from kosua20/MIDIVisualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.linux
78 lines (59 loc) · 2.28 KB
/
Makefile.linux
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
#Compiler: g++
CXX = g++
#Include directories (for headers): standard include dirs in /usr and /usr/local, and our helper directory.
INCLUDEDIR = -I/usr/include/ -I/usr/local/include/ -Isrc/helpers/ -Isrc/libs/
#Library directory (just in case)
LIBDIR = -L/usr/local/lib
#Libraries needed: OpenGL and glfw3. glfw3 require X11, Xi, and so on...
LIBS = -lglfw3 -lnfd -lGL -lX11 -lXi -lXrandr -lXxf86vm -lXinerama -lXcursor -lrt -lm -pthread -ldl
#Compiler flags: C++11 standard, and display 'all' warnings.
CXXFLAGS = -std=c++11 -Wall -O3
#Build directory
BUILDDIR = build
#Source directory
SRCDIR = src
#Paths to the source files
#Collect sources from subdirectories (up to depth 3)
# /!\ at depth 4, src/helpers/glm/detail contains dummy cpp files that we want to ignore.
SRC_DEPTH_2 = $(wildcard $(SRCDIR)/*/*.cpp)
SRC_DEPTH_3 = $(wildcard $(SRCDIR)/*/*/*.cpp)
SOURCES = $(SRC_DEPTH_3) $(SRC_DEPTH_2) $(SRCDIR)/main.cpp
TOOLSOURCES = $(SRC_DEPTH_3) $(SRC_DEPTH_2) $(SRCDIR)/packager.cpp
#Paths to the object files
OBJECTS = $(SOURCES:$(SRCDIR)/%.cpp=$(BUILDDIR)/%.o)
TOOLOBJECTS = $(TOOLSOURCES:$(SRCDIR)/%.cpp=$(BUILDDIR)/%.o)
#Paths to the subdirectories
SUBDIRS_LIST = $(shell find src -type d)
SUBDIRS = $(SUBDIRS_LIST:$(SRCDIR)%=$(BUILDDIR)%)
#Executable name
EXECNAME = midiviz
TOOLNAME = midiviz-packager
#Re-create the build dir if needed, compile and link.
all: $(TOOLNAME) $(EXECNAME)
#Linking phase: combine all objects files to generate the executable
$(EXECNAME): dirs $(OBJECTS)
@echo "Linking $(EXECNAME)..."
@$(CXX) $(LIBDIR) $(OBJECTS) $(LIBS) -o $(BUILDDIR)/$(EXECNAME)
@echo "Done!"
$(TOOLNAME): dirs $(TOOLOBJECTS)
@echo "Linking $(TOOLNAME)..."
@$(CXX) $(TOOLOBJECTS) $(LIBS) -o $(BUILDDIR)/$(TOOLNAME)
@echo "Done!"
#Compiling phase: generate the object files from the source files
$(BUILDDIR)/%.o : $(SRCDIR)/%.cpp
@echo "Compiling $<"
@$(CXX) -c $(CXXFLAGS) $(INCLUDEDIR) $< -o $@
#Run the executable
run:
@./$(BUILDDIR)/$(EXECNAME)
# Package the images as raw arrays and write them in the source directory.
package: dirs $(TOOLNAME)
@./$(BUILDDIR)/$(TOOLNAME)
@echo "You can now compile $(EXECNAME) with the updated data."
#Create the build directory and its subdirectories
dirs:
@mkdir -p $(SUBDIRS)
#Remove the whole build directory
.PHONY: clean
clean :
rm -r $(BUILDDIR)