aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile22
1 files changed, 17 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 55e0d7b..c1af191 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,13 @@
-NAME = libft.a
-
CC = cc
CFLAGS = -Wall -Wextra -Werror
+SRCDIR = src
+INCDIR = inc
+OBJDIR = obj
+LIBDIR = lib
+
+NAME = $(LIBDIR)/libft.a
+
SRCS = ft_isalpha.c ft_isdigit.c ft_isalnum.c ft_isascii.c ft_isprint.c \
ft_strlen.c ft_memset.c ft_bzero.c ft_memcpy.c ft_memmove.c \
ft_memchr.c ft_memcmp.c ft_strncmp.c \
@@ -11,18 +16,25 @@ SRCS = ft_isalpha.c ft_isdigit.c ft_isalnum.c ft_isascii.c ft_isprint.c \
ft_calloc.c ft_strdup.c \
ft_toupper.c ft_tolower.c
-OBJS = $(SRCS:.c=.o)
+OBJS = $(SRCS:%.c=$(OBJDIR)/%.o)
-$(NAME): $(OBJS)
+$(NAME): $(OBJS) | $(LIBDIR)
ar rcs $(NAME) $(OBJS)
all: $(NAME)
+$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
+ $(CC) $(CFLAGS) -I $(INCDIR) -c $< -o $@
+
+$(OBJDIR):
+ mkdir -p $(OBJDIR)
+
clean:
- rm -f $(OBJS)
+ rm -rf $(OBJDIR)
fclean: clean
rm -f $(NAME)
+ $(MAKE) -C tests clean
re: fclean all