ln-frag/Makefile

65 lines
1.8 KiB
Makefile

NAME = ln-frag
TARGET = $(NAME).out
SRC_DIR = src
INC_DIR = $(SRC_DIR)/include
SHADER_DIR = res/shaders
BUILD_DIR = build
OBJ_DIR = $(BUILD_DIR)/obj
SPV_DIR = $(BUILD_DIR)/spv
CXX = clang++
LINK = clang
GLSLC = glslc
CFLAGS = -Wall -DDBG -ggdb
LDFLAGS =
SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp)
OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRC_FILES))
OBJ_FILES_NOMAIN = $(filter-out $(OBJ_DIR)/main.o, $(OBJ_FILES)) # Object files without main.c.
SHADER_FILES = $(wildcard $(SHADER_DIR)/*)
RESETCOLOR = \033[0m
WHITE = $(RESETCOLOR)\033[37m
WHITE_BOLD = $(RESETCOLOR)\033[37;1m
all: $(TARGET)
release: clean
release: CFLAGS = -Wall -O2
release: $(TARGET)
run: $(TARGET)
@ echo -e "$(WHITE_BOLD)Running... $(RESETCOLOR)./$(TARGET)"
@ ./$(TARGET)
# Compile project sources.
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(INC_DIR)/%.hpp
@ mkdir -p $(OBJ_DIR)
@ echo -e "$(WHITE_BOLD)Compiling $(WHITE)$<$(WHITE_BOLD)... $(RESETCOLOR)$(CXX) $(CFLAGS) -c $< -o $@"
@ $(CXX) $(CFLAGS) -c $< -o $@
# Compile vertex shaders.
$(SPV_DIR)/%-vert.spv: $(SHADER_DIR)/%.vert
@ mkdir -p $(SPV_DIR)
@ echo -e "$(WHITE_BOLD)Compiling vertex shader $(WHITE)$<$(WHITE_BOLD)... $(RESETCOLOR)$(GLSLC) $< -o $@"
@ $(GLSLC) $< -o $@
# Compile fragment shaders.
$(SPV_DIR)/%-frag.spv: $(SHADER_DIR)/%.frag
@ mkdir -p $(SPV_DIR)
@ echo -e "$(WHITE_BOLD)Compiling fragment shader $(WHITE)$<$(WHITE_BOLD)... $(RESETCOLOR)$(GLSLC) $< -o $@"
@ $(GLSLC) $< -o $@
# Link to final binary.
$(TARGET): $(OBJ_FILES)
@ echo -e "$(WHITE_BOLD)Linking $(WHITE)$(TARGET)$(WHITE_BOLD)...$(RESETCOLOR) $(LINK) -o $(TARGET) $(OBJ_FILES) $(LDFLAGS)"
@ $(LINK) -o $(TARGET) $(OBJ_FILES) $(LDFLAGS)
clean:
@ echo -e "$(WHITE_BOLD)Cleaning up...$(WHITE) $(OBJ_DIR)/*.o $(TARGET) $(SPV_DIR)/*.spv $(RESETCOLOR)"
@ rm -rf $(OBJ_DIR)/*.o $(TARGET) $(SPV_DIR)/*.spv
.PHONY: all clean nocolor release run