diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-06-20 11:08:06 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-06-20 11:08:06 +0200 |
| commit | e1f3547e236671697c66e27ba02b6a151e59af04 (patch) | |
| tree | 342e3cfdc26697c7ef4c54346070dc646e3e1362 /Makefile | |
| download | tar-e1f3547e236671697c66e27ba02b6a151e59af04.tar.gz tar-e1f3547e236671697c66e27ba02b6a151e59af04.tar.bz2 tar-e1f3547e236671697c66e27ba02b6a151e59af04.zip | |
Initial commit
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..78da46f --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +RM = rm -f + +INCDIR = inc +SRCDIR = src +OBJDIR = obj +OBJDIRS = $(shell find $(SRCDIR) -type d | sed 's/src/$(OBJDIR)/') + +INC = $(shell find $(INCLUDEDIR) -name "*.h") +SRC = $(shell find $(SRCDIR) -name "*.c") +OBJ = $(SRC:$(SRCDIR)/%.c=$(OBJDIR)/%.o) + +CC = gcc +CCFLAGS = -g -I$(INCDIR) --std=c99 -Wall -Wextra -Wpedantic #-Werror +LDFLAGS = -L$(LIBFTDIR) -lft + +NAME = tar + +all: prebuild $(NAME) + +prebuild: + @echo "Making dir $$subdir"; mkdir -p $(OBJDIR) + @for subdir in $(OBJDIRS); do echo "Making dir $$subdir"; mkdir -p $$subdir; done + +$(NAME): $(OBJ) + @echo "Linking: $@" + @$(CC) -o $@ $(OBJ) $(LDFLAGS) + +$(OBJDIR)/%.o: $(SRCDIR)/%.c $(INC) + @echo "Compiling: $@" + @$(CC) $(CCFLAGS) -c -o $@ $< + +clean: + @echo "Removing objects" + @$(RM) -r $(OBJDIR) + +fclean: + @echo "Removing objects" + @$(RM) -r $(OBJDIR) + @echo "Removing exectable" + @$(RM) $(NAME) + +re: fclean all + +.PHONY: all prebuild clean fclean re |
