1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
From: Kentaro Hayashi <kenhys@xdump.org>
Date: Sat, 10 Aug 2024 22:13:30 +0900
Subject: Tweak GRDIR for debian package
There is a assumption that gr-framework is installed under
prefix/gr/{bin,lib,fonts} etc and GRDIR use it.
This assumption will not fit for Debian because binary should be
installed at /usr/bin, library should be installed at
/usr/lib/x86_64-linux-gnu/, and fonts should be installed at
/usr/share/gr/fonts so on.
GRDIR vary on the context, we don't use GRDIR, instead use
specific fallback path by default.
ref. https://gr-framework.org/environment_variables.html
Author: Kentaro HAYASHI <kenhys@xdump.org>
Subject: Tweak GRDIR for debian package
Forwarded: not-needed
Signed-off-by: Kentaro Hayashi <kenhys@xdump.org>
---
CMakeLists.txt | 2 ++
lib/gks/font.c | 5 +++++
lib/gks/ft.c | 5 +++++
lib/gks/plugin.c | 5 +++++
lib/gks/socket.c | 5 +++++
lib/gks/util.c | 6 ++++++
lib/gr/mathtex2_kerning.c | 5 +++++
lib/gr/stream.c | 6 ++++++
lib/gr3/gr3_glx.c | 10 ++++++++++
9 files changed, 49 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3adc93..bb3b5c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -315,6 +315,7 @@ foreach(LIBRARY gks_static gks_shared)
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_definitions(${LIBRARY} PRIVATE GRDIR="${GR_DIRECTORY}")
+ target_compile_definitions(${LIBRARY} PRIVATE GRLIB="${CMAKE_INSTALL_LIBDIR}")
set_target_properties(
${LIBRARY}
PROPERTIES C_STANDARD 90
@@ -457,6 +458,7 @@ foreach(LIBRARY gr3_static gr3_shared)
target_compile_definitions(${LIBRARY} PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
target_compile_definitions(${LIBRARY} PRIVATE GRDIR="${GR_DIRECTORY}")
+ target_compile_definitions(${LIBRARY} PRIVATE GRLIB="${CMAKE_INSTALL_LIBDIR}")
if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC"))
target_compile_options(${LIBRARY} ${GR3_LINK_MODE} -pthread)
endif()
diff --git a/lib/gks/font.c b/lib/gks/font.c
index dd64f9f..c02a266 100644
--- a/lib/gks/font.c
+++ b/lib/gks/font.c
@@ -37,8 +37,13 @@ int gks_open_font(void)
path = gks_getenv("GKS_FONTPATH");
if (path == NULL)
{
+#if 1
+ /* Force debian specific fallback path - /usr/share/gr/fonts/gksfont.dat */
+ path = "/usr/share/gr";
+#else
path = gks_getenv("GRDIR");
if (path == NULL) path = GRDIR;
+#endif
}
strcpy(fontdb, (char *)path);
strcat(fontdb, "/fonts/gksfont.dat");
diff --git a/lib/gks/ft.c b/lib/gks/ft.c
index 5f08162..6d7cf18 100644
--- a/lib/gks/ft.c
+++ b/lib/gks/ft.c
@@ -734,7 +734,12 @@ static ft_path_char_t *gks_ft_get_font_path(const char *font_name, const char *f
prefix = gks_getenv("GKS_FONTPATH");
if (prefix == NULL)
{
+#if 1
+ /* Force debian specific falllback /usr/share/gr/fonts/... */
+ prefix = "/usr/share/gr";
+#else
prefix = gks_getenv("GRDIR");
+#endif
}
if (prefix == NULL)
{
diff --git a/lib/gks/plugin.c b/lib/gks/plugin.c
index abc92ee..4b58d5c 100644
--- a/lib/gks/plugin.c
+++ b/lib/gks/plugin.c
@@ -67,9 +67,14 @@ static void *load_library(const char *name)
handle = dlopen(pathname, RTLD_LAZY);
if (handle == NULL)
{
+#if 1
+ /* Force debian specific fallback path - /usr/lib/$(DEB_HOST_MULTIARCH)/gr/ */
+ snprintf(pathname, MAXPATHLEN, "%s/gr/%s.%s", GRLIB, name, EXTENSION);
+#else
grdir = gks_getenv("GRDIR");
if (grdir == NULL) grdir = GRDIR;
snprintf(pathname, MAXPATHLEN, "%s/lib/%s.%s", grdir, name, EXTENSION);
+#endif
handle = dlopen(pathname, RTLD_LAZY);
}
#endif
diff --git a/lib/gks/socket.c b/lib/gks/socket.c
index 0f00afd..18e38f5 100644
--- a/lib/gks/socket.c
+++ b/lib/gks/socket.c
@@ -316,6 +316,10 @@ static int open_socket(int wstype)
command = gks_getenv("GKS_QT");
if (command == NULL)
{
+#if 1
+ /* Force debian specific fallback path */
+ command = "/usr/bin/gksqt";
+#else
env = gks_getenv("GRDIR");
if (env == NULL) env = GRDIR;
@@ -326,6 +330,7 @@ static int open_socket(int wstype)
snprintf(cmd, MAXPATHLEN, "%s/bin/gksqt", env);
#endif
command = cmd;
+#endif
}
#endif
}
diff --git a/lib/gks/util.c b/lib/gks/util.c
index 08e29ce..4db608f 100644
--- a/lib/gks/util.c
+++ b/lib/gks/util.c
@@ -1576,6 +1576,11 @@ static int have_gksqt(void)
env = gks_getenv("GKS_QT");
if (env == NULL)
{
+#if 1
+ /* Force debian specific fallback path */
+ path = (char *)gks_malloc(MAXPATHLEN);
+ snprintf(path, MAXPATHLEN, "/usr/bin/gksqt");
+#else
env = gks_getenv("GRDIR");
if (env == NULL) env = GRDIR;
@@ -1588,6 +1593,7 @@ static int have_gksqt(void)
#endif
#else
snprintf(path, MAXPATHLEN, "%s\\bin\\gksqt.exe", env);
+#endif
#endif
}
else
diff --git a/lib/gr/mathtex2_kerning.c b/lib/gr/mathtex2_kerning.c
index 7a182ba..cdda650 100644
--- a/lib/gr/mathtex2_kerning.c
+++ b/lib/gr/mathtex2_kerning.c
@@ -21,8 +21,13 @@ static void init_offsets(void)
path = gks_getenv("GKS_FONTPATH");
if (path == NULL)
{
+#if 1
+ /* Force debian specific fallback path - /usr/share/gr/fonts/mathtex2_offsets.bin */
+ path = "/usr/share/gr";
+#else
path = gks_getenv("GRDIR");
if (path == NULL) path = GRDIR;
+#endif
}
strcpy(offsets_path, (char *)path);
#ifndef _WIN32
diff --git a/lib/gr/stream.c b/lib/gr/stream.c
index 27fac81..9aab3b8 100644
--- a/lib/gr/stream.c
+++ b/lib/gr/stream.c
@@ -513,6 +513,11 @@ int gr_startlistener(void)
command = gks_getenv("GR_PLOT");
if (command == NULL)
{
+#if 1
+ /* Force debian specific fallback path - /usr/bin/grplot */
+ cmd = (char *)gks_malloc(MAXPATHLEN);
+ snprintf(cmd, MAXPATHLEN, "/usr/bin/grplot --listen");
+#else
env = gks_getenv("GRDIR");
if (env == NULL) env = GRDIR;
@@ -521,6 +526,7 @@ int gr_startlistener(void)
snprintf(cmd, MAXPATHLEN, "%s/Applications/grplot.app/Contents/MacOS/grplot --listen", env);
#else
snprintf(cmd, MAXPATHLEN, "%s/bin/grplot --listen", env);
+#endif
#endif
command = cmd;
}
diff --git a/lib/gr3/gr3_glx.c b/lib/gr3/gr3_glx.c
index 0e5ba38..ab29152 100644
--- a/lib/gr3/gr3_glx.c
+++ b/lib/gr3/gr3_glx.c
@@ -42,6 +42,15 @@ int gr3_platform_initGL_(void)
gr3_log_("gr3_platform_initGL_();");
if (!platform_library)
{
+#if 1
+ const char *grdir = GRLIB;
+ if (strlen(grdir) + strlen("libGR3platform.so") < MAXPATHLEN)
+ {
+ char pathname[MAXPATHLEN];
+ snprintf(pathname, MAXPATHLEN, "%s/libGR3platform.so", grdir);
+ platform_library = dlopen(pathname, RTLD_NOW | RTLD_LOCAL);
+ }
+#else
const char *grdir = getenv("GRDIR");
if (grdir == NULL)
{
@@ -53,6 +62,7 @@ int gr3_platform_initGL_(void)
snprintf(pathname, MAXPATHLEN, "%s/lib/libGR3platform.so", grdir);
platform_library = dlopen(pathname, RTLD_NOW | RTLD_LOCAL);
}
+#endif
}
if (!platform_library)
{
|