aboutsummaryrefslogtreecommitdiff
path: root/philo_three/Makefile
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-09-30 14:48:12 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-09-30 14:48:12 +0200
commitf57ec76fd1be738d7b9d82c1f7548883efa15d0c (patch)
tree804162e060808d93324b211111c985d164d9abac /philo_three/Makefile
parent99f67bde096ad84dad5b41bc779ae2ad2d807e6f (diff)
downloadphilosophers-f57ec76fd1be738d7b9d82c1f7548883efa15d0c.tar.gz
philosophers-f57ec76fd1be738d7b9d82c1f7548883efa15d0c.tar.bz2
philosophers-f57ec76fd1be738d7b9d82c1f7548883efa15d0c.zip
Added philo_three draft
Diffstat (limited to 'philo_three/Makefile')
-rw-r--r--philo_three/Makefile28
1 files changed, 19 insertions, 9 deletions
diff --git a/philo_three/Makefile b/philo_three/Makefile
index 431bf62..6428673 100644
--- a/philo_three/Makefile
+++ b/philo_three/Makefile
@@ -6,11 +6,12 @@
# By: cacharle <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/11/24 05:50:15 by cacharle #+# #+# #
-# Updated: 2020/02/15 00:46:58 by cacharle ### ########.fr #
+# Updated: 2020/09/30 08:48:37 by cacharle ### ########.fr #
# #
# **************************************************************************** #
RM = rm -f
+MAKE = --no-print-directory
COMMON_DIR = ../common
@@ -19,18 +20,25 @@ CCFLAGS = -I$(COMMON_DIR) -Wall -Wextra #-Werror
LDFLAGS = -lpthread -L$(COMMON_DIR) -lphilocommon
NAME = philo_three
-SRC = main.c
-OBJ = $(SRC:.c=.o)
-all: $(NAME)
+SRCDIR = src
+OBJDIR = obj
+
+SRC = $(shell find $(SRCDIR) -type f -name '*.c')
+OBJ = $(SRC:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
+
+all: prebuild $(NAME)
+
+prebuild:
+ @mkdir -p $(OBJDIR)
$(NAME): common_all $(OBJ)
$(CC) $(LDFLAGS) -o $@ $(OBJ)
-%.o: %.c
+$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CCFLAGS) -c -o $@ $<
-clean: common_fclean
+clean: common_clean
$(RM) $(OBJ)
fclean: clean
@@ -39,7 +47,9 @@ fclean: clean
re: fclean all
common_all:
- make -C $(COMMON_DIR) all
+ $(MAKE) -C $(COMMON_DIR) all
+
+common_clean:
+ $(MAKE) -C $(COMMON_DIR) clean
-common_fclean:
- make -C $(COMMON_DIR) fclean
+.PHONY: all prebuild clean fclean re common_all common_clean