2017-09-28 17:02:05 +00:00
|
|
|
REPO := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
|
|
|
|
|
|
EXE = $(REPO)/sarpd
|
2017-10-03 19:14:46 +00:00
|
|
|
STATIC_LIB = $(REPO)/libsarp.a
|
2017-09-28 17:02:05 +00:00
|
|
|
|
2017-10-03 19:14:46 +00:00
|
|
|
STATIC_SRC = $(wildcard $(REPO)/libsarp/*.cpp)
|
|
|
|
STATIC_OBJ = $(STATIC_SRC:.cpp=.cpp.o)
|
2017-09-28 17:02:05 +00:00
|
|
|
|
|
|
|
DAEMON_SRC = $(wildcard $(REPO)/daemon/*.c)
|
|
|
|
DAEMON_OBJ = $(DAEMON_SRC:.c=.o)
|
|
|
|
|
|
|
|
PKG = pkg-config
|
|
|
|
|
|
|
|
PKGS = libsodium
|
|
|
|
|
2017-10-03 19:14:46 +00:00
|
|
|
REQUIRED_CFLAGS = $(shell $(PKG) --cflags $(PKGS)) -I$(REPO)/include -std=c99
|
|
|
|
REQUIRED_CXXFLAGS = $(shell $(PKG) --cflags $(PKGS)) -I$(REPO)/include -std=c++17
|
|
|
|
REQUIRED_LDFLAGS = $(LDFLAGS) $(shell $(PKG) --libs $(PKGS)) -ljemalloc
|
|
|
|
CXXFLAGS := $(REQUIRED_CXXFLAGS)
|
|
|
|
CFLAGS := $(REQUIRED_CFLAGS)
|
2017-09-28 17:02:05 +00:00
|
|
|
|
|
|
|
all: build
|
|
|
|
|
|
|
|
build: $(EXE)
|
|
|
|
|
|
|
|
$(EXE): $(DAEMON_OBJ) $(STATIC_LIB)
|
2017-10-03 19:14:46 +00:00
|
|
|
$(CXX) $(DAEMON_OBJ) $(STATIC_LIB) $(REQUIRED_LDFLAGS) -o $(EXE)
|
|
|
|
|
|
|
|
%.cpp.o: %.cpp
|
|
|
|
$(CXX) $(CXXFLAGS) -c $< -o $<.o
|
2017-09-28 17:02:05 +00:00
|
|
|
|
|
|
|
$(STATIC_LIB): $(STATIC_OBJ)
|
|
|
|
$(AR) -r $(STATIC_LIB) $(STATIC_OBJ)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(DAEMON_OBJ) $(EXE) $(STATIC_OBJ) $(STATIC_LIB)
|