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-11 18:48:27 +05:00
|
|
|
NNTPCHAN_PATH = $(REPO)/libnntpchan
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-10-11 18:48:27 +05:00
|
|
|
NNTPCHAN_SRC := $(wildcard $(NNTPCHAN_PATH)/*.cpp)
|
|
|
|
NNTPCHAN_HDR := $(wildcard $(NNTPCHAN_PATH)/*.hpp)
|
|
|
|
NNTPCHAN_OBJ := $(NNTPCHAN_SRC:.cpp=.o)
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-10-11 18:48:27 +05:00
|
|
|
HEADERS_PATH=$(REPO)/include
|
|
|
|
|
|
|
|
TOOL_PATH := $(REPO)/tools
|
|
|
|
|
|
|
|
TOOL_SRC := $(wildcard $(TOOL_PATH)/*.cpp)
|
2017-05-03 20:37:09 +05:00
|
|
|
TOOLS := $(TOOL_SRC:.cpp=)
|
|
|
|
|
2018-05-06 18:42:31 +05:00
|
|
|
SRCS = $(NNTPCHAN_SRC) $(TOOL_SRC)
|
2018-05-06 17:10:01 +05:00
|
|
|
|
2017-10-13 16:58:41 +05:00
|
|
|
OBJ := $(NNTPCHAN_OBJ)
|
|
|
|
|
|
|
|
TEST = $(REPO)/test
|
2017-10-11 18:48:27 +05:00
|
|
|
|
2017-05-03 20:37:09 +05:00
|
|
|
DAEMON_SRC = $(REPO)/daemon
|
|
|
|
|
2018-05-06 18:43:29 +05:00
|
|
|
ifeq ($(shell uname -s),"FreeBSD")
|
2018-05-06 18:42:31 +05:00
|
|
|
SODIUM_INC = /usr/local/include
|
|
|
|
SODIUM_LIB = /usr/local/lib/libsodium.a
|
|
|
|
else
|
|
|
|
SODIUM_INC = $(shell pkg-config --cflags libsodium)
|
|
|
|
SODIUM_LIB = $(shell pkg-config --libs --static libsodium)
|
|
|
|
endif
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2018-05-06 18:42:31 +05:00
|
|
|
LD_FLAGS := -lstdc++fs $(SODIUM_LIB)
|
|
|
|
INC_FLAGS := -I$(HEADERS_PATH) $(SODIUM_INC)
|
2017-10-17 19:29:56 +05:00
|
|
|
REQUIRED_CXXFLAGS = -std=c++17 -Wall -Wextra -Werror -pedantic $(INC_FLAGS)
|
2017-10-13 16:58:41 +05:00
|
|
|
|
|
|
|
DEBUG = 1
|
2016-10-15 21:37:59 +05:00
|
|
|
|
2017-05-03 20:37:09 +05:00
|
|
|
ifeq ($(DEBUG),1)
|
2017-10-17 19:29:56 +05:00
|
|
|
REQUIRED_CXXFLAGS += -g
|
2017-05-03 20:37:09 +05:00
|
|
|
endif
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-10-17 19:29:56 +05:00
|
|
|
CXXFLAGS += $(REQUIRED_CXXFLAGS)
|
|
|
|
|
2017-10-11 18:48:27 +05:00
|
|
|
NNTPCHAN_LIB = $(REPO)/libnntpchan.a
|
|
|
|
|
2018-05-06 18:42:31 +05:00
|
|
|
LIBS = $(NNTPCHAN_LIB)
|
2017-05-03 20:37:09 +05:00
|
|
|
|
|
|
|
EXE = $(REPO)/nntpd
|
|
|
|
|
|
|
|
|
2017-10-09 20:48:10 +05:00
|
|
|
all: build
|
|
|
|
|
2018-05-06 17:10:01 +05:00
|
|
|
format:
|
|
|
|
clang-format -i $(SRCS)
|
|
|
|
|
2018-05-04 17:38:34 +05:00
|
|
|
build: $(EXE) tools
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-10-11 18:48:27 +05:00
|
|
|
$(NNTPCHAN_LIB): $(NNTPCHAN_OBJ)
|
|
|
|
$(AR) -r $(NNTPCHAN_LIB) $(NNTPCHAN_OBJ)
|
2017-05-03 20:37:09 +05:00
|
|
|
|
2017-10-11 18:48:27 +05:00
|
|
|
$(EXE): $(LIBS)
|
2017-10-13 16:58:41 +05:00
|
|
|
$(CXX) $(CXXFLAGS) $(DAEMON_SRC)/main.cpp $(LIBS) $(LD_FLAGS) -o $(EXE)
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2018-05-04 17:38:34 +05:00
|
|
|
tools: $(TOOLS)
|
|
|
|
|
|
|
|
$(TOOLS): $(LIBS)
|
|
|
|
$(CXX) $(CXXFLAGS) $@.cpp $(LIBS) $(LD_FLAGS) -o $@
|
2016-10-15 18:12:01 +05:00
|
|
|
|
2017-10-13 16:58:41 +05:00
|
|
|
build-test: $(LIBS)
|
|
|
|
$(CXX) -o $(TEST) $(CXXFLAGS) test.cpp $(LIBS) $(LD_FLAGS)
|
2016-10-18 17:17:40 +05:00
|
|
|
|
|
|
|
test: build-test
|
2017-10-13 16:58:41 +05:00
|
|
|
$(TEST)
|
2016-10-18 17:17:40 +05:00
|
|
|
|
2016-10-15 18:12:01 +05:00
|
|
|
clean:
|
2017-10-13 16:58:41 +05:00
|
|
|
$(RM) $(OBJ) $(LIBS) $(EXE) $(TOOLS) $(TEST)
|