|
| 1 | +From ae29a8772f38fdb1efc24af9ec2e3f6814eb2158 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Petr Hodina < [email protected]> |
| 3 | +Date: Sun, 4 May 2025 09:30:55 +0200 |
| 4 | +Subject: [PATCH] Makefile: Add install into the system |
| 5 | + |
| 6 | +--- |
| 7 | + Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++ |
| 8 | + libnop.pc.in | 7 +++++++ |
| 9 | + 2 files changed, 51 insertions(+) |
| 10 | + create mode 100644 libnop.pc.in |
| 11 | + |
| 12 | +diff --git a/Makefile b/Makefile |
| 13 | +index 84cb459..e5b8a67 100644 |
| 14 | +--- a/Makefile |
| 15 | ++++ b/Makefile |
| 16 | +@@ -1,5 +1,7 @@ |
| 17 | + what_to_build:: all |
| 18 | + |
| 19 | ++VERSION ?= 0-unstable-2022-09-04 |
| 20 | ++ |
| 21 | + -include local.mk |
| 22 | + |
| 23 | + TOOLCHAIN ?= |
| 24 | +@@ -17,6 +19,12 @@ HOST_CFLAGS := -g -O2 -Wall -Werror -Wextra -Iinclude |
| 25 | + HOST_CXXFLAGS := -std=c++14 |
| 26 | + HOST_LDFLAGS := |
| 27 | + |
| 28 | ++# Define install locations in the system |
| 29 | ++INSTALL_PREFIX ?= /usr/local |
| 30 | ++INCLUDE_INSTALL_DIR ?= $(INSTALL_PREFIX)/include/ |
| 31 | ++PKGCONFIG_INSTALL_DIR ?= $(INSTALL_PREFIX)/lib/pkgconfig |
| 32 | ++CMAKE_CONFIG_INSTALL_DIR ?= $(INSTALL_PREFIX)/lib/cmake/libnop |
| 33 | ++ |
| 34 | + ifeq ($(HOST_OS),Linux) |
| 35 | + HOST_LDFLAGS := -lpthread |
| 36 | + endif |
| 37 | +@@ -138,3 +146,39 @@ all:: $(ALL) |
| 38 | + # we generate .d as a side-effect of compiling. override generic rule: |
| 39 | + %.d: |
| 40 | + -include $(DEPS) |
| 41 | ++ |
| 42 | ++# Handle install into the system |
| 43 | ++.PHONY: install install-pkgconfig install-cmake |
| 44 | ++ |
| 45 | ++install: install-headers install-pkgconfig install-cmake |
| 46 | ++ |
| 47 | ++install-headers: |
| 48 | ++ @echo "Installing headers to $(INCLUDE_INSTALL_DIR)" |
| 49 | ++ mkdir -p $(INCLUDE_INSTALL_DIR) |
| 50 | ++ cp -r include/* $(INCLUDE_INSTALL_DIR) |
| 51 | ++ |
| 52 | ++install-pkgconfig: $(OUT)/libnop.pc |
| 53 | ++ @echo "Installing pkg-config file to $(PKGCONFIG_INSTALL_DIR)" |
| 54 | ++ mkdir -p $(PKGCONFIG_INSTALL_DIR) |
| 55 | ++ cp $< $(PKGCONFIG_INSTALL_DIR) |
| 56 | ++ |
| 57 | ++PC_TEMPLATE := libnop.pc.in |
| 58 | ++ |
| 59 | ++$(OUT)/libnop.pc: $(PC_TEMPLATE) |
| 60 | ++ mkdir -p $(dir $@) |
| 61 | ++ sed \ |
| 62 | ++ -e 's|@prefix@|$(INSTALL_PREFIX)|g' \ |
| 63 | ++ -e 's|@includedir@|$(INSTALL_PREFIX)/include|g' \ |
| 64 | ++ -e 's|@version@|$(VERSION)|g' \ |
| 65 | ++ $< > $@ |
| 66 | ++ |
| 67 | ++install-cmake: $(OUT)/libnopConfig.cmake |
| 68 | ++ @echo "Installing CMake config to $(CMAKE_CONFIG_INSTALL_DIR)" |
| 69 | ++ mkdir -p $(CMAKE_CONFIG_INSTALL_DIR) |
| 70 | ++ cp $< $(CMAKE_CONFIG_INSTALL_DIR) |
| 71 | ++ |
| 72 | ++$(OUT)/libnopConfig.cmake: |
| 73 | ++ mkdir -p $(dir $@) |
| 74 | ++ echo "set(LIBNOP_INCLUDE_DIR \"$(INCLUDE_INSTALL_DIR)\")" > $@ |
| 75 | ++ echo "set(LIBNOP_FOUND TRUE)" >> $@ |
| 76 | ++ echo "mark_as_advanced(LIBNOP_INCLUDE_DIR)" >> $@ |
| 77 | +diff --git a/libnop.pc.in b/libnop.pc.in |
| 78 | +new file mode 100644 |
| 79 | +index 0000000..8c5475b |
| 80 | +--- /dev/null |
| 81 | ++++ b/libnop.pc.in |
| 82 | +@@ -0,0 +1,7 @@ |
| 83 | ++prefix=@prefix@ |
| 84 | ++includedir=@includedir@ |
| 85 | ++ |
| 86 | ++Name: libnop |
| 87 | ++Description: Header-only C++ Native Object Protocols library |
| 88 | ++Version: @version@ |
| 89 | ++Cflags: -I${includedir} |
0 commit comments