makefile create obj folder

This commit is contained in:
starnakin 2023-07-12 02:08:59 +02:00
parent 16ab359cf2
commit bd77483ed4
4 changed files with 4 additions and 2 deletions

View File

@ -2,7 +2,7 @@ CXX = c++
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g
SRCDIR = src SRCDIR = src
OBJDIR = obj OBJDIR = obj
NAME = megaphone NAME = ex02
SRCS = $(wildcard $(SRCDIR)/*.cpp) SRCS = $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS)) OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
@ -10,6 +10,7 @@ OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
all: $(NAME) all: $(NAME)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p obj
$(CXX) $(CPPFLAGS) -c $< -o $@ $(CXX) $(CPPFLAGS) -c $< -o $@
$(NAME): $(OBJS) $(NAME): $(OBJS)

View File

View File

@ -2,7 +2,7 @@ CXX = c++
CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g CPPFLAGS = -std=c++98 -Wall -Wextra -Werror -g
SRCDIR = src SRCDIR = src
OBJDIR = obj OBJDIR = obj
NAME = contacts NAME = ex02
SRCS = $(wildcard $(SRCDIR)/*.cpp) SRCS = $(wildcard $(SRCDIR)/*.cpp)
OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS)) OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
@ -10,6 +10,7 @@ OBJS = $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o,$(SRCS))
all: $(NAME) all: $(NAME)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p obj
$(CXX) $(CPPFLAGS) -c $< -o $@ $(CXX) $(CPPFLAGS) -c $< -o $@
$(NAME): $(OBJS) $(NAME): $(OBJS)

View File