代码拉取完成,页面将自动刷新
# src = $(wildcard src/*.cpp) $(wildcard src/*/*/*.cpp) $(wildcard src/config/*.cpp)
src = $(shell find . -name *.cpp)
bin_dir = bin
obj = $(src:cpp=o)
h_path = $(shell find . -name *.h)
# Debug模式
ifeq ($(debug), true)
CXXFLAGS = -g -std=c++11 -Wall
else
CXXFLAGS = -std=c++11 -Wall -O3
endif
ifeq ($(target), windows)
cc = i686-w64-mingw32-g++-posix $(CXXFLAGS)
else
cc = g++ $(CXXFLAGS)
endif
CXXFLAGS += $(addprefix -I,$(dir $(h_path)))
default:
@echo compile started
@make main -j8 debug=$(debug)
@echo "\033[0;35mExecutable file at $(shell pwd)/$(bin_dir)/main"
@echo "Configure file at $(shell pwd)/$(bin_dir)/config.conf"
@echo "\033[0;32mFinish!\033[0;0m"
debug:
# make clean
make default debug=true
@echo "\033[0;31m"
@echo " You are using DEBUG MODE"
@echo "Use this version in production environment is NOT RECOMMANDED"
@echo "If you want to run in production environment, please use \033[0;32m\"make clean default\"\033[0;0m"
@echo "\033[0;0m"
run: debug
./$(bin_dir)/main -c $(bin_dir)/config.conf
main: $(obj)
@echo Linking target files
$(cc) $(obj) -o $(bin_dir)/main -lpthread
windows:
make build-windows target=windows -j8
build-windows:$(obj)
$(cc) $(obj) -o $(bin_dir)/main.exe -lpthread -lws2_32 -static
%.o: %.cpp
$(cc) -c $^ -o $@ $(CXXFLAGS)
clean:
-@rm $(src:cpp=o)
-@rm $(bin_dir)/main
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。