forked from jlwitthuhn/cycles-shader-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (55 loc) · 1.86 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
CC ?= gcc
CXX ?= g++
AR ?= ar
BINARY_NAME = shader_editor
LIB_NAME = libshadereditor.a
SRC_DIR = ./src
INC_DIR = ./include
OBJ_DIR = ./obj
LIB_DIR = ./lib
LIB_PATH := $(LIB_DIR)/$(LIB_NAME)
CPP_PATHS := $(shell find $(SRC_DIR) -name *.cpp)
CPP_FILES := $(notdir ${CPP_PATHS})
OBJ_PATHS := $(CPP_FILES:%=$(OBJ_DIR)/%.o)
GCC_MAKEFILES := $(OBJ_PATHS:.o=.d)
# Uncomment these and point them to your libraries if
# their includes and libs are not on the default paths
#DEP_CXXFLAGS := -I../lib/glfw-3.2.1/dist/include/ -I../lib/glew-2.1.0/dist/include/
#DEP_LDFLAGS := -L../lib/glfw-3.2.1/dist/lib/ -L../lib/glew-2.1.0/dist/lib/
OS := $(shell uname)
ifeq ($(OS),Darwin)
GL_LDFLAGS = -framework OpenGL
MORE_LDFLAGS = -framework Cocoa -framework CoreVideo -framework IOKit
else
GL_LDFLAGS = -lGL
endif
CPPFLAGS_NVG := -MMD -MP
CPPFLAGS := -MMD -MP -Inanovg/src/
CXXFLAGS := -Wall -Wextra -std=c++14 $(DEP_CXXFLAGS)
LDFLAGS := -lstdc++ -lm -lGLEW -lglfw $(GL_LDFLAGS) $(DEP_LDFLAGS) $(MORE_LDFLAGS)
MKDIR_P = mkdir -p
PUBLIC_INCLUDES = graph_decoder.h graph_editor.h output.h util_platform.h
PUBLIC_INCLUDE_DST := $(addprefix $(INC_DIR)/,$(PUBLIC_INCLUDES))
$(BINARY_NAME): $(LIB_PATH) $(PUBLIC_INCLUDE_DST)
$(MKDIR_P) $(dir $@)
$(CXX) ./example/main.cpp $(LIB_DIR)/$(LIB_NAME) $(CXXFLAGS) $(LDFLAGS) -I$(INC_DIR) -o $@
$(OBJ_DIR)/%.cpp.o: $(SRC_DIR)/%.cpp
$(MKDIR_P) $(dir $@)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
$(OBJ_DIR)/nanovg.o: nanovg/src/nanovg.c
$(MKDIR_P) $(dir $@)
$(CC) $(CPPFLAGS_NVG) -c $< -o $@
$(INC_DIR)/%.h: $(SRC_DIR)/%.h
$(MKDIR_P) $(dir $@)
cp $< $@
$(LIB_PATH): $(OBJ_PATHS) $(OBJ_DIR)/nanovg.o
$(MKDIR_P) $(dir $@)
$(AR) rcs $(LIB_DIR)/$(LIB_NAME) $^
iwyu: CXX := include-what-you-use
iwyu: CXXFLAGS += -Xiwyu --mapping_file=./extra/iwyu.imp
iwyu: $(BINARY_NAME)
-include $(GCC_MAKEFILES)
clean:
rm -rf $(OBJ_DIR)
rm -rf $(INC_DIR)
rm -rf $(LIB_DIR)