-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (36 loc) · 1.11 KB
/
Makefile
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
ADDR ?= 127.0.0.1
TARGET ?= senddata.out
OBJDIR = .obj
SRCS := $(wildcard *.c)
OBJS := $(SRCS:%.c=$(OBJDIR)/%.o)
DEPS := $(OBJS:.o=.d)
FORMATS := $(SRCS) $(wildcard *.h)
CC := clang
CSTD := c99
CFLAGS += -Wall -Wextra -pedantic -pedantic-errors -MMD -MP -std=$(CSTD)
CFLAGS += $(shell pkg-config --cflags openssl)
LDFLAGS += -lssl -lcrypto
ANSI_COLOR_RED := \033[0;31m
ANSI_COLOR_GREEN := \033[0;32m
ANSI_COLOR_YELLOW := \033[0;33m
ANSI_COLOR_BLUE := \033[0;34m
ANSI_COLOR_MAGENTA := \033[0;35m
ANSI_COLOR_CYAN := \033[0;36m
ANSI_COLOR_RESET := \033[0m
.PHONY: compile clean format
$(TARGET): $(OBJS)
@printf "$(ANSI_COLOR_GREEN)--> Linking $@$(ANSI_COLOR_RESET)\n"
$(CC) $(LDFLAGS) -o $@ $^
$(OBJDIR)/%.o: %.c | $(OBJDIR)
@printf "$(ANSI_COLOR_GREEN)--> Compiling $@$(ANSI_COLOR_RESET)\n"
$(CC) $(CFLAGS) -c -o $@ $<
$(OBJDIR):
mkdir -p $(OBJDIR)
format: $(FORMATS)
@printf "$(ANSI_COLOR_RED)--> Formatting$(ANSI_COLOR_RESET)\n"
clang-tidy --fix $^ -- $(CFLAGS)
clang-format --verbose -i $^
clean:
@printf "$(ANSI_COLOR_RED)--> Cleaning$(ANSI_COLOR_RESET)\n"
$(RM) $(TARGET) $(OBJS)
-include $(DEPS)