-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
54 lines (43 loc) · 849 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
51
52
53
54
# C/C++ compiler
CC ?= gcc
CXX ?= g++
# Directories
INCDIRS =
LIBDIRS =
# Includes/Libraries
INCLUDE = $(foreach dir, $(INCDIRS), -I$(dir))
LIBS = $(foreach dir, $(LIBDIRS), -L$(dir))
# C/C++ flags
CFLAGS = -O2 -Wall -std=c99 $(INCLUDE)
CXXFLAGS = -O2 -Wall $(INCLUDE)
# Linker flags
LDFLAGS = $(LIBS) -lpthread
# Objects
OBJS = \
client.o \
error_page.o \
file.o \
header.o \
http.o \
log.o \
server.o \
socket.o \
thread.o \
main.o
# Executable target
TARGET = httpd
# Compile target
$(TARGET): $(OBJS)
@echo -e " LD\t$(notdir $(TARGET))"
@$(CXX) $(OBJS) -o $(TARGET) $(LDFLAGS)
# Compile objects
%.o: %.c
@echo -e " CC\t$(notdir $<)"
@$(CC) $(CFLAGS) -c $< -o $@
%.o: %.cpp
@echo -e " CXX\t$(notdir $<)"
@$(CXX) $(CXXFLAGS) -c $< -o $@
# Clean data
clean:
@echo -e "Cleaning..."
@rm -f *.o $(TARGET)