# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # . name = value \ . += append to a variable # # VARIABLES . value . != set result of command # # . name is case sensitive . ?= set if not already set # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # NAME = microshell CC = gcc EXT = c CFLAGS = -Wall -Wextra -Werror $(INCLUDES) VPATH = $(D_SRCS) LIBS = INCLUDES = -I$(D_HEADERS) D_SRCS = . SRCS = microshell.c D_HEADERS = . HEADERS = D_OBJS = builds OBJS = $(SRCS:%.$(EXT)=$(D_OBJS)/%.o) RM_OBJS = rm -rf $(D_OBJS) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # . target: prerequisites . $@ : target # # RULES . recipe . $< : 1st prerequisite # # . recipe . $^ : all prerequisites # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # all: $(NAME) $(D_OBJS)/%.o: %.$(EXT) | $(D_OBJS) $(CC) $(CFLAGS) -c $< -o $@ $(D_OBJS): mkdir $@ $(OBJS): $(HEADERS:%=$(D_HEADERS)/%) $(NAME): $(OBJS) $(CC) $(OBJS) -o $@ $(LIBS) leaks: $(NAME) valgrind --leak-check=full --show-leak-kinds=all ./$(NAME) test: $(NAME) ./microshell /bin/ls "|" /usr/bin/grep microshell ";" /bin/echo i love my microshell clean: $(RM_OBJS) fclean: clean rm -f $(NAME) re: fclean all .PHONY : all clean fclean re