~ chicken-core (chicken-5) b1a32afc675a74753691778d8d3604801b6c9d34


commit b1a32afc675a74753691778d8d3604801b6c9d34
Author:     Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Thu Jun 12 21:13:49 2014 +0200
Commit:     Christian Kellermann <ckeen@pestilenz.org>
CommitDate: Thu Jun 19 19:59:16 2014 +0200

    Make the handling of variables for directory prefixes a little more consistent with common UNIX practice, and support setting the important ones from Make through the environment (by using ?=-style instead of =-style assignment)
    
    Unfortunately this is slightly backwards-incompatible, as it renames
    INCDIR and changes the meaning of MANDIR.  I think sticking with
    common practice is more important than backwards compat for the small
    set of cases where these variables will be overridden.
    
    Signed-off-by: Christian Kellermann <ckeen@pestilenz.org>

diff --git a/NEWS b/NEWS
index df838ca9..74f06980 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,15 @@
     C_get_environment_variable[_2] functions.
   - C_mutate2 has been deprecated in favor of C_mutate
 
+- Build system
+  - MANDIR was renamed to MAN1DIR and TOPMANDIR was renamed to MANDIR
+     in order to comply with standard Makefile practice in UNIX.
+  - INCDIR was renamed to CHICKENINCDIR, and now derives from
+     INCLUDEDIR, which defaults to $(PREFIX)/include
+  - BINDIR, LIBDIR, SHAREDIR, INCLUDEDIR, MANDIR, MAN1DIR, DOCDIR,
+     CHICKENINCDIR and CHICKENLIBDIR will now also be taken from
+     the environment, if present (like PLATFORM, DESTDIR and PREFIX).
+
 4.9.0
 
 - Security fixes
diff --git a/defaults.make b/defaults.make
index 6deb228e..52867819 100644
--- a/defaults.make
+++ b/defaults.make
@@ -37,23 +37,25 @@ SEP ?= /
 DESTDIR ?=
 PREFIX ?= /usr/local
 
-BINDIR = $(PREFIX)/bin
-LIBDIR = $(PREFIX)/lib
-SHAREDIR = $(PREFIX)/share
-DATADIR = $(SHAREDIR)/$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)
-TOPMANDIR = $(SHAREDIR)/man
-MANDIR = $(TOPMANDIR)/man1
-INCDIR = $(PREFIX)/include/$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)
-DOCDIR = $(DATADIR)/doc
+BINDIR ?= $(PREFIX)/bin
+LIBDIR ?= $(PREFIX)/lib
+SHAREDIR ?= $(PREFIX)/share
+DATADIR ?= $(SHAREDIR)/$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)
+INCLUDEDIR ?= $(PREFIX)/include
+MANDIR ?= $(SHAREDIR)/man
+
+DOCDIR ?= $(DATADIR)/doc
 VARDIR ?= $(LIBDIR)
-CHICKENLIBDIR = $(VARDIR)/$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)
+MAN1DIR ?= $(MANDIR)/man1
+CHICKENLIBDIR ?= $(VARDIR)/$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)
 EGGDIR ?= $(CHICKENLIBDIR)/$(BINARYVERSION)
+CHICKENINCDIR ?= $(INCLUDEDIR)/$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)
 
 # For the windows shell, we must distinguish between paths built into
 # binaries (system calls may use slash as a separator) and paths
 # passed to shell commands when installing.  We prefix the latter with
 # an 'I':
-INST_DIRS=BINDIR LIBDIR SHAREDIR DATADIR MANDIR INCDIR DOCDIR EGGDIR
+INST_DIRS=BINDIR LIBDIR SHAREDIR DATADIR MAN1DIR CHICKENINCDIR DOCDIR EGGDIR
 $(foreach dir,$(INST_DIRS),$(eval I$(dir)=$(subst /,$(SEP),$($(dir)))))
 
 INSTALL_LIB_NAME = $(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)
@@ -361,7 +363,7 @@ endif
 	$(call echo, >>, $@,# define C_INSTALL_STATIC_LIB_HOME "$(LIBDIR)")
 	$(call echo, >>, $@,#endif)
 	$(call echo, >>, $@,#ifndef C_INSTALL_INCLUDE_HOME)
-	$(call echo, >>, $@,# define C_INSTALL_INCLUDE_HOME "$(INCDIR)")
+	$(call echo, >>, $@,# define C_INSTALL_INCLUDE_HOME "$(CHICKENINCDIR)")
 	$(call echo, >>, $@,#endif)
 	$(call echo, >>, $@,#ifndef C_INSTALL_MORE_LIBS)
 	$(call echo, >>, $@,# define C_INSTALL_MORE_LIBS "$(LIBRARIES)")
diff --git a/rules.make b/rules.make
index 05a1a49d..e12632ec 100644
--- a/rules.make
+++ b/rules.make
@@ -324,14 +324,14 @@ install-dev: install-libs
 	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)"
 	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ISHAREDIR)"
 	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IEGGDIR)"
-	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IINCDIR)"
+	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)"
 	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) "$(DESTDIR)$(ILIBDIR)"
 ifneq ($(POSTINSTALL_STATIC_LIBRARY),true)
 	$(POSTINSTALL_STATIC_LIBRARY) $(POSTINSTALL_STATIC_LIBRARY_FLAGS) "$(ILIBDIR)$(SEP)libchicken$(A)"
 endif
-	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.h "$(DESTDIR)$(IINCDIR)"
-	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(CHICKEN_CONFIG_H) "$(DESTDIR)$(IINCDIR)"
+	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.h "$(DESTDIR)$(ICHICKENINCDIR)"
+	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(CHICKEN_CONFIG_H) "$(DESTDIR)$(ICHICKENINCDIR)"
 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)"
@@ -410,12 +410,12 @@ endif
 endif
 
 install-other-files:
-	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IMANDIR)"
+	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)"
 	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDOCDIR)"
 	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 	$(foreach obj, $(MANPAGES), \
 		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) \
-		$(SRCDIR)$(obj) "$(DESTDIR)$(IMANDIR)" $(NL))
+		$(SRCDIR)$(obj) "$(DESTDIR)$(IMAN1DIR)" $(NL))
 	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDOCDIR)$(SEP)manual"
 	-$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)manual-html$(SEP)* "$(DESTDIR)$(IDOCDIR)$(SEP)manual"
 	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)README "$(DESTDIR)$(IDOCDIR)"
@@ -452,10 +452,10 @@ endif
 
 	$(foreach obj,$(MANPAGES),\
 		$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) \
-		"$(DESTDIR)$(IMANDIR)$(SEP)$(obj)" $(NL))
+		"$(DESTDIR)$(IMAN1DIR)$(SEP)$(obj)" $(NL))
 
-	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IINCDIR)$(SEP)chicken.h"
-	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IINCDIR)$(SEP)$(CHICKEN_CONFIG_H)"
+	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)$(SEP)chicken.h"
+	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)$(SEP)$(CHICKEN_CONFIG_H)"
 	$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 	$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) "$(DESTDIR)$(IEGGDIR)"
 ifdef WINDOWS_SHELL
Trap