~ chicken-core (chicken-5) 9171d5fea8bac02833f6c103c6b7533574f31fa6


commit 9171d5fea8bac02833f6c103c6b7533574f31fa6
Author:     felix <felix@call-with-current-continuation.org>
AuthorDate: Fri Dec 8 20:27:46 2017 +0100
Commit:     Peter Bex <peter@more-magic.net>
CommitDate: Sun Dec 10 12:54:27 2017 +0100

    Build egg-tools even when doing a static build
    
    Also, avoid building dynamic extensions in this mode when compiling
    eggs.
    
    Signed-off-by: Peter Bex <peter@more-magic.net>

diff --git a/NEWS b/NEWS
index b7d8aeec..6af7064e 100644
--- a/NEWS
+++ b/NEWS
@@ -113,6 +113,9 @@
     environment variables.
   - Static compilation of eggs is now fully supported and static
     versions of compiled eggs are available by default.
+  - In a statically built chicken, the egg-tools ("chicken-install", "-status",
+    "-uninstall") are still available, but only support static compilation
+    of eggs.
 
 - Foreign function interface
   - The foreign type specifier "ssize_t" is now accepted, and "size_t"
diff --git a/README b/README
index 3920775f..dfc87c4e 100644
--- a/README
+++ b/README
@@ -167,13 +167,11 @@ _/        _/    _/    _/    _/        _/  _/    _/        _/    _/_/
 
         STATICBUILD=1
           Build only static versions of the runtime library, compiler
-          and interpreter. `chicken-install', `chicken-uninstall' and
-          `chicken-status' will not be generated, as it is mostly 
-          useless unless compiled code can be loaded.
+          and interpreter.
 
-	EXTRA_CHICKEN_OPTIONS=...
-	  Additional options that should be passed to `chicken' when
-	  building the system.
+        EXTRA_CHICKEN_OPTIONS=...
+          Additional options that should be passed to `chicken' when
+          building the system.
 
         C_COMPILER_OPTIMIZATION_OPTIONS=...
           Override built-in C compiler optimization options. Available
diff --git a/defaults.make b/defaults.make
index 04c070ea..24b787be 100644
--- a/defaults.make
+++ b/defaults.make
@@ -298,9 +298,7 @@ CHICKEN_SHARED_EXECUTABLE = $(CHICKEN_PROGRAM)-shared$(EXE)
 CSI_SHARED_EXECUTABLE = $(CSI_PROGRAM)-shared$(EXE)
 TARGETLIBS ?= lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A)
 TARGETS += $(TARGETLIBS) $(CHICKEN_STATIC_EXECUTABLE) \
-	$(CSI_STATIC_EXECUTABLE) $(CHICKEN_PROFILE_PROGRAM)$(EXE) \
-	$(CSC_PROGRAM)$(EXE) \
-	$(CHICKEN_BUG_PROGRAM)$(EXE) $(CHICKEN_DO_PROGRAM)$(EXE) $(CHICKEN_DEBUGGER_PROGRAM)
+	$(CSI_STATIC_EXECUTABLE)
 else
 CHICKEN_STATIC_EXECUTABLE = $(CHICKEN_PROGRAM)-static$(EXE)
 CSI_STATIC_EXECUTABLE = $(CSI_PROGRAM)-static$(EXE)
@@ -308,12 +306,18 @@ CHICKEN_SHARED_EXECUTABLE = $(CHICKEN_PROGRAM)$(EXE)
 CSI_SHARED_EXECUTABLE = $(CSI_PROGRAM)$(EXE)
 TARGETLIBS ?= lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) $(LIBCHICKEN_SO_FILE)
 TARGETS += $(TARGETLIBS) $(CHICKEN_SHARED_EXECUTABLE) \
-	$(CSI_SHARED_EXECUTABLE) $(CHICKEN_PROFILE_PROGRAM)$(EXE) \
-	$(CSC_PROGRAM)$(EXE) $(CHICKEN_INSTALL_PROGRAM)$(EXE) $(CHICKEN_UNINSTALL_PROGRAM)$(EXE) \
-	$(CHICKEN_STATUS_PROGRAM)$(EXE) \
-	$(CHICKEN_BUG_PROGRAM)$(EXE) $(CHICKEN_DO_PROGRAM)$(EXE) $(CHICKEN_DEBUGGER_PROGRAM) \
+	$(CSI_SHARED_EXECUTABLE) \
 	$(IMPORT_LIBRARIES:%=%.import.so)
 endif
+
+TARGETS += $(CHICKEN_INSTALL_PROGRAM)$(EXE) \
+	$(CHICKEN_UNINSTALL_PROGRAM)$(EXE) \
+	$(CHICKEN_STATUS_PROGRAM)$(EXE) \
+	$(CHICKEN_PROFILE_PROGRAM)$(EXE) \
+	$(CSC_PROGRAM)$(EXE) \
+	$(CHICKEN_DO_PROGRAM)$(EXE) \
+	$(CHICKEN_DEBUGGER_PROGRAM)
+
 ifdef WINDOWS
 TARGETS += chicken.rc$(O)
 endif
diff --git a/egg-compile.scm b/egg-compile.scm
index a6e0f571..8b88bd8e 100644
--- a/egg-compile.scm
+++ b/egg-compile.scm
@@ -30,12 +30,14 @@
 (define default-dynamic-program-link-options '())
 (define default-static-extension-link-options '())
 (define default-dynamic-extension-link-options '())
-(define default-extension-linkage '(static dynamic))
 (define default-program-linkage '(dynamic))
 (define default-static-compilation-options '("-O2" "-d1"))
 (define default-dynamic-compilation-options '("-O2" "-d1"))
 (define default-import-library-compilation-options '("-O2" "-d0"))
 
+(define default-extension-linkage
+  (if staticbuild '(static) '(static dynamic)))
+
 (define +unix-executable-extension+ "")
 (define +windows-executable-extension+ ".exe")
 (define +unix-object-extension+ ".o")
@@ -411,7 +413,8 @@
                   (if (memq 'dynamic link)
                       (list (apply install-dynamic-extension ext))
                       '())
-                  (if (uses-compiled-import-library? (get-keyword mode: ext))
+                  (if (and (memq 'dynamic link)
+                           (uses-compiled-import-library? (get-keyword mode: ext)))
                       (map (lambda (mod)
                              (apply install-import-library
                                     mod (cdr ext))) ; override name
diff --git a/rules.make b/rules.make
index b44c42ec..d8fecb0a 100644
--- a/rules.make
+++ b/rules.make
@@ -63,12 +63,9 @@ MANPAGES = \
 # care of which programs should actually be installed/uninstalled
 INSTALLED_PROGRAMS = \
 	$(CHICKEN_PROGRAM) $(CSI_PROGRAM) $(CHICKEN_PROFILE_PROGRAM) \
-	$(CSC_PROGRAM) $(CHICKEN_BUG_PROGRAM) $(CHICKEN_DO_PROGRAM)
-
-ifndef STATICBUILD
-INSTALLED_PROGRAMS += $(CHICKEN_STATUS_PROGRAM) \
+	$(CSC_PROGRAM) \
+	$(CHICKEN_DO_PROGRAM) $(CHICKEN_STATUS_PROGRAM) \
 	$(CHICKEN_INSTALL_PROGRAM) $(CHICKEN_UNINSTALL_PROGRAM)
-endif
 
 # These generated files make up a bootstrapped distribution build.
 # They are not cleaned by the 'clean' target, but only by 'spotless'.
@@ -333,11 +330,9 @@ install-bin:
 # Damn. What was this for, again?
 #
 # 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_PROGRAM)$(EXE) $(CSI_PROGRAM)$(EXE) $(CSC_PROGRAM)$(EXE) $(CHICKEN_PROFILE_PROGRAM)$(EXE)
-# ifndef STATICBUILD
 # 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_INSTALL_PROGRAM)$(EXE)
 # 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_UNINSTALL_PROGRAM)$(EXE)
 # 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_STATUS_PROGRAM)$(EXE)
-# endif
 else
 install-bin: $(TARGETS) install-libs install-dev
 	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)"
@@ -359,8 +354,8 @@ else
 		$(lib).import.so "$(DESTDIR)$(IEGGDIR)" $(NL))
 endif
 
-ifndef STATICBUILD
 ifneq ($(POSTINSTALL_PROGRAM),true)
+ifndef STATICBUILD
 	$(foreach prog,$(INSTALLED_PROGRAMS),\
 		$(POSTINSTALL_PROGRAM) $(POSTINSTALL_PROGRAM_FLAGS) \
 		"$(DESTDIR)$(IBINDIR)$(SEP)$(prog)" $(NL))
@@ -369,6 +364,7 @@ ifneq ($(POSTINSTALL_PROGRAM),true)
 		$(POSTINSTALL_PROGRAM) $(POSTINSTALL_PROGRAM_FLAGS) \
 		"$(DESTDIR)$(IEGGDIR)$(SEP)$(import-lib).import.so" $(NL))
 endif
+endif
 ifeq ($(CROSS_CHICKEN)$(DESTDIR),0)
 	-$(IBINDIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM) -update-db
 else
@@ -380,7 +376,6 @@ endif
 ifdef WINDOWS_SHELL
 	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) $(SRCDIR)csibatch.bat "$(DESTDIR)$(IBINDIR)"
 endif
-endif
 
 install-other-files:
 	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)"
@@ -913,7 +908,7 @@ clean:
 	  $(CHICKEN_INSTALL_PROGRAM)$(EXE) \
 	  $(CHICKEN_UNINSTALL_PROGRAM)$(EXE) \
 	  $(CHICKEN_STATUS_PROGRAM)$(EXE) \
-	  $(CHICKEN_BUG_PROGRAM)$(EXE) *$(O) \
+	  *$(O) \
 	  $(CHICKEN_DO_PROGRAM)$(EXE) \
 	  $(CHICKEN_DEBUGGER_PROGRAM) \
 	  $(LIBCHICKEN_SO_FILE) \
Trap