
2 changed files with 94 additions and 24 deletions
@ -1,49 +1,77 @@ |
|||||
# this file is under GNU GPL 3.0, see LICENSE.txt
|
# Copyright 2018, pEp Foundation
|
||||
|
# This file is part of lib pEp Adapter
|
||||
|
# This file may be used under the terms of the GNU General Public License version 3
|
||||
# see LICENSE.txt
|
# see LICENSE.txt
|
||||
|
|
||||
include Makefile.conf |
include Makefile.conf |
||||
-include local.conf |
|
||||
|
|
||||
CXXFLAGS += -I$(HOME)/include -std=c++14 -O0 -g |
ifneq ($(wildcard local.conf),) |
||||
|
$(info ================================================) |
||||
|
$(info Overrides in \`local.conf\` are used.) |
||||
|
$(info ================================================) |
||||
|
endif |
||||
|
|
||||
|
ifdef BUILD_CONFIG |
||||
|
$(info ================================================) |
||||
|
$(info Overrides in \`$(BUILD_CONFIG)\` are used.) |
||||
|
$(info ================================================) |
||||
|
endif |
||||
|
|
||||
SOURCE=$(wildcard *.cc) |
SOURCE=$(wildcard *.cc) |
||||
HEADERS=$(wildcard *.hh *.hxx) |
HEADERS=$(wildcard *.hh *.hxx) |
||||
OBJECTS=$(subst .cc,.o,$(SOURCE)) |
OBJECTS=$(subst .cc,.o,$(SOURCE)) |
||||
WITHOUT_TESTS=$(patsubst test%.o,,$(OBJECTS)) |
WITHOUT_TESTS=$(patsubst test%.o,,$(OBJECTS)) |
||||
|
TARGET=libpEpAdapter.a |
||||
|
|
||||
|
EXTRA_LIB_PATHS=.: |
||||
|
ifdef ENGINE_LIB |
||||
|
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ENGINE_LIB)): |
||||
|
endif |
||||
|
|
||||
|
# Remove trailing ':'
|
||||
|
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=) |
||||
|
|
||||
|
ifeq ($(BUILD_FOR),Darwin) |
||||
|
LIBPATH=DYLD_LIBRARY_PATH |
||||
|
else |
||||
|
LIBPATH=LD_LIBRARY_PATH |
||||
|
endif |
||||
|
|
||||
|
$(TEST_CMD_PFX)=$(LIBPATH)=$(EXTRA_LIB_PATHS) |
||||
|
|
||||
|
|
||||
|
.PHONY: all |
||||
all: $(TARGET) |
all: $(TARGET) |
||||
|
|
||||
|
# Rule copied from make's built-in rules
|
||||
%.o: %.cc %.hh |
%.o: %.cc %.hh |
||||
$(CXX) $(CXXFLAGS) -c $< |
$(COMPILE.cc) $(OUTPUT_OPTION) $< |
||||
|
|
||||
$(TARGET): $(WITHOUT_TESTS) |
$(TARGET): $(WITHOUT_TESTS) |
||||
ar -rc $@ $^ |
ar -rc $@ $^ |
||||
|
|
||||
.PHONY: clean distclean test install uninstall |
.PHONY: clean |
||||
|
|
||||
clean: |
clean: |
||||
rm -f $(TARGET) $(OBJECTS) *.a test_adapter lib |
rm -f $(TARGET) $(OBJECTS) *.a test_adapter test_library lib |
||||
|
|
||||
|
.PHONY: distclean |
||||
distclean: clean |
distclean: clean |
||||
rm -Rf .gnupg .pEp_management* |
rm -Rf .gnupg .pEp_management* |
||||
|
|
||||
|
# $$(pwd) will return the incorrect directory, if make is run with `make -C ...`.
|
||||
|
.PHONY: test |
||||
test: test_adapter test_library |
test: test_adapter test_library |
||||
ifeq ($(HOME),$(PREFIX)) |
$(TEST_CMD_PFX) HOME=$$(pwd) ./test_adapter |
||||
-ln -fs $$HOME/lib |
|
||||
endif |
|
||||
HOME=$$(pwd) ./test_adapter |
|
||||
|
|
||||
test_adapter: test_adapter.o $(TARGET) |
|
||||
$(CXX) -o $@ -L$(PEP)/lib -lpEpEngine -L. -lpEpAdapter $< |
|
||||
|
|
||||
test_library: test_library.o $(TARGET) |
test_%: test_%.o $(TARGET) |
||||
$(CXX) -o $@ -L$(PEP)/lib -lpEpEngine -L. -lpEpAdapter $< |
|
||||
|
|
||||
|
.PHONY: install |
||||
install: $(TARGET) |
install: $(TARGET) |
||||
-mkdir -p $(PEP)/include/pEp |
-mkdir -p $(PREFIX)/include/pEp |
||||
cp $(HEADERS) $(PEP)/include/pEp/ |
cp $(HEADERS) $(PREFIX)/include/pEp/ |
||||
cp $(TARGET) $(PEP)/lib/ |
cp $(TARGET) $(PREFIX)/lib/ |
||||
|
|
||||
|
.PHONY: uninstall |
||||
uninstall: |
uninstall: |
||||
cd $(PEP)/include && rm -f $(HEADERS) |
cd $(PREFIX)/include/pEp && rm -f $(HEADERS) |
||||
cd $(PEP)/lib && rm -f $(TARGET) |
cd $(PREFIX)/lib && rm -f $(TARGET) |
||||
|
@ -1,7 +1,49 @@ |
|||||
# this file is under GNU GPL 3.0, see LICENSE.txt
|
# Copyright 2018, pEp Foundation
|
||||
|
# This file is part of lib pEp Adapter
|
||||
|
# This file may be used under the terms of the GNU General Public License version 3
|
||||
# see LICENSE.txt
|
# see LICENSE.txt
|
||||
|
|
||||
TARGET=libpEpAdapter.a |
######### Header #########
|
||||
|
HERE:=$(dir $(lastword $(MAKEFILE_LIST))) |
||||
|
|
||||
|
|
||||
|
######### General #########
|
||||
|
BUILD_FOR:=$(shell uname) |
||||
|
|
||||
PREFIX=$(HOME) |
PREFIX=$(HOME) |
||||
PEP=$(HOME) |
|
||||
|
|
||||
|
|
||||
|
######### C and C++ #########
|
||||
|
LDFLAGS=$(ENGINE_LIB) |
||||
|
|
||||
|
LDLIBS=-lstdc++ -lpEpEngine -lpEpAdapter |
||||
|
|
||||
|
|
||||
|
######### C++ #########
|
||||
|
ifeq ($(BUILD_FOR),Linux) |
||||
|
CXX=g++ -std=c++14 |
||||
|
else ifeq ($(BUILD_FOR),Darwin) |
||||
|
CXX=clang -std=c++14 |
||||
|
endif |
||||
|
|
||||
|
ifeq ($(BUILD_FOR),Linux) |
||||
|
CXXFLAGS=-fdiagnostics-color=always -O0 -g $(ENGINE_INC) |
||||
|
else ifeq ($(BUILD_FOR),Darwin) |
||||
|
CXXFLAGS=-fcolor-diagnostics -O0 -g $(ENGINE_INC) |
||||
|
endif |
||||
|
|
||||
|
|
||||
|
######### Engine #########
|
||||
|
ENGINE_LIB=-L$(HOME)/code/engine/build/lib |
||||
|
#ENGINE_LIB=-L$(HOME)/local/lib
|
||||
|
|
||||
|
ENGINE_INC=-I$(HOME)/code/engine/build/include |
||||
|
#ENGINE_INC=-I$(HOME)/local/inc
|
||||
|
|
||||
|
|
||||
|
######### Footer #########
|
||||
|
-include $(HERE)/local.conf |
||||
|
|
||||
|
ifdef BUILD_CONFIG |
||||
|
include $(BUILD_CONFIG) |
||||
|
endif |
||||
|
Loading…
Reference in new issue