@@ -18,11 +18,11 @@ CXX := g++
1818CXXFLAGS := -std=c++20 -Wall -Wextra -Wpedantic -O2
1919DEBUG_FLAGS := -g -DDEBUG -O0
2020RELEASE_FLAGS := -DNDEBUG -O3
21- INCLUDE_FLAGS := -I$(INCLUDE_DIR )
21+ INCLUDE_FLAGS := -I$(INCLUDE_DIR ) -I $( INCLUDE_DIR ) /data -I $( INCLUDE_DIR ) /network -I $( INCLUDE_DIR ) /world -I $( INCLUDE_DIR ) /lib
2222
2323# Linker flags (add your libraries here)
2424LDFLAGS :=
25- LIBS :=
25+ LIBS := -lz
2626
2727# ================================ COLOR SETUP ===============================
2828# ANSI color codes for beautiful output
8282endif
8383
8484# ================================= TARGETS ==================================
85- .PHONY : all clean debug release info help run install uninstall compile_commands
85+ .PHONY : all clean distclean clean-test debug release info help run install uninstall compile_commands
8686
8787# Default target
8888all : info $(TARGET )
@@ -129,14 +129,44 @@ $(DEPS_DIR):
129129# Clean build artifacts
130130clean :
131131 @printf " $( BOLD) $( BRIGHT_RED) 🧹 Cleaning build artifacts...$( RESET) \n"
132+ @find $(BUILD_DIR ) -type f -name " *.o" -delete 2> /dev/null || true
133+ @find $(BUILD_DIR ) -name " $( TARGET_NAME) " -delete 2> /dev/null || true
134+ @find $(BUILD_DIR ) -type d -empty -delete 2> /dev/null || true
135+ @find $(DEPS_DIR ) -type f -name " *.d" -delete 2> /dev/null || true
136+ @find $(DEPS_DIR ) -type d -empty -delete 2> /dev/null || true
137+ @printf " $( BOLD) $( BRIGHT_GREEN) ✨ Clean completed! (Preserved directories and config.json)$( RESET) \n"
138+
139+ # Complete clean - removes everything including directories
140+ distclean :
141+ @printf " $( BOLD) $( BRIGHT_RED) 🧹 Complete cleanup (removing all build artifacts and directories)...$( RESET) \n"
132142 @rm -rf $(BUILD_DIR ) $(DEPS_DIR )
133- @printf " $( BOLD) $( BRIGHT_GREEN) ✨ Clean completed!$( RESET) \n"
143+ @printf " $( BOLD) $( BRIGHT_GREEN) ✨ Complete cleanup finished!$( RESET) \n"
144+
145+ # Clean test-server directory
146+ clean-test :
147+ @printf " $( BOLD) $( BRIGHT_RED) 🧹 Cleaning test-server directory...$( RESET) \n"
148+ @rm -rf test-server
149+ @printf " $( BOLD) $( BRIGHT_GREEN) ✨ Test-server cleanup finished!$( RESET) \n"
134150
135151# Run the executable
136152run : $(TARGET )
153+ @printf " $( BOLD) $( BRIGHT_MAGENTA) 🚀 Setting up test-server environment...$( RESET) \n"
154+ @mkdir -p test-server
155+ @printf " $( BOLD) $( BRIGHT_BLUE) 📦 Copying executable to test-server...$( RESET) \n"
156+ @cp $(TARGET ) test-server/$(TARGET_NAME )
157+ @printf " $( BOLD) $( BRIGHT_BLUE) 📦 Copying config.json to test-server...$( RESET) \n"
158+ @cp -f config.json test-server/ 2> /dev/null || printf " $( YELLOW) ⚠️ config.json not found, skipping...$( RESET) \n"
159+ @printf " $( BOLD) $( BRIGHT_BLUE) 📦 Copying world folder to test-server...$( RESET) \n"
160+ @if [ -d " world" ]; then \
161+ cp -r world test-server/; \
162+ printf " $( BOLD) $( BRIGHT_GREEN) ✅ World folder copied successfully!$( RESET) \n" ; \
163+ else \
164+ printf " $( YELLOW) ⚠️ World folder not found, skipping...$( RESET) \n" ; \
165+ fi
166+ @printf " $( BOLD) $( BRIGHT_GREEN) ✅ Test environment ready!$( RESET) \n"
137167 @printf " $( BOLD) $( BRIGHT_MAGENTA) 🚀 Running $( TARGET_NAME) ...$( RESET) \n"
138168 @printf " $( DIM) $( WHITE) " && echo " ================================================" && printf " $( RESET) "
139- @./$(TARGET )
169+ @cd test-server && ./$(TARGET_NAME )
140170 @printf " $( DIM) $( WHITE) " && echo " ================================================" && printf " $( RESET) "
141171
142172# Display project information
@@ -190,8 +220,10 @@ help:
190220 @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " all" " Build the project (default: release mode)"
191221 @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " debug" " Build in debug mode"
192222 @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " release" " Build in release mode"
193- @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " clean" " Remove all build artifacts"
194- @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " run" " Build and run the executable"
223+ @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " clean" " Remove build artifacts (preserve dirs)"
224+ @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " distclean" " Remove all build artifacts and dirs"
225+ @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " clean-test" " Remove test-server directory"
226+ @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " run" " Setup test-server and run executable"
195227 @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " compile_commands" " Generate compile_commands.json for LSP"
196228 @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " install" " Install the executable to system"
197229 @printf " $( BOLD) $( BRIGHT_CYAN) ║$( RESET) $( BRIGHT_GREEN) %-10s$( RESET) %-39s $( BOLD) $( BRIGHT_CYAN) ║$( RESET) \n" " uninstall" " Remove the executable from system"
0 commit comments