Makefile
author Volker Birk <vb@pep-project.org>
Thu, 14 Nov 2019 23:22:05 +0100
changeset 134 b6e70c7067b3
parent 109 fd5d91cc2250
child 147 c4a0c2203808
permissions -rw-r--r--
merging
     1 # Copyright 2018, pEp Foundation
     2 # This file is part of lib pEp Adapter
     3 # This file may be used under the terms of the GNU General Public License version 3
     4 # see LICENSE.txt
     5 
     6 include Makefile.conf
     7 
     8 ifneq ($(wildcard local.conf),)
     9     $(info ================================================)
    10     $(info Overrides in \`local.conf\` are used.)
    11     $(info ================================================)
    12 endif
    13 
    14 ifdef BUILD_CONFIG
    15     $(info ================================================)
    16     $(info Overrides in \`$(BUILD_CONFIG)\` are used.)
    17     $(info ================================================)
    18 endif
    19 
    20 SOURCE=$(wildcard *.cc)
    21 HEADERS=$(wildcard *.hh *.hxx)
    22 OBJECTS=$(subst .cc,.o,$(SOURCE))
    23 WITHOUT_TESTS=$(patsubst test%.o,,$(OBJECTS))
    24 TARGET=libpEpAdapter.a
    25 
    26 EXTRA_LIB_PATHS=.:
    27 ifdef ENGINE_LIB
    28 	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ENGINE_LIB)):
    29 endif
    30 
    31 # Remove trailing ':'
    32 EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    33 
    34 ifeq ($(BUILD_FOR),Darwin)
    35     LIBPATH=DYLD_LIBRARY_PATH
    36 else
    37     LIBPATH=LD_LIBRARY_PATH
    38 endif
    39 
    40 TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS)
    41 
    42 
    43 .PHONY: all
    44 all: $(TARGET)
    45 
    46 # Rule copied from make's built-in rules
    47 %.o: %.cc %.hh
    48 	$(COMPILE.cc) $(OUTPUT_OPTION) $<
    49 
    50 $(TARGET): $(WITHOUT_TESTS)
    51 	$(AR) -rc $@ $^
    52 
    53 .PHONY: clean
    54 clean:
    55 	rm -vf $(TARGET) $(OBJECTS) *.a test_adapter test_library lib
    56 	rm -rvf test_adapter.dSYM
    57 	rm -rvf test_library.dSYM
    58 	rm -rvf .gnupg/
    59 	rm -vf .pEp_management.db*
    60 
    61 .PHONY: distclean
    62 distclean: clean
    63 	rm -Rvf .gnupg .pEp_management*
    64 
    65 # $$(pwd) will return the incorrect directory, if make is run with `make -C ...`.
    66 .PHONY: test
    67 test: test_adapter test_library
    68 	 $(TEST_CMD_PFX) HOME=$$(pwd) ./test_adapter
    69 
    70 test_%: test_%.o $(TARGET)
    71 
    72 .PHONY: install
    73 install: $(TARGET)
    74 	mkdir -p $(PREFIX)/include/pEp
    75 	mkdir -p $(PREFIX)/lib
    76 	cp -v $(HEADERS) $(PREFIX)/include/pEp/
    77 	cp -v $(TARGET) $(PREFIX)/lib/
    78 
    79 .PHONY: uninstall
    80 uninstall:
    81 	cd $(PREFIX)/include/pEp && rm -vf $(HEADERS)
    82 	cd $(PREFIX)/lib && rm -vf $(TARGET)