-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (26 loc) · 799 Bytes
/
Makefile
File metadata and controls
35 lines (26 loc) · 799 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
# Makefile for a simple web server using cpp-httplib
CXX = g++ # The compiler being used
CXXFLAGS = -std=c++11 -Wall -O2 # Compiler flags
LDFLAGS = # Any specific linking flags
LDLIBS = -lpthread # Libraries to link against
# Define the source files and the resulting executable
SRCS = server.cpp
OBJS = $(SRCS:.cpp=.o)
EXEC = webserver
# Rule for building the final executable
$(EXEC): $(OBJS)
$(CXX) $(LDFLAGS) -o $(EXEC) $(OBJS) $(LDLIBS)
# Rule for building object files
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $<
# Phony targets for cleaning and running
.PHONY: clean run
clean:
rm -f $(OBJS) $(EXEC)
run: $(EXEC)
./$(EXEC)
# Include dependencies
-include $(OBJS:.o=.d)
# Rule for building dependency files
%.d: %.cpp
$(CXX) $(CXXFLAGS) -MM -MT $@ -o $*.d $<