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
|
|
|
|
2018-01-08 13:49:05 +00:00
|
|
|
STATIC_SRC_CPP = $(wildcard $(REPO)/libsarp/*.cpp)
|
|
|
|
STATIC_SRC_C = $(wildcard $(REPO)/libsarp/*.c)
|
|
|
|
|
|
|
|
STATIC_OBJ = $(STATIC_SRC_CPP:.cpp=.cpp.o) $(STATIC_SRC_C:.c=.c.o)
|
2017-09-28 17:02:05 +00:00
|
|
|
|
|
|
|
DAEMON_SRC = $(wildcard $(REPO)/daemon/*.c)
|
2018-01-08 13:49:05 +00:00
|
|
|
DAEMON_OBJ = $(DAEMON_SRC:.c=.c.o)
|
2017-09-28 17:02:05 +00:00
|
|
|
|
2017-11-28 14:05:31 +00:00
|
|
|
SODIUM_FLAGS = $(shell pkg-config --cflags libsodium)
|
|
|
|
SODIUM_LIBS = $(shell pkg-config --libs libsodium)
|
2017-09-28 17:02:05 +00:00
|
|
|
|
2018-01-08 13:49:05 +00:00
|
|
|
LIBUV_FLAGS = $(shell pkg-config --cflags libuv)
|
|
|
|
LIBUV_LIBS = $(shell pkg-config --libs libuv)
|
|
|
|
|
|
|
|
REQUIRED_CFLAGS = $(LIBUV_FLAGS) $(SODIUM_FLAGS) -I$(REPO)/include -std=c99 $(CFLAGS)
|
|
|
|
REQUIRED_CXXFLAGS = $(LIBUV_FLAGS) $(SODIUM_FLAGS) -I$(REPO)/include -std=c++17 $(CXXFLAGS)
|
|
|
|
REQUIRED_LDFLAGS = $(LDFLAGS) -ljemalloc $(SODIUM_LIBS) $(LIBUV_LIBS)
|
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
|
2018-01-08 13:49:05 +00:00
|
|
|
$(CXX) $(REQUIRED_CXXFLAGS) -c $< -o $<.o
|
|
|
|
|
|
|
|
%.c.o: %.c
|
|
|
|
$(CC) $(REQUIRED_CFLAGS) -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)
|