-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (40 loc) · 900 Bytes
/
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
43
44
45
46
47
48
49
50
# Compiler settings
CC = cc
CCFLAGS := -Wall -ggdb -lssl -lcrypto -lpthread
# Folders
SRC = src
BUILD = build
BIN = bin
CFL := $(BUILD) $(BIN) # Create Folder List
# Files
EXE = $(BIN)/clichat
CFILES := main.c sock.c conf.c err.c client.c server.c
OFILES := $(addprefix $(BUILD)/, $(notdir $(CFILES:.c=.o)))
# Aesthetics
GREEN = \033[0;32m
RESET = \033[0m
# Compile
all: $(CFL) $(EXE)
$(EXE): $(OFILES)
@echo -n 'Creating executable $@: '
@ $(CC) -o $@ $^ $(CCFLAGS)
@echo -e ' $(GREEN)Done$(RESET)'
$(BUILD)/%.o: $(SRC)/%.c
@echo -n 'Building object $<: '
@ $(CC) -o $@ -c $^
@echo -e ' $(GREEN)Done$(RESET)'
# Others
$(CFL):
ifeq ("$(wildcard $@)", "")
@echo -n 'Creating $@ folder: '
@ mkdir $@
@echo -e ' $(GREEN)Done$(RESET)'
endif
server: $(CFL) $(EXE)
$(EXE) -t s
client: $(CFL) $(EXE)
$(EXE) -t c
clean:
rm $(BIN)/* $(BUILD)/*
cleanall:
rm -r $(BIN)/ $(BUILD)/