build(run): adding the run rules

This commit is contained in:
Raphael 2025-05-13 12:05:25 +02:00
parent cbb11f1822
commit bb38065e50

View file

@ -23,22 +23,19 @@ RM = rm -rf
CXXFLAGS = -Werror -Wextra -Wall -std=c++98 CXXFLAGS = -Werror -Wextra -Wall -std=c++98
# Flags to have the dependences (can be removed for correction) # Flags to have the dependences (can be removed for correction)
# Flags to have the debug (can be removed for correction) # Flags to have the debug (can be removed for correction)
DEBUG = -g3 SESSION = test-irc
# DEBUG += -fsanitize=address
CXXFLAGS += $(DEBUG)
# Sources # Sources
SRC = sources/core/main.cpp SRC = sources/core/main.cpp \
sources/core/server.cpp \
sources/core/check.cpp
INC_DIR = include/core \ INC_DIR = include/core \
include include
CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP
# Flags to have the dependences (can be removed for correction)
# DEBUG = -g3
# CPPFLAGS += $(DEBUG)
# Objects # Objects
OBJDIRNAME = ./build OBJDIRNAME = ./build
OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.cpp=.o)) OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.cpp=.o))
@ -82,9 +79,10 @@ $(OBJDIRNAME)/%.o: %.cpp
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $< @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $<
debug: CPPFLAGS += -D DEBUG=1 debug: CPPFLAGS += -D DEBUG=1
debug: CXXFLAGS += -g
# debug: CXXFLAGS += -fsanitize=address
debug: re debug: re
SESSION = test-irc
test: debug test: debug
@printf '$(GREY) now running with\n\t- Port:\t\t$(GREEN)4243$(GREY)\n\t- Password:\t$(GREEN)irc$(END)\n' @printf '$(GREY) now running with\n\t- Port:\t\t$(GREEN)4243$(GREY)\n\t- Password:\t$(GREEN)irc$(END)\n'
@if tmux has-session -t $(SESSION) 2>/dev/null; then \ @if tmux has-session -t $(SESSION) 2>/dev/null; then \
@ -98,6 +96,19 @@ test: debug
'bash -lc "nc localhost 4243 || exec yes \"netcat exit code: $?\""' 'bash -lc "nc localhost 4243 || exec yes \"netcat exit code: $?\""'
@tmux attach -t $(SESSION) @tmux attach -t $(SESSION)
run: re
@printf '$(GREY) now running with\n\t- Port:\t\t$(GREEN)4243$(GREY)\n\t- Password:\t$(GREEN)irc$(END)\n'
@if tmux has-session -t $(SESSION) 2>/dev/null; then \
tmux kill-session -t $(SESSION); \
fi
@tmux new-session -d -s $(SESSION) \
'bash -lc "./$(NAME) 4243 irc; exec bash"'
@tmux split-window -h -p 70 -t $(SESSION):0 \
'bash -lc "irssi 4243 irc || exec yes \"irssi exit code: $?\""'
@tmux split-window -v -p 50 -t $(SESSION):0.1 \
'bash -lc "nc localhost 4243 || exec yes \"netcat exit code: $?\""'
@tmux attach -t $(SESSION)
# Header # Header
header: header:
@clear @clear