diff --git a/Makefile b/Makefile index a3c039c..1b3b594 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ NAME = woody_woodpacker SRC_FILE = main.c \ + woody_woodpacker.c \ OBJ_FILE = $(SRC_FILE:.c=.o) @@ -27,11 +28,7 @@ WHITE = \033[0m all: $(NAME) -$(NAME): $(OBJ) $(INC) - @echo -e "$(PURPLE)[MAKE]$(WHITE) ft_printf" - @make --no-print-directory -C ft_printf - @$(CC) $(CFLAGS) -I $(INC_DIR) -c $(SRC) - @mv $(OBJ_FILE) $(OBJ_DIR) +$(NAME): ft_printf $(OBJ) $(INC) @$(CC) $(CFLAGS) $(OBJ) $(LIB) -o $(NAME) @echo -e "$(GREEN)[OK]$(WHITE) $(NAME)" @@ -39,19 +36,25 @@ $(OBJ_DIR)%.o: $(SRC_DIR)%.c $(INC) @if [ ! -d ./obj ]; then \ mkdir -p ./obj; \ fi; - @$(CC) $(CFLAGS) -I $(INC_DIR) -o $@ -c $< - @echo -e "$(CYAN)[CC]$(WHITE) $<" + @$(CC) $(CFLAGS) -I $(INC_DIR) -I ft_printf/inc -o $@ -c $< + @echo -e "$(CYAN)[CC]$(WHITE) $(<:$(SRC_DIR)%=%)" + +ft_printf: + @echo -e "$(PURPLE)[MAKE]$(WHITE) ft_printf" + @make --no-print-directory -C ft_printf clean: @make --no-print-directory -C ft_printf clean @echo -e "$(ORANGE)[CLEAN]$(WHITE) $(NAME)" @rm -rf $(OBJ_DIR) -fclean: clean +fclean: @make --no-print-directory -C ft_printf fclean + @echo -e "$(ORANGE)[CLEAN]$(WHITE) $(NAME)" + @rm -rf $(OBJ_DIR) @echo -e "$(RED)[DELETE]$(WHITE) $(NAME)" @rm -f $(NAME) re: fclean all -.PHONY: all clean fclean re +.PHONY: all ft_printf clean fclean re diff --git a/ft_printf/Makefile b/ft_printf/Makefile index 6aab069..a83eab5 100644 --- a/ft_printf/Makefile +++ b/ft_printf/Makefile @@ -34,9 +34,7 @@ WHITE = \033[0m all: $(NAME) -$(NAME): $(OBJ) $(INC) - @echo -e "$(PURPLE)[MAKE]$(WHITE) libft" - @make --no-print-directory -C ./libft +$(NAME): libft $(OBJ) $(INC) @cp libft/libft.a $(NAME) @ar -rcs $(NAME) $(OBJ) @ranlib $(NAME) @@ -47,18 +45,24 @@ $(OBJ_DIR)%.o: $(SRC_DIR)%.c libft/ $(INC) mkdir -p ./obj; \ fi; @$(CC) $(CFLAGS) -I $(INC_DIR) -I libft/inc -o $@ -c $< - @echo -e "$(CYAN)[CC]$(WHITE) $<" + @echo -e "$(CYAN)[CC]$(WHITE) $(<:$(SRC_DIR)%=%)" + +libft: + @echo -e "$(PURPLE)[MAKE]$(WHITE) libft" + @make --no-print-directory -C ./libft clean: @make --no-print-directory -C libft clean @echo -e "$(ORANGE)[CLEAN]$(WHITE) $(NAME)" @rm -rf $(OBJ_DIR) -fclean: clean +fclean: @make --no-print-directory -C libft fclean + @echo -e "$(ORANGE)[CLEAN]$(WHITE) $(NAME)" + @rm -rf $(OBJ_DIR) @echo -e "$(RED)[DELETE]$(WHITE) $(NAME)" @rm -f $(NAME) re: fclean all -.PHONY: all clean fclean re +.PHONY: all libft clean fclean re diff --git a/ft_printf/libft/Makefile b/ft_printf/libft/Makefile index cb479e1..05c4a40 100644 --- a/ft_printf/libft/Makefile +++ b/ft_printf/libft/Makefile @@ -85,13 +85,15 @@ $(OBJ_DIR)%.o: $(SRC_DIR)%.c $(INC) mkdir -p ./obj; \ fi; @$(CC) $(CFLAGS) -I $(INC_DIR) -o $@ -c $< - @echo -e "$(CYAN)[CC]$(WHITE) $<" + @echo -e "$(CYAN)[CC]$(WHITE) $(<:$(SRC_DIR)%=%)" clean: @echo -e "$(ORANGE)[CLEAN]$(WHITE) $(NAME)" @rm -rf $(OBJ_DIR) -fclean: clean +fclean: + @echo -e "$(ORANGE)[CLEAN]$(WHITE) $(NAME)" + @rm -rf $(OBJ_DIR) @echo -e "$(RED)[DELETE]$(WHITE) $(NAME)" @rm -f $(NAME) diff --git a/inc/woody.h b/inc/woody.h index cd8412c..4db4815 100644 --- a/inc/woody.h +++ b/inc/woody.h @@ -1,6 +1,8 @@ #ifndef WOODY_H # define WOODY_H -# include "../ft_printf/inc/ft_printf.h" +# include "ft_printf.h" + +int woody_woodpacker(char *path); #endif diff --git a/src/main.c b/src/main.c index 156616e..5da71ea 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,10 @@ #include "woody.h" -int main(void) { - ft_printf("Hello, World!\n"); +int main(int ac, char **av) { + if (ac == 2) { + return woody_woodpacker(av[1]); + } else { + ft_printf("usage: %s [filename]\n", av[0]); + } return 0; } diff --git a/src/woody_woodpacker.c b/src/woody_woodpacker.c new file mode 100644 index 0000000..254d0fa --- /dev/null +++ b/src/woody_woodpacker.c @@ -0,0 +1,6 @@ +#include "ft_printf.h" + +int woody_woodpacker(char *path) { + ft_printf("%s\n", path); + return 0; +}