~ chicken-core (chicken-5) 217883572c2ae7593c910fa377ae05663c90314a


commit 217883572c2ae7593c910fa377ae05663c90314a
Author:     Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Fri Jan 24 23:24:29 2014 +0100
Commit:     Mario Domenech Goulart <mario.goulart@gmail.com>
CommitDate: Wed Feb 5 22:08:45 2014 -0200

    Fix SONAME handling on Windows
    
    This removes unnecessarily duplicated rules for chicken-defaults.h from Cygwin
    Makefile and fixes MingW makefile to set the new USES_SONAME definition.
    
    The only actual difference between Makefile.cygwin and defaults.make was that
    it set TARGET_RUN_LIB_HOME to TARGET_PREFIX/bin - now make this dependent on
    DLLSINPATH, which also controls where the library is copied during install.
    
    Signed-off-by: Mario Domenech Goulart <mario.goulart@gmail.com>

diff --git a/Makefile.cygwin b/Makefile.cygwin
index 6989ab8b..abe7fa05 100644
--- a/Makefile.cygwin
+++ b/Makefile.cygwin
@@ -80,7 +80,6 @@ APPLY_HACK_OBJECT = apply-hack.$(ARCH)$(O)
 
 # select default and internal settings
 
-CUSTOM_CHICKEN_DEFAULTS=1
 include $(SRCDIR)/defaults.make
 
 LIBCHICKEN_SO_LIBRARIES = $(LIBRARIES)
@@ -127,141 +126,4 @@ ifdef HACKED_APPLY
 endif
 	cat chicken-defaults.h >>$@
 
-chicken-defaults.h:
-	echo "/* generated */" >$@
-	echo "#define C_CHICKEN_PROGRAM \"$(CHICKEN_PROGRAM)$(EXE)\"" >>$@
-	echo "#ifndef C_INSTALL_CC" >>$@
-	echo "# define C_INSTALL_CC \"$(C_COMPILER)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_CXX" >>$@
-	echo "# define C_INSTALL_CXX \"$(CXX_COMPILER)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_POSTINSTALL_PROGRAM" >>$@
-	echo "# define C_INSTALL_POSTINSTALL_PROGRAM \"$(POSTINSTALL_PROGRAM)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_CFLAGS" >>$@
-	echo "# define C_INSTALL_CFLAGS \"$(C_COMPILER_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_LDFLAGS" >>$@
-	echo "# define C_INSTALL_LDFLAGS \"$(LINKER_OPTIONS) $(LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_PREFIX" >>$@
-	echo "# define C_INSTALL_PREFIX \"$(PREFIX)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_SHARE_HOME" >>$@
-	echo "# define C_INSTALL_SHARE_HOME \"$(DATADIR)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_BIN_HOME" >>$@
-	echo "# define C_INSTALL_BIN_HOME \"$(BINDIR)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_EGG_HOME" >>$@
-	echo "# define C_INSTALL_EGG_HOME \"$(EGGDIR)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_LIB_HOME" >>$@
-	echo "# define C_INSTALL_LIB_HOME \"$(LIBDIR)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_LIB_NAME" >>$@
-	echo "# define C_INSTALL_LIB_NAME \"$(INSTALL_LIB_NAME)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_STATIC_LIB_HOME" >>$@
-	echo "# define C_INSTALL_STATIC_LIB_HOME \"$(LIBDIR)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_INCLUDE_HOME" >>$@
-	echo "# define C_INSTALL_INCLUDE_HOME \"$(INCDIR)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_MORE_LIBS" >>$@
-	echo "# define C_INSTALL_MORE_LIBS \"$(LIBRARIES)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_INSTALL_MORE_STATIC_LIBS" >>$@
-	echo "# define C_INSTALL_MORE_STATIC_LIBS \"$(LIBRARIES)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_DEFAULT_TARGET_STACK_SIZE" >>$@
-	echo "# define C_DEFAULT_TARGET_STACK_SIZE $(NURSERY)" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_DEFAULT_TARGET_HEAP_SIZE" >>$@
-	echo "# define C_DEFAULT_TARGET_HEAP_SIZE 0" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_STACK_GROWS_DOWNWARD" >>$@
-	echo "# define C_STACK_GROWS_DOWNWARD $(STACKDIRECTION)" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_MORE_LIBS" >>$@
-	echo "# define C_TARGET_MORE_LIBS \"$(TARGET_LIBRARIES)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_MORE_LIBS" >>$@
-	echo "# define C_TARGET_MORE_LIBS \"$(TARGET_LIBRARIES)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_MORE_STATIC_LIBS" >>$@
-	echo "# define C_TARGET_MORE_STATIC_LIBS \"$(TARGET_LIBRARIES)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_CC" >>$@
-	echo "# define C_TARGET_CC \"$(TARGET_C_COMPILER)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_CXX" >>$@
-	echo "# define C_TARGET_CXX \"$(TARGET_CXX_COMPILER)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_CFLAGS" >>$@
-	echo "# define C_TARGET_CFLAGS \"$(TARGET_C_COMPILER_OPTIONS) $(TARGET_C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_LDFLAGS" >>$@
-	echo "# define C_TARGET_LDFLAGS \"$(TARGET_LINKER_OPTIONS) $(TARGET_LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_FEATURES" >>$@
-	echo "# define C_TARGET_FEATURES \"$(TARGET_FEATURES)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_CROSS_CHICKEN" >>$@
-	echo "# define C_CROSS_CHICKEN $(CROSS_CHICKEN)" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_PREFIX" >>$@
-	echo "# define C_TARGET_PREFIX \"$(TARGET_PREFIX)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_BIN_HOME" >>$@
-	echo "# define C_TARGET_BIN_HOME \"$(TARGET_PREFIX)/bin\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_LIB_HOME" >>$@
-	echo "# define C_TARGET_LIB_HOME \"$(TARGET_PREFIX)/lib\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_LIB_NAME" >>$@
-	echo "# define C_TARGET_LIB_NAME \"$(TARGET_LIB_NAME)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_RUN_LIB_HOME" >>$@
-	echo "# define C_TARGET_RUN_LIB_HOME \"$(TARGET_RUN_PREFIX)/bin\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_SHARE_HOME" >>$@
-	echo "# define C_TARGET_SHARE_HOME \"$(TARGET_PREFIX)/share\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_INCLUDE_HOME" >>$@
-	echo "# define C_TARGET_INCLUDE_HOME \"$(TARGET_PREFIX)/include/chicken\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_TARGET_STATIC_LIB_HOME" >>$@
-	echo "# define C_TARGET_STATIC_LIB_HOME \"$(TARGET_PREFIX)/lib\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_CHICKEN_PROGRAM" >>$@
-	echo "# define C_CHICKEN_PROGRAM \"$(CHICKEN_PROGRAM)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_CSC_PROGRAM" >>$@
-	echo "# define C_CSC_PROGRAM \"$(CSC_PROGRAM)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_CSI_PROGRAM" >>$@
-	echo "# define C_CSI_PROGRAM \"$(CSI_PROGRAM)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_CHICKEN_BUG_PROGRAM" >>$@
-	echo "# define C_CHICKEN_BUG_PROGRAM \"$(CHICKEN_BUG_PROGRAM)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_CHICKEN_INSTALL_PROGRAM" >>$@
-	echo "# define C_CHICKEN_INSTALL_PROGRAM \"$(CHICKEN_INSTALL_PROGRAM)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_CHICKEN_UNINSTALL_PROGRAM" >>$@
-	echo "# define C_CHICKEN_UNINSTALL_PROGRAM \"$(CHICKEN_UNINSTALL_PROGRAM)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_CHICKEN_STATUS_PROGRAM" >>$@
-	echo "# define C_CHICKEN_STATUS_PROGRAM \"$(CHICKEN_STATUS_PROGRAM)\"" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_WINDOWS_SHELL" >>$@
-	echo "# define C_WINDOWS_SHELL 0" >>$@
-	echo "#endif" >>$@
-	echo "#ifndef C_BINARY_VERSION" >>$@
-	echo "# define C_BINARY_VERSION $(BINARYVERSION)" >>$@
-	echo "#endif" >>$@
-	echo "/* END OF FILE */" >>$@
-
 include $(SRCDIR)/rules.make
diff --git a/Makefile.mingw b/Makefile.mingw
index 4027171c..9f803e70 100644
--- a/Makefile.mingw
+++ b/Makefile.mingw
@@ -134,9 +134,6 @@ endif
 	echo #ifndef C_INSTALL_CXX >>$@
 	echo # define C_INSTALL_CXX "$(CXX_COMPILER)" >>$@
 	echo #endif >>$@
-	echo #ifndef C_INSTALL_POSTINSTALL_PROGRAM >>$@
-	echo # define C_INSTALL_POSTINSTALL_PROGRAM "$(POSTINSTALL_PROGRAM)" >>$@
-	echo #endif" >>$@
 	echo #ifndef C_INSTALL_RC_COMPILER >>$@
 	echo # define C_INSTALL_RC_COMPILER "$(RC_COMPILER)" >>$@
 	echo #endif >>$@
@@ -222,7 +219,7 @@ endif
 	echo # define C_TARGET_LIB_NAME "$(TARGET_LIB_NAME)" >>$@
 	echo #endif >>$@
 	echo #ifndef C_TARGET_RUN_LIB_HOME >>$@
-	echo # define C_TARGET_RUN_LIB_HOME "$(TARGET_PREFIX)/lib" >>$@
+	echo # define C_TARGET_RUN_LIB_HOME "$(TARGET_PREFIX)/bin" >>$@
 	echo #endif >>$@
 	echo #ifndef C_TARGET_SHARE_HOME >>$@
 	echo # define C_TARGET_SHARE_HOME "$(TARGET_PREFIX)/share" >>$@
@@ -253,6 +250,13 @@ endif
 	echo #endif >>$@
 	echo #ifndef C_BINARY_VERSION >>$@
 	echo # define C_BINARY_VERSION $(BINARYVERSION) >>$@
+	echo #endif >>$@
+	echo #ifndef C_USES_SONAME >>$@
+ifdef USES_SONAME
+	echo # define C_USES_SONAME 1 >>$@
+else
+	echo # define C_USES_SONAME 0 >>$@
+endif
 	echo #endif >>$@
 	echo /* END OF FILE */ >>$@
 
diff --git a/csc.scm b/csc.scm
index 5b3c8dfc..a39c3f53 100644
--- a/csc.scm
+++ b/csc.scm
@@ -68,7 +68,6 @@
 
 (define mingw (eq? (build-platform) 'mingw32))
 (define osx (eq? (software-version) 'macosx))
-(define win mingw)
 (define cygwin (eq? (build-platform) 'cygwin))
 (define aix (eq? (build-platform) 'aix))
 
@@ -962,11 +961,9 @@ EOF
 (define (lib-path)
   (prefix "" 
 	  "lib"
-	  (if win
-	      INSTALL_BIN_HOME
-	      (if host-mode
-		  INSTALL_LIB_HOME
-		  TARGET_RUN_LIB_HOME))))
+	  (if host-mode
+	      INSTALL_LIB_HOME
+	      TARGET_RUN_LIB_HOME)))
 
 (define (target-lib-path)
   (let ((tdir TARGET_LIB_HOME))
@@ -981,7 +978,7 @@ EOF
 	      (target-lib-path) 
 	      libchicken
 	      (cond (osx "dylib")
-		    ((or win cygwin) "dll")
+		    ((or mingw cygwin) "dll")
 		    (else (string-append
                            "so."
                            (number->string BINARY_VERSION)))))))
diff --git a/defaults.make b/defaults.make
index a32dfbd7..8cf5dffb 100644
--- a/defaults.make
+++ b/defaults.make
@@ -340,6 +340,9 @@ all: $(TARGETS)
 
 # generic part of chicken-config.h
 
+# IMPORTANT: If you change anything here, remember to make a
+# corresponding change in the makefiles which have
+# CUSTOM_CHICKEN_DEFAULTS (currently only mingw)
 ifndef CUSTOM_CHICKEN_DEFAULTS
 chicken-defaults.h:
 ifdef OPTIMIZE_FOR_SPEED
@@ -443,7 +446,11 @@ endif
 	echo "# define C_TARGET_LIB_NAME \"$(TARGET_LIB_NAME)\"" >>$@
 	echo "#endif" >>$@
 	echo "#ifndef C_TARGET_RUN_LIB_HOME" >>$@
+ifdef DLLSINPATH
+	echo "# define C_TARGET_RUN_LIB_HOME \"$(TARGET_RUN_PREFIX)/bin\"" >>$@
+else
 	echo "# define C_TARGET_RUN_LIB_HOME \"$(TARGET_RUN_PREFIX)/lib\"" >>$@
+endif
 	echo "#endif" >>$@
 	echo "#ifndef C_TARGET_SHARE_HOME" >>$@
 	echo "# define C_TARGET_SHARE_HOME \"$(TARGET_PREFIX)/share\"" >>$@
@@ -494,6 +501,7 @@ endif
 	echo "#endif" >>$@
 	echo "/* END OF FILE */" >>$@
 endif
+# IMPORTANT: Did you read the note at the start of this Make rule?
 
 ifndef CUSTOM_RC_FILE
 chicken-install.rc:
Trap