2016-10-15 18:12:01 +05:00
|
|
|
|
2017-04-14 15:24:53 +05:00
|
|
|
REPO=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
2017-10-09 20:48:10 +05:00
|
|
|
SRC_PATH = $(REPO)/libnntpchan
|
2016-10-15 18:12:01 +05:00
|
|
|
|
|
|
|
SOURCES := $(wildcard $(SRC_PATH)/*.cpp)
|
|
|
|
HEADERS := $(wildcard $(SRC_PATH)/*.hpp)
|
|
|
|
OBJECTS := $(SOURCES:.cpp=.o)
|
|
|
|
|
2017-05-03 20:37:09 +05:00
|
|
|
TOOL_SRC_PATH := $(REPO)/tools
|
|
|
|
|
|
|
|
TOOL_SRC := $(wildcard $(TOOL_SRC_PATH)/*.cpp)
|
|
|
|
TOOLS := $(TOOL_SRC:.cpp=)
|
|
|
|
|
|
|
|
DAEMON_SRC = $(REPO)/daemon
|
|
|
|
|
2016-10-15 21:37:59 +05:00
|
|
|
PKGS := libuv libsodium
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-10-09 20:48:10 +05:00
|
|
|
LD_FLAGS := $(shell pkg-config --libs $(PKGS)) -lstdc++fs
|
|
|
|
INC_FLAGS := $(shell pkg-config --cflags $(PKGS)) -I$(SRC_PATH)
|
|
|
|
CXXFLAGS := -std=c++17 -Wall -Wextra -pedantic $(INC_FLAGS)
|
2016-10-15 21:37:59 +05:00
|
|
|
|
2017-05-03 20:37:09 +05:00
|
|
|
ifeq ($(DEBUG),1)
|
|
|
|
CXXFLAGS += -g
|
|
|
|
endif
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-05-03 20:37:09 +05:00
|
|
|
LIB = $(REPO)/libnntpchan.a
|
|
|
|
|
|
|
|
EXE = $(REPO)/nntpd
|
|
|
|
|
|
|
|
|
2017-10-09 20:48:10 +05:00
|
|
|
all: build
|
|
|
|
|
|
|
|
build: $(EXE) $(TOOLS)
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-05-03 17:09:23 +05:00
|
|
|
$(LIB): $(OBJECTS)
|
2017-05-03 20:01:32 +05:00
|
|
|
$(AR) -r $(LIB) $(OBJECTS)
|
2017-05-03 17:09:23 +05:00
|
|
|
|
|
|
|
$(EXE): $(LIB)
|
2017-05-03 20:37:09 +05:00
|
|
|
$(CXX) $(CXXFLAGS) $(DAEMON_SRC)/main.cpp $(LIB) $(LD_FLAGS) -o $(EXE)
|
|
|
|
|
|
|
|
$(TOOL_SRC): $(LIB)
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-05-03 20:37:09 +05:00
|
|
|
$(TOOLS): $(TOOL_SRC)
|
|
|
|
$(CXX) $(CXXFLAGS) $< $(LIB) $(LD_FLAGS) -o $@
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-05-03 17:09:23 +05:00
|
|
|
build-test: $(LIB)
|
2017-09-24 17:18:56 +05:00
|
|
|
$(CXX) -o $(REPO)/test $(CXXFLAGS) test.cpp $(LIB) $(LD_FLAGS)
|
2016-10-18 17:17:40 +05:00
|
|
|
|
|
|
|
test: build-test
|
2017-09-24 17:18:56 +05:00
|
|
|
$(REPO)/test
|
2016-10-18 17:17:40 +05:00
|
|
|
|
2016-10-15 18:12:01 +05:00
|
|
|
%.o: src/%.cpp
|
2017-04-14 15:24:53 +05:00
|
|
|
$(CXX) $(CXXFLAGS) -c -o $@
|
2016-10-15 18:12:01 +05:00
|
|
|
|
|
|
|
clean:
|
2017-05-03 20:37:09 +05:00
|
|
|
rm -f $(OBJECTS) $(LIB) $(EXE) $(TOOLS)
|