Browse Source

cleanup makefiles, prepare for new test/ dir

sync
heck 2 years ago
parent
commit
82513674a7
2 changed files with 21 additions and 53 deletions
  1. +4
    -35
      Makefile
  2. +17
    -18
      Makefile.conf

+ 4
- 35
Makefile View File

@ -7,50 +7,29 @@ include Makefile.conf
ifneq ($(wildcard local.conf),)
$(info ================================================)
$(info Overrides in \`local.conf\` are used.)
$(info Overrides in `local.conf` are used.)
$(info ================================================)
endif
ifdef BUILD_CONFIG
$(info ================================================)
$(info Overrides in \`$(BUILD_CONFIG)\` are used.)
$(info Overrides in `$(BUILD_CONFIG)` are used.)
$(info ================================================)
endif
.PHONY: all, clean, distclean, test, install, uninstall
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
$(COMPILE.cc) $(OUTPUT_OPTION) $<
$(TARGET): $(WITHOUT_TESTS)
$(AR) -rc $@ $^
.PHONY: clean
clean:
rm -vf $(TARGET) $(OBJECTS) *.a test_adapter test_library lib
rm -rvf test_adapter.dSYM
@ -58,25 +37,15 @@ clean:
rm -rvf .gnupg/
rm -vf .pEp_management.db*
.PHONY: distclean
distclean: clean
rm -Rvf .gnupg .pEp_management*
# $$(pwd) will return the incorrect directory, if make is run with `make -C ...`.
.PHONY: test
test: test_adapter test_library
$(TEST_CMD_PFX) HOME=$$(pwd) ./test_adapter
test_%: test_%.o $(TARGET)
.PHONY: install
install: $(TARGET)
mkdir -p $(PREFIX)/include/pEp
mkdir -p $(PREFIX)/lib
cp -v $(HEADERS) $(PREFIX)/include/pEp/
cp -v $(TARGET) $(PREFIX)/lib/
.PHONY: uninstall
uninstall:
cd $(PREFIX)/include/pEp && rm -vf $(HEADERS)
cd $(PREFIX)/lib && rm -vf $(TARGET)

+ 17
- 18
Makefile.conf View File

@ -6,44 +6,43 @@
######### Header #########
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
######### General #########
BUILD_FOR:=$(shell uname)
PREFIX=$(HOME)
######### C and C++ #########
LDFLAGS=$(ENGINE_LIB) -L.
LDFLAGS=-L. $(ENGINE_LIB)
LDLIBS=-lstdc++ -lpEpEngine -lpEpAdapter
CXXFLAGS=-std=c++11
######### C++ #########
ifeq ($(BUILD_FOR),Linux)
CXX=g++ -std=c++11
CXX=g++
else ifeq ($(BUILD_FOR),Darwin)
CXX=clang -std=c++11
CXX=clang
endif
ifeq ($(BUILD_FOR),Linux)
CXXFLAGS=-fdiagnostics-color=always -O0 -g $(ENGINE_INC) -fPIC
CXXFLAGS+=-fdiagnostics-color=always -O0 -g $(ENGINE_INC) -fPIC
else ifeq ($(BUILD_FOR),Darwin)
CXXFLAGS=-fcolor-diagnostics -O0 -g $(ENGINE_INC)
CXXFLAGS+=-fcolor-diagnostics -O0 -g $(ENGINE_INC)
endif
######### Engine #########
ENGINE_LIB=-L$(HOME)/lib
#ENGINE_LIB=-L$(HOME)/local/lib
ENGINE_LIB_PATH=$(HOME)/lib
ENGINE_INC_PATH=$(HOME)/include
ENGINE_INC=-I$(HOME)/include
#ENGINE_INC=-I$(HOME)/local/inc
######### Footer #########
######### Overrides #########
-include $(HERE)/local.conf
# Add Prefixes to paths, if not already explicitly set in local.conf(s)
ifndef ENGINE_LIB
ENGINE_LIB=-L$(ENGINE_LIB_PATH)
endif
ifndef ENGINE_INC
ENGINE_INC=-I$(ENGINE_INC_PATH)
endif
ifdef BUILD_CONFIG
include $(BUILD_CONFIG)
endif

Loading…
Cancel
Save