Skip to content

Commit

Permalink
Have make targets install-capi-lib,install-pkgconfig work without bui…
Browse files Browse the repository at this point in the history
…lding binary

1. modified target `install-capi-lib` to detect version without requiring the binary being built.
2. added separate install target for library: `install-capi` instead of using `install` for both binary and library
3. added target `install-capi-pkgconfig` that outputs this example `.pc` file if the binary is missing:

   ```pc
   prefix=/usr/local
   includedir=${prefix}/include
   libdir=${prefix}/lib

   Name: wasmer
   Description: The Wasmer library for running WebAssembly
   Version: 2.3.0
   Cflags: -I${prefix}/include
   Libs: -L${prefix}/lib -lwasmer
   ```

Fixes #2541
  • Loading branch information
epilys committed Jun 29, 2022
1 parent 711bfef commit 1ca5a05
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,8 @@ DESTDIR ?= /usr/local

install: install-wasmer install-capi-headers install-capi-lib install-pkgconfig install-misc

install-capi: install-capi-headers install-capi-lib install-capi-pkgconfig install-misc

install-wasmer:
install -Dm755 target/release/wasmer $(DESTDIR)/bin/wasmer

Expand All @@ -657,7 +659,7 @@ install-capi-headers:

# Currently implemented for linux only. TODO
install-capi-lib:
pkgver=$$(target/release/wasmer --version | cut -d\ -f2) && \
pkgver=$$($(CARGO_BINARY) pkgid --manifest-path lib/c-api/Cargo.toml | sed --posix 's/^.*wasmer-c-api:\([0-9.]*\)$\/\1/') && \
shortver="$${pkgver%.*}" && \
majorver="$${shortver%.*}" && \
install -Dm755 target/release/libwasmer.so "$(DESTDIR)/lib/libwasmer.so.$$pkgver" && \
Expand All @@ -668,6 +670,10 @@ install-capi-lib:
install-misc:
install -Dm644 LICENSE "$(DESTDIR)"/share/licenses/wasmer/LICENSE

install-capi-pkgconfig:
@pkgver=$$($(CARGO_BINARY) pkgid --manifest-path lib/c-api/Cargo.toml | sed --posix 's/^.*wasmer-c-api:\([0-9.]*\)$\/\1/') && \
printf "prefix=%s\nincludedir=\044{prefix}/include\nlibdir=\044{prefix}/lib\n\nName: wasmer\nDescription: The Wasmer library for running WebAssembly\nVersion: %s\nCflags: -I\044{prefix}/include\nLibs: -L\044{prefix}/lib -lwasmer\n" "$(DESTDIR)" "$${pkgver}" | install -Dm644 /dev/stdin "$(DESTDIR)"/lib/pkgconfig/wasmer.pc

install-pkgconfig:
# Make sure WASMER_INSTALL_PREFIX is set during build
unset WASMER_DIR; \
Expand Down

0 comments on commit 1ca5a05

Please sign in to comment.