From: Trent Huber Date: Thu, 17 Apr 2025 07:21:34 +0000 (-0400) Subject: Linux portability tested X-Git-Url: https://trenthuber.com/code?a=commitdiff_plain;h=ba6a8da9724b9e43054c64662aa0b43be6431166;p=xpmview.git Linux portability tested --- diff --git a/build.h b/build.h index 4cd39a7..4e79208 100644 --- a/build.h +++ b/build.h @@ -13,7 +13,6 @@ #define RLHDR RLSRC "raylib" #define RLLIB RLROOT "raylib" RLEXT -#define CFGLOBALS "-Wall", "-Wextra", "-Wpedantic" #define CFRAYLIB "-I" RLSRC #define CFSRC "-I" SRC diff --git a/external/build.c b/external/build.c index b42568d..5f44c4e 100644 --- a/external/build.c +++ b/external/build.c @@ -7,7 +7,11 @@ RLSRC "rtextures", RLSRC "utils", \ RLSRC "rcore", RLSRC "rglfw" -#define CFRLPLAT "-DPLATFORM_DESKTOP" +#ifdef RLDYNAMIC +#define CFRLGLOBAL "-DPLATFORM_DESKTOP", "-fPIC" +#else +#define CFRLGLOBAL "-DPLATFORM_DESKTOP" +#endif #define CFRLGLFW "-I" RLSRC "external/glfw/include" #ifdef __APPLE__ #define CFRLX "-x", "objective-c" @@ -30,11 +34,11 @@ int main(void) { build(NULL); src = (char *[]){RLSRCS, NULL}; - cflags = (char *[]){CFRLPLAT, NULL}; + cflags = (char *[]){CFRLGLOBAL, NULL}; for (i = 0; i < 6; ++i) compile(src[i], NULL); - cflags = (char *[]){CFRLPLAT, CFRLGLFW, NULL}; + cflags = (char *[]){CFRLGLOBAL, CFRLGLFW, NULL}; compile(src[6], NULL); - cflags = (char *[]){CFRLPLAT, CFRLGLFW, CFRLX, NULL}; + cflags = (char *[]){CFRLGLOBAL, CFRLGLFW, CFRLX, NULL}; compile(src[7], NULL); #ifdef RLDYNAMIC diff --git a/external/cbs b/external/cbs index 08b7229..3f59e2f 160000 --- a/external/cbs +++ b/external/cbs @@ -1 +1 @@ -Subproject commit 08b7229355a54a4339931411629bcb9ea48b5926 +Subproject commit 3f59e2fa436ef5d7e527fd39e52a050536669db7 diff --git a/src/build.c b/src/build.c index 618ee8e..c199a03 100644 --- a/src/build.c +++ b/src/build.c @@ -11,17 +11,16 @@ int main(void) { build(NULL); - cflags = (char *[]){CFGLOBALS, NULL}; compile("error", NULL); build("colors/"); build("font/"); - cflags = (char *[]){CFGLOBALS, CFRAYLIB, NULL}; + cflags = (char *[]){CFRAYLIB, NULL}; compile("main", "error", RLHDR, "xpm", "font.c", NULL); - cflags = (char *[]){CFGLOBALS, NULL}; + cflags = NULL; compile("options", "error", NULL); - cflags = (char *[]){CFGLOBALS, CFRAYLIB, CFCBS, NULL}; + cflags = (char *[]){CFRAYLIB, CFCBS, NULL}; compile("xpm", "error", RLHDR, "xpm", CBS "cbs.c", "colors.c", NULL); #ifndef RLDYNAMIC diff --git a/src/colors/build.c b/src/colors/build.c index 2e5c8b4..d6fcbfb 100644 --- a/src/colors/build.c +++ b/src/colors/build.c @@ -6,7 +6,7 @@ int main(void) { build(NULL); - cflags = (char *[]){CFGLOBALS, CFSRC, NULL}; + cflags = (char *[]){CFSRC, NULL}; compile("gencolors", SRC "error", NULL); load('x', "gencolors", SRC "error", "gencolors", NULL); diff --git a/src/font/build.c b/src/font/build.c index ac5e31a..87f5e39 100644 --- a/src/font/build.c +++ b/src/font/build.c @@ -6,7 +6,7 @@ int main(void) { build(NULL); - cflags = (char *[]){CFGLOBALS, CFRAYLIB, CFSRC, NULL}; + cflags = (char *[]){CFRAYLIB, CFSRC, NULL}; compile("genfont", SRC "error", RLHDR, NULL); #ifndef RLDYNAMIC diff --git a/src/main.c b/src/main.c index 87f6f2c..89d0e93 100644 --- a/src/main.c +++ b/src/main.c @@ -88,8 +88,8 @@ int main(int argc, char **argv) { ClearBackground(CLITERAL(Color){0xec, 0xec, 0xec, 0xff}); - width = GetRenderWidth(); - height = GetRenderHeight(); + width = GetScreenWidth(); + height = GetScreenHeight(); if (texture.id) { scale = width * texture.height > height * texture.width ? (float)height / texture.height diff --git a/src/xpm.c b/src/xpm.c index de5a5ae..01f144e 100644 --- a/src/xpm.c +++ b/src/xpm.c @@ -125,7 +125,7 @@ static unsigned int str2color(char **strp) { return 0; } - if (r > 0xffffff || r < 0) { + if (r > 0xffffff) { xpmerror("`0x%06x' is not a valid RGB color", r); return 0; } @@ -269,21 +269,21 @@ static Image process(char *xpm) { } if (cpid == -1 || waitpid(cpid, &status, 0) == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS) { - xpmerror("Unable to create `/tmp/libxpm.dylib'"); + xpmerror("Unable to create `/tmp/libxpm" DYEXT "'"); goto munmap; } - if ((d = dlopen("/tmp/libxpm.dylib", 0)) == NULL) { - xpmerror("Unable to load `/tmp/libxpm.dylib': %s", dlerror()); + if ((d = dlopen("/tmp/libxpm" DYEXT, RTLD_LAZY)) == NULL) { + xpmerror("Unable to load `/tmp/libxpm" DYEXT "': %s", dlerror()); goto munmap; } if ((data = (char **)dlsym(d, a)) == NULL) { - xpmerror("Unable to load image data from `/tmp/libxpm.dylib': `%s'", + xpmerror("Unable to load image data from `/tmp/libxpm" DYEXT "': `%s'", dlerror()); goto dlclose; } if ((sizep = (long *)dlsym(d, "size")) == NULL) { - xpmerror("Unable to load image length from `/tmp/libxpm.dylib': `%s'", + xpmerror("Unable to load image length from `/tmp/libxpm" DYEXT "': `%s'", dlerror()); goto dlclose; } @@ -292,7 +292,7 @@ static Image process(char *xpm) { dlclose: if (dlclose(d)) - xpmerror("Unable to unload `/tmp/libxpm.dylib': %s", dlerror()); + xpmerror("Unable to unload `/tmp/libxpm" DYEXT "': %s", dlerror()); munmap: if (munmap(map, l) == -1) xpmerror("Unable to unmap `%s' from memory", xpm);