makefiles fix

This commit is contained in:
Camille Chauvet 2023-08-29 13:47:04 +00:00
parent 91c1a2d3e2
commit ce91cbdfd6
3 changed files with 36 additions and 33 deletions

View File

@ -1,25 +1,26 @@
CXX = c++ CXX := c++
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g CXXFLAGS := -std=c++98 -Wall -Wextra -Werror -g
SRCDIR = src SRCDIR := src
OBJDIR = obj OBJDIR := obj
NAME = ex00 NAME := ex00
SRCS = $(wildcard $(SRCDIR)/*.cpp) SRCS := $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS)) OBJS := $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
all: $(NAME) all: $(NAME)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p obj mkdir -p obj
$(CXX) $(CPPFLAGS) -c $< -o $@ $(CXX) $(CXXFLAGS) -c $< -o $@
$(NAME): $(OBJS) $(NAME): $(OBJS)
$(CXX) $(CPPFLAGS) $^ -o $@ $(CXX) $(CXXFLAGS) $^ -o $@
clean: clean:
rm -rf $(OBJDIR)/*.o rm -rf $(OBJDIR)
fclean: clean fclean: clean
rm -fr $(NAME) rm -fr $(NAME)
re: fclean all re: fclean
@make --no-print-directory all

View File

@ -1,25 +1,26 @@
CXX = c++ CXX := c++
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g CXXFLAGS := -std=c++98 -Wall -Wextra -Werror -g
SRCDIR = src SRCDIR := src
OBJDIR = obj OBJDIR := obj
NAME = ex01 NAME := ex01
SRCS = $(wildcard $(SRCDIR)/*.cpp) SRCS := $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS)) OBJS := $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
all: $(NAME) all: $(NAME)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p obj mkdir -p obj
$(CXX) $(CPPFLAGS) -c $< -o $@ $(CXX) $(CXXFLAGS) -c $< -o $@
$(NAME): $(OBJS) $(NAME): $(OBJS)
$(CXX) $(CPPFLAGS) $^ -o $@ $(CXX) $(CXXFLAGS) $^ -o $@
clean: clean:
rm -rf $(OBJDIR)/*.o rm -rf $(OBJDIR)
fclean: clean fclean: clean
rm -fr $(NAME) rm -fr $(NAME)
re: fclean all re: fclean
@make --no-print-directory all

View File

@ -1,25 +1,26 @@
CXX = c++ CXX := c++
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g CXXFLAGS := -std=c++98 -Wall -Wextra -Werror -g
SRCDIR = src SRCDIR := src
OBJDIR = obj OBJDIR := obj
NAME = ex02 NAME := ex02
SRCS = $(wildcard $(SRCDIR)/*.cpp) SRCS := $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS)) OBJS := $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
all: $(NAME) all: $(NAME)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p obj mkdir -p obj
$(CXX) $(CPPFLAGS) -c $< -o $@ $(CXX) $(CXXFLAGS) -c $< -o $@
$(NAME): $(OBJS) $(NAME): $(OBJS)
$(CXX) $(CPPFLAGS) $^ -o $@ $(CXX) $(CXXFLAGS) $^ -o $@
clean: clean:
rm -rf $(OBJDIR)/*.o rm -rf $(OBJDIR)
fclean: clean fclean: clean
rm -fr $(NAME) rm -fr $(NAME)
re: fclean all re: fclean
@make --no-print-directory all