ssl_des/Makefile

178 lines
3.9 KiB
Makefile
Raw Normal View History

2018-10-07 19:34:39 +03:00
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: gtertysh <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/02/18 16:06:01 by gtertysh #+# #+# #
2018-10-16 21:16:37 +03:00
# Updated: 2018/10/16 21:05:56 by gtertysh ### ########.fr #
2018-10-07 19:34:39 +03:00
# #
# **************************************************************************** #
# name of the executable file
NAME := ft_ssl
# project directories
ROOT := $(shell pwd)
SRC_DIR := $(ROOT)/src/
2018-10-20 22:21:19 +03:00
MD5_DIR := $(SRC_DIR)/md5/
2018-10-21 20:46:05 +03:00
SHA_DIR := $(SRC_DIR)/sha/
2018-10-07 19:34:39 +03:00
OBJ_DIR := $(ROOT)/obj/
INC_DIR := $(ROOT)/inc/
LIB_DIR := $(ROOT)/lib/
TST_DIR := $(ROOT)/t/
# libraries
LIBFT_DIR := $(LIB_DIR)libft/
LIBFT_INC := -I $(LIBFT_DIR)includes/
LIBFT_LIB := -lft -L $(LIBFT_DIR)
LIBFT = $(LIBFT_DIR)libft.a
2018-10-08 02:39:31 +03:00
MUINUT_DIR := $(LIB_DIR)munit/
MUINUT_INC := -I $(MUINUT_DIR)
2018-10-07 19:34:39 +03:00
# project source files
2018-10-20 20:56:18 +03:00
MD5_SRC = ft_md5_init.c \
ft_md5_update.c \
ft_md5_transform.c \
ft_md5_decode.c \
ft_md5_encode_len.c \
ft_md5_encode_register.c \
ft_md5_final.c \
ft_md5_padding.c \
ft_md5_digest_string.c
2018-10-07 19:34:39 +03:00
2018-10-21 20:46:05 +03:00
SHA_SRC = ft_sha256_init.c \
ft_sha256_update.c \
ft_sha256_decode.c \
ft_sha256_encode_len.c \
ft_sha256_encode_register.c \
ft_sha256_transform.c \
ft_sha256_padding.c \
ft_sha256_final.c \
ft_sha256_digest_string.c \
ft_sha256_constants.c
2018-10-18 21:57:26 +03:00
SRC = main.c
SRC += $(MD5_SRC)
2018-10-07 19:34:39 +03:00
# project object files
OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o))
# project test files
2018-10-08 02:39:31 +03:00
TEST_BIN = ft_ssl_test
2018-10-18 21:57:26 +03:00
MD5_TESTS = md5_tests.c
MD5_TESTS += $(MD5_SRC)
2018-10-08 02:39:31 +03:00
2018-10-21 20:46:05 +03:00
SHA_TESTS = sha_tests.c
SHA_TESTS += $(SHA_SRC)
TEST_SRC = tests.c \
2018-10-18 21:57:26 +03:00
munit.c
2018-10-21 20:46:05 +03:00
TEST_SRC += $(MD5_TESTS) \
$(SHA_TESTS)
2018-10-08 02:39:31 +03:00
TEST_OBJ = $(addprefix $(OBJ_DIR), $(TEST_SRC:.c=.o))
2018-10-07 19:34:39 +03:00
# compilation flags
CC_FLAGS = -Wall -Wextra -Werror
CC_FLAGS += -Wpointer-arith
CC_FLAGS += -Wcast-align
CC_FLAGS += -Wwrite-strings
CC_FLAGS += -Wunreachable-code
CC_FLAGS += -Winit-self
CC_FLAGS += -Wmissing-field-initializers
CC_FLAGS += -Wno-unknown-pragmas
CC_FLAGS += -Wstrict-prototypes
CC_FLAGS += -Wundef
CC_FLAGS += -Wold-style-definition
# for debug
ifeq ($(DEBUG),true)
CC_FLAGS += -g
CC_FLAGS += -O0
endif
# linking flags
2018-10-18 21:57:26 +03:00
LINK_FLAGS = $(LIBFT_LIB)
2018-10-07 19:34:39 +03:00
# header flags
2018-10-09 11:42:59 +03:00
HEADER_FLAGS = -I $(INC_DIR) \
2018-10-18 21:57:26 +03:00
$(MUINUT_INC) \
$(LIBFT_INC)
2018-10-07 19:34:39 +03:00
# compiler
CC := clang
# rules
all: $(NAME)
2018-10-08 02:39:31 +03:00
$(NAME): check $(LIBFT) $(OBJ)
2018-10-07 19:34:39 +03:00
$(CC) $(OBJ) $(LINK_FLAGS) -o $(NAME)
2018-10-08 02:39:31 +03:00
check: $(TEST_BIN)
2018-10-09 11:42:59 +03:00
clear
2018-10-08 02:39:31 +03:00
./$(TEST_BIN)
2018-10-07 19:34:39 +03:00
2018-10-08 02:39:31 +03:00
$(TEST_BIN): $(LIBFT) $(TEST_OBJ)
$(CC) $(TEST_OBJ) $(LINK_FLAGS) -o $(TEST_BIN)
2018-10-07 19:34:39 +03:00
2018-10-08 02:39:31 +03:00
$(TEST_OBJ) $(OBJ): | $(OBJ_DIR)
2018-10-07 19:34:39 +03:00
$(OBJ_DIR):
mkdir $(OBJ_DIR)
$(OBJ_DIR)%.o: %.c
$(CC) -c $< -o $@ $(CC_FLAGS) $(HEADER_FLAGS)
$(LIBFT):
$(MAKE) -C $(LIBFT_DIR)
2018-10-20 20:56:18 +03:00
clean:
2018-10-07 19:34:39 +03:00
rm -f $(OBJ)
rm -f $(TEST_OBJ)
$(MAKE) -C $(LIBFT_DIR) clean
fclean: clean
rm -f $(NAME)
2018-10-16 21:16:37 +03:00
rm -f $(TEST_BIN)
2018-10-07 19:34:39 +03:00
$(MAKE) -C $(LIBFT_DIR) fclean
re: fclean all
multi:
$(MAKE) $(LIBFT)
$(MAKE) check
$(MAKE) $(NAME)
# special stuff
2018-10-20 22:21:19 +03:00
vpath %.c $(SRC_DIR) \
$(MD5_DIR) \
2018-10-21 20:46:05 +03:00
$(SHA_DIR) \
2018-10-20 22:21:19 +03:00
$(TST_DIR) \
2018-10-08 02:39:31 +03:00
$(MUINUT_DIR)
2018-10-07 19:34:39 +03:00
.PHONY: all check clean fclean re multi