From a4b98e61bf02079e36098a2c66473fb7e58b5c59 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Mon, 2 Jul 2018 13:43:25 +0200 Subject: [PATCH 1/4] lib: generate a pkg-config files To ease development, create a gamemode.pc and a gamemode-auto.pc file, that other projects can use integrate with gamemode. The former if they want to integrate at the source level and the latter if the automatic integration is preferred. --- lib/meson.build | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/meson.build b/lib/meson.build index d00cc12..5935053 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -1,5 +1,5 @@ # Main client library to message the daemon -shared_library( +gamemode = shared_library( 'gamemode', sources: [ 'client_impl.c', @@ -15,7 +15,7 @@ libgamemode_includes = [ ] # Small library to automatically use gamemode -shared_library( +gamemodeauto = shared_library( 'gamemodeauto', sources: [ 'client_loader.c', @@ -32,3 +32,28 @@ gamemode_headers = [ ] install_headers(gamemode_headers) + +# Generate a pkg-config files +pkg = import('pkgconfig') +desc = 'GameMode temporarily applies game specific optimisations to the host OS.' +pkg.generate( + name: 'gamemode', + description: desc, + filebase: 'gamemode', + version: meson.project_version(), + libraries: [ + libdl + ], +) + +pkg.generate( + name: 'gamemode', + description: desc, + filebase: 'gamemode-auto', + libraries: gamemodeauto, + version: meson.project_version(), + libraries_private: [ + libdl + ], +) + From ea3e135ae0bad92e3e6d371496a47851d7272553 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Mon, 2 Jul 2018 13:59:18 +0200 Subject: [PATCH 2/4] lib: use libtool like versioning In order to be safe for future ABI changes and to fulfill packaging requirements for e.g. Fedora, provide libtool like versioning for both libraries, i.e. libgamemode and libgamemodeauto. --- lib/meson.build | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/meson.build b/lib/meson.build index 5935053..5d25cc8 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -1,3 +1,10 @@ +# Libtool like versioning (current.revision.age) for the libraries +# See https://www.sourceware.org/autobook/autobook/autobook_61.html#Library-Versioning +lt_current = '0' +lt_revision = '0' +lt_age = '0' +lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision) + # Main client library to message the daemon gamemode = shared_library( 'gamemode', @@ -8,6 +15,8 @@ gamemode = shared_library( dep_systemd, ], install: true, + soversion: lt_current, + version: lt_version, ) libgamemode_includes = [ @@ -24,6 +33,8 @@ gamemodeauto = shared_library( libdl, ], install: true, + soversion: lt_current, + version: lt_version, ) # Install the gamemode_client header From 8f8a6d4f9186a57c7176be62213975446834ae96 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Mon, 2 Jul 2018 14:02:23 +0200 Subject: [PATCH 3/4] lib: dlopen versioned library Instead of dlopen'ing the plain, not versioned library, use the versioned one with current interface, i.e. 0: libgamemode.so.0 --- lib/gamemode_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gamemode_client.h b/lib/gamemode_client.h index 4a42338..465da5b 100644 --- a/lib/gamemode_client.h +++ b/lib/gamemode_client.h @@ -152,7 +152,7 @@ __attribute__((always_inline)) static inline int internal_load_libgamemode(void) void *libgamemode = NULL; /* Try and load libgamemode */ - libgamemode = dlopen("libgamemode.so", RTLD_NOW); + libgamemode = dlopen("libgamemode.so.0", RTLD_NOW); if (!libgamemode) { snprintf(internal_gamemode_client_error_string, sizeof(internal_gamemode_client_error_string), From 1369629972f1ad06d3b95ebc29c24ec88763028e Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Mon, 2 Jul 2018 14:14:47 +0200 Subject: [PATCH 4/4] README.md: use version library in examples Now that versioned libraries are created, use that in the examples provided. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e9c326d..6de0117 100644 --- a/README.md +++ b/README.md @@ -57,13 +57,13 @@ This will also satisfy the build requirement `inih` by pulling it in as a git su ## Requesting GameMode ### Users -After installing `libgamemodeauto.so` simply preload it into the game: +After installing `libgamemodeauto.so.0` simply preload it into the game: ```bash -LD_PRELOAD=/usr/\$LIB/libgamemodeauto.so ./game +LD_PRELOAD=/usr/\$LIB/libgamemodeauto.so.0 ./game ``` Or edit the steam launch options: ```bash -LD_PRELOAD=$LD_PRELOAD:/usr/\$LIB/libgamemodeauto.so %command% +LD_PRELOAD=$LD_PRELOAD:/usr/\$LIB/libgamemodeauto.so.0 %command% ``` Please note the backslash here in `\$LIB` is required.