-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (33 loc) · 1.25 KB
/
Makefile
File metadata and controls
44 lines (33 loc) · 1.25 KB
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
CC = gcc
CFLAGS = -Wall -Wextra -Werror -pedantic -std=c11 -O2
CFLAGS_DEBUG = -Wall -Wextra -Werror -pedantic -std=c11 -g -DDEBUG
INCLUDES = -Iinclude
SRC_DIR = src
OBJ_DIR = obj
LIB_DIR = lib
EXAMPLES_DIR = examples
TESTS_DIR = tests
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
LIB_NAME = libfpbm.a
.PHONY: all clean debug examples tests
all: $(LIB_DIR)/$(LIB_NAME)
debug: CFLAGS = $(CFLAGS_DEBUG)
debug: clean all
$(LIB_DIR)/$(LIB_NAME): $(OBJS)
@mkdir -p $(LIB_DIR)
ar rcs $@ $^
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(OBJ_DIR)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
examples: $(LIB_DIR)/$(LIB_NAME)
$(CC) $(CFLAGS) $(INCLUDES) $(EXAMPLES_DIR)/echo_server.c -L$(LIB_DIR) -lfpbm -o echo_server
$(CC) $(CFLAGS) $(INCLUDES) $(EXAMPLES_DIR)/echo_client.c -L$(LIB_DIR) -lfpbm -o echo_client
$(CC) $(CFLAGS) $(INCLUDES) $(EXAMPLES_DIR)/chat_server.c -L$(LIB_DIR) -lfpbm -o chat_server
$(CC) $(CFLAGS) $(INCLUDES) $(EXAMPLES_DIR)/chat_client.c -L$(LIB_DIR) -lfpbm -o chat_client
tests:
$(CC) $(CFLAGS) $(INCLUDES) $(TESTS_DIR)/test_protocol.c $(SRC_DIR)/protocol.c $(SRC_DIR)/error.c -o test_protocol
./test_protocol
clean:
rm -rf $(OBJ_DIR) $(LIB_DIR)
rm -f echo_server echo_client chat_server chat_client test_protocol