Browse Source

Merge with make-cleanup

sync
Hussein Kasem 6 years ago
parent
commit
cab6b68dbf
  1. 1
      .hgignore
  2. 75
      Makefile
  3. 48
      Makefile.conf
  4. 23
      readme.md

1
.hgignore

@ -8,3 +8,4 @@ test_adapter
.pEp*
lib
local.conf
build/

75
Makefile

@ -1,49 +1,82 @@
# 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
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)
HEADERS=$(wildcard *.hh *.hxx)
OBJECTS=$(subst .cc,.o,$(SOURCE))
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)
# Rule copied from make's built-in rules
%.o: %.cc %.hh
$(CXX) $(CXXFLAGS) -c $<
$(COMPILE.cc) $(OUTPUT_OPTION) $<
$(TARGET): $(WITHOUT_TESTS)
ar -rc $@ $^
.PHONY: clean distclean test install uninstall
.PHONY: clean
clean:
rm -f $(TARGET) $(OBJECTS) *.a test_adapter lib
rm -f $(TARGET) $(OBJECTS) *.a test_adapter test_library lib
rm -rf test_adapter.dSYM
rm -rf test_library.dSYM
rm -rf .gnupg/
rm -f .pEp_management.db*
.PHONY: distclean
distclean: clean
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
ifeq ($(HOME),$(PREFIX))
-ln -fs $$HOME/lib
endif
HOME=$$(pwd) ./test_adapter
test_adapter: test_adapter.o $(TARGET)
$(CXX) -o $@ -L$(PEP)/lib -lpEpEngine -L. -lpEpAdapter $<
$(TEST_CMD_PFX) HOME=$$(pwd) ./test_adapter
test_library: test_library.o $(TARGET)
$(CXX) -o $@ -L$(PEP)/lib -lpEpEngine -L. -lpEpAdapter $<
test_%: test_%.o $(TARGET)
.PHONY: install
install: $(TARGET)
-mkdir -p $(PEP)/include/pEp
cp $(HEADERS) $(PEP)/include/pEp/
cp $(TARGET) $(PEP)/lib/
-mkdir -p $(PREFIX)/include/pEp
-mkdir -p $(PREFIX)/lib
cp $(HEADERS) $(PREFIX)/include/pEp/
cp $(TARGET) $(PREFIX)/lib/
.PHONY: uninstall
uninstall:
cd $(PEP)/include && rm -f $(HEADERS)
cd $(PEP)/lib && rm -f $(TARGET)
cd $(PREFIX)/include/pEp && rm -f $(HEADERS)
cd $(PREFIX)/lib && rm -f $(TARGET)

48
Makefile.conf

@ -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
TARGET=libpEpAdapter.a
######### Header #########
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
######### General #########
BUILD_FOR:=$(shell uname)
PREFIX=$(HOME)
PEP=$(HOME)
######### C and C++ #########
LDFLAGS=$(ENGINE_LIB) -L.
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

23
readme.md

@ -0,0 +1,23 @@
# How to build
To customize your build, you may change several variables that are consumed by make.
These variables, along with some explanations can be found in Makefile.conf.
You can edit that file, or create a file `local.conf` in the root of the repository, which will also be parsed by make.
A sample `local.conf` looks like this:
~~~
PREFIX=$(HOME)/code/libad/build
ENGINE_LIB=-L$(HOME)/code/engine/build/lib
ENGINE_INC=-I$(HOME)/code/engine/build/include
~~~
Now, run:
~~~
make all
make install
~~~
Loading…
Cancel
Save