~ chicken-core (chicken-5) 7d4ad3f1044661505532eb16f624e52265716506
commit 7d4ad3f1044661505532eb16f624e52265716506 Author: felix <felix@call-with-current-continuation.org> AuthorDate: Mon Feb 8 12:31:55 2010 +0100 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Mon Feb 8 12:31:55 2010 +0100 removed libchickengui, libchicken handles distinction at runtime; added -gui to csc and deprecated -W/-windows diff --git a/Makefile.cross-linux-mingw b/Makefile.cross-linux-mingw index 459671ba..950fe5d7 100644 --- a/Makefile.cross-linux-mingw +++ b/Makefile.cross-linux-mingw @@ -60,18 +60,14 @@ C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os -fomit-frame-pointer endif endif C_COMPILER_SHARED_OPTIONS = -DPIC -C_COMPILER_GUI_RUNTIME_OPTIONS = -DC_WINDOWS_GUI LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared LIBRARIES = -lm -lws2_32 LIBCHICKEN_SO_LINKER_OPTIONS = -Wl,--out-implib,libchicken.dll.a LIBUCHICKEN_SO_LINKER_OPTIONS = -Wl,--out-implib,libuchicken.dll.a -LIBCHICKENGUI_SO_LINKER_OPTIONS = -Wl,--out-implib,libchickengui.dll.a LIBCHICKEN_SO_LIBRARIES = -lws2_32 LIBUCHICKEN_SO_LIBRARIES = -lws2_32 -LIBCHICKENGUI_SO_LIBRARIES = -lkernel32 -luser32 -lgdi32 -lws2_32 LIBCHICKEN_IMPORT_LIBRARY = libchicken.dll.a LIBUCHICKEN_IMPORT_LIBRARY = libuchicken.dll.a -LIBCHICKENGUI_IMPORT_LIBRARY = libchickengui.dll.a TARGET_C_COMPILER = gcc TARGET_CXX_COMPILER = g++ @@ -90,13 +86,13 @@ ifndef BUILD_SETUP_TOOLS TARGETS = libchicken$(A) libuchicken$(A) $(CHICKEN_PROGRAM)$(EXE) $(CSI_PROGRAM)$(EXE) \ $(CHICKEN_PROFILE_PROGRAM)$(EXE) $(CSC_PROGRAM)$(EXE) libchicken$(SO) \ libuchicken$(SO) \ - libchickengui$(SO) $(CHICKEN_BUG_PROGRAM)$(EXE) + $(CHICKEN_BUG_PROGRAM)$(EXE) else TARGETS = libchicken$(A) libuchicken$(A) $(CHICKEN_PROGRAM)$(EXE) $(CSI_PROGRAM)$(EXE) \ $(CHICKEN_PROFILE_PROGRAM)$(EXE) $(CSC_PROGRAM)$(EXE) libchicken$(SO) \ libuchicken$(SO) $(CHICKEN_INSTALL_PROGRAM)$(EXE) $(CHICKEN_UNINSTALL_PROGRAM)$(EXE) \ $(CHICKEN_STATUS_PROGRAM)$(EXE) \ - libchickengui$(SO) $(CHICKEN_BUG_PROGRAM)$(EXE) + $(CHICKEN_BUG_PROGRAM)$(EXE) endif chicken-config.h: chicken-defaults.h diff --git a/Makefile.mingw b/Makefile.mingw index eb9ec70d..a1b11c51 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -66,17 +66,13 @@ C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os endif endif C_COMPILER_SHARED_OPTIONS = -DPIC -C_COMPILER_GUI_RUNTIME_OPTIONS = -DC_WINDOWS_GUI LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared LIBRARIES = -lm -lws2_32 LINKER_OPTIONS = -Wl,--enable-auto-import LIBCHICKEN_SO_LINKER_OPTIONS = -Wl,--out-implib,libchicken.dll.a LIBUCHICKEN_SO_LINKER_OPTIONS = -Wl,--out-implib,libuchicken.dll.a -LIBCHICKENGUI_SO_LINKER_OPTIONS = -Wl,--out-implib,libchickengui.dll.a LIBCHICKEN_SO_LIBRARIES = -lm -lws2_32 LIBUCHICKEN_SO_LIBRARIES = -lm -lws2_32 -LIBCHICKENGUI_SO_LIBRARIES = -lm -lkernel32 -luser32 -lgdi32 -lws2_32 -LIBCHICKENGUI_IMPORT_LIBRARY = libchickengui.dll.a LIBCHICKEN_IMPORT_LIBRARY = libchicken.dll.a LIBUCHICKEN_IMPORT_LIBRARY = libuchicken.dll.a MAKEDIR_COMMAND_OPTIONS = @@ -90,7 +86,6 @@ POSIXFILE = posixwin # select default and internal settings CUSTOM_CHICKEN_DEFAULTS=1 -TARGETS = libchickengui$(SO) libchickengui$(A) include $(SRCDIR)defaults.make diff --git a/Makefile.mingw-msys b/Makefile.mingw-msys index 3d06e908..02be4a34 100644 --- a/Makefile.mingw-msys +++ b/Makefile.mingw-msys @@ -56,17 +56,13 @@ C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os endif endif C_COMPILER_SHARED_OPTIONS = -DPIC -C_COMPILER_GUI_RUNTIME_OPTIONS = -DC_WINDOWS_GUI LINKER_OPTIONS = -Wl,--enable-auto-import LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared LIBRARIES = -lm -lws2_32 LIBCHICKEN_SO_LINKER_OPTIONS = -Wl,--out-implib,libchicken.dll.a LIBUCHICKEN_SO_LINKER_OPTIONS = -Wl,--out-implib,libuchicken.dll.a -LIBCHICKENGUI_SO_LINKER_OPTIONS = -Wl,--out-implib,libchickengui.dll.a LIBCHICKEN_SO_LIBRARIES = -lm -lws2_32 LIBUCHICKEN_SO_LIBRARIES = -lm -lws2_32 -LIBCHICKENGUI_SO_LIBRARIES = -lm -lkernel32 -luser32 -lgdi32 -lws2_32 -LIBCHICKENGUI_IMPORT_LIBRARY = libchickengui.dll.a LIBCHICKEN_IMPORT_LIBRARY = libchicken.dll.a LIBUCHICKEN_IMPORT_LIBRARY = libuchicken.dll.a @@ -78,8 +74,6 @@ POSIXFILE = posixwin # select default and internal settings -TARGETS = libchickengui$(SO) libchickengui$(A) - include $(SRCDIR)/defaults.make chicken-config.h: chicken-defaults.h diff --git a/c-backend.scm b/c-backend.scm index 5d575dbc..17c15e3e 100644 --- a/c-backend.scm +++ b/c-backend.scm @@ -551,7 +551,6 @@ (gen "C_noret_decl(C_" uname ")" #t) (when emit-unsafe-marker (gen "C_externexport void C_dynamic_and_unsafe(void) {}" #t) ) - (gen "C_gui_nongui_marker" #t) (gen "C_externexport void C_ccall ") (gen "C_" uname) ) ] ) (gen #\() diff --git a/chicken.h b/chicken.h index 571dbdfa..58a95eec 100644 --- a/chicken.h +++ b/chicken.h @@ -326,7 +326,6 @@ typedef unsigned __int64 uint64_t; /* Have a GUI? */ #if defined(C_WINDOWS_GUI) -# define C_MICROSOFT_WINDOWS # include <windows.h> # ifndef WINAPI # define WINAPI @@ -564,8 +563,6 @@ typedef unsigned __int64 uint64_t; #define C_RUNTIME_SAFE_DLOAD_UNSAFE_ERROR 34 #define C_BAD_ARGUMENT_TYPE_NO_FLONUM_ERROR 35 #define C_BAD_ARGUMENT_TYPE_NO_CLOSURE_ERROR 36 -#define C_RUNTIME_GUI_DLOAD_NONGUI_ERROR 37 -#define C_RUNTIME_NONGUI_DLOAD_GUI_ERROR 38 /* Platform information */ @@ -1305,24 +1302,25 @@ extern double trunc(double); #define C_end_of_main +/* left for backwards-compatibility */ +#define C_gui_nongui_marker + #if !defined(C_EMBEDDED) && !defined(C_SHARED) # ifndef C_WINDOWS_GUI # define C_main_entry_point int main(int argc, char *argv[]) { return CHICKEN_main(argc, argv, (void*)C_toplevel); } C_end_of_main # else # define C_main_entry_point \ int WINAPI WinMain(HINSTANCE me, HINSTANCE you, LPSTR cmdline, int show) \ - { return CHICKEN_main(0, NULL, (void *)C_toplevel); } C_end_of_main + { \ + C_gui_mode = 1; \ + return CHICKEN_main(0, NULL, (void *)C_toplevel); \ + } \ + C_end_of_main # endif #else # define C_main_entry_point #endif -#if defined(C_SHARED) && defined(C_WINDOWS_GUI) -# define C_gui_nongui_marker C_externexport void C_dynamic_and_gui(void) {} -#else -# define C_gui_nongui_marker -#endif - #define C_alloc_flonum C_word *___tmpflonum = C_alloc(WORDS_PER_FLONUM) #define C_kontinue_flonum(k, n) C_kontinue((k), C_flonum(&___tmpflonum, (n))) @@ -1371,6 +1369,7 @@ C_varextern C_TLS C_byte C_varextern C_TLS jmp_buf C_restart; C_varextern C_TLS void *C_restart_address; C_varextern C_TLS int C_entry_point_status; +C_varextern C_TLS int C_gui_mode; C_varextern C_TLS void (C_fcall *C_restart_trampoline)(void *proc) C_regparm C_noret; C_varextern C_TLS void (*C_pre_gc_hook)(int mode); diff --git a/csc.scm b/csc.scm index 49430d7d..51c73299 100644 --- a/csc.scm +++ b/csc.scm @@ -118,11 +118,6 @@ (if msvc "libuchicken-static." "libuchicken.") library-extension)) -(define default-gui-library - (string-append - (if msvc "libchickengui-static." "libchickengui.") - library-extension)) - (define cleanup-filename quotewrap) (define default-compilation-optimization-options (string-split (if host-mode INSTALL_CFLAGS TARGET_CFLAGS))) @@ -212,19 +207,6 @@ (list (string-append "libchicken." library-extension)) '("-lchicken"))) -(define default-gui-library-files - (list - (quotewrap - (prefix default-gui-library "lib" - (string-append - (if host-mode INSTALL_LIB_HOME TARGET_LIB_HOME) - (string-append "/" default-library)))) )) - -(define default-gui-shared-library-files - (if msvc - (list (string-append "libchickengui." library-extension)) - '("-lchickengui"))) - (define unsafe-libraries #f) (define unsafe-library-files @@ -245,8 +227,6 @@ (set! library-files unsafe-library-files) (set! shared-library-files unsafe-shared-library-files)) -(define gui-library-files default-gui-library-files) -(define gui-shared-library-files default-gui-shared-library-files) (define library-files default-library-files) (define shared-library-files default-shared-library-files) @@ -297,7 +277,6 @@ (define static-libs #f) (define static-extensions '()) (define required-extensions '()) -(define gui #f) ;;; Display usage information: @@ -425,7 +404,7 @@ Usage: ~a FILENAME | OPTION ... -e -embedded compile as embedded (don't generate `main()') - -W -windows compile as Windows GUI application + -gui compile as GUI application -R -require-extension NAME require extension and import in compiled code -dll -library compile multiple units into a dynamic @@ -638,19 +617,19 @@ EOF (set! static-extensions (append static-extensions (list (car rest)))) (t-options "-static-extension" (car rest)) (set! rest (cdr rest)) ] - [(-windows |-W|) + [(-gui + -windows |-W|) ;DEPRECATED (when (or msvc mingw) - (set! gui #t) - (cond - (mingw - (set! link-options - (cons* "-lkernel32" "-luser32" "-lgdi32" "-mwindows" - link-options)) - (set! compile-options (cons "-DC_WINDOWS_GUI" compile-options))) - (msvc - (set! link-options - (cons* "kernel32.lib" "user32.lib" "gdi32.lib" link-options)) - (set! compile-options (cons "-DC_WINDOWS_GUI" compile-options)))) ) ] + (cond + (mingw + (set! link-options + (cons* "-lkernel32" "-luser32" "-lgdi32" "-mwindows" + link-options)) + (set! compile-options (cons "-DC_WINDOWS_GUI" compile-options))) + (msvc + (set! link-options + (cons* "kernel32.lib" "user32.lib" "gdi32.lib" link-options)) + (set! compile-options (cons "-DC_WINDOWS_GUI" compile-options)))) ) ] [(-framework) (check s rest) (when osx @@ -912,8 +891,8 @@ EOF (append (if staticexts (nth-value 0 (static-extension-info)) '()) (if (or static static-libs) - (if gui gui-library-files library-files) - (if gui gui-shared-library-files shared-library-files)) + library-files + shared-library-files) (if (or static static-libs) (list extra-libraries) (list extra-shared-libraries))))) diff --git a/defaults.make b/defaults.make index 0ba7e4e8..3f5fc952 100644 --- a/defaults.make +++ b/defaults.make @@ -212,17 +212,14 @@ ifeq ($(PLATFORM),cygwin) PRIMARY_LIBCHICKEN = cygchicken-0.dll LIBCHICKEN_SO_FILE = cygchicken-0.dll LIBUCHICKEN_SO_FILE = cyguchicken-0.dll -LIBCHICKENGUI_SO_FILE ?= else PRIMARY_LIBCHICKEN ?= libchicken$(SO) LIBCHICKEN_SO_FILE ?= libchicken$(SO) LIBUCHICKEN_SO_FILE ?= libuchicken$(SO) -LIBCHICKENGUI_SO_FILE ?= endif endif LIBCHICKEN_SO_LIBRARIES ?= $(LIBRARIES) LIBUCHICKEN_SO_LIBRARIES ?= $(LIBRARIES) -LIBCHICKENGUI_SO_LIBRARIES ?= $(LIBRARIES) # cross settings diff --git a/library.scm b/library.scm index bbb52983..fe823d0b 100644 --- a/library.scm +++ b/library.scm @@ -3846,12 +3846,6 @@ EOF args) ) ((35) (apply ##sys#signal-hook #:type-error loc "bad argument type - not a flonum" args)) ((36) (apply ##sys#signal-hook #:type-error loc "bad argument type - not a procedure" args)) - ((37) (apply ##sys#signal-hook #:runtime-error loc - "code to load dynamically was linked with non-GUI runtime libraries, but executing runtime was not" - args) ) - ((38) (apply ##sys#signal-hook #:runtime-error loc - "code to load dynamically was linked with GUI runtime libraries, but executing runtime was not" - args) ) (else (apply ##sys#signal-hook #:runtime-error loc "unknown internal error" args)) ) ) ) ) diff --git a/rules.make b/rules.make index 3f39cc41..9ec63d8f 100644 --- a/rules.make +++ b/rules.make @@ -42,13 +42,6 @@ LIBUCHICKEN_OBJECTS_1 = \ LIBUCHICKEN_SHARED_OBJECTS = $(LIBUCHICKEN_OBJECTS_1:=$(O)) LIBUCHICKEN_STATIC_OBJECTS = $(LIBUCHICKEN_OBJECTS_1:=-static$(O)) -LIBCHICKENGUI_OBJECTS_1 = \ - library eval data-structures ports files extras lolevel utils tcp srfi-1 srfi-4 srfi-13 \ - srfi-14 srfi-18 srfi-69 $(POSIXFILE) regex scheduler \ - profiler stub expand chicken-syntax gui-runtime -LIBCHICKENGUI_SHARED_OBJECTS = $(LIBCHICKENGUI_OBJECTS_1:=$(O)) -LIBCHICKENGUI_STATIC_OBJECTS = $(LIBCHICKENGUI_OBJECTS_1:=-static$(O)) - COMPILER_OBJECTS_1 = \ chicken batch-driver compiler optimizer compiler-syntax scrutinizer unboxing support \ c-platform c-backend @@ -62,11 +55,6 @@ runtime$(O): runtime.c chicken.h $(CHICKEN_CONFIG_H) $(C_COMPILER) $(C_COMPILER_OPTIONS) $(INCLUDES) \ $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) \ $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT) -gui-runtime$(O): runtime.c chicken.h $(CHICKEN_CONFIG_H) - $(C_COMPILER) $(C_COMPILER_OPTIONS) $(INCLUDES) \ - $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) \ - $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $(C_COMPILER_GUI_RUNTIME_OPTIONS) $< \ - $(C_COMPILER_OUTPUT) eval$(O): eval.c chicken.h $(CHICKEN_CONFIG_H) $(C_COMPILER) $(C_COMPILER_OPTIONS) $(INCLUDES) \ $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $(C_COMPILER_SHARED_OPTIONS) \ @@ -242,12 +230,6 @@ runtime-static$(O): runtime.c chicken.h $(CHICKEN_CONFIG_H) $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) \ $(C_COMPILER_STATIC_OPTIONS) \ $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $< $(C_COMPILER_OUTPUT) -gui-runtime-static$(O): runtime.c chicken.h $(CHICKEN_CONFIG_H) - $(C_COMPILER) $(C_COMPILER_OPTIONS) $(INCLUDES) \ - $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) \ - $(C_COMPILER_STATIC_OPTIONS) \ - $(C_COMPILER_BUILD_RUNTIME_OPTIONS) $(C_COMPILER_GUI_RUNTIME_OPTIONS) $< \ - $(C_COMPILER_OUTPUT) eval-static$(O): eval.c chicken.h $(CHICKEN_CONFIG_H) $(C_COMPILER) $(C_COMPILER_OPTIONS) $(INCLUDES) \ $(C_COMPILER_STATIC_OPTIONS) \ @@ -727,19 +709,12 @@ cyguchicken-0.dll: $(LIBUCHICKEN_SHARED_OBJECTS) $(APPLY_HACK_OBJECT) -Wl,--no-whole-archive $(LIBUCHICKEN_SO_LIBRARIES) -libchickengui$(SO): $(APPLY_HACK_OBJECT) $(LIBCHICKENGUI_SHARED_OBJECTS) - $(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_LIBRARY_OPTIONS) $(LIBCHICKENGUI_SO_LINKER_OPTIONS) \ - $(LINKER_OUTPUT) $^ $(LIBCHICKENGUI_SO_LIBRARIES) - libchicken$(A): $(APPLY_HACK_OBJECT) $(LIBCHICKEN_STATIC_OBJECTS) $(LIBRARIAN) $(LIBRARIAN_OPTIONS) $(LIBRARIAN_OUTPUT) $^ libuchicken$(A): $(APPLY_HACK_OBJECT) $(LIBUCHICKEN_STATIC_OBJECTS) $(LIBRARIAN) $(LIBRARIAN_OPTIONS) $(LIBRARIAN_OUTPUT) $^ -libchickengui$(A): $(APPLY_HACK_OBJECT) $(LIBCHICKENGUI_STATIC_OBJECTS) - $(LIBRARIAN) $(LIBRARIAN_OPTIONS) $(LIBRARIAN_OUTPUT) $^ - # import libraries and extensions .SUFFIXES: .so @@ -800,10 +775,6 @@ install-libs: ifneq ($(LIBCHICKEN_IMPORT_LIBRARY),) $(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) $(LIBCHICKEN_IMPORT_LIBRARY) "$(DESTDIR)$(ILIBDIR)" $(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) $(LIBUCHICKEN_IMPORT_LIBRARY) "$(DESTDIR)$(ILIBDIR)" -ifdef WINDOWS - -$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) libchickengui$(A) "$(DESTDIR)$(ILIBDIR)" - $(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) $(LIBCHICKENGUI_IMPORT_LIBRARY) "$(DESTDIR)$(ILIBDIR)" -endif endif ifneq ($(POSTINSTALL_STATIC_LIBRARY),true) $(POSTINSTALL_STATIC_LIBRARY) $(POSTINSTALL_STATIC_LIBRARY_FLAGS) \ @@ -823,9 +794,6 @@ else $(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBUCHICKEN_SO_FILE) \ "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBUCHICKEN_SO_FILE)$(SONAME_VERSION)" endif -ifdef WINDOWS - $(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) libchickengui$(SO) "$(DESTDIR)$(IBINDIR)" -endif ifdef USES_SONAME cd "$(DESTDIR)$(ILIBDIR)" && ln -sf $(LIBCHICKEN_SO_FILE).$(BINARYVERSION) libchicken$(SO) cd "$(DESTDIR)$(ILIBDIR)" && ln -sf $(LIBUCHICKEN_SO_FILE).$(BINARYVERSION) libuchicken$(SO) @@ -1016,11 +984,8 @@ endif ifdef WINDOWS $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)libchicken$(SO)" $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)libuchicken$(SO)" - $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)libchickengui$(SO)" - $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)libchickengui$(A)" $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_IMPORT_LIBRARY)" $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBUCHICKEN_IMPORT_LIBRARY)" - $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKENGUI_IMPORT_LIBRARY)" endif ifdef ($(PLATFORM),cygwin) $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)cygchicken*" "$(DESTDIR)$(IBINDIR)$(SEP)cyguchicken*" @@ -1255,22 +1220,16 @@ html: .PHONY: clean distclean spotless confclean testclean -ifeq ($(PLATFORM),mingw) -CLEAN_MINGW_LIBS = libchickengui.a libchickengui.dll libchickengui.dll.a -else -CLEAN_MINGW_LIBS = -endif - clean: -$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) chicken$(EXE) csi$(EXE) csc$(EXE) \ chicken-profile$(EXE) csi-static$(EXE) \ chicken-install$(EXE) chicken-uninstall$(EXE) chicken-status$(EXE) \ csc-static$(EXE) chicken-static$(EXE) chicken-bug$(EXE) *$(O) \ - $(LIBCHICKEN_SO_FILE) $(LIBUCHICKEN_SO_FILE) $(LIBCHICKENGUI_SO_FILE) \ - libchicken$(A) libuchicken$(A) libchickengui$(A) libchicken$(SO) $(PROGRAM_IMPORT_LIBRARIES) \ + $(LIBCHICKEN_SO_FILE) $(LIBUCHICKEN_SO_FILE) \ + libchicken$(A) libuchicken$(A) libchicken$(SO) $(PROGRAM_IMPORT_LIBRARIES) \ $(IMPORT_LIBRARIES:=.import.so) $(LIBCHICKEN_IMPORT_LIBRARY) $(LIBUCHICKEN_IMPORT_LIBRARY) \ - $(LIBCHICKENGUI_IMPORT_LIBRARY) setup-api.so setup-api.import.scm setup-download.so \ - setup-download.import.scm $(CLEAN_MINGW_LIBS) + setup-api.so setup-api.import.scm setup-download.so \ + setup-download.import.scm ifdef USES_SONAME $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) libchicken.so.$(BINARYVERSION) $(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) libuchicken.so.$(BINARYVERSION) diff --git a/runtime.c b/runtime.c index 31fdae64..39f31da7 100644 --- a/runtime.c +++ b/runtime.c @@ -336,6 +336,7 @@ C_TLS void (*C_post_gc_hook)(int mode, long ms) = NULL; C_TLS void (C_fcall *C_restart_trampoline)(void *proc) C_regparm C_noret; C_TLS int + C_gui_mode = 0, C_abort_on_thread_exceptions, C_enable_repl, C_interrupts_enabled, @@ -354,7 +355,6 @@ C_TLS C_uword C_heap_shrinkage; C_TLS C_uword C_maximal_heap_size; C_TLS time_t C_startup_time_seconds; - C_TLS char **C_main_argv, *C_dlerror; @@ -515,11 +515,15 @@ int CHICKEN_main(int argc, char *argv[], void *toplevel) { C_word h, s, n; -#if defined(C_WINDOWS_GUI) - parse_argv(GetCommandLine()); - argc = C_main_argc; - argv = C_main_argv; + if(C_gui_mode) { +#ifdef _WIN32 + parse_argv(GetCommandLine()); + argc = C_main_argc; + argv = C_main_argv; +#else + /* ??? */ #endif + } CHICKEN_parse_command_line(argc, argv, &h, &s, &n); @@ -533,7 +537,6 @@ int CHICKEN_main(int argc, char *argv[], void *toplevel) /* Custom argv parser for Windoze: */ -#ifdef C_WINDOWS_GUI void parse_argv(C_char *cmds) { C_char *ptr = cmds, @@ -565,7 +568,6 @@ void parse_argv(C_char *cmds) C_main_argv[ C_main_argc++ ] = aptr; } } -#endif /* Initialize runtime system: */ @@ -1342,16 +1344,16 @@ void usual_panic(C_char *msg) C_dbg_hook(C_SCHEME_UNDEFINED); -#ifdef C_MICROSOFT_WINDOWS - C_sprintf(buffer, C_text("%s\n\n%s"), msg, dmp); + if(C_gui_mode) { + C_sprintf(buffer, C_text("%s\n\n%s"), msg, dmp); +#if defined(_WIN32) && !defined(__CYGWIN__) + MessageBox(NULL, buffer, C_text("CHICKEN runtime"), MB_OK | MB_ICONERROR); + ExitProcess(1); +#endif + } /* fall through if not WIN32 GUI app */ - MessageBox(NULL, buffer, C_text("CHICKEN runtime"), MB_OK); - ExitProcess(1); -#else C_fprintf(C_stderr, C_text("\n%s - execution terminated\n\n%s"), msg, dmp); - C_exit(1); -#endif } @@ -1359,16 +1361,16 @@ void horror(C_char *msg) { C_dbg_hook(C_SCHEME_UNDEFINED); -#ifdef C_MICROSOFT_WINDOWS - C_sprintf(buffer, C_text("%s"), msg); + if(C_gui_mode) { + C_sprintf(buffer, C_text("%s"), msg); +#if defined(_WIN32) && !defined(__CYGWIN__) + MessageBox(NULL, buffer, C_text("CHICKEN runtime"), MB_OK | MB_ICONERROR); + ExitProcess(1); +#endif + } /* fall through */ - MessageBox(NULL, buffer, C_text("CHICKEN runtime"), MB_OK); - ExitProcess(1); -#else - C_fprintf(C_stderr, C_text("\n%s - execution terminated"), msg); - + C_fprintf(C_stderr, C_text("\n%s - execution terminated"), msg); C_exit(1); -#endif } @@ -1560,16 +1562,6 @@ void barf(int code, char *loc, ...) c = 0; break; - case C_RUNTIME_GUI_DLOAD_NONGUI_ERROR: - msg = C_text("code to load dynamically was linked with non-GUI runtime libraries, but executing runtime was not"); - c = 0; - break; - - case C_RUNTIME_NONGUI_DLOAD_GUI_ERROR: - msg = C_text("code to load dynamically was linked with GUI runtime libraries, but executing runtime was not"); - c = 0; - break; - case C_BAD_ARGUMENT_TYPE_NO_FLONUM_ERROR: msg = C_text("bad argument type - not a flonum"); c = 1; @@ -3743,30 +3735,33 @@ C_word C_halt(C_word msg) { C_char *dmp = msg != C_SCHEME_FALSE ? C_dump_trace(0) : NULL; -#ifdef C_MICROSOFT_WINDOWS - if(msg != C_SCHEME_FALSE) { - int n = C_header_size(msg); + if(C_gui_mode) { + if(msg != C_SCHEME_FALSE) { + int n = C_header_size(msg); + + if (n >= sizeof(buffer)) + n = sizeof(buffer) - 1; + C_strncpy(buffer, (C_char *)C_data_pointer(msg), n); + buffer[ n ] = '\0'; + } + else C_strcpy(buffer, C_text("(aborted)")); - if (n >= sizeof(buffer)) - n = sizeof(buffer) - 1; - C_strncpy(buffer, (C_char *)C_data_pointer(msg), n); - buffer[ n ] = '\0'; - } - else C_strcpy(buffer, C_text("(aborted)")); + C_strcat(buffer, C_text("\n\n")); - C_strcat(buffer, C_text("\n\n")); + if(dmp != NULL) C_strcat(buffer, dmp); - if(dmp != NULL) C_strcat(buffer, dmp); +#if defined(_WIN32) && !defined(__CYGWIN__) + MessageBox(NULL, buffer, C_text("CHICKEN runtime"), MB_OK | MB_ICONERROR); + ExitProcess(1); +#endif + } /* otherwise fall through */ - MessageBox(NULL, buffer, C_text("CHICKEN runtime"), MB_OK); -#else if(msg != C_SCHEME_FALSE) { C_fwrite(C_data_pointer(msg), C_header_size(msg), sizeof(C_char), C_stderr); C_fputc('\n', C_stderr); } if(dmp != NULL) C_fprintf(stderr, C_text("\n%s"), dmp); -#endif C_exit(EX_SOFTWARE); return 0; @@ -3775,18 +3770,21 @@ C_word C_halt(C_word msg) C_word C_message(C_word msg) { -#ifdef C_MICROSOFT_WINDOWS - int n = C_header_size(msg); + if(C_gui_mode) { + int n = C_header_size(msg); + + if (n >= sizeof(buffer)) + n = sizeof(buffer) - 1; + C_strncpy(buffer, (C_char *)((C_SCHEME_BLOCK *)msg)->data, n); + buffer[ n ] = '\0'; +#if defined(_WIN32) && !defined(__CYGWIN__) + MessageBox(NULL, buffer, C_text("CHICKEN runtime"), MB_OK | MB_ICONERROR); + ExitProcess(1); +#endif + } /* fall through */ - if (n >= sizeof(buffer)) - n = sizeof(buffer) - 1; - C_strncpy(buffer, (C_char *)((C_SCHEME_BLOCK *)msg)->data, n); - buffer[ n ] = '\0'; - MessageBox(NULL, buffer, C_text("CHICKEN runtime"), MB_OK); -#else C_fwrite(((C_SCHEME_BLOCK *)msg)->data, C_header_size(msg), sizeof(C_char), stdout); C_putchar('\n'); -#endif return C_SCHEME_UNDEFINED; } @@ -3989,21 +3987,19 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor) return C_SCHEME_FALSE; #endif - case C_fix(4): -#ifdef C_GENERIC_CONSOLE - return C_SCHEME_TRUE; + case C_fix(4): /* is this a console application? */ + return C_mk_bool(!C_gui_mode); + + case C_fix(5): /* is this a GUI/console or Windows-GUI application? (silly) */ + if(C_gui_mode) { +#ifdef _WIN32 + return C_fix(1); #else - return C_SCHEME_FALSE; + return C_SCHEME_FALSE; #endif + } - case C_fix(5): -#ifdef C_GENERIC_CONSOLE return C_fix(0); -#elif defined(C_WINDOWS_GUI) - return C_fix(1); -#else - return C_SCHEME_FALSE; -#endif case C_fix(6): return C_fix(C_MOST_POSITIVE_FIXNUM & cpu_milliseconds()); @@ -8013,8 +8009,7 @@ void dload_2(void *dummy) } if(p != NULL) { - /* check whether dloaded code is not a library unit - * and matches current safety/gui setting: */ + /* check whether dloaded code is not a library unit */ if((p2 = C_dlsym(handle, C_text("C_dynamic_and_unsafe"))) == NULL) p2 = C_dlsym(handle, C_text("_C_dynamic_and_unsafe")); @@ -8109,23 +8104,6 @@ void dload_2(void *dummy) #endif } - /* do the same check for GUI libraries: */ - p2 = GetProcAddress(handle, C_text("C_dynamic_and_gui")); - -#ifdef C_WINDOWS_GUI - ok = p2 != NULL; /* GUI runtime, GUI code */ -#else - ok = p2 == NULL; /* non-GUI runtime, non-GUI code */ -#endif - - /* GUI marker not found and this is not a library unit? */ - if(!ok && !C_strcmp(topname, "C_toplevel")) -#ifdef C_WINDOWS_GUI - barf(C_RUNTIME_GUI_DLOAD_NONGUI_ERROR, NULL); -#else - barf(C_RUNTIME_NONGUI_DLOAD_GUI_ERROR, NULL); -#endif - current_module_name = C_strdup(mname); current_module_handle = handle;Trap