-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (39 loc) · 1.3 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
# executable name
EXEC=opengl
LIBS=-lm -L/usr/X11R6/lib -lglfw -lglew
CXX=g++
CXXFLAGS=-Wall --std=c++14 -O -g -MMD -DGL_SILENCE_DEPRECATION
INCLUDES=-I/usr/X11R6/include -framework OpenGL # -framework Cocoa
VENDOR=-Iinclude
SRC_DIR=src
BUILD_DIR=build
VENDOR_DIR=include
SRC_FILES=$(shell echo ${SRC_DIR}/*.cc ${SRC_DIR}/**/*.cc)
OBJ_FILES=$(SRC_FILES:${SRC_DIR}%.cc=${BUILD_DIR}%.o)
SRC_DEPS=${OBJ_FILES:.o=.d}
# we expect and assume that the vendor source code to be organized into
# subdirectories within the VENDOR_DIR directory;
VENDOR_SRC=$(shell echo ${VENDOR_DIR}/**/*.cc)
VENDOR_OBJ=$(VENDOR_SRC:${VENDOR_DIR}%.cc=${BUILD_DIR}%.o)
${EXEC}: ${OBJ_FILES} ${VENDOR_OBJ}
@echo "==========================="
@echo "linking object files..."
@mkdir -p ${BUILD_DIR}
${CXX} -o "${BUILD_DIR}/${EXEC}" ${OBJ_FILES} ${VENDOR_OBJ} ${LIBS} ${INCLUDES}
@echo "done"
${BUILD_DIR}/%.o: ${SRC_DIR}/%.cc Makefile
@echo "==========================="
@echo "compiling project source file '$<'"
@mkdir -p "$(@D)"
${CXX} -c $< -o $@ ${CXXFLAGS} ${VENDOR}
@echo "done"
${BUILD_DIR}/%.o: ${VENDOR_DIR}/%.cc Makefile
@echo "==========================="
@echo "compiling vendor source file '$<'"
@mkdir -p "$(@D)"
${CXX} -c $< -o $@ ${CXXFLAGS}
@echo "done"
-include ${SRC_DEPS}
.PHONY: clean
clean:
rm -rf ${BUILD_DIR}