-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
29 lines (24 loc) · 1016 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
CXX := g++ # This is the main compiler
SRCDIR := src
BUILDDIR := build
TARGET := client server
SRCEXT := cpp
# Get all files with SRCEXT a folder inside src i.e src/*/*.cpp
SOURCES := $(shell find $(SRCDIR)/*/ -type f -name *.$(SRCEXT))
# Convert all the SOURCES to OBJECTS with root dir build and extension .o
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o))
# Optimization ON and show all warnings
CFLAGS := -O2 -Wall
# LIB := -pthread -lmongoclient -L lib -lboost_thread-mt -lboost_filesystem-mt -lboost_system-mt
RM = /bin/rm -f
$(TARGET): $(OBJECTS)
@echo " Linking..."
$(CXX) $(CFLAGS) src/client.cpp $^ -o client $(LIB);
$(CXX) $(CFLAGS) src/server.cpp $^ -o server $(LIB);
# @echo " $(CXX) $^ -o $(TARGET) $(LIB)"; $(CXX) $^ -o $(TARGET) $(LIB)
$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT)
@mkdir -p $(@D)
@echo " $(CXX) $(CFLAGS) -c -o $@ $<"; $(CXX) $(CFLAGS) -c -o $@ $<
clean:
@echo " Cleaning...";
@echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET)