1 Star 1 Fork 0

三笠阿卡曼/opengl

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Makefile 2.87 KB
一键复制 编辑 原始数据 按行查看 历史
v-szeyu 提交于 2024-06-03 16:16 . 引入模型加载库assimp
#
# 'make' build executable file 'main'
# 'make clean' removes all .o and executable files
#
# define the Cpp compiler to use
CXX = g++
# define any compile-time flags
CXXFLAGS := -std=c++17 -Wall -Wextra -g
# define library paths in addition to /usr/lib
# if I wanted to include libraries not in /usr/lib I'd specify
# their path using -Lpath, something like:
LFLAGS =
# define output directory
OUTPUT := output
# define userParam
CURRENT_DIR := $(1)
# define source directory
ifdef CURRENT_DIR
SRC := src/${CURRENT_DIR}
else
SRC := src
endif
# define include directory
INCLUDE := include
# define lib directory
LIB := lib
Libraries := -lglad -lglfw3dll -lassimp.dll
ifeq ($(OS),Windows_NT)
MAIN := main.exe
SOURCEDIRS := $(SRC)
INCLUDEDIRS := $(INCLUDE)
LIBDIRS := $(LIB)
FIXPATH = $(subst /,\,$1)
RM := del /q /f
MD := mkdir
else
MAIN := main
SOURCEDIRS := $(shell find $(SRC) -type d)
INCLUDEDIRS := $(shell find $(INCLUDE) -type d)
LIBDIRS := $(shell find $(LIB) -type d)
FIXPATH = $1
RM = rm -f
MD := mkdir -p
endif
# define any directories containing header files other than /usr/include
INCLUDES := $(patsubst %,-I%, $(INCLUDEDIRS:%/=%)) # -Iinclude
# define the C libs
LIBS := $(patsubst %,-L%, $(LIBDIRS:%/=%)) # -Llib
# define the C source files
SOURCES := $(wildcard $(patsubst %,%/*.cpp, $(SOURCEDIRS))) # src/main.cpp
# define the C object files
OBJECTS := $(SOURCES:.cpp=.o) # src/main.o
# define the dependency output files
DEPS := $(OBJECTS:.o=.d) # src/main.d
#
# The following part of the makefile is generic; it can be used to
# build any executable just by changing the definitions above and by
# deleting dependencies appended to the file from 'make depend'
#
OUTPUTMAIN := $(call FIXPATH,$(OUTPUT)/$(MAIN)) # output\main.exe
all: $(OUTPUT) $(MAIN)
@echo Executing 'all' complete!
$(OUTPUT):
$(MD) $(OUTPUT)
$(MAIN): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(INCLUDES) -o $(OUTPUTMAIN) $(OBJECTS) $(LFLAGS) $(LIBS) $(Libraries)
# include all .d files
-include $(DEPS)
ifdef CURRENT_DIR
OBJECTS := src/${CURRENT_DIR}/*.o
DEPS := src/${CURRENT_DIR}/*.d
endif
# this is a suffix replacement rule for building .o's and .d's from .c's
# it uses automatic variables $<: the name of the prerequisite of
# the rule(a .c file) and $@: the name of the target of the rule (a .o file)
# -MMD generates dependency output files same name as the .o file
# (see the gnu make manual section about automatic variables)
.cpp.o:
$(CXX) $(CXXFLAGS) $(INCLUDES) -c -MMD $< -o $@
.PHONY: clean log
clean:
$(RM) $(OUTPUTMAIN)
$(RM) $(call FIXPATH,$(OBJECTS))
$(RM) $(call FIXPATH,$(DEPS))
@echo Cleanup complete!
log:
@echo this is log
@echo "INCLUDES is ${INCLUDES}"
@echo "$(CXX) $(CXXFLAGS) $(INCLUDES) -c -MMD $< -o $@"
@echo "$(CXX) $(CXXFLAGS) $(INCLUDES) -o $(OUTPUTMAIN) $(OBJECTS) $(LFLAGS) $(LIBS) $(Libraries)"
run: all
./$(OUTPUTMAIN)
@echo Executing 'run: all' complete!
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sanli-akaman/opengl.git
git@gitee.com:sanli-akaman/opengl.git
sanli-akaman
opengl
opengl
master

搜索帮助