~ chicken-core (master) /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 r7lib
  41LIBCHICKEN_OBJECTS_1 = $(LIBCHICKEN_SCHEME_OBJECTS_1) runtime utf
  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 utf.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
  88define declare-shared-library-object
  89$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
  90	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
  91	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
  92	  $$(C_COMPILER_BUILD_RUNTIME_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
  93	  $$(INCLUDES)
  94endef
  95
  96# The above meta-rule is reused in the setup API stuff below, so we alias it
  97declare-libchicken-object = $(declare-shared-library-object)
  98
  99$(foreach obj, $(LIBCHICKEN_OBJECTS_1),\
 100          $(eval $(call declare-libchicken-object,$(obj))))
 101
 102# static versions
 103
 104define declare-static-library-object
 105$(1)-static$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
 106	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
 107	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) \
 108	  $$(C_COMPILER_STATIC_OPTIONS) \
 109	  $$(C_COMPILER_BUILD_RUNTIME_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
 110	  $$(INCLUDES)
 111endef
 112
 113declare-static-libchicken-object = $(declare-static-library-object)
 114
 115$(foreach obj, $(LIBCHICKEN_OBJECTS_1),\
 116          $(eval $(call declare-static-libchicken-object,$(obj))))
 117
 118$(eval $(call declare-static-libchicken-object,eval-modules))
 119
 120# import library objects
 121
 122define declare-import-lib-object
 123$(1).import$(O): $(1).import.c chicken.h $$(CHICKEN_CONFIG_H)
 124	$$(C_COMPILER) $$(C_COMPILER_OPTIONS)  \
 125	  -DC_SHARED $$(C_COMPILER_COMPILE_OPTION) \
 126	  $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
 127	  $$(C_COMPILER_BUILD_RUNTIME_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
 128	  $$(INCLUDES)
 129endef
 130
 131$(foreach obj,$(IMPORT_LIBRARIES),\
 132          $(eval $(call declare-import-lib-object,$(obj))))
 133
 134# compiler objects
 135
 136define declare-compiler-object
 137$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
 138	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
 139	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) $$< \
 140	  $$(C_COMPILER_OUTPUT) $$(INCLUDES)
 141endef
 142
 143$(foreach obj, $(COMPILER_OBJECTS_1),\
 144          $(eval $(call declare-compiler-object,$(obj))))
 145
 146# static compiler objects
 147
 148define declare-static-compiler-object
 149$(1)-static$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
 150	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
 151	  $$(C_COMPILER_STATIC_OPTIONS) \
 152	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
 153	  $$(INCLUDES)
 154endef
 155
 156$(foreach obj, $(COMPILER_OBJECTS_1),\
 157          $(eval $(call declare-static-compiler-object,$(obj))))
 158
 159# program objects
 160
 161define declare-utility-program-object
 162$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
 163	$$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
 164	  $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
 165	 $$(INCLUDES)
 166endef
 167
 168$(foreach obj, $(UTILITY_PROGRAM_OBJECTS_1),\
 169          $(eval $(call declare-utility-program-object,$(obj))))
 170
 171
 172# resource objects
 173
 174%.rc.o: %.rc
 175	$(RC_COMPILER) $< $@
 176
 177# libraries
 178
 179.PHONY: libs
 180
 181libs: $(TARGETLIBS)
 182
 183lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO): $(LIBCHICKEN_SHARED_OBJECTS)
 184	$(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_LINKER_OPTIONS) \
 185	  $(LINKER_OUTPUT) $^ $(LIBCHICKEN_SO_LIBRARIES)
 186ifdef USES_SONAME
 187	ln -sf $(LIBCHICKEN_SO_FILE) $(LIBCHICKEN_SO_FILE).$(BINARYVERSION)
 188endif
 189
 190cyg$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-0.dll: $(LIBCHICKEN_SHARED_OBJECTS)
 191	$(LINKER) -shared -o $(LIBCHICKEN_SO_FILE) -Wl,--dll -Wl,--add-stdcall-alias \
 192	    -Wl,--enable-stdcall-fixup -Wl,--warn-unresolved-symbols \
 193	    -Wl,--dll-search-prefix=cyg -Wl,--allow-multiple-definition \
 194	    -Wl,--allow-shlib-undefined \
 195	    -Wl,--out-implib=libchicken.dll.a -Wl,--export-all-symbols \
 196	    -Wl,--enable-auto-import \
 197	    -Wl,--whole-archive $(LIBCHICKEN_SHARED_OBJECTS) \
 198	    -Wl,--no-whole-archive $(LIBCHICKEN_SO_LIBRARIES)
 199
 200lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A): $(LIBCHICKEN_STATIC_OBJECTS)
 201	$(LIBRARIAN) $(LIBRARIAN_OPTIONS) $(LIBRARIAN_OUTPUT) $^
 202
 203# import libraries and extensions
 204
 205%.so: %.o $(LIBCHICKEN_SO_FILE)
 206	$(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_DLOADABLE_OPTIONS) $< $(LINKER_OUTPUT_OPTION) $@ \
 207	  $(LINKER_LIBRARY_PREFIX)$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(LINKER_LIBRARY_SUFFIX) \
 208	  $(LIBRARIES)
 209
 210# executables
 211
 212$(CHICKEN_SHARED_EXECUTABLE): $(COMPILER_OBJECTS) $(PRIMARY_LIBCHICKEN)
 213	$(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $(COMPILER_OBJECTS) $(LINKER_OUTPUT) \
 214          $(LINKER_LIBRARY_PREFIX)$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
 215	$(PREINSTALL_PROGRAM_FIXUP) $(CHICKEN_SHARED_EXECUTABLE)
 216
 217define declare-program-from-object
 218$(1)-RC_FILE = $(if $(and $(RC_COMPILER),$(3)),$(2).rc$(O))
 219
 220$(1): $(2)$(O) $$(PRIMARY_LIBCHICKEN) $$($(1)-RC_FILE)
 221	$$(LINKER) $$(LINKER_OPTIONS) $$(LINKER_EXECUTABLE_OPTIONS) $$< \
 222          $$($(1)-RC_FILE) $$(LINKER_OUTPUT) \
 223          $$(LINKER_LIBRARY_PREFIX)$$(PROGRAM_PREFIX)chicken$$(PROGRAM_SUFFIX)$$(LINKER_LIBRARY_SUFFIX) \
 224          $$(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $$(LIBRARIES)
 225	$(PREINSTALL_PROGRAM_FIXUP) $(1)
 226endef
 227
 228# Unfortunately, we can't loop over INSTALLED_PROGRAMS here because of
 229# the possible name mangling and EXE suffixing in there :(
 230$(eval $(call declare-program-from-object,$(CSI_SHARED_EXECUTABLE),csi))
 231$(eval $(call declare-program-from-object,$(CHICKEN_INSTALL_PROGRAM)$(EXE),chicken-install,true))
 232$(eval $(call declare-program-from-object,$(CHICKEN_UNINSTALL_PROGRAM)$(EXE),chicken-uninstall,true))
 233$(eval $(call declare-program-from-object,$(CHICKEN_STATUS_PROGRAM)$(EXE),chicken-status))
 234$(eval $(call declare-program-from-object,$(CHICKEN_PROFILE_PROGRAM)$(EXE),chicken-profile))
 235$(eval $(call declare-program-from-object,$(CSC_PROGRAM)$(EXE),csc))
 236
 237# static executables
 238
 239$(CHICKEN_STATIC_EXECUTABLE): $(COMPILER_STATIC_OBJECTS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A)
 240	$(LINKER) $(LINKER_OPTIONS) $(LINKER_STATIC_OPTIONS) $(COMPILER_STATIC_OBJECTS) $(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A) $(LIBRARIES)
 241
 242define declare-static-program-from-object
 243$(1): $(2)$(O) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A)
 244	$$(LINKER) $$(LINKER_OPTIONS) $$(LINKER_STATIC_OPTIONS) $$< $$(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A) $$(LIBRARIES)
 245endef
 246
 247$(eval $(call declare-program-from-object,$(CSI_STATIC_EXECUTABLE),csi))
 248
 249# "chicken-do"
 250
 251$(CHICKEN_DO_PROGRAM)$(EXE): $(SRCDIR)chicken-do.c chicken.h $(CHICKEN_CONFIG_H)
 252	$(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS) $< -o $@
 253
 254
 255# installation
 256
 257.PHONY: install uninstall install-libs
 258.PHONY: install-target install-dev install-bin install-other-files install-wrappers
 259
 260install: $(TARGETS) install-target install-bin install-libs install-dev install-other-files
 261
 262install-target: install-libs
 263
 264install-libs: libs $(LIBCHICKEN_IMPORT_LIBRARY)
 265	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)"
 266ifneq ($(LIBCHICKEN_IMPORT_LIBRARY),)
 267	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) $(LIBCHICKEN_IMPORT_LIBRARY) "$(DESTDIR)$(ILIBDIR)"
 268endif
 269ifndef STATICBUILD
 270ifdef DLLSINPATH
 271	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)"
 272	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_FILE) "$(DESTDIR)$(IBINDIR)"
 273else
 274ifdef USES_SONAME
 275	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_FILE) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_SO_FILE).$(BINARYVERSION)"
 276	cd "$(DESTDIR)$(ILIBDIR)" && ln -sf $(LIBCHICKEN_SO_FILE).$(BINARYVERSION) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)
 277else
 278	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_FILE) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_SO_FILE)"
 279endif
 280endif
 281endif
 282
 283define NL
 284
 285
 286endef # A newline, used to inject recipe lines in a loop. Ugly, but necessary
 287
 288install-dev: install-libs
 289	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)"
 290	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ISHAREDIR)"
 291	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IEGGDIR)"
 292	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)"
 293	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 294	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A) "$(DESTDIR)$(ILIBDIR)"
 295ifneq ($(POSTINSTALL_STATIC_LIBRARY),true)
 296	$(POSTINSTALL_STATIC_LIBRARY) $(POSTINSTALL_STATIC_LIBRARY_FLAGS) "$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A)"
 297endif
 298	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.h "$(DESTDIR)$(ICHICKENINCDIR)"
 299	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(CHICKEN_CONFIG_H) "$(DESTDIR)$(ICHICKENINCDIR)"
 300ifdef WINDOWS
 301	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.ico "$(DESTDIR)$(IDATADIR)"
 302	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.rc$(O) "$(DESTDIR)$(IDATADIR)"
 303endif
 304	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)types.db "$(DESTDIR)$(IEGGDIR)"
 305
 306ifeq ($(NEEDS_RELINKING),yes)
 307install-bin: $(TARGETS) install-libs install-dev
 308	$(foreach prog,$(INSTALLED_PROGRAMS),\
 309		$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(prog)$(EXE) $(NL))
 310
 311	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(IMPORT_LIBRARIES:%=%.so)
 312	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(IMPORT_LIBRARIES:%=%.import.so)
 313	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(LIBCHICKEN_SO_FILE)
 314	"$(MAKE)" PLATFORM=$(PLATFORM) CONFIG=$(CONFIG) NEEDS_RELINKING=no RUNTIME_LINKER_PATH="$(LIBDIR)" install-bin
 315# Damn. What was this for, again?
 316#
 317# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_PROGRAM)$(EXE) $(CSI_PROGRAM)$(EXE) $(CSC_PROGRAM)$(EXE) $(CHICKEN_PROFILE_PROGRAM)$(EXE)
 318# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_INSTALL_PROGRAM)$(EXE)
 319# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_UNINSTALL_PROGRAM)$(EXE)
 320# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_STATUS_PROGRAM)$(EXE)
 321else
 322install-bin: $(TARGETS) install-libs install-dev
 323	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)"
 324
 325	$(foreach prog,$(INSTALLED_PROGRAMS),\
 326		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) \
 327		$(prog)$(EXE) "$(DESTDIR)$(IBINDIR)" $(NL))
 328
 329ifdef STATICBUILD
 330	$(foreach lib,$(IMPORT_LIBRARIES),\
 331		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) \
 332		$(lib).import.scm "$(DESTDIR)$(IEGGDIR)" $(NL))
 333else
 334	$(foreach lib,$(IMPORT_LIBRARIES),\
 335		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) \
 336		$(lib).import.so "$(DESTDIR)$(IEGGDIR)" $(NL))
 337endif
 338
 339ifneq ($(POSTINSTALL_PROGRAM),true)
 340ifndef STATICBUILD
 341	$(foreach prog,$(INSTALLED_PROGRAMS),\
 342		$(POSTINSTALL_PROGRAM) $(POSTINSTALL_PROGRAM_FLAGS) \
 343		"$(DESTDIR)$(IBINDIR)$(SEP)$(prog)" $(NL))
 344
 345	$(foreach import-lib,$(IMPORT_LIBRARIES),\
 346		$(POSTINSTALL_PROGRAM) $(POSTINSTALL_PROGRAM_FLAGS) \
 347		"$(DESTDIR)$(IEGGDIR)$(SEP)$(import-lib).import.so" $(NL))
 348endif
 349endif
 350ifeq ($(CROSS_CHICKEN)$(DESTDIR),0)
 351	-$(IBINDIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM) -defaults $(SRCDIR)setup.defaults -update-db
 352else
 353	@echo
 354	@echo "Warning: cannot run \`$(CHICKEN_INSTALL_PROGRAM) -update-db' when cross-compiling or DESTDIR is set"
 355	@echo
 356endif
 357endif
 358
 359install-other-files:
 360	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)"
 361	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDOCDIR)"
 362	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 363
 364	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROGRAM).1"
 365	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)csc$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSC_PROGRAM).1"
 366	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)csi$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSI_PROGRAM).1"
 367	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-do$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_DO_PROGRAM).1"
 368	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-install$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM).1"
 369	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-uninstall$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_UNINSTALL_PROGRAM).1"
 370	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-status$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_STATUS_PROGRAM).1"
 371	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-profile$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROFILE_PROGRAM).1"
 372
 373	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDOCDIR)$(SEP)manual"
 374	-$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)manual-html$(SEP)* "$(DESTDIR)$(IDOCDIR)$(SEP)manual"
 375	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)README "$(DESTDIR)$(IDOCDIR)"
 376	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)DEPRECATED "$(DESTDIR)$(IDOCDIR)"
 377	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)LICENSE "$(DESTDIR)$(IDOCDIR)"
 378	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)setup.defaults "$(DESTDIR)$(IDATADIR)"
 379
 380install-wrappers:
 381ifeq ($(WRAPPERDIR),)
 382	@echo
 383	@echo Error: WRAPPERDIR is not set
 384	@echo
 385	@exit 1
 386endif
 387	$(foreach prg, $(INSTALLED_PROGRAMS), \
 388		$(CSI) -s $(SRCDIR)scripts$(SEP)make-wrapper.scm $(prg) "$(WRAPPERDIR)" $(NL))
 389
 390uninstall:
 391	$(foreach prog,$(INSTALLED_PROGRAMS),\
 392		$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS)\
 393		"$(DESTDIR)$(IBINDIR)$(SEP)$(prog)$(EXE)" $(NL))
 394	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A)"
 395	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)"
 396ifdef USES_SONAME
 397	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO).$(BINARYVERSION)"
 398endif
 399ifdef WINDOWS
 400	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)"
 401	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_IMPORT_LIBRARY)"
 402endif
 403ifeq ($(PLATFORM),cygwin)
 404	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)cyg$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)*"
 405endif
 406
 407	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROGRAM).1"
 408	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSC_PROGRAM).1"
 409	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSI_PROGRAM).1"
 410	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_DO_PROGRAM).1"
 411	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM).1"
 412	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_UNINSTALL_PROGRAM).1"
 413	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_STATUS_PROGRAM).1"
 414	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROFILE_PROGRAM).1"
 415
 416	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)$(SEP)chicken.h"
 417	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)$(SEP)$(CHICKEN_CONFIG_H)"
 418	$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 419	$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) "$(DESTDIR)$(IEGGDIR)"
 420
 421# build versioning
 422
 423ifdef WINDOWS_SHELL
 424buildbranch:
 425	echo.$(BRANCHNAME)>buildbranch
 426buildid:
 427	echo.$(BUILD_ID)>buildid
 428else
 429.PHONY: identify-me
 430
 431identify-me:
 432	@sh $(SRCDIR)identify.sh $(SRCDIR)
 433
 434buildbranch: identify-me
 435buildid: identify-me
 436endif
 437
 438# bootstrapping c sources
 439
 440define declare-emitted-import-lib-dependency
 441.SECONDARY: $(1).import.scm
 442$(1).import.scm: $(2).c
 443endef
 444
 445define declare-emitted-chicken-import-lib-dependency
 446$(call declare-emitted-import-lib-dependency,chicken.$(1),$(1))
 447endef
 448
 449define declare-emitted-compiler-import-lib-dependency
 450$(call declare-emitted-import-lib-dependency,chicken.compiler.$(1),$(1))
 451endef
 452
 453$(foreach lib, $(DYNAMIC_IMPORT_LIBRARIES),\
 454          $(eval $(call declare-emitted-import-lib-dependency,$(lib),$(lib))))
 455
 456$(foreach lib, $(DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES),\
 457          $(eval $(call declare-emitted-chicken-import-lib-dependency,$(lib))))
 458
 459$(foreach lib, $(COMPILER_OBJECTS_1),\
 460          $(eval $(call declare-emitted-compiler-import-lib-dependency,$(lib))))
 461
 462# special cases for modules not corresponding directly to units
 463$(eval $(call declare-emitted-import-lib-dependency,chicken.errno,$(POSIXFILE)))
 464$(eval $(call declare-emitted-import-lib-dependency,chicken.file.posix,$(POSIXFILE)))
 465$(eval $(call declare-emitted-import-lib-dependency,chicken.time.posix,$(POSIXFILE)))
 466$(eval $(call declare-emitted-import-lib-dependency,chicken.process,$(POSIXFILE)))
 467$(eval $(call declare-emitted-import-lib-dependency,chicken.process.signal,$(POSIXFILE)))
 468$(eval $(call declare-emitted-import-lib-dependency,chicken.process-context.posix,$(POSIXFILE)))
 469$(eval $(call declare-emitted-import-lib-dependency,chicken.bitwise,library))
 470$(eval $(call declare-emitted-import-lib-dependency,chicken.bytevector,library))
 471$(eval $(call declare-emitted-import-lib-dependency,chicken.fixnum,library))
 472$(eval $(call declare-emitted-import-lib-dependency,chicken.flonum,library))
 473$(eval $(call declare-emitted-import-lib-dependency,chicken.gc,library))
 474$(eval $(call declare-emitted-import-lib-dependency,chicken.keyword,library))
 475$(eval $(call declare-emitted-import-lib-dependency,chicken.platform,library))
 476$(eval $(call declare-emitted-import-lib-dependency,chicken.plist,library))
 477$(eval $(call declare-emitted-import-lib-dependency,chicken.process-context,library))
 478$(eval $(call declare-emitted-import-lib-dependency,chicken.time,library))
 479$(eval $(call declare-emitted-import-lib-dependency,chicken.load,eval))
 480$(eval $(call declare-emitted-import-lib-dependency,chicken.format,extras))
 481$(eval $(call declare-emitted-import-lib-dependency,chicken.io,library))
 482$(eval $(call declare-emitted-import-lib-dependency,chicken.pretty-print,extras))
 483$(eval $(call declare-emitted-import-lib-dependency,chicken.version,extras))
 484$(eval $(call declare-emitted-import-lib-dependency,chicken.random,extras))
 485$(eval $(call declare-emitted-import-lib-dependency,chicken.locative,lolevel))
 486$(eval $(call declare-emitted-import-lib-dependency,chicken.memory,lolevel))
 487$(eval $(call declare-emitted-import-lib-dependency,chicken.memory.representation,lolevel))
 488$(eval $(call declare-emitted-import-lib-dependency,chicken.number-vector,srfi-4))
 489$(eval $(call declare-emitted-import-lib-dependency,chicken.sort,data-structures))
 490$(eval $(call declare-emitted-import-lib-dependency,chicken.string,data-structures))
 491$(eval $(call declare-emitted-import-lib-dependency,scheme.write,r7lib))
 492$(eval $(call declare-emitted-import-lib-dependency,scheme.time,r7lib))
 493$(eval $(call declare-emitted-import-lib-dependency,scheme.file,r7lib))
 494$(eval $(call declare-emitted-import-lib-dependency,scheme.process-context,r7lib))
 495
 496chicken.c: chicken.scm mini-srfi-1.scm \
 497		chicken.compiler.batch-driver.import.scm \
 498		chicken.compiler.c-platform.import.scm \
 499		chicken.compiler.support.import.scm \
 500		chicken.compiler.user-pass.import.scm \
 501		chicken.process-context.import.scm \
 502		chicken.string.import.scm
 503batch-driver.c: batch-driver.scm mini-srfi-1.scm \
 504		chicken.compiler.core.import.scm \
 505		chicken.compiler.compiler-syntax.import.scm \
 506		chicken.compiler.optimizer.import.scm \
 507		chicken.compiler.scrutinizer.import.scm \
 508		chicken.compiler.c-platform.import.scm \
 509		chicken.compiler.lfa2.import.scm \
 510		chicken.compiler.c-backend.import.scm \
 511		chicken.compiler.support.import.scm \
 512		chicken.compiler.user-pass.import.scm \
 513		chicken.format.import.scm \
 514		chicken.gc.import.scm \
 515		chicken.internal.import.scm \
 516		chicken.load.import.scm \
 517		chicken.pathname.import.scm \
 518		chicken.platform.import.scm \
 519		chicken.pretty-print.import.scm \
 520		chicken.process-context.import.scm \
 521		chicken.process-context.posix.import.scm \
 522		chicken.condition.import.scm \
 523		chicken.port.import.scm \
 524		chicken.string.import.scm \
 525		chicken.syntax.import.scm \
 526		chicken.time.import.scm
 527c-platform.c: c-platform.scm mini-srfi-1.scm \
 528		chicken.compiler.optimizer.import.scm \
 529		chicken.compiler.support.import.scm \
 530		chicken.compiler.core.import.scm \
 531		chicken.internal.import.scm
 532c-backend.c: c-backend.scm mini-srfi-1.scm \
 533		chicken.compiler.c-platform.import.scm \
 534		chicken.compiler.support.import.scm \
 535		chicken.compiler.core.import.scm \
 536		chicken.bitwise.import.scm \
 537		chicken.flonum.import.scm \
 538		chicken.foreign.import.scm \
 539		chicken.format.import.scm \
 540		chicken.internal.import.scm \
 541		chicken.sort.import.scm \
 542		chicken.string.import.scm \
 543		chicken.time.import.scm
 544core.c: core.scm mini-srfi-1.scm \
 545		chicken.compiler.scrutinizer.import.scm \
 546		chicken.compiler.support.import.scm \
 547		chicken.eval.import.scm \
 548		chicken.file.import.scm \
 549		chicken.fixnum.import.scm \
 550		chicken.format.import.scm \
 551		chicken.io.import.scm \
 552		chicken.keyword.import.scm \
 553		chicken.load.import.scm \
 554		chicken.pretty-print.import.scm \
 555		chicken.string.import.scm \
 556		chicken.syntax.import.scm
 557optimizer.c: optimizer.scm mini-srfi-1.scm \
 558		chicken.compiler.support.import.scm \
 559		chicken.fixnum.import.scm \
 560		chicken.internal.import.scm \
 561		chicken.sort.import.scm \
 562		chicken.string.import.scm
 563scheduler.c: scheduler.scm \
 564		chicken.fixnum.import.scm \
 565		chicken.format.import.scm \
 566		chicken.condition.import.scm
 567scrutinizer.c: scrutinizer.scm mini-srfi-1.scm \
 568		chicken.compiler.support.import.scm \
 569		chicken.fixnum.import.scm \
 570		chicken.format.import.scm \
 571		chicken.internal.import.scm \
 572		chicken.io.import.scm \
 573		chicken.pathname.import.scm \
 574		chicken.platform.import.scm \
 575		chicken.sort.import.scm \
 576		chicken.port.import.scm \
 577		chicken.pretty-print.import.scm \
 578		chicken.string.import.scm
 579lfa2.c: lfa2.scm mini-srfi-1.scm \
 580		chicken.compiler.support.import.scm \
 581		chicken.format.import.scm
 582compiler-syntax.c: compiler-syntax.scm mini-srfi-1.scm \
 583		chicken.compiler.support.import.scm \
 584		chicken.compiler.core.import.scm \
 585		chicken.fixnum.import.scm \
 586		chicken.format.import.scm \
 587		chicken.syntax.import.scm
 588chicken-ffi-syntax.c: chicken-ffi-syntax.scm \
 589		chicken.format.import.scm \
 590		chicken.internal.import.scm \
 591		chicken.string.import.scm
 592support.c: support.scm mini-srfi-1.scm \
 593		chicken.bitwise.import.scm \
 594		chicken.bytevector.import.scm \
 595		chicken.condition.import.scm \
 596		chicken.file.import.scm \
 597		chicken.fixnum.import.scm \
 598		chicken.foreign.import.scm \
 599		chicken.format.import.scm \
 600		chicken.internal.import.scm \
 601		chicken.io.import.scm \
 602		chicken.keyword.import.scm \
 603		chicken.pathname.import.scm \
 604		chicken.platform.import.scm \
 605		chicken.plist.import.scm \
 606		chicken.port.import.scm \
 607		chicken.pretty-print.import.scm \
 608		chicken.random.import.scm \
 609		chicken.sort.import.scm \
 610		chicken.string.import.scm \
 611		chicken.time.import.scm
 612modules.c: modules.scm \
 613		chicken.internal.import.scm \
 614		chicken.format.import.scm \
 615		chicken.keyword.import.scm \
 616		chicken.base.import.scm \
 617		chicken.syntax.import.scm \
 618		chicken.load.import.scm \
 619		chicken.platform.import.scm
 620csc.c: csc.scm \
 621		chicken.file.import.scm \
 622		chicken.foreign.import.scm \
 623		chicken.format.import.scm \
 624		chicken.io.import.scm \
 625		chicken.pathname.import.scm \
 626		chicken.process.import.scm \
 627		chicken.process-context.import.scm \
 628		chicken.string.import.scm
 629csi.c: csi.scm \
 630		chicken.condition.import.scm \
 631		chicken.file.import.scm \
 632		chicken.foreign.import.scm \
 633		chicken.format.import.scm \
 634		chicken.gc.import.scm \
 635		chicken.internal.import.scm \
 636		chicken.io.import.scm \
 637		chicken.keyword.import.scm \
 638		chicken.load.import.scm \
 639		chicken.platform.import.scm \
 640		chicken.port.import.scm \
 641		chicken.pretty-print.import.scm \
 642		chicken.process.import.scm \
 643		chicken.process-context.import.scm \
 644		chicken.repl.import.scm \
 645		chicken.sort.import.scm \
 646		chicken.string.import.scm \
 647		scheme.write.import.scm
 648chicken-profile.c: chicken-profile.scm \
 649		chicken.internal.import.scm \
 650		chicken.file.import.scm \
 651		chicken.file.posix.import.scm \
 652		chicken.fixnum.import.scm \
 653		chicken.process-context.import.scm \
 654		chicken.sort.import.scm \
 655		chicken.string.import.scm
 656chicken-status.c: chicken-status.scm \
 657		chicken.file.import.scm \
 658		chicken.file.posix.import.scm \
 659		chicken.fixnum.import.scm \
 660		chicken.foreign.import.scm \
 661		chicken.format.import.scm \
 662		chicken.irregex.import.scm \
 663		chicken.pathname.import.scm \
 664		chicken.port.import.scm \
 665		chicken.pretty-print.import.scm \
 666		chicken.process-context.import.scm \
 667		chicken.sort.import.scm \
 668		chicken.string.import.scm
 669chicken-install.c: chicken-install.scm \
 670		chicken.condition.import.scm \
 671		chicken.file.import.scm \
 672		chicken.file.posix.import.scm \
 673		chicken.fixnum.import.scm \
 674		chicken.foreign.import.scm \
 675		chicken.format.import.scm \
 676		chicken.internal.import.scm \
 677		chicken.io.import.scm \
 678		chicken.irregex.import.scm \
 679		chicken.pathname.import.scm \
 680		chicken.port.import.scm \
 681		chicken.pretty-print.import.scm \
 682		chicken.process.import.scm \
 683		chicken.process-context.import.scm \
 684		chicken.sort.import.scm \
 685		chicken.string.import.scm \
 686		chicken.version.import.scm \
 687		chicken.tcp.import.scm
 688chicken-uninstall.c: chicken-uninstall.scm \
 689		chicken.file.import.scm \
 690		chicken.fixnum.import.scm \
 691		chicken.foreign.import.scm \
 692		chicken.format.import.scm \
 693		chicken.irregex.import.scm \
 694		chicken.pathname.import.scm \
 695		chicken.port.import.scm \
 696		chicken.process.import.scm \
 697		chicken.process-context.import.scm \
 698		chicken.string.import.scm
 699chicken-syntax.c: chicken-syntax.scm \
 700		chicken.fixnum.import.scm \
 701		chicken.platform.import.scm \
 702		chicken.internal.import.scm
 703srfi-4.c: srfi-4.scm \
 704		chicken.bitwise.import.scm \
 705		chicken.bytevector.import.scm \
 706		chicken.fixnum.import.scm \
 707		chicken.foreign.import.scm \
 708		chicken.gc.import.scm \
 709		chicken.platform.import.scm
 710posixunix.c: posixunix.scm \
 711		chicken.bitwise.import.scm \
 712		chicken.condition.import.scm \
 713		chicken.foreign.import.scm \
 714		chicken.memory.import.scm \
 715		chicken.pathname.import.scm \
 716		chicken.platform.import.scm \
 717		chicken.port.import.scm \
 718		chicken.process-context.import.scm \
 719		chicken.time.import.scm
 720posixwin.c: posixwin.scm \
 721		chicken.condition.import.scm \
 722		chicken.bitwise.import.scm \
 723		chicken.foreign.import.scm \
 724		chicken.memory.import.scm \
 725		chicken.pathname.import.scm \
 726		chicken.platform.import.scm \
 727		chicken.port.import.scm \
 728		chicken.process-context.import.scm \
 729		chicken.string.import.scm \
 730		chicken.time.import.scm
 731data-structures.c: data-structures.scm \
 732		chicken.condition.import.scm \
 733		chicken.fixnum.import.scm \
 734		chicken.foreign.import.scm
 735expand.c: expand.scm \
 736		chicken.bytevector.import.scm \
 737		chicken.condition.import.scm \
 738		chicken.fixnum.import.scm \
 739		chicken.keyword.import.scm \
 740		chicken.platform.import.scm \
 741		chicken.string.import.scm \
 742		chicken.internal.import.scm
 743extras.c: extras.scm \
 744		chicken.fixnum.import.scm \
 745		chicken.string.import.scm \
 746		chicken.time.import.scm
 747eval.c: eval.scm \
 748		chicken.bytevector.import.scm \
 749		chicken.condition.import.scm \
 750		chicken.fixnum.import.scm \
 751		chicken.foreign.import.scm \
 752		chicken.internal.import.scm \
 753		chicken.keyword.import.scm \
 754		chicken.syntax.import.scm \
 755		chicken.platform.import.scm
 756repl.c: repl.scm \
 757		chicken.eval.import.scm
 758file.c: file.scm \
 759		chicken.condition.import.scm \
 760		chicken.fixnum.import.scm \
 761		chicken.io.import.scm \
 762		chicken.irregex.import.scm \
 763		chicken.foreign.import.scm \
 764		chicken.pathname.import.scm \
 765		chicken.process-context.import.scm
 766lolevel.c: lolevel.scm \
 767		chicken.fixnum.import.scm \
 768		chicken.foreign.import.scm
 769pathname.c: pathname.scm \
 770		chicken.fixnum.import.scm \
 771		chicken.irregex.import.scm \
 772		chicken.platform.import.scm \
 773		chicken.string.import.scm
 774port.c: port.scm \
 775		chicken.fixnum.import.scm \
 776		chicken.io.import.scm
 777read-syntax.c: read-syntax.scm \
 778		chicken.internal.import.scm \
 779		chicken.platform.import.scm
 780tcp.c: tcp.scm \
 781		chicken.fixnum.import.scm \
 782		chicken.foreign.import.scm \
 783		chicken.port.import.scm \
 784		chicken.time.import.scm
 785eval-modules.c: eval-modules.scm $(DYNAMIC_IMPORT_LIBRARIES:=.import.scm) \
 786	$(foreach lib,$(DYNAMIC_CHICKEN_IMPORT_LIBRARIES),chicken.$(lib).import.scm) \
 787	$(foreach lib,$(DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES),$(lib).c)
 788continuation.c: continuation.scm \
 789		chicken.fixnum.import.scm
 790internal.c: internal.scm \
 791		chicken.fixnum.import.scm
 792irregex.c: irregex.scm \
 793		chicken.fixnum.import.scm \
 794		chicken.syntax.import.scm
 795profiler.c: profiler.scm \
 796		chicken.fixnum.import.scm
 797stub.c: stub.scm \
 798		chicken.platform.import.scm
 799r7lib.c: r7lib.scm \
 800		chicken.platform.import.scm \
 801		chicken.process-context.import.scm \
 802		chicken.time.import.scm \
 803		chicken.io.import.scm \
 804		chicken.file.import.scm
 805
 806define profile-flags
 807$(if $(filter $(basename $(1)),$(PROFILE_OBJECTS)),-profile)
 808endef
 809
 810bootstrap-lib = $(CHICKEN) $(call profile-flags, $@) $< $(CHICKEN_LIBRARY_OPTIONS) -output-file $@
 811
 812library.c: $(SRCDIR)library.scm
 813	$(bootstrap-lib) \
 814	-no-module-registration \
 815	-emit-import-library chicken.bitwise \
 816	-emit-import-library chicken.bytevector \
 817	-emit-import-library chicken.fixnum \
 818	-emit-import-library chicken.flonum \
 819	-emit-import-library chicken.gc \
 820	-emit-import-library chicken.keyword \
 821	-emit-import-library chicken.platform \
 822	-emit-import-library chicken.plist \
 823	-emit-import-library chicken.io \
 824	-emit-import-library chicken.process-context
 825internal.c: $(SRCDIR)internal.scm $(SRCDIR)mini-srfi-1.scm
 826	$(bootstrap-lib) -emit-import-library chicken.internal
 827eval.c: $(SRCDIR)eval.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 828	$(bootstrap-lib) \
 829	-emit-import-library chicken.eval \
 830	-emit-import-library chicken.load
 831r7lib.c: $(SRCDIR)r7lib.scm $(SRCDIR)common-declarations.scm
 832	$(bootstrap-lib) -emit-import-library scheme.write \
 833	-emit-import-library scheme.time \
 834	-emit-import-library scheme.file \
 835	-emit-import-library scheme.process-context
 836read-syntax.c: $(SRCDIR)read-syntax.scm $(SRCDIR)common-declarations.scm
 837	$(bootstrap-lib) -emit-import-library chicken.read-syntax
 838repl.c: $(SRCDIR)repl.scm $(SRCDIR)common-declarations.scm
 839	$(bootstrap-lib) -emit-import-library chicken.repl
 840expand.c: $(SRCDIR)expand.scm $(SRCDIR)synrules.scm $(SRCDIR)common-declarations.scm
 841	$(bootstrap-lib) \
 842	-no-module-registration
 843modules.c: $(SRCDIR)modules.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 844	$(bootstrap-lib)
 845extras.c: $(SRCDIR)extras.scm $(SRCDIR)common-declarations.scm
 846	$(bootstrap-lib) \
 847	-emit-import-library chicken.format \
 848	-emit-import-library chicken.pretty-print \
 849	-emit-import-library chicken.random \
 850	-emit-import-library chicken.version
 851posixunix.c: $(SRCDIR)posix.scm $(SRCDIR)posixunix.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
 852	$(bootstrap-lib) -feature platform-unix \
 853	-emit-import-library chicken.errno \
 854	-emit-import-library chicken.file.posix \
 855	-emit-import-library chicken.time.posix \
 856	-emit-import-library chicken.process \
 857	-emit-import-library chicken.process.signal \
 858	-emit-import-library chicken.process-context.posix \
 859	-no-module-registration
 860posixwin.c: $(SRCDIR)posix.scm $(SRCDIR)posixwin.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
 861	$(bootstrap-lib) -feature platform-windows \
 862	-emit-import-library chicken.errno \
 863	-emit-import-library chicken.file.posix \
 864	-emit-import-library chicken.time.posix \
 865	-emit-import-library chicken.process \
 866	-emit-import-library chicken.process.signal \
 867	-emit-import-library chicken.process-context.posix \
 868	-no-module-registration
 869irregex.c: $(SRCDIR)irregex.scm $(SRCDIR)irregex-core.scm $(SRCDIR)irregex-utils.scm $(SRCDIR)common-declarations.scm
 870	$(bootstrap-lib) -emit-import-library chicken.irregex
 871chicken-syntax.c: $(SRCDIR)chicken-syntax.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 872	$(bootstrap-lib)
 873chicken-ffi-syntax.c: $(SRCDIR)chicken-ffi-syntax.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 874	$(bootstrap-lib)
 875continuation.c: $(SRCDIR)continuation.scm $(SRCDIR)common-declarations.scm
 876	$(bootstrap-lib) -emit-import-library chicken.continuation
 877data-structures.c: $(SRCDIR)data-structures.scm $(SRCDIR)common-declarations.scm
 878	$(bootstrap-lib) \
 879	-emit-import-library chicken.sort \
 880	-emit-import-library chicken.string
 881pathname.c: $(SRCDIR)pathname.scm $(SRCDIR)common-declarations.scm
 882	$(bootstrap-lib) -emit-import-library chicken.pathname
 883port.c: $(SRCDIR)port.scm $(SRCDIR)common-declarations.scm
 884	$(bootstrap-lib) -emit-import-library chicken.port
 885file.c: $(SRCDIR)file.scm $(SRCDIR)common-declarations.scm
 886	$(bootstrap-lib) -emit-import-library chicken.file
 887lolevel.c: $(SRCDIR)lolevel.scm $(SRCDIR)common-declarations.scm
 888	$(bootstrap-lib) \
 889	-emit-import-library chicken.locative \
 890	-emit-import-library chicken.memory \
 891	-emit-import-library chicken.memory.representation
 892tcp.c: $(SRCDIR)tcp.scm $(SRCDIR)common-declarations.scm
 893	$(bootstrap-lib) -emit-import-library chicken.tcp
 894srfi-4.c: $(SRCDIR)srfi-4.scm $(SRCDIR)common-declarations.scm
 895	$(bootstrap-lib) -emit-import-library srfi-4 \
 896	 -emit-import-library chicken.number-vector
 897scheduler.c: $(SRCDIR)scheduler.scm $(SRCDIR)common-declarations.scm
 898	$(bootstrap-lib)
 899profiler.c: $(SRCDIR)profiler.scm $(SRCDIR)common-declarations.scm
 900	$(bootstrap-lib)
 901stub.c: $(SRCDIR)stub.scm $(SRCDIR)common-declarations.scm
 902	$(bootstrap-lib)
 903debugger-client.c: $(SRCDIR)debugger-client.scm $(SRCDIR)common-declarations.scm dbg-stub.c
 904	$(bootstrap-lib)
 905build-version.c: $(SRCDIR)build-version.scm $(SRCDIR)buildversion buildbranch buildid
 906	$(bootstrap-lib)
 907eval-modules.c: $(SRCDIR)eval-modules.scm $(SRCDIR)common-declarations.scm
 908	$(bootstrap-lib)
 909
 910define declare-bootstrap-import-lib
 911$(1).import.c: $$(SRCDIR)$(1).import.scm
 912	$$(CHICKEN) $$< $$(CHICKEN_IMPORT_LIBRARY_OPTIONS) -output-file $$@
 913endef
 914
 915$(foreach obj, $(IMPORT_LIBRARIES),\
 916          $(eval $(call declare-bootstrap-import-lib,$(obj))))
 917
 918# Bootstrap compiler objects
 919
 920define declare-bootstrap-compiler-object
 921$(1).c: $$(SRCDIR)$(1).scm $$(SRCDIR)tweaks.scm
 922	$$(CHICKEN) $$< $$(CHICKEN_PROGRAM_OPTIONS) -emit-import-library chicken.compiler.$(1) \
 923		-output-file $$@
 924endef
 925
 926$(foreach obj, $(COMPILER_OBJECTS_1),\
 927          $(eval $(call declare-bootstrap-compiler-object,$(obj))))
 928
 929csi.c: $(SRCDIR)csi.scm $(SRCDIR)banner.scm $(SRCDIR)mini-srfi-1.scm
 930	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 931chicken-profile.c: $(SRCDIR)chicken-profile.scm $(SRCDIR)mini-srfi-1.scm
 932	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 933chicken-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
 934	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 935chicken-uninstall.c: $(SRCDIR)chicken-uninstall.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-environment.scm $(SRCDIR)egg-information.scm
 936	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 937chicken-status.c: $(SRCDIR)chicken-status.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-environment.scm $(SRCDIR)egg-information.scm
 938	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 939csc.c: $(SRCDIR)csc.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-environment.scm
 940	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 941
 942# distribution files
 943
 944.PHONY: distfiles dist html
 945
 946distfiles: $(DISTFILES)
 947
 948dist: distfiles html
 949	echo '# this file is intentionally empty' > config.make
 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	  $(LIBCHICKEN_SO_FILE) \
 975	  $(PRIMARY_LIBCHICKEN) \
 976	  lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A) \
 977	  $(IMPORT_LIBRARIES:=.import.so) $(LIBCHICKEN_IMPORT_LIBRARY) \
 978	  $(foreach lib,$(DYNAMIC_IMPORT_LIBRARIES),chicken.$(lib).import.scm) \
 979	  $(BUILD_CONFIG_FILES)
 980ifdef USES_SONAME
 981	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX).so.$(BINARYVERSION)
 982endif
 983
 984confclean:
 985	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(BUILD_CONFIG_FILES)
 986	touch config.make
 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)
1021	cd tests; sh runtests.sh
1022
1023# benchmark
1024
1025.PHONY: bench
1026
1027bench: $(CHICKEN_SHARED_EXECUTABLE) $(CSI_SHARED_EXECUTABLE) $(CSC_PROGRAM)$(EXE)
1028	cd tests; echo >>bench.log; date >>bench.log; sh runbench.sh 2>&1 | tee -a bench.log
1029
1030
1031# build static bootstrapping chicken
1032
1033.PHONY: boot-chicken bootclean
1034
1035STAGE1_CONFIG = PLATFORM=$(PLATFORM) PREFIX=/nowhere CONFIG= \
1036    CHICKEN=$(CHICKEN) PROGRAM_SUFFIX=-boot-stage1 STATICBUILD=1 \
1037    C_COMPILER_OPTIMIZATION_OPTIONS="$(C_COMPILER_OPTIMIZATION_OPTIONS)" BUILDING_CHICKEN_BOOT=1
1038
1039BOOT_CONFIG = PLATFORM=$(PLATFORM) PREFIX=/nowhere CONFIG= \
1040    CHICKEN=.$(SEP)chicken-boot-stage1$(EXE) PROGRAM_SUFFIX=-boot \
1041    STATICBUILD=1 C_COMPILER_OPTIMIZATION_OPTIONS="$(C_COMPILER_OPTIMIZATION_OPTIONS)"
1042
1043boot-chicken:
1044	"$(MAKE)" $(STAGE1_CONFIG) confclean
1045	"$(MAKE)" $(STAGE1_CONFIG) chicken-boot-stage1$(EXE)
1046	"$(MAKE)" $(BOOT_CONFIG) touchfiles
1047	"$(MAKE)" $(BOOT_CONFIG) chicken-boot$(EXE)
1048	"$(MAKE)" $(BOOT_CONFIG) confclean
1049
1050bootclean:
1051	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) \
1052	  $(SRCDIR)chicken-boot$(EXE) \
1053	  $(SRCDIR)chicken-boot-stage1$(EXE) \
1054	  $(SRCDIR)libchicken-boot$(A) \
1055	  $(SRCDIR)libchicken-boot-stage1$(A)
1056
1057.PHONY: touchfiles
1058
1059touchfiles:
1060ifdef WINDOWS_SHELL
1061	for %%x in (*.scm) do copy /b %%x +,,
1062else
1063	touch *.scm
1064endif
Trap