-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (38 loc) · 1.21 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
CC := g++
BUILD_DIR := build
TARGET := $(BUILD_DIR)/ray-marching
RENDER_DIR := output
INCLUDES := -Iexternal -Iexternal/glfw/include
CXXFLAGS := -MP -MMD -fopenmp -O2 $(INCLUDES)
SRCS := $(wildcard *.cpp)
OBJS := $(patsubst %.cpp, $(BUILD_DIR)/%.o, $(notdir $(SRCS)))
SRC_GLFW := external/glfw/src
OBJS_GLFW := $(patsubst %.c, $(BUILD_DIR)/glfw/%.o, $(notdir $(wildcard $(SRC_GLFW)/*.c)))
LDFLAGS :=
ifeq ($(OS), Windows_NT)
LDFLAGS += -lgdi32
GLFW_PLATFORM := _GLFW_WIN32
else
LDFLAGS += -lGL -lm
GLFW_PLATFORM := _GLFW_X11
endif
all: build
build: create_dir $(TARGET)
create_dir:
@mkdir -p $(BUILD_DIR)
@mkdir -p $(BUILD_DIR)/glfw
@mkdir -p $(RENDER_DIR)
$(TARGET): $(OBJS_GLFW) $(OBJS)
@echo "Linking $(TARGET)"
@$(CC) $(CXXFLAGS) $(INCLUDES) $(OBJS) $(OBJS_GLFW) $(LDFLAGS) -o $(TARGET)
@echo "Build complete for $(TARGET)"
$(BUILD_DIR)/glfw/%.o: $(SRC_GLFW)/%.c
@echo "Compiling $(notdir $<)"
@$(CC) $(CXXFLAGS) -x c $ -c $< -o$@ -D$(GLFW_PLATFORM)
$(BUILD_DIR)/%.o: %.cpp
@echo "Compiling $(notdir $<)"
@$(CC) $(CXXFLAGS) -o $@ -c $<
run:
@$(TARGET)
clean:
@rm -f $(TARGET) $(wildcard $(BUILD_DIR)/*.o) $(wildcard $(BUILD_DIR)/glfw/*.o) $(DEPFILES)