Makefile
author Damiano Boppart <damiano.boppart@pep.security>
Mon, 17 Dec 2018 13:07:21 +0100
branchmake-cleanup
changeset 86 8773b3febc6f
parent 85 c318ce6c21ed
child 91 ee5ef7f04461
permissions -rw-r--r--
Fix variable definition syntax
damiano@85
     1
# Copyright 2018, pEp Foundation
damiano@85
     2
# This file is part of lib pEp Adapter
damiano@85
     3
# This file may be used under the terms of the GNU General Public License version 3
vb@21
     4
# see LICENSE.txt
vb@6
     5
vb@0
     6
include Makefile.conf
vb@0
     7
damiano@85
     8
ifneq ($(wildcard local.conf),)
damiano@85
     9
    $(info ================================================)
damiano@85
    10
    $(info Overrides in \`local.conf\` are used.)
damiano@85
    11
    $(info ================================================)
damiano@85
    12
endif
damiano@85
    13
damiano@85
    14
ifdef BUILD_CONFIG
damiano@85
    15
    $(info ================================================)
damiano@85
    16
    $(info Overrides in \`$(BUILD_CONFIG)\` are used.)
damiano@85
    17
    $(info ================================================)
damiano@85
    18
endif
vb@0
    19
vb@0
    20
SOURCE=$(wildcard *.cc)
vb@74
    21
HEADERS=$(wildcard *.hh *.hxx)
vb@0
    22
OBJECTS=$(subst .cc,.o,$(SOURCE))
vb@15
    23
WITHOUT_TESTS=$(patsubst test%.o,,$(OBJECTS))
damiano@85
    24
TARGET=libpEpAdapter.a
vb@0
    25
damiano@85
    26
EXTRA_LIB_PATHS=.:
damiano@85
    27
ifdef ENGINE_LIB
damiano@85
    28
	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ENGINE_LIB)):
damiano@85
    29
endif
damiano@85
    30
damiano@85
    31
# Remove trailing ':'
damiano@85
    32
EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
damiano@85
    33
damiano@85
    34
ifeq ($(BUILD_FOR),Darwin)
damiano@85
    35
    LIBPATH=DYLD_LIBRARY_PATH
damiano@85
    36
else
damiano@85
    37
    LIBPATH=LD_LIBRARY_PATH
damiano@85
    38
endif
damiano@85
    39
damiano@86
    40
TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
damiano@85
    41
damiano@85
    42
damiano@85
    43
.PHONY: all
vb@0
    44
all: $(TARGET)
vb@0
    45
damiano@85
    46
# Rule copied from make's built-in rules
vb@0
    47
%.o: %.cc %.hh
damiano@85
    48
	$(COMPILE.cc) $(OUTPUT_OPTION) $<
vb@0
    49
vb@15
    50
$(TARGET): $(WITHOUT_TESTS)
vb@0
    51
	ar -rc $@ $^
vb@0
    52
damiano@85
    53
.PHONY: clean
damiano@85
    54
clean:
damiano@85
    55
	rm -f $(TARGET) $(OBJECTS) *.a test_adapter test_library lib
vb@0
    56
damiano@85
    57
.PHONY: distclean
vb@22
    58
distclean: clean
vb@22
    59
	rm -Rf .gnupg .pEp_management*
vb@15
    60
damiano@85
    61
# $$(pwd) will return the incorrect directory, if make is run with `make -C ...`.
damiano@85
    62
.PHONY: test
roker@63
    63
test: test_adapter test_library
damiano@85
    64
	 $(TEST_CMD_PFX) HOME=$$(pwd) ./test_adapter
vb@15
    65
damiano@85
    66
test_%: test_%.o $(TARGET)
vb@15
    67
damiano@85
    68
.PHONY: install
damiano@85
    69
install: $(TARGET)
damiano@85
    70
	-mkdir -p $(PREFIX)/include/pEp
damiano@85
    71
	cp $(HEADERS) $(PREFIX)/include/pEp/
damiano@85
    72
	cp $(TARGET) $(PREFIX)/lib/
roker@63
    73
damiano@85
    74
.PHONY: uninstall
vb@20
    75
uninstall:
damiano@85
    76
	cd $(PREFIX)/include/pEp && rm -f $(HEADERS)
damiano@85
    77
	cd $(PREFIX)/lib && rm -f $(TARGET)