Skip to content

Instantly share code, notes, and snippets.

@tasinttttttt
Last active March 21, 2017 14:00
Show Gist options
  • Save tasinttttttt/10925b1af28bae4475044bd5589e52fa to your computer and use it in GitHub Desktop.
Save tasinttttttt/10925b1af28bae4475044bd5589e52fa to your computer and use it in GitHub Desktop.
Makefile ft_printf
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tbayri <tbayri@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2017/03/21 14:13:56 by tbayri #+# #+# #
# Updated: 2017/03/21 14:50:00 by tbayri ### ########.fr #
# #
# **************************************************************************** #
CC = gcc
AR = ar rc
CFLAGS = -Wall -Werror -Wextra
NAME = libftprintf.a
# line below produces "./libft/libft.a". Files separated by spaces (not commas!)
# info here: https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html
LIBFT = $(addprefix $(LIBFTFOLDER), libft.a)
SRCFOLDER = ./src/
LIBFTFOLDER = ./libft/
SRC = $(addprefix $(SRCFOLDER), ft_printf.c)
# replaces ".c" by ".o" in "$(SRC)" list
OBJ = $(SRC:.c=.o)
INCLUDES = -I ./includes
all: $(NAME)
#adds ".o" to an already compiled lib
$(NAME): $(OBJ) $(LIBFT)
libtool -static -o $@ $^
#recompiles with changes in ".o"
%.o:%.c
$(CC) -c -o $@ $^ $(CFLAGS) $(INCLUDES)
clean:
rm -f $(OBJ)
fclean: clean
rm -f $(NAME)
re: clean fclean all
# used to specify rules, not filenames
# info: http://stackoverflow.com/questions/2145590/what-is-the-purpose-of-phony-in-a-makefile
.PHONY: all clean fclean re
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment