-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
35 lines (28 loc) · 772 Bytes
/
makefile
File metadata and controls
35 lines (28 loc) · 772 Bytes
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
CC=gcc
CFLAGS=-I./include -Wall -Wextra
SRCDIR=server/core
DBDIR=server/db
UTILDIR=server/util
BINDIR=bin
LIBS=-lsqlite3 -lbcrypt
# Source files
SRCS=$(SRCDIR)/server.c $(SRCDIR)/router.c $(SRCDIR)/socket_pool.c $(SRCDIR)/socket.c
DB_SRCS=$(DBDIR)/user_db.c
UTIL_SRCS=$(UTILDIR)/user_cache.c
# Object files
OBJS=$(SRCS:.c=.o)
DB_OBJS=$(DB_SRCS:.c=.o)
UTIL_OBJS=$(UTIL_SRCS:.c=.o)
# Binary name
TARGET=$(BINDIR)/server
# Create bin directory if it doesn't exist
$(shell mkdir -p $(BINDIR))
$(shell mkdir -p $(DBDIR))
$(shell mkdir -p $(UTILDIR))
all: $(TARGET)
$(TARGET): $(OBJS) $(DB_OBJS) $(UTIL_OBJS)
$(CC) $(OBJS) $(DB_OBJS) $(UTIL_OBJS) -o $(TARGET) $(LIBS)
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f $(OBJS) $(DB_OBJS) $(UTIL_OBJS) $(TARGET)