~ chicken-core (chicken-5) c1b3d35d78bfabf9bb989d4204ede10619e2cf8c


commit c1b3d35d78bfabf9bb989d4204ede10619e2cf8c
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Tue Mar 16 13:03:02 2010 +0100
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Tue Mar 16 13:09:23 2010 +0100

    csc handles .rc files; install .rc for windows gui apps; patch by Thomas Chust for embedding manifest; new csc option -no-elevation

diff --git a/Makefile.cygwin b/Makefile.cygwin
index 927352f1..2104de65 100644
--- a/Makefile.cygwin
+++ b/Makefile.cygwin
@@ -44,6 +44,7 @@ EXE = .exe
 
 C_COMPILER = gcc
 CXX_COMPILER = g++
+RC_COMPILER = windres
 LINKER = gcc
 
 
diff --git a/Makefile.mingw b/Makefile.mingw
index 847e9471..9903e592 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -66,6 +66,7 @@ C_COMPILER_OPTIMIZATION_OPTIONS ?= -Os
 endif
 endif
 C_COMPILER_SHARED_OPTIONS = -DPIC
+RC_COMPILER ?= windres
 LINKER_LINK_SHARED_LIBRARY_OPTIONS = -shared
 LIBRARIES = -lm -lws2_32
 LINKER_OPTIONS += -Wl,--enable-auto-import
@@ -76,6 +77,7 @@ LIBUCHICKEN_SO_LIBRARIES = -lm -lws2_32
 LIBCHICKEN_IMPORT_LIBRARY = libchicken.dll.a
 LIBUCHICKEN_IMPORT_LIBRARY = libuchicken.dll.a
 MAKEDIR_COMMAND_OPTIONS =
+CUSTOM_RC_FILE = 1
 
 # special files
 
@@ -143,6 +145,9 @@ endif
 	echo #ifndef C_INSTALL_CXX >>$@
 	echo # define C_INSTALL_CXX "$(CXX_COMPILER)" >>$@
 	echo #endif >>$@
+	echo #ifndef C_INSTALL_RC_COMPILER >>$@
+	echo # define C_INSTALL_RC_COMPILER "$(RC_COMPILER)" >>$@
+	echo #endif >>$@
 	echo #ifndef C_INSTALL_CFLAGS >>$@
 	echo # define C_INSTALL_CFLAGS "$(C_COMPILER_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS)" >>$@
 	echo #endif >>$@
@@ -197,6 +202,9 @@ endif
 	echo #ifndef C_TARGET_CXX >>$@
 	echo # define C_TARGET_CXX "$(TARGET_CXX_COMPILER)" >>$@
 	echo #endif >>$@
+	echo #ifndef C_TARGET_RC_COMPILER >>$@
+	echo # define C_TARGET_RC_COMPILER "$(TARGET_RC_COMPILER)" >>$@
+	echo #endif >>$@
 	echo #ifndef C_TARGET_CFLAGS >>$@
 	echo # define C_TARGET_CFLAGS "$(TARGET_C_COMPILER_OPTIONS) $(TARGET_C_COMPILER_OPTIMIZATION_OPTIONS)" >>$@
 	echo #endif >>$@
@@ -241,4 +249,40 @@ endif
 	echo #endif >>$@
 	echo /* END OF FILE */ >>$@
 
+chicken-install.rc:
+	echo /* GENERATED */ >$@
+	echo 1 24 MOVEABLE PURE >>$@
+	echo BEGIN >>$@
+	echo   "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>\r\n" >>$@
+	echo   "<assembly xmlns=""urn:schemas-microsoft-com:asm.v1"" manifestVersion=""1.0"">\r\n" >>$@
+	echo   "  <assemblyIdentity version=""1.0.0.0"" processorArchitecture=""*"" name=""$(PROGRAM_PREFIX)chicken-install$(PROGRAM_SUFFIX)"" type=""win32""/>\r\n" >>$@
+	echo   "  <ms_asmv2:trustInfo xmlns:ms_asmv2=""urn:schemas-microsoft-com:asm.v2"">\r\n" >>$@
+	echo   "    <ms_asmv2:security>\r\n" >>$@
+	echo   "      <ms_asmv2:requestedPrivileges>\r\n" >>$@
+	echo   "        <ms_asmv2:requestedExecutionLevel level=""asInvoker"" uiAccess=""false""/>\r\n" >>$@
+	echo   "      </ms_asmv2:requestedPrivileges>\r\n" >>$@
+	echo   "    </ms_asmv2:security>\r\n" >>$@
+	echo   "  </ms_asmv2:trustInfo>\r\n" >>$@
+	echo   "</assembly>\r\n" >>$@
+	echo END >>$@
+	echo /* END OF FILE */ >>$@
+
+chicken-uninstall.rc:
+	echo /* END OF FILE */ >$@
+	echo 1 24 MOVEABLE PURE >>$@
+	echo BEGIN >>$@
+	echo   "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>\r\n" >>$@
+	echo   "<assembly xmlns=""urn:schemas-microsoft-com:asm.v1"" manifestVersion=""1.0"">\r\n" >>$@
+	echo   "  <assemblyIdentity version=""1.0.0.0"" processorArchitecture=""*"" name=""$(PROGRAM_PREFIX)chicken-uninstall$(PROGRAM_SUFFIX)"" type=""win32""/>\r\n" >>$@
+	echo   "  <ms_asmv2:trustInfo xmlns:ms_asmv2=""urn:schemas-microsoft-com:asm.v2"">\r\n" >>$@
+	echo   "    <ms_asmv2:security>\r\n" >>$@
+	echo   "      <ms_asmv2:requestedPrivileges>\r\n" >>$@
+	echo   "        <ms_asmv2:requestedExecutionLevel level=""asInvoker"" uiAccess=""false""/>\r\n" >>$@
+	echo   "      </ms_asmv2:requestedPrivileges>\r\n" >>$@
+	echo   "    </ms_asmv2:security>\r\n" >>$@
+	echo   "  </ms_asmv2:trustInfo>\r\n" >>$@
+	echo   "</assembly>\r\n" >>$@
+	echo END >>$@
+	echo /* END OF FILE */ >>$@
+
 include $(SRCDIR)rules.make
diff --git a/config.make b/config.make
index bf45faf9..1d94f4ef 100644
--- a/config.make
+++ b/config.make
@@ -29,6 +29,9 @@
 # Add additional C compiler options:
 #C_COMPILER_OPTIMIZATION_OPTIONS=...
 
+# Use alternative resource compiler (for Win32 builds)
+#RC_COMPILER=
+
 # Choose prefix to be added to installed programs:
 #PROGRAM_PREFIX= 
 
diff --git a/csc.scm b/csc.scm
index 1457e379..0a076e37 100644
--- a/csc.scm
+++ b/csc.scm
@@ -32,8 +32,10 @@
 (define-foreign-variable INSTALL_BIN_HOME c-string "C_INSTALL_BIN_HOME")
 (define-foreign-variable INSTALL_CC c-string "C_INSTALL_CC")
 (define-foreign-variable INSTALL_CXX c-string "C_INSTALL_CXX")
+(define-foreign-variable TARGET_RC_COMPILER c-string "C_INSTALL_RC_COMPILER")
 (define-foreign-variable TARGET_CC c-string "C_TARGET_CC")
 (define-foreign-variable TARGET_CXX c-string "C_TARGET_CXX")
+(define-foreign-variable TARGET_RC_COMPILER c-string "C_TARGET_RC_COMPILER")
 (define-foreign-variable TARGET_CFLAGS c-string "C_TARGET_CFLAGS")
 (define-foreign-variable INSTALL_CFLAGS c-string "C_INSTALL_CFLAGS")
 (define-foreign-variable TARGET_LDFLAGS c-string "C_TARGET_LDFLAGS")
@@ -99,6 +101,7 @@
 
 (define compiler (quotewrap (if host-mode INSTALL_CC TARGET_CC)))
 (define c++-compiler (quotewrap (if host-mode INSTALL_CXX TARGET_CXX)))
+(define rc-compiler (quotewrap (if host-mode INSTALL_RC_COMPILER TARGET_RC_COMPILER)))
 (define linker (quotewrap (if msvc "link" (if host-mode INSTALL_CC TARGET_CC))))
 (define c++-linker (quotewrap (if msvc "link" (if host-mode INSTALL_CXX TARGET_CXX))))
 (define object-extension (if msvc "obj" "o"))
@@ -111,6 +114,7 @@
 (define default-translation-optimization-options '())
 (define pic-options (if (or mingw msvc) '("-DPIC") '("-fPIC" "-DPIC")))
 (define windows-shell WINDOWS_SHELL)
+(define generate-manifest #f)
 
 (define default-library
   (string-append
@@ -136,7 +140,7 @@
     -analyze-only -keep-shadowed-macros -inline-global -ignore-repository
     -no-symbol-escape -no-parentheses-synonyms -r5rs-syntax
     -no-argc-checks -no-bound-checks -no-procedure-checks -no-compiler-syntax
-    -emit-all-import-libraries -setup-mode -unboxing
+    -emit-all-import-libraries -setup-mode -unboxing -no-elevation
     -no-procedure-checks-for-usual-bindings))
 
 (define-constant complex-options
@@ -174,7 +178,9 @@
 (define scheme-files '())
 (define generated-scheme-files '())
 (define c-files '())
+(define rc-files '())
 (define generated-c-files '())
+(define generated-rc-files '())
 (define object-files '())
 (define generated-object-files '())
 (define cpp-mode #f)
@@ -478,6 +484,8 @@ Usage: #{csc} FILENAME | OPTION ...
     -private-repository            load extensions from executable path
     -deployed                      compile support file to be used from a deployed 
                                     executable
+    -no-elevation                  embed manifest on Windows to supress elevation
+                                    warnings for programs named `install' or `setup'
 
   Options can be collapsed if unambiguous, so
 
@@ -532,12 +540,9 @@ EOF
 	     (when show-libs (print* (linker-libraries #t) #\space))
 	     (newline)
 	     (exit) )
-	   #; ;UNUSED
-	   (when (null? scheme-files)
-	     (set! scheme-files c-files)
-	     (set! c-files '()) )
 	   (cond [(null? scheme-files)
-		  (when (and (null? c-files) (null? object-files))
+		  (when (and (null? c-files) 
+			     (null? object-files))
 		    (quit "no source files specified") )
 		  (let ((f0 (last (if (null? c-files) object-files c-files))))
 		    (unless target-filename
@@ -642,10 +647,17 @@ EOF
 		(set! rest (cdr rest)) ]
 	       ((-private-repository)
 		(use-private-repository))
+	       ((-no-elevation)
+		(set! generate-manifest #t))
 	       [(-gui
 		 -windows |-W|)		;DEPRECATED
 		(set! gui #t)
 		(set! compile-options (cons "-DC_GUI" compile-options))
+		(set! object-files 
+		  (cons (make-pathname 
+			 INSTALL_SHARE_HOME "chicken.rc"
+			 object-extension) 
+			object-files))
 		(when (or msvc mingw)
 		  (cond
 		   (mingw
@@ -778,9 +790,12 @@ EOF
 			     [else (quit "invalid option `~A'" s)] ) ]
 		      [(file-exists? arg)
 		       (let-values ([(dirs name ext) (decompose-pathname arg)])
-			 (cond [(not ext) (set! scheme-files (append scheme-files (list arg)))]
+			 (cond [(not ext)
+				(set! scheme-files (append scheme-files (list arg)))]
 			       [(member ext '("h" "c"))
 				(set! c-files (append c-files (list arg))) ]
+			       ((string-ci=? ext "rc")
+				(set! rc-files (append rc-files (list arg))) )
 			       [(member ext '("cpp" "C" "cc" "cxx" "hpp"))
 				(when osx (set! compile-options (cons "-no-cpp-precomp" compile-options)))
 				(set! cpp-mode #t)
@@ -827,7 +842,7 @@ EOF
   (unless keep-files (for-each $delete-file generated-scheme-files)) )
 
 
-;;; Compile all C files:
+;;; Compile all C  and .rc files:
 
 (define (run-compilation)
   (let ((ofiles '()))
@@ -845,8 +860,24 @@ EOF
 	 (set! generated-object-files (cons fo generated-object-files))
 	 (set! ofiles (cons fo ofiles))))
      c-files)
+    (when (and generate-manifest (eq? 'windows (software-type)))
+      (let ((rcf (pathname-replace-extension target-filename "rc")))
+	(create-win-manifest (pathname-file target-filename) rcf)
+	(set! rc-files (cons rcf rc-files))
+	(set! generated-rc-files (cons rcf generated-rc-files))))
+    (for-each
+     (lambda (f)
+       (let ((fo (string-append f "." object-extension)))
+	 (command
+	  (string-intersperse
+	   (list rc-compiler (quotewrap f) (quotewrap fo))))
+	 (set! generated-object-files (cons fo generated-object-files))
+	 (set! ofiles (cons fo ofiles))))
+     rc-files)
     (set! object-files (append (reverse ofiles) object-files)) ; put generated object files first
-    (unless keep-files (for-each $delete-file generated-c-files)) ) )
+    (unless keep-files 
+      (for-each $delete-file generated-c-files)
+      (for-each $delete-file generated-rc-files))))
 
 (define (compiler-options)
   (string-intersperse
@@ -1049,6 +1080,7 @@ EOF
 	 d2)))
     (let ((pl (make-pathname d0 "Info.plist")))
       (unless (file-exists? pl)
+	(when verbose (print "generating " pl))
 	(with-output-to-file pl
 	  (cut print #<#EOF
 <?xml version="1.0" encoding="UTF-8"?>
@@ -1071,6 +1103,28 @@ EOF
 )))
       d)))
 
+(define (create-win-manifest prg rcfname)
+  (when verbose (print "generating " rcfname))
+  (with-output-to-file rcfname
+    (lambda ()
+      (print #<#EOF
+1 24 MOVEABLE PURE
+BEGIN
+  "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>\r\n"
+  "<assembly xmlns=""urn:schemas-microsoft-com:asm.v1"" manifestVersion=""1.0"">\r\n"
+  "  <assemblyIdentity version=""1.0.0.0"" processorArchitecture=""*"" name=""#{prg}"" type=""win32""/>\r\n"
+  "  <ms_asmv2:trustInfo xmlns:ms_asmv2=""urn:schemas-microsoft-com:asm.v2"">\r\n"
+  "    <ms_asmv2:security>\r\n"
+  "      <ms_asmv2:requestedPrivileges>\r\n"
+  "        <ms_asmv2:requestedExecutionLevel level=""asInvoker"" uiAccess=""false""/>\r\n"
+  "      </ms_asmv2:requestedPrivileges>\r\n"
+  "    </ms_asmv2:security>\r\n"
+  "  </ms_asmv2:trustInfo>\r\n"
+  "</assembly>\r\n"
+END
+EOF
+) ) ) )
+
 
 ;;; Run it:
 
diff --git a/defaults.make b/defaults.make
index e57128be..1b94ced8 100644
--- a/defaults.make
+++ b/defaults.make
@@ -96,6 +96,13 @@ C_COMPILER ?= gcc
 CXX_COMPILER ?= g++
 LIBRARIAN ?= ar
 endif
+ifdef WINDOWS
+ifdef HOSTSYSTEM
+RC_COMPILER ?= $(HOSTSYSTEM)-windres
+else
+RC_COMPILER ?= windres
+endif
+endif
 LINKER ?= $(C_COMPILER)
 ifdef WINDOWS_SHELL
 REMOVE_COMMAND ?= del
@@ -123,9 +130,11 @@ HOST_LIBRARIAN ?= $(LIBRARIAN)
 ifdef TARGETSYSTEM
 TARGET_C_COMPILER ?= $(TARGETSYSTEM)-$(C_COMPILER)
 TARGET_CXX_COMPILER ?= $(TARGETSYSTEM)-$(CXX_COMPILER)
+TARGET_RC_COMPILER ?= $(TARGETSYSTEM)-$(RC_COMPILER)
 else
 TARGET_C_COMPILER ?= $(C_COMPILER)
 TARGET_CXX_COMPILER ?= $(CXX_COMPILER)
+TARGET_RC_COMPILER ?= $(RC_COMPILER)
 endif
 
 TARGET_C_COMPILER_OPTIONS ?= $(C_COMPILER_OPTIONS)
@@ -345,6 +354,9 @@ TARGETS += $(TARGETLIBS) $(CHICKEN_SHARED_EXECUTABLE) \
 	$(CHICKEN_BUG_PROGRAM)$(EXE) \
 	$(IMPORT_LIBRARIES:%=%.import.so)
 endif
+ifdef WINDOWS
+TARGETS += chicken.rc$(O)
+endif
 
 # main rule
 
@@ -367,6 +379,9 @@ endif
 	echo "#ifndef C_INSTALL_CXX" >>$@
 	echo "# define C_INSTALL_CXX \"$(CXX_COMPILER)\"" >>$@
 	echo "#endif" >>$@
+	echo "#ifndef C_INSTALL_RC_COMPILER" >>$@
+	echo "# define C_INSTALL_RC_COMPILER \"$(RC_COMPILER)\"" >>$@
+	echo "#endif" >>$@
 	echo "#ifndef C_INSTALL_CFLAGS" >>$@
 	echo "# define C_INSTALL_CFLAGS \"$(C_COMPILER_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
 	echo "#endif" >>$@
@@ -421,6 +436,9 @@ endif
 	echo "#ifndef C_TARGET_CXX" >>$@
 	echo "# define C_TARGET_CXX \"$(TARGET_CXX_COMPILER)\"" >>$@
 	echo "#endif" >>$@
+	echo "#ifndef C_TARGET_RC_COMPILER" >>$@
+	echo "# define C_TARGET_RC_COMPILER \"$(TARGET_RC_COMPILER)\"" >>$@
+	echo "#endif" >>$@
 	echo "#ifndef C_TARGET_CFLAGS" >>$@
 	echo "# define C_TARGET_CFLAGS \"$(TARGET_C_COMPILER_OPTIONS) $(TARGET_C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
 	echo "#endif" >>$@
@@ -475,3 +493,41 @@ endif
 	echo "#endif" >>$@
 	echo "/* END OF FILE */" >>$@
 endif
+
+ifndef CUSTOM_RC_FILE
+chicken-install.rc:
+	echo '/* GENERATED */' >$@
+	echo '1 24 MOVEABLE PURE' >>$@
+	echo 'BEGIN' >>$@
+	echo '  "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>\r\n"' >>$@
+	echo '  "<assembly xmlns=""urn:schemas-microsoft-com:asm.v1"" manifestVersion=""1.0"">\r\n"' >>$@
+	echo '  "  <assemblyIdentity version=""1.0.0.0"" processorArchitecture=""*"" name=""chicken-install"" type=""win32""/>\r\n"' >>$@
+	echo '  "  <ms_asmv2:trustInfo xmlns:ms_asmv2=""urn:schemas-microsoft-com:asm.v2"">\r\n"' >>$@
+	echo '  "    <ms_asmv2:security>\r\n"' >>$@
+	echo '  "      <ms_asmv2:requestedPrivileges>\r\n"' >>$@
+	echo '  "        <ms_asmv2:requestedExecutionLevel level=""asInvoker"" uiAccess=""false""/>\r\n"' >>$@
+	echo '  "      </ms_asmv2:requestedPrivileges>\r\n"' >>$@
+	echo '  "    </ms_asmv2:security>\r\n"' >>$@
+	echo '  "  </ms_asmv2:trustInfo>\r\n"' >>$@
+	echo '  "</assembly>\r\n"' >>$@
+	echo 'END' >>$@
+	echo '/* END OF FILE */' >>$@
+
+chicken-uninstall.rc:
+	echo '/* GENERATED */' >$@
+	echo '1 24 MOVEABLE PURE' >>$@
+	echo 'BEGIN' >>$@
+	echo '  "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?>\r\n"' >>$@
+	echo '  "<assembly xmlns=""urn:schemas-microsoft-com:asm.v1"" manifestVersion=""1.0"">\r\n"' >>$@
+	echo '  "  <assemblyIdentity version=""1.0.0.0"" processorArchitecture=""*"" name=""$(PROGRAM_PREFIX)chicken-install$(PROGRAM_SUFFIX)"" type=""win32""/>\r\n"' >>$@
+	echo '  "  <ms_asmv2:trustInfo xmlns:ms_asmv2=""urn:schemas-microsoft-com:asm.v2"">\r\n"' >>$@
+	echo '  "    <ms_asmv2:security>\r\n"' >>$@
+	echo '  "      <ms_asmv2:requestedPrivileges>\r\n"' >>$@
+	echo '  "        <ms_asmv2:requestedExecutionLevel level=""asInvoker"" uiAccess=""false""/>\r\n"' >>$@
+	echo '  "      </ms_asmv2:requestedPrivileges>\r\n"' >>$@
+	echo '  "    </ms_asmv2:security>\r\n"' >>$@
+	echo '  "  </ms_asmv2:trustInfo>\r\n"' >>$@
+	echo '  "</assembly>\r\n"' >>$@
+	echo 'END' >>$@
+	echo '/* END OF FILE */' >>$@
+endif
diff --git a/rules.make b/rules.make
index c7ea82e7..88caeb09 100644
--- a/rules.make
+++ b/rules.make
@@ -668,6 +668,13 @@ chicken-bug$(O): chicken-bug.c chicken.h $(CHICKEN_CONFIG_H)
 	  $(C_COMPILER_STATIC_OPTIONS) \
 	  $(C_COMPILER_COMPILE_OPTION) $(C_COMPILER_OPTIMIZATION_OPTIONS) $< $(C_COMPILER_OUTPUT)
 
+# resource objects
+
+.SUFFIXES: .rc
+
+%.rc.o: %.rc
+	$(RC_COMPILER) $< $@
+
 # libraries
 
 .PHONY: libs
@@ -719,7 +726,7 @@ libuchicken$(A): $(APPLY_HACK_OBJECT) $(LIBUCHICKEN_STATIC_OBJECTS)
 
 .SUFFIXES: .so
 
-%.so: %.o
+%.so: %.$(O)
 	$(HOST_LINKER) $(HOST_LINKER_OPTIONS) $(HOST_LINKER_LINK_SHARED_DLOADABLE_OPTIONS) $^ $(HOST_LINKER_OUTPUT_OPTION) $@ \
 	  $(HOST_LINKER_LIBRARY_PREFIX)chicken$(HOST_LINKER_LIBRARY_SUFFIX) \
 	  $(HOST_LIBRARIES)
@@ -734,12 +741,24 @@ $(CSI_SHARED_EXECUTABLE): csi$(O) $(PRIMARY_LIBCHICKEN)
 	$(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $< $(LINKER_OUTPUT) \
           $(LINKER_LIBRARY_PREFIX)chicken$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
 
+ifneq ($(RC_COMPILER),)
+$(CHICKEN_INSTALL_PROGRAM)$(EXE): chicken-install$(O) chicken-install.rc$(O) $(PRIMARY_LIBCHICKEN)
+	$(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $< chicken-install.rc$(O) $(LINKER_OUTPUT) \
+          $(LINKER_LIBRARY_PREFIX)chicken$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
+else
 $(CHICKEN_INSTALL_PROGRAM)$(EXE): chicken-install$(O) $(PRIMARY_LIBCHICKEN)
 	$(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $< $(LINKER_OUTPUT) \
           $(LINKER_LIBRARY_PREFIX)chicken$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
+endif
+ifneq ($(RC_COMPILER),)
+$(CHICKEN_UNINSTALL_PROGRAM)$(EXE): chicken-uninstall$(O) chicken-uninstall.rc$(O) $(PRIMARY_LIBCHICKEN)
+	$(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $< chicken-uninstall.rc$(O) $(LINKER_OUTPUT) \
+          $(LINKER_LIBRARY_PREFIX)chicken$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
+else
 $(CHICKEN_UNINSTALL_PROGRAM)$(EXE): chicken-uninstall$(O) $(PRIMARY_LIBCHICKEN)
 	$(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $< $(LINKER_OUTPUT) \
           $(LINKER_LIBRARY_PREFIX)chicken$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
+endif
 $(CHICKEN_STATUS_PROGRAM)$(EXE): chicken-status$(O) $(PRIMARY_LIBCHICKEN)
 	$(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $< $(LINKER_OUTPUT) \
           $(LINKER_LIBRARY_PREFIX)chicken$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
@@ -907,6 +926,11 @@ endif
 endif
 ifeq ($(PLATFORM),macosx)
 	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)mac.r "$(DESTDIR)$(ISHAREDIR)"
+	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)CHICKEN.icns "$(DESTDIR)$(IDATADIR)"
+endif
+ifdef WINDOWS
+	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.ico "$(DESTDIR)$(IDATADIR)"
+	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.rc$(O) "$(DESTDIR)$(IDATADIR)"
 endif
 
 ifdef STATICBUILD
@@ -964,9 +988,6 @@ install-setup-files:
 	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)setup.defaults "$(DESTDIR)$(IDATADIR)"
 	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) setup-api.so "$(DESTDIR)$(IEGGDIR)"
 	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) setup-download.so "$(DESTDIR)$(IEGGDIR)"
-ifeq ($(PLATFORM),macosx)
-	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)CHICKEN.icns "$(DESTDIR)$(IDATADIR)"
-endif
 
 uninstall:
 	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)$(CHICKEN_PROGRAM)$(EXE)" \
@@ -1240,7 +1261,8 @@ ifdef USES_SONAME
 endif
 
 confclean:
-	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) chicken-config.h chicken-defaults.h
+	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) \
+	  chicken-config.h chicken-defaults.h chicken-install.rc chicken-uninstall.rc
 
 spotless: distclean testclean
 	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) library.c eval.c data-structures.c \
Trap