Revive modules support

This commit is contained in:
kichikuou
2019-07-27 10:09:27 +09:00
parent f866d097be
commit 13c77cd890
10 changed files with 91 additions and 35 deletions
+10
View File
@@ -40,6 +40,13 @@ else()
include(TestBigEndian)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
if (NOT DEFINED ENABLE_MODULES)
check_library_exists(dl dlopen "" ENABLE_MODULES)
endif()
if (ENABLE_MODULES)
link_libraries(dl)
endif()
find_package(ZLIB REQUIRED)
optional_find_package(X11)
optional_find_package(GTK2 COMPONENTS gtk)
@@ -254,3 +261,6 @@ if (ENABLE_NLS)
add_subdirectory(po)
endif()
if (ENABLE_MODULES)
add_subdirectory(modules)
endif()
+1
View File
@@ -15,6 +15,7 @@
#cmakedefine ENABLE_MIDI_RAWMIDI @ENABLE_MIDI_RAWMIDI@
#cmakedefine ENABLE_MIDI_SDLMIXER @ENABLE_MIDI_SDLMIXER@
#cmakedefine ENABLE_MIDI_SEQMIDI @ENABLE_MIDI_SEQMIDI@
#cmakedefine ENABLE_MODULES @ENABLE_MODULES@
#cmakedefine ENABLE_NLS @ENABLE_NLS@
#cmakedefine ENABLE_SDL @ENABLE_SDL@
#cmakedefine ENABLE_X11FONT @ENABLE_X11FONT@
+9
View File
@@ -0,0 +1,9 @@
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if (APPLE)
add_link_options("SHELL:-undefined dynamic_lookup")
endif()
add_subdirectory(lib)
add_subdirectory(Gpx)
add_subdirectory(Math)
+6
View File
@@ -0,0 +1,6 @@
add_library(Gpx MODULE Gpx.c effectcopy.c)
target_link_libraries(Gpx PRIVATE graph)
target_include_directories(Gpx PRIVATE ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/modules/lib)
install(TARGETS Gpx DESTINATION lib/xsystem35)
+5
View File
@@ -0,0 +1,5 @@
add_library(Math MODULE Math.c)
target_include_directories(Math PRIVATE ${CMAKE_SOURCE_DIR}/src)
install(TARGETS Math DESTINATION lib/xsystem35)
+30
View File
@@ -0,0 +1,30 @@
add_library(graph STATIC
graph.c
surface.c
cg.c
graph_expandcolor_blend.c
graph_fillrect.c
graph_fillrect_amap.c
graph_fillrect_acolor.c
graph_rect.c
graph_copy.c
graph_copy_amap.c
graph_copy_bright.c
graph_copy_whiteout.c
graph_blend_amap.c
graph_blend_screen.c
graph_saturadd_amap.c
graph_draw_amap.c
graph_stretch.c
graph_cg.c
graph_buller.c
gre_blend_useamap.c
gre_blend.c
gre_blend_screen.c
)
add_library(alk STATIC alk.c)
add_library(drawtext STATIC drawtext.c)
include_directories(${CMAKE_SOURCE_DIR}/src)
+14
View File
@@ -37,8 +37,22 @@ add_library(objLib OBJECT
${SRC_MISC}
${SRC_NET}
${SRC_DLL})
if (ENABLE_MODULES)
set(CMAKE_BUILD_RPATH ${CMAKE_CURRENT_BINARY_DIR}/../modules)
if (APPLE)
set(CMAKE_INSTALL_RPATH @loader_path/../lib/xsystem35)
else()
set(CMAKE_INSTALL_RPATH $ORIGIN/../lib/xsystem35)
endif()
endif()
add_executable(xsystem35 $<TARGET_OBJECTS:objLib>)
if (ENABLE_MODULES)
target_link_libraries(xsystem35 PRIVATE -rdynamic)
endif()
if (EMSCRIPTEN)
add_executable(xsystem35.asm $<TARGET_OBJECTS:objLib>)
+5 -5
View File
@@ -22,15 +22,15 @@
/* $Id: cmd2F60.c,v 1.11 2003/01/12 10:48:50 chikama Exp $ */
#include <stdio.h>
#ifdef ENABLE_LTDL
#include <ltdl.h>
#endif
#include "portab.h"
#include "system.h"
#include "nact.h"
#include "s39ain.h"
#include "xsystem35.h"
#ifdef ENABLE_MODULES
#include <dlfcn.h>
#endif
#define dll nact->ain.dll
#define msgi nact->ain.msg
@@ -42,7 +42,7 @@ void commands2F60() {
int fnum = sys_getdw(); /* function number */
entrypoint *function = NULL;
#ifdef ENABLE_LTDL
#ifdef ENABLE_MODULES
if (dll == NULL) {
SYSERROR("No DLL initilized\n");
}
@@ -55,7 +55,7 @@ void commands2F60() {
if (dll[type].function[fnum].name == NULL) goto eexit;
function = lt_dlsym((lt_dlhandle)(dll[type].handle), dll[type].function[fnum].name);
function = dlsym(dll[type].handle, dll[type].function[fnum].name);
if (function) {
(*function)();
+10 -23
View File
@@ -33,6 +33,10 @@
#include "s39ain.h"
#include "xsystem35.h"
#ifdef ENABLE_MODULES
#include <dlfcn.h>
#endif
/* short cut */
#define dll nact->ain.dll
#define msg nact->ain.msg
@@ -173,40 +177,23 @@ int s39ain_init(void) {
}
}
#ifndef ENABLE_LTDL
#ifndef ENABLE_MODULES
free(buf);
return dllnum == 0 ? OK : NG;
#else
errors = lt_dlinit();
if (errors) {
printf("lt_dlinit fail\n");
free(buf);
return FALSE;
}
/* open dll */
for (i = 0; i < dllnum; i++) {
char searchpath[512];
char soname[64];
void *handle;
if (dll[i].function_num == 0) continue;
// 最初にカレントディレクトリのソースツリーの下の
// モジュールを検索
snprintf(searchpath, sizeof(searchpath) -1, "%s/%s",
path_to_dll, dll[i].name);
lt_dlsetsearchpath(searchpath);
// 次にデフォルトのモジュールを検索
/* package default path, ex. /usr/local/lib/xsystem35/ */
lt_dladdsearchdir(MODULE_PATH);
// fprintf(stderr, "try to open %s/%s\n", searchpath, dll[i].name);
handle = lt_dlopenext(dll[i].name);
snprintf(soname, sizeof(soname), "lib%s.so", dll[i].name);
handle = dlopen(soname, RTLD_NOW);
if (handle == NULL) {
SYSERROR("dlopen: %s(%s)\n", lt_dlerror(), dll[i].name);
SYSERROR("dlopen: %s(%s)\n", dlerror(), dll[i].name);
}
dll[i].handle = handle;
@@ -214,5 +201,5 @@ int s39ain_init(void) {
free(buf);
return OK;
#endif // ENABLE_LTDL
#endif // ENABLE_MODULES
}
+1 -7
View File
@@ -24,12 +24,6 @@
#ifndef __S39AIN_H__
#define __S39AIN_H__
#ifdef ENABLE_LTDL
#include <ltdl.h>
#else
typedef void lt_dlhandle;
#endif
#include "portab.h"
/* DLL 内関数情報 */
@@ -41,7 +35,7 @@ typedef struct {
/* DLL 情報 */
typedef struct {
lt_dlhandle *handle; /* DLL handler */
void *handle; /* DLL handler */
char *name; /* DLL 名 */
int function_num; /* 関数の数 */
S39AIN_DLLFN *function; /* 関数本体 */