Skip to content

Commit e284a06

Browse files
committed
Added build variant using Makefile
1 parent db3d837 commit e284a06

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
RM = rm -rf
2+
MKDIR = mkdir -p
3+
4+
#CXX = g++
5+
CXXFLAGS += -std=c++14 -c -Wall -O2
6+
LDFLAGS = -ldl -lpthread -lrt -lgnutls
7+
8+
DEFS = POSIX
9+
DEFINES = $(patsubst %, -D%, $(DEFS) )
10+
11+
SOURCEDIR = ./src
12+
BUILDDIR = ./build
13+
OBJDIR = $(BUILDDIR)/obj
14+
15+
SOURCES = $(shell find $(SOURCEDIR) -type f -name '*.cpp')
16+
OBJECTS = $(patsubst $(SOURCEDIR)/%.cpp, $(OBJDIR)/%.o, $(SOURCES) )
17+
18+
EXECUTABLE = $(BUILDDIR)/httpserver
19+
20+
.PHONY: all clean
21+
all: $(BUILDDIR) $(EXECUTABLE)
22+
23+
$(BUILDDIR):
24+
$(MKDIR) $@
25+
26+
$(EXECUTABLE): $(OBJECTS)
27+
$(CXX) $(LDFLAGS) $(OBJECTS) -o $@
28+
29+
$(OBJECTS) : $(OBJDIR)/%.o : $(SOURCEDIR)/%.cpp
30+
@$(MKDIR) $(dir $@)
31+
$(CXX) $(DEFINES) $(CXXFLAGS) $< -o $@
32+
33+
clean:
34+
$(RM) $(OBJDIR) $(EXECUTABLE)

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ Windows: `ws2_32.lib`, `libgnutls.dll.a`
3636

3737
Linux:
3838

39+
```sh
40+
git clone https://github.com/awwit/httpserver.git
41+
cd httpserver
42+
make
43+
```
44+
45+
or
46+
3947
```sh
4048
git clone https://github.com/awwit/httpserver.git
4149
cd httpserver

0 commit comments

Comments
 (0)