mirror of
https://github.com/lindbergh-loader/lindbergh-loader.git
synced 2026-10-14 01:49:12 +03:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d0996b905 | ||
|
|
52cb3eaf6b | ||
|
|
8b6604efc5 | ||
|
|
7b426f0d11 | ||
|
|
442d03b144 | ||
|
|
50a1a35f7f | ||
|
|
728c308835 | ||
|
|
543ebe4817 |
@@ -1,7 +1,8 @@
|
|||||||
CC = gcc -m32 -pthread
|
CC ?= gcc
|
||||||
CFLAGS = -g -fPIC -m32 -Wall -Werror -Wno-misleading-indentation -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-function -D_GNU_SOURCE -Wno-char-subscripts
|
CFLAGS = -g -fPIC -m32 -pthread -Wall -Werror -Wno-misleading-indentation -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-function -D_GNU_SOURCE -Wno-char-subscripts
|
||||||
LD = g++ -m32
|
CXX ?= g++
|
||||||
LDFLAGS = -Wl,-z,defs -rdynamic -static-libgcc -lc -ldl -lGL -lglut -lX11 -lSDL2 -lm -lpthread -shared -nostdlib -lasound -L./src/libxdiff -lxdiff
|
LD = $(CXX)
|
||||||
|
LDFLAGS = -m32 -Wl,-z,defs -rdynamic -static-libgcc -lc -ldl -lGL -lglut -lX11 -lXcursor -lSDL2 -lm -lpthread -shared -nostdlib -lasound -L./src/libxdiff -lxdiff
|
||||||
|
|
||||||
BUILD = build
|
BUILD = build
|
||||||
|
|
||||||
@@ -17,14 +18,14 @@ all: lindbergh libxdiff.a lindbergh.so libsegaapi.so libkswapapi.so libposixtime
|
|||||||
|
|
||||||
lindbergh: src/lindbergh/lindbergh.c src/lindbergh/log.c src/lindbergh/log.h src/lindbergh/jvs.c src/lindbergh/jvs.h src/lindbergh/config.h src/lindbergh/config.c src/lindbergh/evdevinput.h src/lindbergh/evdevinput.c
|
lindbergh: src/lindbergh/lindbergh.c src/lindbergh/log.c src/lindbergh/log.h src/lindbergh/jvs.c src/lindbergh/jvs.h src/lindbergh/config.h src/lindbergh/config.c src/lindbergh/evdevinput.h src/lindbergh/evdevinput.c
|
||||||
mkdir -p $(BUILD)
|
mkdir -p $(BUILD)
|
||||||
$(CC) src/lindbergh/lindbergh.c src/lindbergh/log.h src/lindbergh/log.c src/lindbergh/jvs.h src/lindbergh/jvs.c src/lindbergh/config.h src/lindbergh/config.c src/lindbergh/evdevinput.c src/lindbergh/evdevinput.h -o $(BUILD)/lindbergh -lm
|
$(CC) -m32 src/lindbergh/lindbergh.c src/lindbergh/log.h src/lindbergh/log.c src/lindbergh/jvs.h src/lindbergh/jvs.c src/lindbergh/config.h src/lindbergh/config.c src/lindbergh/evdevinput.c src/lindbergh/evdevinput.h -o $(BUILD)/lindbergh -lm
|
||||||
|
|
||||||
libxdiff.a: $(XDIFF_OBJS)
|
libxdiff.a: $(XDIFF_OBJS)
|
||||||
mkdir -p $(BUILD)
|
mkdir -p $(BUILD)
|
||||||
ar rcs src/libxdiff/libxdiff.a $(XDIFF_OBJS)
|
ar rcs src/libxdiff/libxdiff.a $(XDIFF_OBJS)
|
||||||
|
|
||||||
src/libxdiff/xdiff/%.o: src/libxdiff/xdiff/%.c
|
src/libxdiff/xdiff/%.o: src/libxdiff/xdiff/%.c
|
||||||
$(CC) -DHAVE_CONFIG_H -fPIC -c $< -o $@
|
$(CC) -m32 -DHAVE_CONFIG_H -fPIC -c $< -o $@
|
||||||
|
|
||||||
lindbergh.so: $(OBJS)
|
lindbergh.so: $(OBJS)
|
||||||
mkdir -p $(BUILD)
|
mkdir -p $(BUILD)
|
||||||
@@ -34,13 +35,13 @@ lindbergh.so: $(OBJS)
|
|||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
libsegaapi.so: src/libsegaapi/libsegaapi.o
|
libsegaapi.so: src/libsegaapi/libsegaapi.o
|
||||||
gcc -m32 -O0 -g src/libsegaapi/libsegaapi.c -lFAudio -fPIC -shared -o $(BUILD)/libsegaapi.so
|
$(CC) -m32 -O0 -g src/libsegaapi/libsegaapi.c -lFAudio -fPIC -shared -o $(BUILD)/libsegaapi.so
|
||||||
|
|
||||||
libkswapapi.so: src/libkswapapi/libkswapapi.o
|
libkswapapi.so: src/libkswapapi/libkswapapi.o
|
||||||
$(CC) src/libkswapapi/libkswapapi.o -fPIC -shared -o $(BUILD)/libkswapapi.so
|
$(CC) -m32 src/libkswapapi/libkswapapi.o -fPIC -shared -o $(BUILD)/libkswapapi.so
|
||||||
|
|
||||||
libposixtime.so:
|
libposixtime.so:
|
||||||
$(CC) src/libposixtime/libposixtime.c src/libposixtime/libposixtime.h -m32 -shared -o $(BUILD)/libposixtime.so
|
$(CC) -m32 src/libposixtime/libposixtime.c src/libposixtime/libposixtime.h -m32 -shared -o $(BUILD)/libposixtime.so
|
||||||
ln -s -f libposixtime.so $(BUILD)/libposixtime.so.1
|
ln -s -f libposixtime.so $(BUILD)/libposixtime.so.1
|
||||||
ln -s -f libposixtime.so $(BUILD)/libposixtime.so.2.4
|
ln -s -f libposixtime.so $(BUILD)/libposixtime.so.2.4
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
|
#define LD_LIBRARY_PATH "LD_LIBRARY_PATH"
|
||||||
#define LD_PRELOAD "LD_PRELOAD"
|
#define LD_PRELOAD "LD_PRELOAD"
|
||||||
#define PRELOAD_FILE_NAME "lindbergh.so"
|
#define PRELOAD_FILE_NAME "lindbergh.so"
|
||||||
|
#define PRELOAD_FILE_FLATPAK "/app/lib32/lindbergh.so"
|
||||||
#define TEAM "bobbydilley, retrofan, dkeruza-neo, doozer, francesco, rolel, caviar-x"
|
#define TEAM "bobbydilley, retrofan, dkeruza-neo, doozer, francesco, rolel, caviar-x"
|
||||||
#define LINDBERGH_CONFIG_PATH "LINDBERGH_CONFIG_PATH"
|
#define LINDBERGH_CONFIG_PATH "LINDBERGH_CONFIG_PATH"
|
||||||
|
|
||||||
@@ -232,7 +233,7 @@ void testModePath(char *name)
|
|||||||
* Makes sure the environment variables are set correctly
|
* Makes sure the environment variables are set correctly
|
||||||
* to run the game.
|
* to run the game.
|
||||||
*/
|
*/
|
||||||
void setEnvironmentVariables()
|
void setEnvironmentVariables(int isFlatpak)
|
||||||
{
|
{
|
||||||
// Ensure the library path is set correctly
|
// Ensure the library path is set correctly
|
||||||
char libraryPath[128] = {0};
|
char libraryPath[128] = {0};
|
||||||
@@ -249,7 +250,10 @@ void setEnvironmentVariables()
|
|||||||
setenv(LD_LIBRARY_PATH, libraryPath, 1);
|
setenv(LD_LIBRARY_PATH, libraryPath, 1);
|
||||||
|
|
||||||
// Ensure the preload path is set correctly
|
// Ensure the preload path is set correctly
|
||||||
setenv(LD_PRELOAD, PRELOAD_FILE_NAME, 1);
|
if (!isFlatpak)
|
||||||
|
setenv(LD_PRELOAD, PRELOAD_FILE_NAME, 1);
|
||||||
|
else
|
||||||
|
setenv(LD_PRELOAD, PRELOAD_FILE_FLATPAK, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -316,9 +320,6 @@ void printVersion() {
|
|||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
// Ensure environment variables are set correctly
|
|
||||||
setEnvironmentVariables();
|
|
||||||
|
|
||||||
// Check for --version before directory operations
|
// Check for --version before directory operations
|
||||||
if (argc > 1 && strcmp(argv[1], "--version") == 0) {
|
if (argc > 1 && strcmp(argv[1], "--version") == 0) {
|
||||||
printVersion();
|
printVersion();
|
||||||
@@ -338,6 +339,7 @@ int main(int argc, char *argv[])
|
|||||||
char *game = NULL;
|
char *game = NULL;
|
||||||
|
|
||||||
int lindberghSharedObjectFound = 0;
|
int lindberghSharedObjectFound = 0;
|
||||||
|
int isFlatpak = 0;
|
||||||
|
|
||||||
while ((ent = readdir(dir)) != NULL)
|
while ((ent = readdir(dir)) != NULL)
|
||||||
{
|
{
|
||||||
@@ -385,10 +387,22 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (!lindberghSharedObjectFound)
|
if (!lindberghSharedObjectFound)
|
||||||
{
|
{
|
||||||
log_error("The preload object lindbergh.so was not found in this directory.");
|
FILE *file = fopen(PRELOAD_FILE_FLATPAK, "r");
|
||||||
return EXIT_FAILURE;
|
if (file)
|
||||||
|
{
|
||||||
|
fclose(file);
|
||||||
|
isFlatpak = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_error("The preload object lindbergh.so was not found in this directory.");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure environment variables are set correctly
|
||||||
|
setEnvironmentVariables(isFlatpak);
|
||||||
|
|
||||||
// Build up the command to start the game
|
// Build up the command to start the game
|
||||||
|
|
||||||
int testMode = 0;
|
int testMode = 0;
|
||||||
|
|||||||
@@ -1432,16 +1432,30 @@ int parseCgcArgs(const char *input, const char ***compilerArgs, const char **out
|
|||||||
|
|
||||||
void loadLibCg()
|
void loadLibCg()
|
||||||
{
|
{
|
||||||
|
int isFlatpak = 0;
|
||||||
void *handle = dlopen("./libCg.so", RTLD_NOW);
|
void *handle = dlopen("./libCg.so", RTLD_NOW);
|
||||||
if (!handle)
|
if (!handle)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error: Unable to load library libCg.so %s\n", dlerror());
|
handle = dlopen("/app/lib32/libCg2.so", RTLD_NOW);
|
||||||
fprintf(stderr, "Error: libCg.so version 2.0 is needed to compile the shaders in the game's folder.\n");
|
if (!handle)
|
||||||
exit(1);
|
{
|
||||||
|
fprintf(stderr, "Error: Unable to load library libCg.so %s\n", dlerror());
|
||||||
|
fprintf(stderr, "Error: libCg.so version 2.0 is needed to compile the shaders in the game's folder.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isFlatpak = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char libCgVersion[9];
|
char libCgVersion[9];
|
||||||
FILE *libF = fopen("./libCg.so", "r");
|
FILE *libF;
|
||||||
|
if (isFlatpak)
|
||||||
|
libF = fopen("/app/lib32/libCg2.so", "r");
|
||||||
|
else
|
||||||
|
libF = fopen("./libCg.so", "r");
|
||||||
|
|
||||||
fseek(libF, 0x226d84, SEEK_SET);
|
fseek(libF, 0x226d84, SEEK_SET);
|
||||||
fread(libCgVersion, 9, 1, libF);
|
fread(libCgVersion, 9, 1, libF);
|
||||||
fclose(libF);
|
fclose(libF);
|
||||||
|
|||||||
@@ -702,14 +702,14 @@ static int stbi__sse2_available()
|
|||||||
|
|
||||||
static int stbi__sse2_available()
|
static int stbi__sse2_available()
|
||||||
{
|
{
|
||||||
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later
|
//#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later
|
||||||
// GCC 4.8+ has a nice way to do this
|
// GCC 4.8+ has a nice way to do this
|
||||||
return __builtin_cpu_supports("sse2");
|
//return __builtin_cpu_supports("sse2");
|
||||||
#else
|
//#else
|
||||||
// portable way to do this, preferably without using GCC inline ASM?
|
// portable way to do this, preferably without using GCC inline ASM?
|
||||||
// just bail for now.
|
// just bail for now.
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
//#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user