lokinet/Makefile

50 lines
1.4 KiB
Makefile
Raw Normal View History

2017-09-28 17:02:05 +00:00
REPO := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2018-01-25 15:38:14 +00:00
EXE = $(REPO)/llarpd
STATIC_LIB = $(REPO)/libllarp.a
2017-09-28 17:02:05 +00:00
2018-01-25 15:38:14 +00:00
STATIC_SRC_CPP = $(wildcard $(REPO)/llarp/*.cpp)
STATIC_SRC_C = $(wildcard $(REPO)/llarp/*.c)
2018-01-08 13:49:05 +00:00
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)
2018-01-25 16:11:45 +00:00
DEBUG_FLAGS = -g
GIT_VERSION ?= $(shell test -e .git && git rev-parse --short HEAD || true)
ifneq ($(GIT_VERSION),"")
VER_FLAGS=-DGIT_REV=\"$(GIT_VERSION)\"
endif
REQUIRED_CFLAGS = $(LIBUV_FLAGS) $(SODIUM_FLAGS) -I$(REPO)/include -std=c99 $(CFLAGS) $(DEBUG_FLAGS) $(VER_FLAGS)
REQUIRED_CXXFLAGS = $(LIBUV_FLAGS) $(SODIUM_FLAGS) -I$(REPO)/include -std=c++14 $(CXXFLAGS) $(DEBUG_FLAGS) $(VER_FLAGS)
2018-01-08 13:49:05 +00:00
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)