~ chicken-core (chicken-5) /rules.make


   1# rules.make - basic build rules -*- Makefile -*-
   2#
   3# Copyright (c) 2008-2022, The CHICKEN Team
   4# Copyright (c) 2000-2007, Felix L. Winkelmann
   5# All rights reserved.
   6#
   7# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
   8# conditions are met:
   9#
  10#   Redistributions of source code must retain the above copyright notice, this list of conditions and the following
  11#     disclaimer. 
  12#   Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
  13#     disclaimer in the documentation and/or other materials provided with the distribution. 
  14#   Neither the name of the author nor the names of its contributors may be used to endorse or promote
  15#     products derived from this software without specific prior written permission. 
  16#
  17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  18# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  19# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
  20# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  24# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25# POSSIBILITY OF SUCH DAMAGE.
  26
  27VPATH=$(SRCDIR)
  28
  29# Clear Make's default rules for C programs
  30.SUFFIXES:
  31%.o : %.c
  32%: %.o
  33
  34# object files
  35
  36LIBCHICKEN_SCHEME_OBJECTS_1 = \
  37       library eval read-syntax repl data-structures pathname port file \
  38       extras lolevel tcp srfi-4 continuation $(POSIXFILE) internal \
  39       irregex scheduler debugger-client profiler stub expand modules \
  40       chicken-syntax chicken-ffi-syntax build-version
  41LIBCHICKEN_OBJECTS_1 = $(LIBCHICKEN_SCHEME_OBJECTS_1) runtime
  42LIBCHICKEN_SHARED_OBJECTS = $(LIBCHICKEN_OBJECTS_1:=$(O))
  43LIBCHICKEN_STATIC_OBJECTS = $(LIBCHICKEN_OBJECTS_1:=-static$(O)) \
  44	eval-modules-static$(O)
  45
  46COMPILER_OBJECTS_1 = \
  47	chicken batch-driver core optimizer lfa2 compiler-syntax scrutinizer support \
  48	c-platform c-backend user-pass
  49COMPILER_OBJECTS        = $(COMPILER_OBJECTS_1:=$(O))
  50COMPILER_STATIC_OBJECTS = $(COMPILER_OBJECTS_1:=-static$(O))
  51
  52# "Utility programs" is arbitrary. It includes anything but the "chicken" binary.
  53# We can't use the INSTALLED_PROGRAMS below because of the possible $(EXE)
  54# suffix and other possible mangling requested by the user. (is this supported?)
  55UTILITY_PROGRAM_OBJECTS_1 = \
  56	csc csi chicken-install chicken-uninstall chicken-status chicken-profile
  57
  58# Not all programs built are installed(?) This is the master list that takes
  59# care of which programs should actually be installed/uninstalled
  60INSTALLED_PROGRAMS = \
  61	$(CHICKEN_PROGRAM) $(CSI_PROGRAM) $(CHICKEN_PROFILE_PROGRAM) \
  62	$(CSC_PROGRAM) \
  63	$(CHICKEN_DO_PROGRAM) $(CHICKEN_STATUS_PROGRAM) \
  64	$(CHICKEN_INSTALL_PROGRAM) $(CHICKEN_UNINSTALL_PROGRAM)
  65
  66# These generated files make up a bootstrapped distribution build.
  67# They are not cleaned by the 'clean' target, but only by 'spotless'.
  68DISTFILES = $(filter-out runtime.c,$(LIBCHICKEN_OBJECTS_1:=.c)) \
  69	$(UTILITY_PROGRAM_OBJECTS_1:=.c) \
  70	$(COMPILER_OBJECTS_1:=.c) \
  71	$(IMPORT_LIBRARIES:=.import.c) \
  72	$(DYNAMIC_IMPORT_LIBRARIES:=.import.scm) \
  73	$(foreach lib,$(DYNAMIC_CHICKEN_IMPORT_LIBRARIES),chicken.$(lib).import.scm) \
  74	$(foreach lib,$(DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES),chicken.$(lib).import.scm) \
  75	$(foreach lib,$(COMPILER_OBJECTS_1),chicken.compiler.$(lib).import.scm) \
  76	eval-modules.c posixunix.c posixwin.c
  77# Remove the duplicate $(POSIXFILE) entry:
  78DISTFILES := $(sort $(DISTFILES))
  79
  80# library objects
  81
  82## Any variable that starts with "declare-" is a meta-rule. When $(call)ed
  83## it produces output that represents an instantiated rule and recipe.
  84## This output then needs to be $(eval)ed in order to be added to the
  85## ruleset evaluated by Make.  This allows us to automatically generate
  86## similar rules for long lists of targets.
  87
  88## Note: in some of the rules that follow it is important to add
  89## $(INCLUDES) last, because on raw mingw (using the DOS shell) the
  90## backslash in "-I.\" seems to be interpreted as a line-terminator.
  91## This may be caused by cmd.exe-stupidness or a bug in mingw32-make
  92## or some other obscure reason.
  93
  94define declare-shared-library-object
  95$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
  96	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
  97	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
  98	  $$(C_COMPILER_BUILD_RUNTIME_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
  99	  $$(INCLUDES)
 100endef
 101
 102# The above meta-rule is reused in the setup API stuff below, so we alias it
 103declare-libchicken-object = $(declare-shared-library-object)
 104
 105$(foreach obj, $(LIBCHICKEN_OBJECTS_1),\
 106          $(eval $(call declare-libchicken-object,$(obj))))
 107
 108# static versions
 109
 110define declare-static-library-object
 111$(1)-static$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
 112	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
 113	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) \
 114	  $$(C_COMPILER_STATIC_OPTIONS) \
 115	  $$(C_COMPILER_BUILD_RUNTIME_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
 116	  $$(INCLUDES)
 117endef
 118
 119declare-static-libchicken-object = $(declare-static-library-object)
 120
 121$(foreach obj, $(LIBCHICKEN_OBJECTS_1),\
 122          $(eval $(call declare-static-libchicken-object,$(obj))))
 123
 124$(eval $(call declare-static-libchicken-object,eval-modules))
 125
 126# import library objects
 127
 128define declare-import-lib-object
 129$(1).import$(O): $(1).import.c chicken.h $$(CHICKEN_CONFIG_H)
 130	$$(C_COMPILER) $$(C_COMPILER_OPTIONS)  \
 131	  -DC_SHARED $$(C_COMPILER_COMPILE_OPTION) \
 132	  $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
 133	  $$(C_COMPILER_BUILD_RUNTIME_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
 134	  $$(INCLUDES)
 135endef
 136
 137$(foreach obj,$(IMPORT_LIBRARIES),\
 138          $(eval $(call declare-import-lib-object,$(obj))))
 139
 140# compiler objects
 141
 142define declare-compiler-object
 143$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
 144	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
 145	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) $$< \
 146	  $$(C_COMPILER_OUTPUT) $$(INCLUDES)
 147endef
 148
 149$(foreach obj, $(COMPILER_OBJECTS_1),\
 150          $(eval $(call declare-compiler-object,$(obj))))
 151
 152# static compiler objects
 153
 154define declare-static-compiler-object
 155$(1)-static$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
 156	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
 157	  $$(C_COMPILER_STATIC_OPTIONS) \
 158	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
 159	  $$(INCLUDES)
 160endef
 161
 162$(foreach obj, $(COMPILER_OBJECTS_1),\
 163          $(eval $(call declare-static-compiler-object,$(obj))))
 164
 165# program objects
 166
 167define declare-utility-program-object
 168$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
 169	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
 170	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
 171	 $$(INCLUDES) 
 172endef
 173
 174$(foreach obj, $(UTILITY_PROGRAM_OBJECTS_1),\
 175          $(eval $(call declare-utility-program-object,$(obj))))
 176
 177
 178# resource objects
 179
 180%.rc.o: %.rc
 181	$(RC_COMPILER) $< $@
 182
 183# libraries
 184
 185.PHONY: libs
 186
 187libs: $(TARGETLIBS)
 188
 189lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO): $(LIBCHICKEN_SHARED_OBJECTS)
 190	$(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_LINKER_OPTIONS) \
 191	  $(LINKER_OUTPUT) $^ $(LIBCHICKEN_SO_LIBRARIES)
 192ifdef USES_SONAME
 193	ln -sf $(LIBCHICKEN_SO_FILE) $(LIBCHICKEN_SO_FILE).$(BINARYVERSION)
 194endif
 195
 196cyg$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-0.dll: $(LIBCHICKEN_SHARED_OBJECTS)
 197	$(LINKER) -shared -o $(LIBCHICKEN_SO_FILE) -Wl,--dll -Wl,--add-stdcall-alias \
 198	    -Wl,--enable-stdcall-fixup -Wl,--warn-unresolved-symbols \
 199	    -Wl,--dll-search-prefix=cyg -Wl,--allow-multiple-definition \
 200	    -Wl,--allow-shlib-undefined \
 201	    -Wl,--out-implib=libchicken.dll.a -Wl,--export-all-symbols \
 202	    -Wl,--enable-auto-import \
 203	    -Wl,--whole-archive $(LIBCHICKEN_SHARED_OBJECTS) \
 204	    -Wl,--no-whole-archive $(LIBCHICKEN_SO_LIBRARIES)
 205
 206lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A): $(LIBCHICKEN_STATIC_OBJECTS)
 207	$(LIBRARIAN) $(LIBRARIAN_OPTIONS) $(LIBRARIAN_OUTPUT) $^
 208
 209# import libraries and extensions
 210
 211%.so: %.o $(LIBCHICKEN_SO_FILE)
 212	$(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_DLOADABLE_OPTIONS) $< $(LINKER_OUTPUT_OPTION) $@ \
 213	  $(LINKER_LIBRARY_PREFIX)$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(LINKER_LIBRARY_SUFFIX) \
 214	  $(LIBRARIES)
 215
 216# executables
 217
 218$(CHICKEN_SHARED_EXECUTABLE): $(COMPILER_OBJECTS) $(PRIMARY_LIBCHICKEN)
 219	$(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $(COMPILER_OBJECTS) $(LINKER_OUTPUT) \
 220          $(LINKER_LIBRARY_PREFIX)$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
 221	$(PREINSTALL_PROGRAM_FIXUP) $(CHICKEN_SHARED_EXECUTABLE)
 222
 223define declare-program-from-object
 224$(1)-RC_FILE = $(if $(and $(RC_COMPILER),$(3)),$(2).rc$(O))
 225
 226$(1): $(2)$(O) $$(PRIMARY_LIBCHICKEN) $$($(1)-RC_FILE)
 227	$$(LINKER) $$(LINKER_OPTIONS) $$(LINKER_EXECUTABLE_OPTIONS) $$< \
 228          $$($(1)-RC_FILE) $$(LINKER_OUTPUT) \
 229          $$(LINKER_LIBRARY_PREFIX)$$(PROGRAM_PREFIX)chicken$$(PROGRAM_SUFFIX)$$(LINKER_LIBRARY_SUFFIX) \
 230          $$(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $$(LIBRARIES)
 231endef
 232
 233# Unfortunately, we can't loop over INSTALLED_PROGRAMS here because of
 234# the possible name mangling and EXE suffixing in there :(
 235$(eval $(call declare-program-from-object,$(CSI_SHARED_EXECUTABLE),csi))
 236$(eval $(call declare-program-from-object,$(CHICKEN_INSTALL_PROGRAM)$(EXE),chicken-install,true))
 237$(eval $(call declare-program-from-object,$(CHICKEN_UNINSTALL_PROGRAM)$(EXE),chicken-uninstall,true))
 238$(eval $(call declare-program-from-object,$(CHICKEN_STATUS_PROGRAM)$(EXE),chicken-status))
 239$(eval $(call declare-program-from-object,$(CHICKEN_PROFILE_PROGRAM)$(EXE),chicken-profile))
 240$(eval $(call declare-program-from-object,$(CSC_PROGRAM)$(EXE),csc))
 241
 242# static executables
 243
 244$(CHICKEN_STATIC_EXECUTABLE): $(COMPILER_STATIC_OBJECTS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A)
 245	$(LINKER) $(LINKER_OPTIONS) $(LINKER_STATIC_OPTIONS) $(COMPILER_STATIC_OBJECTS) $(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) $(LIBRARIES)
 246
 247define declare-static-program-from-object
 248$(1): $(2)$(O) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A)
 249	$$(LINKER) $$(LINKER_OPTIONS) $$(LINKER_STATIC_OPTIONS) $$< $$(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) $$(LIBRARIES)
 250endef
 251
 252$(eval $(call declare-program-from-object,$(CSI_STATIC_EXECUTABLE),csi))
 253
 254# "chicken-do"
 255
 256$(CHICKEN_DO_PROGRAM)$(EXE): $(SRCDIR)chicken-do.c chicken.h $(CHICKEN_CONFIG_H)
 257	$(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS) $< -o $@
 258
 259# scripts
 260
 261$(CHICKEN_DEBUGGER_PROGRAM): $(SRCDIR)feathers$(SCRIPT_EXT).in
 262	$(GENERATE_DEBUGGER)
 263
 264
 265# installation
 266
 267.PHONY: install uninstall install-libs
 268.PHONY: install-target install-dev install-bin install-other-files install-wrappers
 269
 270install: $(TARGETS) install-target install-bin install-libs install-dev install-other-files
 271
 272install-target: install-libs
 273
 274install-libs: libs $(LIBCHICKEN_IMPORT_LIBRARY)
 275	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)"
 276ifneq ($(LIBCHICKEN_IMPORT_LIBRARY),) 
 277	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) $(LIBCHICKEN_IMPORT_LIBRARY) "$(DESTDIR)$(ILIBDIR)"
 278endif
 279ifndef STATICBUILD
 280ifdef DLLSINPATH
 281	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)"
 282	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_FILE) "$(DESTDIR)$(IBINDIR)"
 283else
 284ifdef USES_SONAME
 285	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_FILE) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_SO_FILE).$(BINARYVERSION)"
 286	cd "$(DESTDIR)$(ILIBDIR)" && ln -sf $(LIBCHICKEN_SO_FILE).$(BINARYVERSION) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)
 287else
 288	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_FILE) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_SO_FILE)"
 289endif
 290endif
 291endif
 292
 293define NL
 294
 295
 296endef # A newline, used to inject recipe lines in a loop. Ugly, but necessary
 297
 298install-dev: install-libs
 299	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)"
 300	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ISHAREDIR)"
 301	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IEGGDIR)"
 302	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)"
 303	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 304	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) "$(DESTDIR)$(ILIBDIR)"
 305ifneq ($(POSTINSTALL_STATIC_LIBRARY),true)
 306	$(POSTINSTALL_STATIC_LIBRARY) $(POSTINSTALL_STATIC_LIBRARY_FLAGS) "$(ILIBDIR)$(SEP)libchicken$(A)"
 307endif
 308	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.h "$(DESTDIR)$(ICHICKENINCDIR)"
 309	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(CHICKEN_CONFIG_H) "$(DESTDIR)$(ICHICKENINCDIR)"
 310ifdef WINDOWS
 311	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.ico "$(DESTDIR)$(IDATADIR)"
 312	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.rc$(O) "$(DESTDIR)$(IDATADIR)"
 313endif
 314	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)types.db "$(DESTDIR)$(IEGGDIR)"
 315
 316ifeq ($(NEEDS_RELINKING),yes)
 317install-bin: $(TARGETS) install-libs install-dev
 318	$(foreach prog,$(INSTALLED_PROGRAMS),\
 319		$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(prog)$(EXE) $(NL))
 320
 321	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(IMPORT_LIBRARIES:%=%.so)
 322	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(IMPORT_LIBRARIES:%=%.import.so)
 323	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(LIBCHICKEN_SO_FILE)
 324	"$(MAKE)" PLATFORM=$(PLATFORM) CONFIG=$(CONFIG) NEEDS_RELINKING=no RUNTIME_LINKER_PATH="$(LIBDIR)" install-bin
 325# Damn. What was this for, again?
 326#
 327# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_PROGRAM)$(EXE) $(CSI_PROGRAM)$(EXE) $(CSC_PROGRAM)$(EXE) $(CHICKEN_PROFILE_PROGRAM)$(EXE)
 328# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_INSTALL_PROGRAM)$(EXE)
 329# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_UNINSTALL_PROGRAM)$(EXE)
 330# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_STATUS_PROGRAM)$(EXE)
 331else
 332install-bin: $(TARGETS) install-libs install-dev
 333	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)"
 334
 335	$(foreach prog,$(INSTALLED_PROGRAMS),\
 336		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) \
 337		$(prog)$(EXE) "$(DESTDIR)$(IBINDIR)" $(NL))
 338
 339	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) $(CHICKEN_DEBUGGER_PROGRAM) "$(DESTDIR)$(IBINDIR)"
 340
 341ifdef STATICBUILD
 342	$(foreach lib,$(IMPORT_LIBRARIES),\
 343		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) \
 344		$(lib).import.scm "$(DESTDIR)$(IEGGDIR)" $(NL))
 345else
 346	$(foreach lib,$(IMPORT_LIBRARIES),\
 347		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) \
 348		$(lib).import.so "$(DESTDIR)$(IEGGDIR)" $(NL))
 349endif
 350
 351ifneq ($(POSTINSTALL_PROGRAM),true)
 352ifndef STATICBUILD
 353	$(foreach prog,$(INSTALLED_PROGRAMS),\
 354		$(POSTINSTALL_PROGRAM) $(POSTINSTALL_PROGRAM_FLAGS) \
 355		"$(DESTDIR)$(IBINDIR)$(SEP)$(prog)" $(NL))
 356
 357	$(foreach import-lib,$(IMPORT_LIBRARIES),\
 358		$(POSTINSTALL_PROGRAM) $(POSTINSTALL_PROGRAM_FLAGS) \
 359		"$(DESTDIR)$(IEGGDIR)$(SEP)$(import-lib).import.so" $(NL))
 360endif
 361endif
 362ifeq ($(CROSS_CHICKEN)$(DESTDIR),0)
 363	-$(IBINDIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM) -defaults $(SRCDIR)setup.defaults -update-db
 364	$(MAKE_READABLE_COMMAND) "$(DESTDIR)$(IEGGDIR)$(SEP)modules.db"
 365else
 366	@echo
 367	@echo "Warning: cannot run \`$(CHICKEN_INSTALL_PROGRAM) -update-db' when cross-compiling or DESTDIR is set"
 368	@echo
 369endif
 370endif
 371ifdef WINDOWS_SHELL
 372	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) $(SRCDIR)csibatch.bat "$(DESTDIR)$(IBINDIR)"
 373endif
 374
 375install-other-files:
 376	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)"
 377	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDOCDIR)"
 378	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 379
 380	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROGRAM).1"
 381	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)csc$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSC_PROGRAM).1"
 382	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)csi$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSI_PROGRAM).1"
 383	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-do$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_DO_PROGRAM).1"
 384	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-install$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM).1"
 385	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-uninstall$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_UNINSTALL_PROGRAM).1"
 386	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-status$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_STATUS_PROGRAM).1"
 387	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-profile$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROFILE_PROGRAM).1"
 388	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)feathers$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_DEBUGGER_PROGRAM).1"
 389
 390	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDOCDIR)$(SEP)manual"
 391	-$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)manual-html$(SEP)* "$(DESTDIR)$(IDOCDIR)$(SEP)manual"
 392	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)README "$(DESTDIR)$(IDOCDIR)"
 393	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)DEPRECATED "$(DESTDIR)$(IDOCDIR)"
 394	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)LICENSE "$(DESTDIR)$(IDOCDIR)"
 395	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)setup.defaults "$(DESTDIR)$(IDATADIR)"
 396	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)feathers.tcl "$(DESTDIR)$(IDATADIR)"
 397
 398install-wrappers:
 399ifeq ($(WRAPPERDIR),)
 400	@echo 
 401	@echo Error: WRAPPERDIR is not set
 402	@echo
 403	@exit 1
 404endif
 405	$(foreach prg, $(INSTALLED_PROGRAMS), \
 406		$(CSI) -s $(SRCDIR)scripts$(SEP)make-wrapper.scm $(prg) "$(WRAPPERDIR)" $(NL))
 407
 408uninstall:
 409	$(foreach prog,$(INSTALLED_PROGRAMS),\
 410		$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS)\
 411		"$(DESTDIR)$(IBINDIR)$(SEP)$(prog)$(EXE)" $(NL))
 412	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)$(CHICKEN_DEBUGGER_PROGRAM)"
 413	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A)"
 414	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)"
 415ifdef USES_SONAME
 416	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO).$(BINARYVERSION)"
 417endif
 418ifdef WINDOWS
 419	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)"
 420	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_IMPORT_LIBRARY)"
 421endif
 422ifeq ($(PLATFORM),cygwin)
 423	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)cyg$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)*"
 424endif
 425
 426	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROGRAM).1"
 427	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSC_PROGRAM).1"
 428	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSI_PROGRAM).1"
 429	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_DO_PROGRAM).1"
 430	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM).1"
 431	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_UNINSTALL_PROGRAM).1"
 432	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_STATUS_PROGRAM).1"
 433	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROFILE_PROGRAM).1"
 434	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_DEBUGGER_PROGRAM).1"
 435
 436	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)$(SEP)chicken.h"
 437	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)$(SEP)$(CHICKEN_CONFIG_H)"
 438	$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 439	$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) "$(DESTDIR)$(IEGGDIR)"
 440ifdef WINDOWS_SHELL
 441	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)csibatch.bat"
 442endif
 443
 444# build versioning
 445
 446ifdef WINDOWS_SHELL
 447buildbranch:
 448	echo.$(BRANCHNAME)>buildbranch
 449buildid:
 450	echo.$(BUILD_ID)>buildid
 451else
 452.PHONY: identify-me
 453
 454identify-me:
 455	@sh $(SRCDIR)identify.sh $(SRCDIR)
 456
 457buildbranch: identify-me
 458buildid: identify-me
 459endif
 460
 461# bootstrapping c sources
 462
 463define declare-emitted-import-lib-dependency
 464.SECONDARY: $(1).import.scm
 465$(1).import.scm: $(2).c
 466endef
 467
 468define declare-emitted-chicken-import-lib-dependency
 469$(call declare-emitted-import-lib-dependency,chicken.$(1),$(1))
 470endef
 471
 472define declare-emitted-compiler-import-lib-dependency
 473$(call declare-emitted-import-lib-dependency,chicken.compiler.$(1),$(1))
 474endef
 475
 476$(foreach lib, $(DYNAMIC_IMPORT_LIBRARIES),\
 477          $(eval $(call declare-emitted-import-lib-dependency,$(lib),$(lib))))
 478
 479$(foreach lib, $(DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES),\
 480          $(eval $(call declare-emitted-chicken-import-lib-dependency,$(lib))))
 481
 482$(foreach lib, $(COMPILER_OBJECTS_1),\
 483          $(eval $(call declare-emitted-compiler-import-lib-dependency,$(lib))))
 484
 485# special cases for modules not corresponding directly to units
 486$(eval $(call declare-emitted-import-lib-dependency,chicken.errno,$(POSIXFILE)))
 487$(eval $(call declare-emitted-import-lib-dependency,chicken.file.posix,$(POSIXFILE)))
 488$(eval $(call declare-emitted-import-lib-dependency,chicken.time.posix,$(POSIXFILE)))
 489$(eval $(call declare-emitted-import-lib-dependency,chicken.process,$(POSIXFILE)))
 490$(eval $(call declare-emitted-import-lib-dependency,chicken.process.signal,$(POSIXFILE)))
 491$(eval $(call declare-emitted-import-lib-dependency,chicken.process-context.posix,$(POSIXFILE)))
 492$(eval $(call declare-emitted-import-lib-dependency,chicken.bitwise,library))
 493$(eval $(call declare-emitted-import-lib-dependency,chicken.blob,library))
 494$(eval $(call declare-emitted-import-lib-dependency,chicken.fixnum,library))
 495$(eval $(call declare-emitted-import-lib-dependency,chicken.flonum,library))
 496$(eval $(call declare-emitted-import-lib-dependency,chicken.gc,library))
 497$(eval $(call declare-emitted-import-lib-dependency,chicken.keyword,library))
 498$(eval $(call declare-emitted-import-lib-dependency,chicken.platform,library))
 499$(eval $(call declare-emitted-import-lib-dependency,chicken.plist,library))
 500$(eval $(call declare-emitted-import-lib-dependency,chicken.process-context,library))
 501$(eval $(call declare-emitted-import-lib-dependency,chicken.time,library))
 502$(eval $(call declare-emitted-import-lib-dependency,chicken.load,eval))
 503$(eval $(call declare-emitted-import-lib-dependency,chicken.format,extras))
 504$(eval $(call declare-emitted-import-lib-dependency,chicken.io,extras))
 505$(eval $(call declare-emitted-import-lib-dependency,chicken.pretty-print,extras))
 506$(eval $(call declare-emitted-import-lib-dependency,chicken.random,extras))
 507$(eval $(call declare-emitted-import-lib-dependency,chicken.locative,lolevel))
 508$(eval $(call declare-emitted-import-lib-dependency,chicken.memory,lolevel))
 509$(eval $(call declare-emitted-import-lib-dependency,chicken.memory.representation,lolevel))
 510$(eval $(call declare-emitted-import-lib-dependency,chicken.sort,data-structures))
 511$(eval $(call declare-emitted-import-lib-dependency,chicken.string,data-structures))
 512
 513chicken.c: chicken.scm mini-srfi-1.scm \
 514		chicken.compiler.batch-driver.import.scm \
 515		chicken.compiler.c-platform.import.scm \
 516		chicken.compiler.support.import.scm \
 517		chicken.compiler.user-pass.import.scm \
 518		chicken.process-context.import.scm \
 519		chicken.string.import.scm
 520batch-driver.c: batch-driver.scm mini-srfi-1.scm \
 521		chicken.compiler.core.import.scm \
 522		chicken.compiler.compiler-syntax.import.scm \
 523		chicken.compiler.optimizer.import.scm \
 524		chicken.compiler.scrutinizer.import.scm \
 525		chicken.compiler.c-platform.import.scm \
 526		chicken.compiler.lfa2.import.scm \
 527		chicken.compiler.c-backend.import.scm \
 528		chicken.compiler.support.import.scm \
 529		chicken.compiler.user-pass.import.scm \
 530		chicken.format.import.scm \
 531		chicken.gc.import.scm \
 532		chicken.internal.import.scm \
 533		chicken.load.import.scm \
 534		chicken.pathname.import.scm \
 535		chicken.platform.import.scm \
 536		chicken.pretty-print.import.scm \
 537		chicken.process-context.import.scm \
 538		chicken.process-context.posix.import.scm \
 539		chicken.condition.import.scm \
 540		chicken.port.import.scm \
 541		chicken.string.import.scm \
 542		chicken.syntax.import.scm \
 543		chicken.time.import.scm
 544c-platform.c: c-platform.scm mini-srfi-1.scm \
 545		chicken.compiler.optimizer.import.scm \
 546		chicken.compiler.support.import.scm \
 547		chicken.compiler.core.import.scm \
 548		chicken.internal.import.scm
 549c-backend.c: c-backend.scm mini-srfi-1.scm \
 550		chicken.compiler.c-platform.import.scm \
 551		chicken.compiler.support.import.scm \
 552		chicken.compiler.core.import.scm \
 553		chicken.bitwise.import.scm \
 554		chicken.flonum.import.scm \
 555		chicken.foreign.import.scm \
 556		chicken.format.import.scm \
 557		chicken.internal.import.scm \
 558		chicken.sort.import.scm \
 559		chicken.string.import.scm \
 560		chicken.time.import.scm
 561core.c: core.scm mini-srfi-1.scm \
 562		chicken.compiler.scrutinizer.import.scm \
 563		chicken.compiler.support.import.scm \
 564		chicken.eval.import.scm \
 565		chicken.file.import.scm \
 566		chicken.fixnum.import.scm \
 567		chicken.format.import.scm \
 568		chicken.io.import.scm \
 569		chicken.keyword.import.scm \
 570		chicken.load.import.scm \
 571		chicken.pretty-print.import.scm \
 572		chicken.string.import.scm \
 573		chicken.syntax.import.scm
 574optimizer.c: optimizer.scm mini-srfi-1.scm \
 575		chicken.compiler.support.import.scm \
 576		chicken.fixnum.import.scm \
 577		chicken.internal.import.scm \
 578		chicken.sort.import.scm \
 579		chicken.string.import.scm
 580scheduler.c: scheduler.scm \
 581		chicken.fixnum.import.scm \
 582		chicken.format.import.scm \
 583		chicken.condition.import.scm
 584scrutinizer.c: scrutinizer.scm mini-srfi-1.scm \
 585		chicken.compiler.support.import.scm \
 586		chicken.fixnum.import.scm \
 587		chicken.format.import.scm \
 588		chicken.internal.import.scm \
 589		chicken.io.import.scm \
 590		chicken.pathname.import.scm \
 591		chicken.platform.import.scm \
 592		chicken.sort.import.scm \
 593		chicken.port.import.scm \
 594		chicken.pretty-print.import.scm \
 595		chicken.string.import.scm
 596lfa2.c: lfa2.scm mini-srfi-1.scm \
 597		chicken.compiler.support.import.scm \
 598		chicken.format.import.scm
 599compiler-syntax.c: compiler-syntax.scm mini-srfi-1.scm \
 600		chicken.compiler.support.import.scm \
 601		chicken.compiler.core.import.scm \
 602		chicken.fixnum.import.scm \
 603		chicken.format.import.scm \
 604		chicken.syntax.import.scm
 605chicken-ffi-syntax.c: chicken-ffi-syntax.scm \
 606		chicken.format.import.scm \
 607		chicken.internal.import.scm \
 608		chicken.string.import.scm
 609support.c: support.scm mini-srfi-1.scm \
 610		chicken.bitwise.import.scm \
 611		chicken.blob.import.scm \
 612		chicken.condition.import.scm \
 613		chicken.file.import.scm \
 614		chicken.fixnum.import.scm \
 615		chicken.foreign.import.scm \
 616		chicken.format.import.scm \
 617		chicken.internal.import.scm \
 618		chicken.io.import.scm \
 619		chicken.keyword.import.scm \
 620		chicken.pathname.import.scm \
 621		chicken.platform.import.scm \
 622		chicken.plist.import.scm \
 623		chicken.port.import.scm \
 624		chicken.pretty-print.import.scm \
 625		chicken.random.import.scm \
 626		chicken.sort.import.scm \
 627		chicken.string.import.scm \
 628		chicken.time.import.scm
 629modules.c: modules.scm \
 630		chicken.internal.import.scm \
 631		chicken.keyword.import.scm \
 632		chicken.base.import.scm \
 633		chicken.syntax.import.scm \
 634		chicken.load.import.scm \
 635		chicken.platform.import.scm
 636csc.c: csc.scm \
 637		chicken.file.import.scm \
 638		chicken.foreign.import.scm \
 639		chicken.format.import.scm \
 640		chicken.io.import.scm \
 641		chicken.pathname.import.scm \
 642		chicken.process.import.scm \
 643		chicken.process-context.import.scm \
 644		chicken.string.import.scm
 645csi.c: csi.scm \
 646		chicken.condition.import.scm \
 647		chicken.file.import.scm \
 648		chicken.foreign.import.scm \
 649		chicken.format.import.scm \
 650		chicken.gc.import.scm \
 651		chicken.internal.import.scm \
 652		chicken.io.import.scm \
 653		chicken.keyword.import.scm \
 654		chicken.load.import.scm \
 655		chicken.platform.import.scm \
 656		chicken.port.import.scm \
 657		chicken.pretty-print.import.scm \
 658		chicken.process.import.scm \
 659		chicken.process-context.import.scm \
 660		chicken.repl.import.scm \
 661		chicken.sort.import.scm \
 662		chicken.string.import.scm
 663chicken-profile.c: chicken-profile.scm \
 664		chicken.internal.import.scm \
 665		chicken.file.import.scm \
 666		chicken.file.posix.import.scm \
 667		chicken.fixnum.import.scm \
 668		chicken.process-context.import.scm \
 669		chicken.sort.import.scm \
 670		chicken.string.import.scm
 671chicken-status.c: chicken-status.scm \
 672		chicken.file.import.scm \
 673		chicken.file.posix.import.scm \
 674		chicken.fixnum.import.scm \
 675		chicken.foreign.import.scm \
 676		chicken.format.import.scm \
 677		chicken.irregex.import.scm \
 678		chicken.pathname.import.scm \
 679		chicken.port.import.scm \
 680		chicken.pretty-print.import.scm \
 681		chicken.process-context.import.scm \
 682		chicken.sort.import.scm \
 683		chicken.string.import.scm
 684chicken-install.c: chicken-install.scm \
 685		chicken.condition.import.scm \
 686		chicken.file.import.scm \
 687		chicken.file.posix.import.scm \
 688		chicken.fixnum.import.scm \
 689		chicken.foreign.import.scm \
 690		chicken.format.import.scm \
 691		chicken.internal.import.scm \
 692		chicken.io.import.scm \
 693		chicken.irregex.import.scm \
 694		chicken.pathname.import.scm \
 695		chicken.port.import.scm \
 696		chicken.pretty-print.import.scm \
 697		chicken.process.import.scm \
 698		chicken.process-context.import.scm \
 699		chicken.sort.import.scm \
 700		chicken.string.import.scm \
 701		chicken.tcp.import.scm
 702chicken-uninstall.c: chicken-uninstall.scm \
 703		chicken.file.import.scm \
 704		chicken.fixnum.import.scm \
 705		chicken.foreign.import.scm \
 706		chicken.format.import.scm \
 707		chicken.irregex.import.scm \
 708		chicken.pathname.import.scm \
 709		chicken.port.import.scm \
 710		chicken.process.import.scm \
 711		chicken.process-context.import.scm \
 712		chicken.string.import.scm
 713chicken-syntax.c: chicken-syntax.scm \
 714		chicken.fixnum.import.scm \
 715		chicken.platform.import.scm \
 716		chicken.internal.import.scm
 717srfi-4.c: srfi-4.scm \
 718		chicken.bitwise.import.scm \
 719		chicken.fixnum.import.scm \
 720		chicken.foreign.import.scm \
 721		chicken.gc.import.scm \
 722		chicken.platform.import.scm
 723posixunix.c: posixunix.scm \
 724		chicken.bitwise.import.scm \
 725		chicken.condition.import.scm \
 726		chicken.foreign.import.scm \
 727		chicken.memory.import.scm \
 728		chicken.pathname.import.scm \
 729		chicken.platform.import.scm \
 730		chicken.port.import.scm \
 731		chicken.process-context.import.scm \
 732		chicken.time.import.scm
 733posixwin.c: posixwin.scm \
 734		chicken.condition.import.scm \
 735		chicken.bitwise.import.scm \
 736		chicken.foreign.import.scm \
 737		chicken.memory.import.scm \
 738		chicken.pathname.import.scm \
 739		chicken.platform.import.scm \
 740		chicken.port.import.scm \
 741		chicken.process-context.import.scm \
 742		chicken.string.import.scm \
 743		chicken.time.import.scm
 744data-structures.c: data-structures.scm \
 745		chicken.condition.import.scm \
 746		chicken.fixnum.import.scm \
 747		chicken.foreign.import.scm
 748expand.c: expand.scm \
 749		chicken.blob.import.scm \
 750		chicken.condition.import.scm \
 751		chicken.fixnum.import.scm \
 752		chicken.keyword.import.scm \
 753		chicken.platform.import.scm \
 754		chicken.string.import.scm \
 755		chicken.internal.import.scm
 756extras.c: extras.scm \
 757		chicken.fixnum.import.scm \
 758		chicken.string.import.scm \
 759		chicken.time.import.scm
 760eval.c: eval.scm \
 761		chicken.blob.import.scm \
 762		chicken.condition.import.scm \
 763		chicken.fixnum.import.scm \
 764		chicken.foreign.import.scm \
 765		chicken.internal.import.scm \
 766		chicken.keyword.import.scm \
 767		chicken.syntax.import.scm \
 768		chicken.platform.import.scm
 769repl.c: repl.scm \
 770		chicken.eval.import.scm
 771file.c: file.scm \
 772		chicken.condition.import.scm \
 773		chicken.fixnum.import.scm \
 774		chicken.io.import.scm \
 775		chicken.irregex.import.scm \
 776		chicken.foreign.import.scm \
 777		chicken.pathname.import.scm \
 778		chicken.process-context.import.scm
 779lolevel.c: lolevel.scm \
 780		chicken.fixnum.import.scm \
 781		chicken.foreign.import.scm
 782pathname.c: pathname.scm \
 783		chicken.fixnum.import.scm \
 784		chicken.irregex.import.scm \
 785		chicken.platform.import.scm \
 786		chicken.string.import.scm
 787port.c: port.scm \
 788		chicken.fixnum.import.scm \
 789		chicken.io.import.scm
 790read-syntax.c: read-syntax.scm \
 791		chicken.internal.import.scm \
 792		chicken.platform.import.scm
 793tcp.c: tcp.scm \
 794		chicken.fixnum.import.scm \
 795		chicken.foreign.import.scm \
 796		chicken.port.import.scm \
 797		chicken.time.import.scm
 798eval-modules.c: eval-modules.scm $(DYNAMIC_IMPORT_LIBRARIES:=.import.scm) \
 799	$(foreach lib,$(DYNAMIC_CHICKEN_IMPORT_LIBRARIES),chicken.$(lib).import.scm) \
 800	$(foreach lib,$(DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES),$(lib).c)
 801continuation.c: continuation.scm \
 802		chicken.fixnum.import.scm
 803internal.c: internal.scm \
 804		chicken.fixnum.import.scm
 805irregex.c: irregex.scm \
 806		chicken.fixnum.import.scm \
 807		chicken.syntax.import.scm
 808profiler.c: profiler.scm \
 809		chicken.fixnum.import.scm
 810stub.c: stub.scm \
 811		chicken.platform.import.scm
 812
 813
 814define profile-flags
 815$(if $(filter $(basename $(1)),$(PROFILE_OBJECTS)),-profile)
 816endef
 817
 818bootstrap-lib = $(CHICKEN) $(call profile-flags, $@) $< $(CHICKEN_LIBRARY_OPTIONS) -output-file $@
 819
 820library.c: $(SRCDIR)library.scm
 821	$(bootstrap-lib) \
 822	-no-module-registration \
 823	-emit-import-library chicken.bitwise \
 824	-emit-import-library chicken.blob \
 825	-emit-import-library chicken.fixnum \
 826	-emit-import-library chicken.flonum \
 827	-emit-import-library chicken.gc \
 828	-emit-import-library chicken.keyword \
 829	-emit-import-library chicken.platform \
 830	-emit-import-library chicken.plist \
 831	-emit-import-library chicken.process-context
 832internal.c: $(SRCDIR)internal.scm $(SRCDIR)mini-srfi-1.scm
 833	$(bootstrap-lib) -emit-import-library chicken.internal
 834eval.c: $(SRCDIR)eval.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 835	$(bootstrap-lib) \
 836	-emit-import-library chicken.eval \
 837	-emit-import-library chicken.load
 838read-syntax.c: $(SRCDIR)read-syntax.scm $(SRCDIR)common-declarations.scm
 839	$(bootstrap-lib) -emit-import-library chicken.read-syntax
 840repl.c: $(SRCDIR)repl.scm $(SRCDIR)common-declarations.scm
 841	$(bootstrap-lib) -emit-import-library chicken.repl
 842expand.c: $(SRCDIR)expand.scm $(SRCDIR)synrules.scm $(SRCDIR)common-declarations.scm
 843	$(bootstrap-lib) \
 844	-no-module-registration
 845modules.c: $(SRCDIR)modules.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 846	$(bootstrap-lib)
 847extras.c: $(SRCDIR)extras.scm $(SRCDIR)common-declarations.scm
 848	$(bootstrap-lib) \
 849	-emit-import-library chicken.format \
 850	-emit-import-library chicken.io \
 851	-emit-import-library chicken.pretty-print \
 852	-emit-import-library chicken.random
 853posixunix.c: $(SRCDIR)posix.scm $(SRCDIR)posixunix.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
 854	$(bootstrap-lib) -feature platform-unix \
 855	-emit-import-library chicken.errno \
 856	-emit-import-library chicken.file.posix \
 857	-emit-import-library chicken.time.posix \
 858	-emit-import-library chicken.process \
 859	-emit-import-library chicken.process.signal \
 860	-emit-import-library chicken.process-context.posix \
 861	-no-module-registration
 862posixwin.c: $(SRCDIR)posix.scm $(SRCDIR)posixwin.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
 863	$(bootstrap-lib) -feature platform-windows \
 864	-emit-import-library chicken.errno \
 865	-emit-import-library chicken.file.posix \
 866	-emit-import-library chicken.time.posix \
 867	-emit-import-library chicken.process \
 868	-emit-import-library chicken.process.signal \
 869	-emit-import-library chicken.process-context.posix \
 870	-no-module-registration
 871irregex.c: $(SRCDIR)irregex.scm $(SRCDIR)irregex-core.scm $(SRCDIR)irregex-utils.scm $(SRCDIR)common-declarations.scm
 872	$(bootstrap-lib) -emit-import-library chicken.irregex
 873chicken-syntax.c: $(SRCDIR)chicken-syntax.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 874	$(bootstrap-lib)
 875chicken-ffi-syntax.c: $(SRCDIR)chicken-ffi-syntax.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 876	$(bootstrap-lib)
 877continuation.c: $(SRCDIR)continuation.scm $(SRCDIR)common-declarations.scm
 878	$(bootstrap-lib) -emit-import-library chicken.continuation
 879data-structures.c: $(SRCDIR)data-structures.scm $(SRCDIR)common-declarations.scm
 880	$(bootstrap-lib) \
 881	-emit-import-library chicken.sort \
 882	-emit-import-library chicken.string
 883pathname.c: $(SRCDIR)pathname.scm $(SRCDIR)common-declarations.scm
 884	$(bootstrap-lib) -emit-import-library chicken.pathname
 885port.c: $(SRCDIR)port.scm $(SRCDIR)common-declarations.scm
 886	$(bootstrap-lib) -emit-import-library chicken.port
 887file.c: $(SRCDIR)file.scm $(SRCDIR)common-declarations.scm
 888	$(bootstrap-lib) -emit-import-library chicken.file
 889lolevel.c: $(SRCDIR)lolevel.scm $(SRCDIR)common-declarations.scm
 890	$(bootstrap-lib) \
 891	-emit-import-library chicken.locative \
 892	-emit-import-library chicken.memory \
 893	-emit-import-library chicken.memory.representation
 894tcp.c: $(SRCDIR)tcp.scm $(SRCDIR)common-declarations.scm
 895	$(bootstrap-lib) -emit-import-library chicken.tcp
 896srfi-4.c: $(SRCDIR)srfi-4.scm $(SRCDIR)common-declarations.scm
 897	$(bootstrap-lib) -emit-import-library srfi-4
 898scheduler.c: $(SRCDIR)scheduler.scm $(SRCDIR)common-declarations.scm
 899	$(bootstrap-lib) 
 900profiler.c: $(SRCDIR)profiler.scm $(SRCDIR)common-declarations.scm
 901	$(bootstrap-lib) 
 902stub.c: $(SRCDIR)stub.scm $(SRCDIR)common-declarations.scm
 903	$(bootstrap-lib) 
 904debugger-client.c: $(SRCDIR)debugger-client.scm $(SRCDIR)common-declarations.scm dbg-stub.c
 905	$(bootstrap-lib)
 906build-version.c: $(SRCDIR)build-version.scm $(SRCDIR)buildversion buildbranch buildid
 907	$(bootstrap-lib)
 908eval-modules.c: $(SRCDIR)eval-modules.scm $(SRCDIR)common-declarations.scm
 909	$(bootstrap-lib)
 910
 911define declare-bootstrap-import-lib
 912$(1).import.c: $$(SRCDIR)$(1).import.scm
 913	$$(CHICKEN) $$< $$(CHICKEN_IMPORT_LIBRARY_OPTIONS) -output-file $$@
 914endef
 915
 916$(foreach obj, $(IMPORT_LIBRARIES),\
 917          $(eval $(call declare-bootstrap-import-lib,$(obj))))
 918
 919# Bootstrap compiler objects
 920
 921define declare-bootstrap-compiler-object
 922$(1).c: $$(SRCDIR)$(1).scm $$(SRCDIR)tweaks.scm
 923	$$(CHICKEN) $$< $$(CHICKEN_PROGRAM_OPTIONS) -emit-import-library chicken.compiler.$(1) \
 924		-output-file $$@ 
 925endef
 926
 927$(foreach obj, $(COMPILER_OBJECTS_1),\
 928          $(eval $(call declare-bootstrap-compiler-object,$(obj))))
 929
 930csi.c: $(SRCDIR)csi.scm $(SRCDIR)banner.scm $(SRCDIR)mini-srfi-1.scm
 931	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 932chicken-profile.c: $(SRCDIR)chicken-profile.scm $(SRCDIR)mini-srfi-1.scm
 933	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@ 
 934chicken-install.c: $(SRCDIR)chicken-install.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-compile.scm $(SRCDIR)egg-download.scm $(SRCDIR)egg-environment.scm $(SRCDIR)egg-information.scm
 935	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@ 
 936chicken-uninstall.c: $(SRCDIR)chicken-uninstall.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-environment.scm $(SRCDIR)egg-information.scm
 937	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@ 
 938chicken-status.c: $(SRCDIR)chicken-status.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-environment.scm $(SRCDIR)egg-information.scm
 939	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@ 
 940csc.c: $(SRCDIR)csc.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-environment.scm
 941	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@ 
 942
 943# distribution files
 944
 945.PHONY: distfiles dist html
 946
 947distfiles: $(DISTFILES)
 948
 949dist: distfiles html
 950	CSI=$(CSI) $(CSI) -s $(SRCDIR)scripts$(SEP)makedist.scm -platform $(PLATFORM) CHICKEN=$(CHICKEN)
 951
 952# Jim's `manual-labor' must be installed (just run "chicken-install manual-labor")
 953html:
 954	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) $(SRCDIR)manual-html
 955	manual-labor $(SRCDIR)manual $(SRCDIR)manual-html
 956	$(COPY_COMMAND) $(SRCDIR)chicken.png manual-html
 957	$(COPY_COMMAND) $(SRCDIR)manual.css manual-html
 958	$(COPY_COMMAND) $(SRCDIR)index.html manual-html
 959
 960# cleaning up
 961
 962.PHONY: clean spotless confclean testclean
 963
 964BUILD_CONFIG_FILES = chicken-config.h chicken-defaults.h chicken-install.rc chicken-uninstall.rc
 965
 966clean:
 967	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(EXE) $(PROGRAM_PREFIX)csi$(PROGRAM_SUFFIX)$(EXE) $(PROGRAM_PREFIX)csc$(PROGRAM_SUFFIX)$(EXE) \
 968	  $(CHICKEN_PROFILE_PROGRAM)$(EXE) \
 969	  $(CHICKEN_INSTALL_PROGRAM)$(EXE) \
 970	  $(CHICKEN_UNINSTALL_PROGRAM)$(EXE) \
 971	  $(CHICKEN_STATUS_PROGRAM)$(EXE) \
 972	  *$(O) \
 973	  $(CHICKEN_DO_PROGRAM)$(EXE) \
 974	  $(CHICKEN_DEBUGGER_PROGRAM) \
 975	  $(LIBCHICKEN_SO_FILE) \
 976	  $(PRIMARY_LIBCHICKEN) \
 977	  lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) \
 978	  $(IMPORT_LIBRARIES:=.import.so) $(LIBCHICKEN_IMPORT_LIBRARY) \
 979	  $(foreach lib,$(DYNAMIC_IMPORT_LIBRARIES),chicken.$(lib).import.scm) \
 980	  $(BUILD_CONFIG_FILES)
 981ifdef USES_SONAME
 982	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX).so.$(BINARYVERSION)
 983endif
 984
 985confclean:
 986	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(BUILD_CONFIG_FILES)
 987
 988spotless: clean testclean
 989	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(DISTFILES) \
 990	buildid buildbranch
 991
 992testclean:
 993	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) \
 994	  $(SRCDIR)tests$(SEP)*.dll \
 995	  $(SRCDIR)tests$(SEP)*.import.scm \
 996	  $(SRCDIR)tests$(SEP)*.inline \
 997	  $(SRCDIR)tests$(SEP)*.link \
 998	  $(SRCDIR)tests$(SEP)*.o \
 999	  $(SRCDIR)tests$(SEP)*.obj \
 1000	  $(SRCDIR)tests$(SEP)*.out \
1001	  $(SRCDIR)tests$(SEP)*.profile \
1002	  $(SRCDIR)tests$(SEP)*.redacted \
1003	  $(SRCDIR)tests$(SEP)*.so \
1004	  $(SRCDIR)tests$(SEP)tmp \
1005	  $(SRCDIR)tests$(SEP)tmp.c \
1006	  $(SRCDIR)tests$(SEP)empty-file \
1007	  $(SRCDIR)tests$(SEP)null \
1008	  $(SRCDIR)tests$(SEP)null.c \
1009	  $(SRCDIR)tests$(SEP)null.exe \
1010	  $(SRCDIR)tests$(SEP)test-repository \
1011	  $(SRCDIR)tests$(SEP)redact-gensyms
1012
1013# run tests
1014
1015.PHONY: check
1016
1017export PROGRAM_PREFIX
1018export PROGRAM_SUFFIX
1019
1020check: $(TARGETS)
1021ifndef WINDOWS_SHELL
1022	cd tests; sh runtests.sh
1023else
1024	cd tests & runtests.bat
1025endif
1026
1027# benchmark
1028
1029.PHONY: bench
1030
1031bench: $(CHICKEN_SHARED_EXECUTABLE) $(CSI_SHARED_EXECUTABLE) $(CSC_PROGRAM)$(EXE)
1032	cd tests; echo >>bench.log; date >>bench.log; sh runbench.sh 2>&1 | tee -a bench.log
1033
1034
1035# build static bootstrapping chicken
1036
1037.PHONY: boot-chicken bootclean
1038
1039STAGE1_CONFIG = PLATFORM=$(PLATFORM) PREFIX=/nowhere CONFIG= \
1040    CHICKEN=$(CHICKEN) PROGRAM_SUFFIX=-boot-stage1 STATICBUILD=1 \
1041    C_COMPILER_OPTIMIZATION_OPTIONS="$(C_COMPILER_OPTIMIZATION_OPTIONS)" BUILDING_CHICKEN_BOOT=1
1042
1043BOOT_CONFIG = PLATFORM=$(PLATFORM) PREFIX=/nowhere CONFIG= \
1044    CHICKEN=.$(SEP)chicken-boot-stage1$(EXE) PROGRAM_SUFFIX=-boot \
1045    STATICBUILD=1 C_COMPILER_OPTIMIZATION_OPTIONS="$(C_COMPILER_OPTIMIZATION_OPTIONS)"
1046
1047boot-chicken:
1048	"$(MAKE)" $(STAGE1_CONFIG) confclean
1049	"$(MAKE)" $(STAGE1_CONFIG) chicken-boot-stage1$(EXE)
1050	"$(MAKE)" $(BOOT_CONFIG) touchfiles
1051	"$(MAKE)" $(BOOT_CONFIG) chicken-boot$(EXE)
1052	"$(MAKE)" $(BOOT_CONFIG) confclean
1053
1054bootclean:
1055	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) \
1056	  $(SRCDIR)chicken-boot$(EXE) \
1057	  $(SRCDIR)chicken-boot-stage1$(EXE) \
1058	  $(SRCDIR)libchicken-boot$(A) \
1059	  $(SRCDIR)libchicken-boot-stage1$(A)
1060
1061.PHONY: touchfiles
1062
1063touchfiles:
1064ifdef WINDOWS_SHELL
1065	for %%x in (*.scm) do copy /b %%x +,,
1066else
1067	touch *.scm
1068endif
Trap