title: Makefile - compiling library and executable when no changes made
body: <p>So, I can understand what the problem is here, but I can't quite figure out how to fix it -- Because it is compiling files from a different directory, but throwing the .a library file and executable into the root...It seems that the makefile is expecting them to be in their source directory, and that's why it rebuilds every time even when no changes are made.</p>
  
  <p>Problem is, my school is very strict on folder structure, so it needs to compile exactly how it is, I just need to figure out how to let the makefile know the executable and library file DO exist, in the root directory.</p>
  
  <p>Here is my Makefile:</p>
  
  <pre><code>NAME = fillit
  LIB = libft.a
  
  CC = gcc
  CFLAGS = -Wall -Wextra -Werror
  RM = /bin/rm -rf
  
  SRC = main.c validation.c create_piece.c game_board.c solver.c tables.c \
      trimmer.c
  
  LIBSRC = ft_putchar.c ft_putstr.c ft_strcpy.c ft_strnew.c ft_strdel.c \
      ft_strequ.c ft_putendl.c ft_error.c
  
  LIBLIST  :=  $(shell ls -1 libft | grep .c$$)
  LIBOBJ   :=  $(LIBLIST:.c=.o)
  LIBOBJ   :=  $(addprefix libft/, $(LIBOBJ))
  
  SRCLIST  :=  $(shell ls -1 src | grep .c$$)
  SRCOBJ   :=  $(SRCLIST:.c=.o)
  SRCOBJ   :=  $(addprefix src/, $(SRCOBJ))
  
  .PHONY: all $(NAME) lib
  
  all: $(NAME)
  
  libft/%.o: libft/%.c
      $(CC) $(CFLAGS) -c -o $@ $&lt;
  
  src/%.o: src/%.c
      $(CC) $(CFLAGS) -c -o $@ $&lt;
  
  lib:
      ar rc $(LIB) $(LIBOBJ)
      ranlib $(LIB)
  
  debug:
      $(CC) $(CFLAGS) $(addprefix libft/, $(LIBLIST)) $(addprefix src/, $(SRCLIST)) -g -o fillit
  
  $(NAME): $(LIBOBJ) $(SRCOBJ) lib
      $(CC) $(CFLAGS) $(SRCOBJ) -L. -lft -o fillit
  
  clean:
      $(RM) $(SRCOBJ)
      $(RM) $(LIBOBJ)
  
  
  fclean: clean
      $(RM) $(NAME)
      $(RM) $(LIB)
  
  re: fclean all
  
  re-db: fclean debug
  </code></pre>
  
  <p>It's working fine for compiling the .o files, it only does that once, but if I continue to type make, it still compiles this part:</p>
  
  <pre><code>➜  fillit git:(master) ✗ make
  ar rc libft.a libft/ft_memset.o libft/ft_putchar.o libft/ft_putendl.o libft/ft_putstr.o libft/ft_strcpy.o libft/ft_strdel.o libft/ft_strequ.o libft/ft_strnew.o
  ranlib libft.a
  gcc -Wall -Wextra -Werror src/create_piece.o src/game_board.o src/main.o src/solver.o src/tables.o src/trimmer.o src/validation.o -L. -lft -o fillit
  </code></pre>