aboutsummaryrefslogtreecommitdiff
path: root/vendor/libftm/Makefile
blob: c33bd78f46fe1d53d87549bc7f2a5627b18f6c35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# **************************************************************************** #
#                                                                              #
#                                                         :::      ::::::::    #
#    Makefile                                           :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: charles <charles.cabergs@gmail.com>        +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2020/05/09 20:44:53 by charles           #+#    #+#              #
#    Updated: 2020/05/12 16:03:51 by charles          ###   ########.fr        #
#                                                                              #
# **************************************************************************** #

LIB = ar rcs
RM = rm -f
MAKE = make --no-print-directory
JOBS = 4

SRC_DIR = src
INC_DIR = inc
OBJ_DIR = obj

CC = gcc
OFLAG ?= -O0
CCFLAGS = $(OFLAG) -I$(INC_DIR) -Wall -Wextra -Werror

NAME = libftm.a

SRC = $(shell find $(SRC_DIR) -type f -name '*.c')
INC = $(shell find $(INC_DIR) -type f -name '*.h')
OBJ = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)

OBJ_SUB_DIR = $(shell find $(SRC_DIR) -type d | sed 's/$(SRC_DIR)/$(OBJ_DIR)/')

all: prebuild
	@$(MAKE) -j$(JOBS) $(NAME)

prebuild:
	@mkdir -p $(OBJ_DIR) $(OBJ_SUB_DIR)

$(NAME): $(OBJ) $(INC)
	@echo "Linking: $@"
	@$(LIB) $@ $(OBJ)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
	@echo "Compiling: $@"
	@$(CC) $(CCFLAGS) -c -o $@ $<

clean:
	@echo "Removing objects"
	@$(RM) $(OBJ)

fclean: clean
	@echo "Removing $(NAME)"
	@$(RM) $(NAME)

re: fclean all