From 87a8e4b2e4ef0b42e2aaed1b366e574bb59a2d61 Mon Sep 17 00:00:00 2001 From: vde-frei Date: Thu, 13 Jun 2024 12:38:17 -0300 Subject: [PATCH 1/4] added make and dirs --- Makefile | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e69de29 From 47f8cafbe4bdfbd767d9bdbfa6d34b5e475d6f52 Mon Sep 17 00:00:00 2001 From: vde-frei Date: Thu, 13 Jun 2024 12:38:48 -0300 Subject: [PATCH 2/4] added make and dirs --- include/.gitkeep | 0 src/.gitkeep | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 include/.gitkeep create mode 100644 src/.gitkeep diff --git a/include/.gitkeep b/include/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/.gitkeep b/src/.gitkeep new file mode 100644 index 0000000..e69de29 From 12f8e4b58b48d64d784ceb900a45d92619990d83 Mon Sep 17 00:00:00 2001 From: vde-frei Date: Thu, 13 Jun 2024 12:43:37 -0300 Subject: [PATCH 3/4] feat: added makefile --- Makefile | 214 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) diff --git a/Makefile b/Makefile index e69de29..be7fae2 100644 --- a/Makefile +++ b/Makefile @@ -0,0 +1,214 @@ +# Compiler +CXX := g++ + +# Directories +SRCDIR := src +INCDIR := include +BUILDDIR := build +TARGETDIR := bin + +# Target executable name +TARGET := webserv + +# Source files +SRCEXT := cpp +SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) + +# Object files +OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) + +# Includes +INC := -I$(INCDIR) + +# Flags +CXXFLAGS = -std=c++98 -Wall -Wextra -Werror + +# Final executable +EXECUTABLE := $(TARGETDIR)/$(TARGET) + +# Default make target +all: directories $(EXECUTABLE) + +# Ensure build directories exist +directories: + @mkdir -p $(BUILDDIR) + @mkdir -p $(TARGETDIR) + +# Rule for linking object files into executable +$(EXECUTABLE): $(OBJECTS) + $(CXX) $(LDFLAGS) $^ -o $(EXECUTABLE) + +# Rule for compiling source files into object files +$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) + $(CXX) $(CXXFLAGS) $(INC) -c -o $@ $< + +# Clean build artifacts +clean: + @rm -rf $(BUILDDIR) + @rm -rf $(TARGETDIR) + +# Run the executable +run: clean all + @./$(EXECUTABLE) $(ARGS) + +fclean: clean + @rm -rf $(TARGETDIR)/$(TARGET) + +re: fclean all + +test: + @ echo "\nRunning test with no argument" + @./$(EXECUTABLE) + @ echo "\nRunning test with no file argument" + @./$(EXECUTABLE) "nan" + @ echo "\nRunning test with a valid file argument" + @./$(EXECUTABLE) "data.csv" + +val: clean all + @valgrind ./$(EXECUTABLE) $(ARGS) + +# Phony targets +.PHONY: all clean run +# Compiler +CXX := c++ + +# Directories +SRCDIR := src +INCDIR := include +BUILDDIR := build +TARGETDIR := bin + +# Target executable name +TARGET := btc + +# Source files +SRCEXT := cpp +SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) + +# Object files +OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) + +# Includes +INC := -I$(INCDIR) + +# Flags +CXXFLAGS = -std=c++98 -Wall -Wextra -Werror + +# Final executable +EXECUTABLE := $(TARGETDIR)/$(TARGET) + +# Default make target +all: directories $(EXECUTABLE) + +# Ensure build directories exist +directories: + @mkdir -p $(BUILDDIR) + @mkdir -p $(TARGETDIR) + +# Rule for linking object files into executable +$(EXECUTABLE): $(OBJECTS) + $(CXX) $(LDFLAGS) $^ -o $(EXECUTABLE) + +# Rule for compiling source files into object files +$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) + $(CXX) $(CXXFLAGS) $(INC) -c -o $@ $< + +# Clean build artifacts +clean: + @rm -rf $(BUILDDIR) + @rm -rf $(TARGETDIR) + +# Run the executable +run: clean all + @./$(EXECUTABLE) $(ARGS) + +fclean: clean + @rm -rf $(TARGETDIR)/$(TARGET) + +re: fclean all + +test: + @ echo "\nRunning test with no argument" + @./$(EXECUTABLE) + @ echo "\nRunning test with no file argument" + @./$(EXECUTABLE) "nan" + @ echo "\nRunning test with a valid file argument" + @./$(EXECUTABLE) "data.csv" + +val: clean all + @valgrind ./$(EXECUTABLE) $(ARGS) + +# Phony targets +.PHONY: all clean run +# Compiler +CXX := c++ + +# Directories +SRCDIR := src +INCDIR := include +BUILDDIR := build +TARGETDIR := bin + +# Target executable name +TARGET := btc + +# Source files +SRCEXT := cpp +SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) + +# Object files +OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) + +# Includes +INC := -I$(INCDIR) + +# Flags +CXXFLAGS = -std=c++98 -Wall -Wextra -Werror + +# Final executable +EXECUTABLE := $(TARGETDIR)/$(TARGET) + +# Default make target +all: directories $(EXECUTABLE) + +# Ensure build directories exist +directories: + @mkdir -p $(BUILDDIR) + @mkdir -p $(TARGETDIR) + +# Rule for linking object files into executable +$(EXECUTABLE): $(OBJECTS) + $(CXX) $(LDFLAGS) $^ -o $(EXECUTABLE) + +# Rule for compiling source files into object files +$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) + $(CXX) $(CXXFLAGS) $(INC) -c -o $@ $< + +# Clean build artifacts +clean: + @rm -rf $(BUILDDIR) + @rm -rf $(TARGETDIR) + +# Run the executable +run: clean all + @./$(EXECUTABLE) $(ARGS) + +fclean: clean + @rm -rf $(TARGETDIR)/$(TARGET) + +re: fclean all + +test: + @ echo "\nRunning test with no argument" + @./$(EXECUTABLE) + @ echo "\nRunning test with no file argument" + @./$(EXECUTABLE) "nan" + @ echo "\nRunning test with a valid file argument" + @./$(EXECUTABLE) "data.csv" + +val: clean all + @valgrind ./$(EXECUTABLE) $(ARGS) + +# Phony targets +.PHONY: all clean run + From 036d1cd08abab1c82494c5dfc790a9b7164594ca Mon Sep 17 00:00:00 2001 From: Bruno Moretti Date: Thu, 13 Jun 2024 12:51:54 -0300 Subject: [PATCH 4/4] fixed makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index be7fae2..1a2ca56 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # Compiler -CXX := g++ +CXX := c++ # Directories SRCDIR := src