adding dll fixes for mingw

This commit is contained in:
Alex Shinn 2010-03-04 12:35:18 +09:00
parent 3123d48da7
commit a630d84413
3 changed files with 24 additions and 2 deletions

View file

@ -24,6 +24,9 @@ GENSTATIC ?= ./tools/genstatic.scm
# system configuration - if not using GNU make, set PLATFORM and the
# following flags as necessary.
#
LIBDL = -ldl
ifndef PLATFORM
ifeq ($(shell uname),Darwin)
PLATFORM=macosx
@ -52,6 +55,7 @@ CLIBFLAGS = -shared
CPPFLAGS += -DSEXP_USE_STRING_STREAMS=0 -DBUILDING_DLL -DSEXP_USE_DEBUG=0
LDFLAGS += -Wl,--out-implib,libchibi-scheme$(SO).a
STATICFLAGS = -DSEXP_USE_DL=0
LIBDL =
else
SO = .so
EXE =
@ -76,7 +80,7 @@ ifeq ($(SEXP_USE_DL),0)
XLDFLAGS := $(LDFLAGS) $(GCLDFLAGS) -lm
XCFLAGS := -Wall -DSEXP_USE_DL=0 -g3 $(CFLAGS)
else
XLDFLAGS := $(LDFLAGS) $(GCLDFLAGS) -ldl -lm
XLDFLAGS := $(LDFLAGS) $(GCLDFLAGS) $(LIBDL) -lm
XCFLAGS := -Wall -g3 $(CFLAGS)
endif

18
eval.c
View file

@ -2039,7 +2039,22 @@ void sexp_warn_undefs (sexp ctx, sexp from, sexp to, sexp out) {
}
#if SEXP_USE_DL
sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
#ifdef __MINGW32__
#include <windows.h>
static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
sexp_proc2 init;
HINSTANCE handle = LoadLibraryA(sexp_string_data(file));
if(!handle)
return sexp_compile_error(ctx, "couldn't load dynamic library", file);
init = (sexp_proc2) GetProcAddress(handle, "sexp_init_library");
if(!init) {
FreeLibrary(handle);
return sexp_compile_error(ctx, "dynamic library has no sexp_init_library", file);
}
return init(ctx, env);
}
#else
static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
sexp_proc2 init;
void *handle = dlopen(sexp_string_data(file), RTLD_LAZY);
if (! handle)
@ -2052,6 +2067,7 @@ sexp sexp_load_dl (sexp ctx, sexp file, sexp env) {
return init(ctx, env);
}
#endif
#endif
sexp sexp_load (sexp ctx, sexp source, sexp env) {
#if SEXP_USE_DL

View file

@ -18,8 +18,10 @@ extern "C" {
#include <stdio.h>
#if SEXP_USE_DL
#ifndef __MINGW32__
#include <dlfcn.h>
#endif
#endif
#ifdef PLAN9
#include <u.h>