ssl_des/Makefile

300 lines
8.2 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 #+# #+# #
2019-01-19 15:21:33 +02:00
# Updated: 2019/01/19 15:21:01 by gtertysh ### ########.fr #
2018-10-07 19:34:39 +03:00
# #
# **************************************************************************** #
# name of the executable file
2019-01-19 15:21:33 +02:00
NAME := ft_ssl
2018-10-07 19:34:39 +03:00
# 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/
2019-01-19 18:16:00 +02:00
B64_DIR := $(SRC_DIR)/base64/
2019-03-06 23:41:59 +02:00
DES_DIR := $(SRC_DIR)/des/
2019-03-27 01:29:06 +02:00
KD2_DIR := $(SRC_DIR)/pbkdf2/
2018-10-07 19:34:39 +03:00
OBJ_DIR := $(ROOT)/obj/
INC_DIR := $(ROOT)/inc/
LIB_DIR := $(ROOT)/lib/
TST_DIR := $(ROOT)/t/
2019-02-02 22:28:23 +02:00
# project headers
MD5_HEADER := $(INC_DIR)/ft_md5.h
SHA_HEADER := $(INC_DIR)/ft_sha.h
SSL_HEADER := $(INC_DIR)/ft_ssl.h
2019-02-10 23:11:01 +02:00
B64_HEADER := $(INC_DIR)/ft_base64.h
2019-03-06 23:41:59 +02:00
DES_HEADER := $(INC_DIR)/ft_des.h
2019-03-27 01:29:06 +02:00
KD2_HEADER := $(INC_DIR)/ft_pbkdf2.h
2019-04-06 14:40:50 +03:00
TST_HEADER := $(INC_DIR)/t.h
HEADERS := $(TST_HEADER) \
$(MD5_HEADER) \
2019-02-20 22:11:29 +02:00
$(SHA_HEADER) \
$(SSL_HEADER) \
2019-03-06 23:41:59 +02:00
$(B64_HEADER) \
2019-03-27 01:29:06 +02:00
$(DES_HEADER) \
$(PBKDF2_HEADER)
2018-10-07 19:34:39 +03:00
# libraries
LIBFT_DIR := $(LIB_DIR)libft/
LIBFT_INC := -I $(LIBFT_DIR)includes/
LIBFT_LIB := -lft -L $(LIBFT_DIR)
LIBFT = $(LIBFT_DIR)libft.a
2019-04-06 18:04:46 +03:00
OPENSSL_DIR := $(LIB_DIR)openssl/
OPENSSL_BLD := $(OPENSSL_DIR)bld/
OPENSSL_LIB := -lssl -lcrypto -L $(OPENSSL_BLD)lib/
OPENSSL_INC := -I $(OPENSSL_BLD)include/
OPENSSL_SSL := $(OPENSSL_BLD)lib/libssl.a
OPENSSL_CRY := $(OPENSSL_BLD)lib/libcrypto.a
2018-10-07 19:34:39 +03:00
# project source files
2019-02-20 22:11:29 +02:00
MD5_SRC = ft_md5.c \
ft_md5_stdin.c \
ft_md5_string.c \
ft_md5_file.c \
ft_md5_print.c \
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 \
2018-10-20 20:56:18 +03:00
ft_md5_digest_string.c
2018-10-07 19:34:39 +03:00
2019-02-20 22:11:29 +02:00
SHA_SRC = ft_sha256.c \
ft_sha256_string.c \
ft_sha256_file.c \
ft_sha256_stdin.c \
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 \
ft_sha224_string.c \
ft_sha224_file.c \
ft_sha224_stdin.c \
ft_sha224.c \
ft_sha224_init.c \
ft_sha224_update.c \
ft_sha224_final.c \
ft_sha224_digest_string.c \
ft_sha_print.c \
ft_sha_usage.c
2018-10-21 20:46:05 +03:00
2019-02-20 22:11:29 +02:00
BASE64_SRC = ft_base64.c \
ft_base64_init.c \
ft_base64_decode.c \
ft_base64_encode.c \
ft_base64_init_encode_buffer.c \
ft_base64_encode_chunk.c \
ft_base64_encode_transform.c \
ft_base64_encode_finish.c \
ft_base64_init_decode_buffer.c \
ft_base64_decode_chunk.c \
ft_base64_decode_filter.c \
ft_base64_decode_transform.c \
ft_base64_decode_finish.c
2018-10-21 20:46:05 +03:00
DES_SRC = ft_des_initial_permutation.c \
ft_des_final_permutation.c \
2019-03-11 00:22:54 +02:00
ft_des_expansion_box.c \
ft_des_s_box.c \
ft_des_s_box_1.c \
ft_des_s_box_2.c \
ft_des_s_box_3.c \
ft_des_s_box_4.c \
ft_des_s_box_5.c \
ft_des_s_box_6.c \
ft_des_s_box_7.c \
ft_des_s_box_8.c \
ft_des_feistel_function_permutation.c \
2019-03-12 00:06:46 +02:00
ft_des_feistel_function.c \
ft_des_key_permuted_choice_one.c \
2019-03-13 19:40:38 +02:00
ft_des_derive_encryption_round_key.c \
ft_des_derive_decryption_round_key.c \
2019-03-12 00:06:46 +02:00
ft_des_rotate_half_key_left.c \
ft_des_rotate_half_key_right.c \
2019-03-13 00:43:47 +02:00
ft_des_key_permuted_choice_two.c \
2019-03-13 19:40:38 +02:00
ft_des_round.c \
ft_des_process_block.c \
ft_des_generate_encryption_round_keys.c \
ft_des_generate_decryption_round_keys.c \
ft_des_ecb.c \
ft_des_init_ctx.c \
ft_des_encryption_key_routine.c \
ft_des_print_error.c \
ft_des_arg_parsers.c \
2019-03-22 01:16:48 +02:00
ft_des_ecb_encrypt.c \
ft_des_ecb_decrypt.c \
2019-03-23 11:33:28 +02:00
ft_des_ecb_decrypt_b64.c \
ft_des_ecb_encrypt_b64.c \
2019-03-22 01:16:48 +02:00
ft_des_ecb_encode_process_chunk.c \
2019-04-06 14:40:50 +03:00
ft_des_hex_to_bit.c \
ft_des_hex_to_byte.c \
ft_des_byte_to_bits.c \
2019-03-22 01:16:48 +02:00
ft_des_ecb_finish_encrypt.c
2019-03-27 01:29:06 +02:00
KD2_SRC = ft_hmac_sha256_init_ctx.c \
2019-03-29 02:06:29 +02:00
ft_hmac_sha256.c \
ft_pbkdf2_sha256_init_ctx.c \
ft_pbkdf2_sha256.c
2019-03-06 23:41:59 +02:00
2019-02-20 22:11:29 +02:00
SRC = main.c \
2018-10-22 22:33:05 +03:00
ft_ssl_usage.c
2019-02-20 22:11:29 +02:00
SRC += $(MD5_SRC) \
$(SHA_SRC) \
2019-03-06 23:41:59 +02:00
$(BASE64_SRC) \
2019-03-27 01:29:06 +02:00
$(DES_SRC) \
$(KD2_SRC)
2018-10-07 19:34:39 +03:00
# project object files
OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o))
# project test files
2019-01-19 15:21:33 +02:00
TEST_BIN = ft_ssl_test
2018-10-08 02:39:31 +03:00
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)
2019-01-19 18:16:00 +02:00
BASE64_TESTS = base64_tests.c
BASE64_TESTS += $(BASE64_SRC)
2019-03-06 23:41:59 +02:00
DES_TESTS = des_tests.c
DES_TESTS += $(DES_SRC)
2019-03-27 01:29:06 +02:00
KD2_TESTS = pbkdf2_tests.c
KD2_TESTS += $(KD2_SRC)
TEST_SRC = tests.c
2019-02-20 22:11:29 +02:00
TEST_SRC += $(MD5_TESTS) \
$(SHA_TESTS) \
2019-03-06 23:41:59 +02:00
$(BASE64_TESTS) \
2019-03-27 01:29:06 +02:00
$(DES_TESTS) \
$(KD2_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
2019-04-06 18:04:46 +03:00
LINK_FLAGS = $(LIBFT_LIB) \
$(OPENSSL_LIB)
2018-10-07 19:34:39 +03:00
# header flags
2019-02-20 22:11:29 +02:00
HEADER_FLAGS = -I $(INC_DIR) \
2019-04-06 18:04:46 +03:00
$(LIBFT_INC) \
$(OPENSSL_INC)
2018-10-07 19:34:39 +03:00
# compiler
CC := clang
# rules
2019-04-06 18:04:46 +03:00
$(NAME): $(OBJ)
2018-10-07 19:34:39 +03:00
$(CC) $(OBJ) $(LINK_FLAGS) -o $(NAME)
2019-04-06 18:04:46 +03:00
$(TEST_BIN): $(TEST_OBJ)
2018-10-08 02:39:31 +03:00
$(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 $(LIBFT) $(OPENSSL_CRY) $(OPENSSL_SSL) $(HEADERS)
2018-10-07 19:34:39 +03:00
$(CC) -c $< -o $@ $(CC_FLAGS) $(HEADER_FLAGS)
$(LIBFT):
$(MAKE) -C $(LIBFT_DIR)
$(OPENSSL_CRY) $(OPENSSL_SSL):
cd $(OPENSSL_DIR) && \
./config --prefix=$(OPENSSL_BLD) && \
make -j 4 && \
make -j 4 install
2019-01-29 23:23:04 +02:00
all: $(NAME)
check: $(TEST_BIN)
clear
./$(TEST_BIN)
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)
rm -rf $(OPENSSL_BLD)
2018-10-07 19:34:39 +03:00
$(MAKE) -C $(LIBFT_DIR) fclean
re: fclean all
multi:
$(MAKE) $(LIBFT)
$(MAKE) $(NAME)
# special stuff
2019-02-20 22:11:29 +02:00
vpath %.c $(SRC_DIR) \
$(MD5_DIR) \
$(SHA_DIR) \
$(B64_DIR) \
2019-03-06 23:41:59 +02:00
$(DES_DIR) \
2019-03-27 01:29:06 +02:00
$(KD2_DIR) \
$(TST_DIR)
2018-10-07 19:34:39 +03:00
.PHONY: all check clean fclean re multi