~ 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)
 225endef
 226
 227# Unfortunately, we can't loop over INSTALLED_PROGRAMS here because of
 228# the possible name mangling and EXE suffixing in there :(
 229$(eval $(call declare-program-from-object,$(CSI_SHARED_EXECUTABLE),csi))
 230$(eval $(call declare-program-from-object,$(CHICKEN_INSTALL_PROGRAM)$(EXE),chicken-install,true))
 231$(eval $(call declare-program-from-object,$(CHICKEN_UNINSTALL_PROGRAM)$(EXE),chicken-uninstall,true))
 232$(eval $(call declare-program-from-object,$(CHICKEN_STATUS_PROGRAM)$(EXE),chicken-status))
 233$(eval $(call declare-program-from-object,$(CHICKEN_PROFILE_PROGRAM)$(EXE),chicken-profile))
 234$(eval $(call declare-program-from-object,$(CSC_PROGRAM)$(EXE),csc))
 235
 236# static executables
 237
 238$(CHICKEN_STATIC_EXECUTABLE): $(COMPILER_STATIC_OBJECTS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A)
 239	$(LINKER) $(LINKER_OPTIONS) $(LINKER_STATIC_OPTIONS) $(COMPILER_STATIC_OBJECTS) $(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A) $(LIBRARIES)
 240
 241define declare-static-program-from-object
 242$(1): $(2)$(O) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A)
 243	$$(LINKER) $$(LINKER_OPTIONS) $$(LINKER_STATIC_OPTIONS) $$< $$(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A) $$(LIBRARIES)
 244endef
 245
 246$(eval $(call declare-program-from-object,$(CSI_STATIC_EXECUTABLE),csi))
 247
 248# "chicken-do"
 249
 250$(CHICKEN_DO_PROGRAM)$(EXE): $(SRCDIR)chicken-do.c chicken.h $(CHICKEN_CONFIG_H)
 251	$(C_COMPILER) $(C_COMPILER_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS) $< -o $@
 252
 253
 254# installation
 255
 256.PHONY: install uninstall install-libs
 257.PHONY: install-target install-dev install-bin install-other-files install-wrappers
 258
 259install: $(TARGETS) install-target install-bin install-libs install-dev install-other-files
 260
 261install-target: install-libs
 262
 263install-libs: libs $(LIBCHICKEN_IMPORT_LIBRARY)
 264	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)"
 265ifneq ($(LIBCHICKEN_IMPORT_LIBRARY),)
 266	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) $(LIBCHICKEN_IMPORT_LIBRARY) "$(DESTDIR)$(ILIBDIR)"
 267endif
 268ifndef STATICBUILD
 269ifdef DLLSINPATH
 270	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)"
 271	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_FILE) "$(DESTDIR)$(IBINDIR)"
 272else
 273ifdef USES_SONAME
 274	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_FILE) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_SO_FILE).$(BINARYVERSION)"
 275	cd "$(DESTDIR)$(ILIBDIR)" && ln -sf $(LIBCHICKEN_SO_FILE).$(BINARYVERSION) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)
 276else
 277	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_FILE) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_SO_FILE)"
 278endif
 279endif
 280endif
 281
 282define NL
 283
 284
 285endef # A newline, used to inject recipe lines in a loop. Ugly, but necessary
 286
 287install-dev: install-libs
 288	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)"
 289	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ISHAREDIR)"
 290	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IEGGDIR)"
 291	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)"
 292	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 293	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_STATIC_LIBRARY_OPTIONS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A) "$(DESTDIR)$(ILIBDIR)"
 294ifneq ($(POSTINSTALL_STATIC_LIBRARY),true)
 295	$(POSTINSTALL_STATIC_LIBRARY) $(POSTINSTALL_STATIC_LIBRARY_FLAGS) "$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A)"
 296endif
 297	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.h "$(DESTDIR)$(ICHICKENINCDIR)"
 298	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(CHICKEN_CONFIG_H) "$(DESTDIR)$(ICHICKENINCDIR)"
 299ifdef WINDOWS
 300	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.ico "$(DESTDIR)$(IDATADIR)"
 301	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken.rc$(O) "$(DESTDIR)$(IDATADIR)"
 302endif
 303	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)types.db "$(DESTDIR)$(IEGGDIR)"
 304
 305ifeq ($(NEEDS_RELINKING),yes)
 306install-bin: $(TARGETS) install-libs install-dev
 307	$(foreach prog,$(INSTALLED_PROGRAMS),\
 308		$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(prog)$(EXE) $(NL))
 309
 310	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(IMPORT_LIBRARIES:%=%.so)
 311	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(IMPORT_LIBRARIES:%=%.import.so)
 312	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(LIBCHICKEN_SO_FILE)
 313	"$(MAKE)" PLATFORM=$(PLATFORM) CONFIG=$(CONFIG) NEEDS_RELINKING=no RUNTIME_LINKER_PATH="$(LIBDIR)" install-bin
 314# Damn. What was this for, again?
 315#
 316# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_PROGRAM)$(EXE) $(CSI_PROGRAM)$(EXE) $(CSC_PROGRAM)$(EXE) $(CHICKEN_PROFILE_PROGRAM)$(EXE)
 317# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_INSTALL_PROGRAM)$(EXE)
 318# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_UNINSTALL_PROGRAM)$(EXE)
 319# 	$(MAKE_WRITABLE_COMMAND) $(CHICKEN_STATUS_PROGRAM)$(EXE)
 320else
 321install-bin: $(TARGETS) install-libs install-dev
 322	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)"
 323
 324	$(foreach prog,$(INSTALLED_PROGRAMS),\
 325		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) \
 326		$(prog)$(EXE) "$(DESTDIR)$(IBINDIR)" $(NL))
 327
 328ifdef STATICBUILD
 329	$(foreach lib,$(IMPORT_LIBRARIES),\
 330		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) \
 331		$(lib).import.scm "$(DESTDIR)$(IEGGDIR)" $(NL))
 332else
 333	$(foreach lib,$(IMPORT_LIBRARIES),\
 334		$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_EXECUTABLE_OPTIONS) \
 335		$(lib).import.so "$(DESTDIR)$(IEGGDIR)" $(NL))
 336endif
 337
 338ifneq ($(POSTINSTALL_PROGRAM),true)
 339ifndef STATICBUILD
 340	$(foreach prog,$(INSTALLED_PROGRAMS),\
 341		$(POSTINSTALL_PROGRAM) $(POSTINSTALL_PROGRAM_FLAGS) \
 342		"$(DESTDIR)$(IBINDIR)$(SEP)$(prog)" $(NL))
 343
 344	$(foreach import-lib,$(IMPORT_LIBRARIES),\
 345		$(POSTINSTALL_PROGRAM) $(POSTINSTALL_PROGRAM_FLAGS) \
 346		"$(DESTDIR)$(IEGGDIR)$(SEP)$(import-lib).import.so" $(NL))
 347endif
 348endif
 349ifeq ($(CROSS_CHICKEN)$(DESTDIR),0)
 350	-$(IBINDIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM) -defaults $(SRCDIR)setup.defaults -update-db
 351else
 352	@echo
 353	@echo "Warning: cannot run \`$(CHICKEN_INSTALL_PROGRAM) -update-db' when cross-compiling or DESTDIR is set"
 354	@echo
 355endif
 356endif
 357
 358install-other-files:
 359	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)"
 360	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDOCDIR)"
 361	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 362
 363	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROGRAM).1"
 364	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)csc$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSC_PROGRAM).1"
 365	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)csi$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSI_PROGRAM).1"
 366	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-do$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_DO_PROGRAM).1"
 367	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-install$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM).1"
 368	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-uninstall$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_UNINSTALL_PROGRAM).1"
 369	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-status$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_STATUS_PROGRAM).1"
 370	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)chicken-profile$(MAN) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROFILE_PROGRAM).1"
 371
 372	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) "$(DESTDIR)$(IDOCDIR)$(SEP)manual"
 373	-$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)manual-html$(SEP)* "$(DESTDIR)$(IDOCDIR)$(SEP)manual"
 374	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)README "$(DESTDIR)$(IDOCDIR)"
 375	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)DEPRECATED "$(DESTDIR)$(IDOCDIR)"
 376	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)LICENSE "$(DESTDIR)$(IDOCDIR)"
 377	$(INSTALL_PROGRAM) $(INSTALL_PROGRAM_FILE_OPTIONS) $(SRCDIR)setup.defaults "$(DESTDIR)$(IDATADIR)"
 378
 379install-wrappers:
 380ifeq ($(WRAPPERDIR),)
 381	@echo
 382	@echo Error: WRAPPERDIR is not set
 383	@echo
 384	@exit 1
 385endif
 386	$(foreach prg, $(INSTALLED_PROGRAMS), \
 387		$(CSI) -s $(SRCDIR)scripts$(SEP)make-wrapper.scm $(prg) "$(WRAPPERDIR)" $(NL))
 388
 389uninstall:
 390	$(foreach prog,$(INSTALLED_PROGRAMS),\
 391		$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS)\
 392		"$(DESTDIR)$(IBINDIR)$(SEP)$(prog)$(EXE)" $(NL))
 393	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A)"
 394	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)"
 395ifdef USES_SONAME
 396	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO).$(BINARYVERSION)"
 397endif
 398ifdef WINDOWS
 399	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO)"
 400	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ILIBDIR)$(SEP)$(LIBCHICKEN_IMPORT_LIBRARY)"
 401endif
 402ifeq ($(PLATFORM),cygwin)
 403	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IBINDIR)$(SEP)cyg$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)*"
 404endif
 405
 406	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROGRAM).1"
 407	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSC_PROGRAM).1"
 408	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CSI_PROGRAM).1"
 409	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_DO_PROGRAM).1"
 410	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_INSTALL_PROGRAM).1"
 411	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_UNINSTALL_PROGRAM).1"
 412	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_STATUS_PROGRAM).1"
 413	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(IMAN1DIR)$(SEP)$(CHICKEN_PROFILE_PROGRAM).1"
 414
 415	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)$(SEP)chicken.h"
 416	$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) "$(DESTDIR)$(ICHICKENINCDIR)$(SEP)$(CHICKEN_CONFIG_H)"
 417	$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) "$(DESTDIR)$(IDATADIR)"
 418	$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) "$(DESTDIR)$(IEGGDIR)"
 419
 420# build versioning
 421
 422ifdef WINDOWS_SHELL
 423buildbranch:
 424	echo.$(BRANCHNAME)>buildbranch
 425buildid:
 426	echo.$(BUILD_ID)>buildid
 427else
 428.PHONY: identify-me
 429
 430identify-me:
 431	@sh $(SRCDIR)identify.sh $(SRCDIR)
 432
 433buildbranch: identify-me
 434buildid: identify-me
 435endif
 436
 437# bootstrapping c sources
 438
 439define declare-emitted-import-lib-dependency
 440.SECONDARY: $(1).import.scm
 441$(1).import.scm: $(2).c
 442endef
 443
 444define declare-emitted-chicken-import-lib-dependency
 445$(call declare-emitted-import-lib-dependency,chicken.$(1),$(1))
 446endef
 447
 448define declare-emitted-compiler-import-lib-dependency
 449$(call declare-emitted-import-lib-dependency,chicken.compiler.$(1),$(1))
 450endef
 451
 452$(foreach lib, $(DYNAMIC_IMPORT_LIBRARIES),\
 453          $(eval $(call declare-emitted-import-lib-dependency,$(lib),$(lib))))
 454
 455$(foreach lib, $(DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES),\
 456          $(eval $(call declare-emitted-chicken-import-lib-dependency,$(lib))))
 457
 458$(foreach lib, $(COMPILER_OBJECTS_1),\
 459          $(eval $(call declare-emitted-compiler-import-lib-dependency,$(lib))))
 460
 461# special cases for modules not corresponding directly to units
 462$(eval $(call declare-emitted-import-lib-dependency,chicken.errno,$(POSIXFILE)))
 463$(eval $(call declare-emitted-import-lib-dependency,chicken.file.posix,$(POSIXFILE)))
 464$(eval $(call declare-emitted-import-lib-dependency,chicken.time.posix,$(POSIXFILE)))
 465$(eval $(call declare-emitted-import-lib-dependency,chicken.process,$(POSIXFILE)))
 466$(eval $(call declare-emitted-import-lib-dependency,chicken.process.signal,$(POSIXFILE)))
 467$(eval $(call declare-emitted-import-lib-dependency,chicken.process-context.posix,$(POSIXFILE)))
 468$(eval $(call declare-emitted-import-lib-dependency,chicken.bitwise,library))
 469$(eval $(call declare-emitted-import-lib-dependency,chicken.bytevector,library))
 470$(eval $(call declare-emitted-import-lib-dependency,chicken.fixnum,library))
 471$(eval $(call declare-emitted-import-lib-dependency,chicken.flonum,library))
 472$(eval $(call declare-emitted-import-lib-dependency,chicken.gc,library))
 473$(eval $(call declare-emitted-import-lib-dependency,chicken.keyword,library))
 474$(eval $(call declare-emitted-import-lib-dependency,chicken.platform,library))
 475$(eval $(call declare-emitted-import-lib-dependency,chicken.plist,library))
 476$(eval $(call declare-emitted-import-lib-dependency,chicken.process-context,library))
 477$(eval $(call declare-emitted-import-lib-dependency,chicken.time,library))
 478$(eval $(call declare-emitted-import-lib-dependency,chicken.load,eval))
 479$(eval $(call declare-emitted-import-lib-dependency,chicken.format,extras))
 480$(eval $(call declare-emitted-import-lib-dependency,chicken.io,library))
 481$(eval $(call declare-emitted-import-lib-dependency,chicken.pretty-print,extras))
 482$(eval $(call declare-emitted-import-lib-dependency,chicken.random,extras))
 483$(eval $(call declare-emitted-import-lib-dependency,chicken.locative,lolevel))
 484$(eval $(call declare-emitted-import-lib-dependency,chicken.memory,lolevel))
 485$(eval $(call declare-emitted-import-lib-dependency,chicken.memory.representation,lolevel))
 486$(eval $(call declare-emitted-import-lib-dependency,chicken.number-vector,srfi-4))
 487$(eval $(call declare-emitted-import-lib-dependency,chicken.sort,data-structures))
 488$(eval $(call declare-emitted-import-lib-dependency,chicken.string,data-structures))
 489$(eval $(call declare-emitted-import-lib-dependency,scheme.write,r7lib))
 490$(eval $(call declare-emitted-import-lib-dependency,scheme.time,r7lib))
 491$(eval $(call declare-emitted-import-lib-dependency,scheme.file,r7lib))
 492$(eval $(call declare-emitted-import-lib-dependency,scheme.process-context,r7lib))
 493
 494chicken.c: chicken.scm mini-srfi-1.scm \
 495		chicken.compiler.batch-driver.import.scm \
 496		chicken.compiler.c-platform.import.scm \
 497		chicken.compiler.support.import.scm \
 498		chicken.compiler.user-pass.import.scm \
 499		chicken.process-context.import.scm \
 500		chicken.string.import.scm
 501batch-driver.c: batch-driver.scm mini-srfi-1.scm \
 502		chicken.compiler.core.import.scm \
 503		chicken.compiler.compiler-syntax.import.scm \
 504		chicken.compiler.optimizer.import.scm \
 505		chicken.compiler.scrutinizer.import.scm \
 506		chicken.compiler.c-platform.import.scm \
 507		chicken.compiler.lfa2.import.scm \
 508		chicken.compiler.c-backend.import.scm \
 509		chicken.compiler.support.import.scm \
 510		chicken.compiler.user-pass.import.scm \
 511		chicken.format.import.scm \
 512		chicken.gc.import.scm \
 513		chicken.internal.import.scm \
 514		chicken.load.import.scm \
 515		chicken.pathname.import.scm \
 516		chicken.platform.import.scm \
 517		chicken.pretty-print.import.scm \
 518		chicken.process-context.import.scm \
 519		chicken.process-context.posix.import.scm \
 520		chicken.condition.import.scm \
 521		chicken.port.import.scm \
 522		chicken.string.import.scm \
 523		chicken.syntax.import.scm \
 524		chicken.time.import.scm
 525c-platform.c: c-platform.scm mini-srfi-1.scm \
 526		chicken.compiler.optimizer.import.scm \
 527		chicken.compiler.support.import.scm \
 528		chicken.compiler.core.import.scm \
 529		chicken.internal.import.scm
 530c-backend.c: c-backend.scm mini-srfi-1.scm \
 531		chicken.compiler.c-platform.import.scm \
 532		chicken.compiler.support.import.scm \
 533		chicken.compiler.core.import.scm \
 534		chicken.bitwise.import.scm \
 535		chicken.flonum.import.scm \
 536		chicken.foreign.import.scm \
 537		chicken.format.import.scm \
 538		chicken.internal.import.scm \
 539		chicken.sort.import.scm \
 540		chicken.string.import.scm \
 541		chicken.time.import.scm
 542core.c: core.scm mini-srfi-1.scm \
 543		chicken.compiler.scrutinizer.import.scm \
 544		chicken.compiler.support.import.scm \
 545		chicken.eval.import.scm \
 546		chicken.file.import.scm \
 547		chicken.fixnum.import.scm \
 548		chicken.format.import.scm \
 549		chicken.io.import.scm \
 550		chicken.keyword.import.scm \
 551		chicken.load.import.scm \
 552		chicken.pretty-print.import.scm \
 553		chicken.string.import.scm \
 554		chicken.syntax.import.scm
 555optimizer.c: optimizer.scm mini-srfi-1.scm \
 556		chicken.compiler.support.import.scm \
 557		chicken.fixnum.import.scm \
 558		chicken.internal.import.scm \
 559		chicken.sort.import.scm \
 560		chicken.string.import.scm
 561scheduler.c: scheduler.scm \
 562		chicken.fixnum.import.scm \
 563		chicken.format.import.scm \
 564		chicken.condition.import.scm
 565scrutinizer.c: scrutinizer.scm mini-srfi-1.scm \
 566		chicken.compiler.support.import.scm \
 567		chicken.fixnum.import.scm \
 568		chicken.format.import.scm \
 569		chicken.internal.import.scm \
 570		chicken.io.import.scm \
 571		chicken.pathname.import.scm \
 572		chicken.platform.import.scm \
 573		chicken.sort.import.scm \
 574		chicken.port.import.scm \
 575		chicken.pretty-print.import.scm \
 576		chicken.string.import.scm
 577lfa2.c: lfa2.scm mini-srfi-1.scm \
 578		chicken.compiler.support.import.scm \
 579		chicken.format.import.scm
 580compiler-syntax.c: compiler-syntax.scm mini-srfi-1.scm \
 581		chicken.compiler.support.import.scm \
 582		chicken.compiler.core.import.scm \
 583		chicken.fixnum.import.scm \
 584		chicken.format.import.scm \
 585		chicken.syntax.import.scm
 586chicken-ffi-syntax.c: chicken-ffi-syntax.scm \
 587		chicken.format.import.scm \
 588		chicken.internal.import.scm \
 589		chicken.string.import.scm
 590support.c: support.scm mini-srfi-1.scm \
 591		chicken.bitwise.import.scm \
 592		chicken.bytevector.import.scm \
 593		chicken.condition.import.scm \
 594		chicken.file.import.scm \
 595		chicken.fixnum.import.scm \
 596		chicken.foreign.import.scm \
 597		chicken.format.import.scm \
 598		chicken.internal.import.scm \
 599		chicken.io.import.scm \
 600		chicken.keyword.import.scm \
 601		chicken.pathname.import.scm \
 602		chicken.platform.import.scm \
 603		chicken.plist.import.scm \
 604		chicken.port.import.scm \
 605		chicken.pretty-print.import.scm \
 606		chicken.random.import.scm \
 607		chicken.sort.import.scm \
 608		chicken.string.import.scm \
 609		chicken.time.import.scm
 610modules.c: modules.scm \
 611		chicken.internal.import.scm \
 612		chicken.format.import.scm \
 613		chicken.keyword.import.scm \
 614		chicken.base.import.scm \
 615		chicken.syntax.import.scm \
 616		chicken.load.import.scm \
 617		chicken.platform.import.scm
 618csc.c: csc.scm \
 619		chicken.file.import.scm \
 620		chicken.foreign.import.scm \
 621		chicken.format.import.scm \
 622		chicken.io.import.scm \
 623		chicken.pathname.import.scm \
 624		chicken.process.import.scm \
 625		chicken.process-context.import.scm \
 626		chicken.string.import.scm
 627csi.c: csi.scm \
 628		chicken.condition.import.scm \
 629		chicken.file.import.scm \
 630		chicken.foreign.import.scm \
 631		chicken.format.import.scm \
 632		chicken.gc.import.scm \
 633		chicken.internal.import.scm \
 634		chicken.io.import.scm \
 635		chicken.keyword.import.scm \
 636		chicken.load.import.scm \
 637		chicken.platform.import.scm \
 638		chicken.port.import.scm \
 639		chicken.pretty-print.import.scm \
 640		chicken.process.import.scm \
 641		chicken.process-context.import.scm \
 642		chicken.repl.import.scm \
 643		chicken.sort.import.scm \
 644		chicken.string.import.scm \
 645		scheme.write.import.scm
 646chicken-profile.c: chicken-profile.scm \
 647		chicken.internal.import.scm \
 648		chicken.file.import.scm \
 649		chicken.file.posix.import.scm \
 650		chicken.fixnum.import.scm \
 651		chicken.process-context.import.scm \
 652		chicken.sort.import.scm \
 653		chicken.string.import.scm
 654chicken-status.c: chicken-status.scm \
 655		chicken.file.import.scm \
 656		chicken.file.posix.import.scm \
 657		chicken.fixnum.import.scm \
 658		chicken.foreign.import.scm \
 659		chicken.format.import.scm \
 660		chicken.irregex.import.scm \
 661		chicken.pathname.import.scm \
 662		chicken.port.import.scm \
 663		chicken.pretty-print.import.scm \
 664		chicken.process-context.import.scm \
 665		chicken.sort.import.scm \
 666		chicken.string.import.scm
 667chicken-install.c: chicken-install.scm \
 668		chicken.condition.import.scm \
 669		chicken.file.import.scm \
 670		chicken.file.posix.import.scm \
 671		chicken.fixnum.import.scm \
 672		chicken.foreign.import.scm \
 673		chicken.format.import.scm \
 674		chicken.internal.import.scm \
 675		chicken.io.import.scm \
 676		chicken.irregex.import.scm \
 677		chicken.pathname.import.scm \
 678		chicken.port.import.scm \
 679		chicken.pretty-print.import.scm \
 680		chicken.process.import.scm \
 681		chicken.process-context.import.scm \
 682		chicken.sort.import.scm \
 683		chicken.string.import.scm \
 684		chicken.tcp.import.scm
 685chicken-uninstall.c: chicken-uninstall.scm \
 686		chicken.file.import.scm \
 687		chicken.fixnum.import.scm \
 688		chicken.foreign.import.scm \
 689		chicken.format.import.scm \
 690		chicken.irregex.import.scm \
 691		chicken.pathname.import.scm \
 692		chicken.port.import.scm \
 693		chicken.process.import.scm \
 694		chicken.process-context.import.scm \
 695		chicken.string.import.scm
 696chicken-syntax.c: chicken-syntax.scm \
 697		chicken.fixnum.import.scm \
 698		chicken.platform.import.scm \
 699		chicken.internal.import.scm
 700srfi-4.c: srfi-4.scm \
 701		chicken.bitwise.import.scm \
 702		chicken.bytevector.import.scm \
 703		chicken.fixnum.import.scm \
 704		chicken.foreign.import.scm \
 705		chicken.gc.import.scm \
 706		chicken.platform.import.scm
 707posixunix.c: posixunix.scm \
 708		chicken.bitwise.import.scm \
 709		chicken.condition.import.scm \
 710		chicken.foreign.import.scm \
 711		chicken.memory.import.scm \
 712		chicken.pathname.import.scm \
 713		chicken.platform.import.scm \
 714		chicken.port.import.scm \
 715		chicken.process-context.import.scm \
 716		chicken.time.import.scm
 717posixwin.c: posixwin.scm \
 718		chicken.condition.import.scm \
 719		chicken.bitwise.import.scm \
 720		chicken.foreign.import.scm \
 721		chicken.memory.import.scm \
 722		chicken.pathname.import.scm \
 723		chicken.platform.import.scm \
 724		chicken.port.import.scm \
 725		chicken.process-context.import.scm \
 726		chicken.string.import.scm \
 727		chicken.time.import.scm
 728data-structures.c: data-structures.scm \
 729		chicken.condition.import.scm \
 730		chicken.fixnum.import.scm \
 731		chicken.foreign.import.scm
 732expand.c: expand.scm \
 733		chicken.bytevector.import.scm \
 734		chicken.condition.import.scm \
 735		chicken.fixnum.import.scm \
 736		chicken.keyword.import.scm \
 737		chicken.platform.import.scm \
 738		chicken.string.import.scm \
 739		chicken.internal.import.scm
 740extras.c: extras.scm \
 741		chicken.fixnum.import.scm \
 742		chicken.string.import.scm \
 743		chicken.time.import.scm
 744eval.c: eval.scm \
 745		chicken.bytevector.import.scm \
 746		chicken.condition.import.scm \
 747		chicken.fixnum.import.scm \
 748		chicken.foreign.import.scm \
 749		chicken.internal.import.scm \
 750		chicken.keyword.import.scm \
 751		chicken.syntax.import.scm \
 752		chicken.platform.import.scm
 753repl.c: repl.scm \
 754		chicken.eval.import.scm
 755file.c: file.scm \
 756		chicken.condition.import.scm \
 757		chicken.fixnum.import.scm \
 758		chicken.io.import.scm \
 759		chicken.irregex.import.scm \
 760		chicken.foreign.import.scm \
 761		chicken.pathname.import.scm \
 762		chicken.process-context.import.scm
 763lolevel.c: lolevel.scm \
 764		chicken.fixnum.import.scm \
 765		chicken.foreign.import.scm
 766pathname.c: pathname.scm \
 767		chicken.fixnum.import.scm \
 768		chicken.irregex.import.scm \
 769		chicken.platform.import.scm \
 770		chicken.string.import.scm
 771port.c: port.scm \
 772		chicken.fixnum.import.scm \
 773		chicken.io.import.scm
 774read-syntax.c: read-syntax.scm \
 775		chicken.internal.import.scm \
 776		chicken.platform.import.scm
 777tcp.c: tcp.scm \
 778		chicken.fixnum.import.scm \
 779		chicken.foreign.import.scm \
 780		chicken.port.import.scm \
 781		chicken.time.import.scm
 782eval-modules.c: eval-modules.scm $(DYNAMIC_IMPORT_LIBRARIES:=.import.scm) \
 783	$(foreach lib,$(DYNAMIC_CHICKEN_IMPORT_LIBRARIES),chicken.$(lib).import.scm) \
 784	$(foreach lib,$(DYNAMIC_CHICKEN_UNIT_IMPORT_LIBRARIES),$(lib).c)
 785continuation.c: continuation.scm \
 786		chicken.fixnum.import.scm
 787internal.c: internal.scm \
 788		chicken.fixnum.import.scm
 789irregex.c: irregex.scm \
 790		chicken.fixnum.import.scm \
 791		chicken.syntax.import.scm
 792profiler.c: profiler.scm \
 793		chicken.fixnum.import.scm
 794stub.c: stub.scm \
 795		chicken.platform.import.scm
 796r7lib.c: r7lib.scm \
 797		chicken.platform.import.scm \
 798		chicken.process-context.import.scm \
 799		chicken.time.import.scm \
 800		chicken.io.import.scm \
 801		chicken.file.import.scm
 802
 803define profile-flags
 804$(if $(filter $(basename $(1)),$(PROFILE_OBJECTS)),-profile)
 805endef
 806
 807bootstrap-lib = $(CHICKEN) $(call profile-flags, $@) $< $(CHICKEN_LIBRARY_OPTIONS) -output-file $@
 808
 809library.c: $(SRCDIR)library.scm
 810	$(bootstrap-lib) \
 811	-no-module-registration \
 812	-emit-import-library chicken.bitwise \
 813	-emit-import-library chicken.bytevector \
 814	-emit-import-library chicken.fixnum \
 815	-emit-import-library chicken.flonum \
 816	-emit-import-library chicken.gc \
 817	-emit-import-library chicken.keyword \
 818	-emit-import-library chicken.platform \
 819	-emit-import-library chicken.plist \
 820	-emit-import-library chicken.io \
 821	-emit-import-library chicken.process-context
 822internal.c: $(SRCDIR)internal.scm $(SRCDIR)mini-srfi-1.scm
 823	$(bootstrap-lib) -emit-import-library chicken.internal
 824eval.c: $(SRCDIR)eval.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 825	$(bootstrap-lib) \
 826	-emit-import-library chicken.eval \
 827	-emit-import-library chicken.load
 828r7lib.c: $(SRCDIR)r7lib.scm $(SRCDIR)common-declarations.scm
 829	$(bootstrap-lib) -emit-import-library scheme.write \
 830	-emit-import-library scheme.time \
 831	-emit-import-library scheme.file \
 832	-emit-import-library scheme.process-context
 833read-syntax.c: $(SRCDIR)read-syntax.scm $(SRCDIR)common-declarations.scm
 834	$(bootstrap-lib) -emit-import-library chicken.read-syntax
 835repl.c: $(SRCDIR)repl.scm $(SRCDIR)common-declarations.scm
 836	$(bootstrap-lib) -emit-import-library chicken.repl
 837expand.c: $(SRCDIR)expand.scm $(SRCDIR)synrules.scm $(SRCDIR)common-declarations.scm
 838	$(bootstrap-lib) \
 839	-no-module-registration
 840modules.c: $(SRCDIR)modules.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 841	$(bootstrap-lib)
 842extras.c: $(SRCDIR)extras.scm $(SRCDIR)common-declarations.scm
 843	$(bootstrap-lib) \
 844	-emit-import-library chicken.format \
 845	-emit-import-library chicken.pretty-print \
 846	-emit-import-library chicken.random
 847posixunix.c: $(SRCDIR)posix.scm $(SRCDIR)posixunix.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
 848	$(bootstrap-lib) -feature platform-unix \
 849	-emit-import-library chicken.errno \
 850	-emit-import-library chicken.file.posix \
 851	-emit-import-library chicken.time.posix \
 852	-emit-import-library chicken.process \
 853	-emit-import-library chicken.process.signal \
 854	-emit-import-library chicken.process-context.posix \
 855	-no-module-registration
 856posixwin.c: $(SRCDIR)posix.scm $(SRCDIR)posixwin.scm $(SRCDIR)posix-common.scm $(SRCDIR)common-declarations.scm
 857	$(bootstrap-lib) -feature platform-windows \
 858	-emit-import-library chicken.errno \
 859	-emit-import-library chicken.file.posix \
 860	-emit-import-library chicken.time.posix \
 861	-emit-import-library chicken.process \
 862	-emit-import-library chicken.process.signal \
 863	-emit-import-library chicken.process-context.posix \
 864	-no-module-registration
 865irregex.c: $(SRCDIR)irregex.scm $(SRCDIR)irregex-core.scm $(SRCDIR)irregex-utils.scm $(SRCDIR)common-declarations.scm
 866	$(bootstrap-lib) -emit-import-library chicken.irregex
 867chicken-syntax.c: $(SRCDIR)chicken-syntax.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 868	$(bootstrap-lib)
 869chicken-ffi-syntax.c: $(SRCDIR)chicken-ffi-syntax.scm $(SRCDIR)common-declarations.scm $(SRCDIR)mini-srfi-1.scm
 870	$(bootstrap-lib)
 871continuation.c: $(SRCDIR)continuation.scm $(SRCDIR)common-declarations.scm
 872	$(bootstrap-lib) -emit-import-library chicken.continuation
 873data-structures.c: $(SRCDIR)data-structures.scm $(SRCDIR)common-declarations.scm
 874	$(bootstrap-lib) \
 875	-emit-import-library chicken.sort \
 876	-emit-import-library chicken.string
 877pathname.c: $(SRCDIR)pathname.scm $(SRCDIR)common-declarations.scm
 878	$(bootstrap-lib) -emit-import-library chicken.pathname
 879port.c: $(SRCDIR)port.scm $(SRCDIR)common-declarations.scm
 880	$(bootstrap-lib) -emit-import-library chicken.port
 881file.c: $(SRCDIR)file.scm $(SRCDIR)common-declarations.scm
 882	$(bootstrap-lib) -emit-import-library chicken.file
 883lolevel.c: $(SRCDIR)lolevel.scm $(SRCDIR)common-declarations.scm
 884	$(bootstrap-lib) \
 885	-emit-import-library chicken.locative \
 886	-emit-import-library chicken.memory \
 887	-emit-import-library chicken.memory.representation
 888tcp.c: $(SRCDIR)tcp.scm $(SRCDIR)common-declarations.scm
 889	$(bootstrap-lib) -emit-import-library chicken.tcp
 890srfi-4.c: $(SRCDIR)srfi-4.scm $(SRCDIR)common-declarations.scm
 891	$(bootstrap-lib) -emit-import-library srfi-4 \
 892	 -emit-import-library chicken.number-vector
 893scheduler.c: $(SRCDIR)scheduler.scm $(SRCDIR)common-declarations.scm
 894	$(bootstrap-lib)
 895profiler.c: $(SRCDIR)profiler.scm $(SRCDIR)common-declarations.scm
 896	$(bootstrap-lib)
 897stub.c: $(SRCDIR)stub.scm $(SRCDIR)common-declarations.scm
 898	$(bootstrap-lib)
 899debugger-client.c: $(SRCDIR)debugger-client.scm $(SRCDIR)common-declarations.scm dbg-stub.c
 900	$(bootstrap-lib)
 901build-version.c: $(SRCDIR)build-version.scm $(SRCDIR)buildversion buildbranch buildid
 902	$(bootstrap-lib)
 903eval-modules.c: $(SRCDIR)eval-modules.scm $(SRCDIR)common-declarations.scm
 904	$(bootstrap-lib)
 905
 906define declare-bootstrap-import-lib
 907$(1).import.c: $$(SRCDIR)$(1).import.scm
 908	$$(CHICKEN) $$< $$(CHICKEN_IMPORT_LIBRARY_OPTIONS) -output-file $$@
 909endef
 910
 911$(foreach obj, $(IMPORT_LIBRARIES),\
 912          $(eval $(call declare-bootstrap-import-lib,$(obj))))
 913
 914# Bootstrap compiler objects
 915
 916define declare-bootstrap-compiler-object
 917$(1).c: $$(SRCDIR)$(1).scm $$(SRCDIR)tweaks.scm
 918	$$(CHICKEN) $$< $$(CHICKEN_PROGRAM_OPTIONS) -emit-import-library chicken.compiler.$(1) \
 919		-output-file $$@
 920endef
 921
 922$(foreach obj, $(COMPILER_OBJECTS_1),\
 923          $(eval $(call declare-bootstrap-compiler-object,$(obj))))
 924
 925csi.c: $(SRCDIR)csi.scm $(SRCDIR)banner.scm $(SRCDIR)mini-srfi-1.scm
 926	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 927chicken-profile.c: $(SRCDIR)chicken-profile.scm $(SRCDIR)mini-srfi-1.scm
 928	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 929chicken-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
 930	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 931chicken-uninstall.c: $(SRCDIR)chicken-uninstall.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-environment.scm $(SRCDIR)egg-information.scm
 932	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 933chicken-status.c: $(SRCDIR)chicken-status.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-environment.scm $(SRCDIR)egg-information.scm
 934	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 935csc.c: $(SRCDIR)csc.scm $(SRCDIR)mini-srfi-1.scm $(SRCDIR)egg-environment.scm
 936	$(CHICKEN) $< $(CHICKEN_PROGRAM_OPTIONS) -output-file $@
 937
 938# distribution files
 939
 940.PHONY: distfiles dist html
 941
 942distfiles: $(DISTFILES)
 943
 944dist: distfiles html
 945	echo '# this file is intentionally empty' > config.make
 946	CSI=$(CSI) $(CSI) -s $(SRCDIR)scripts$(SEP)makedist.scm -platform $(PLATFORM) CHICKEN=$(CHICKEN)
 947
 948# Jim's `manual-labor' must be installed (just run "chicken-install manual-labor")
 949html:
 950	$(MAKEDIR_COMMAND) $(MAKEDIR_COMMAND_OPTIONS) $(SRCDIR)manual-html
 951	manual-labor $(SRCDIR)manual $(SRCDIR)manual-html
 952	$(COPY_COMMAND) $(SRCDIR)chicken.png manual-html
 953	$(COPY_COMMAND) $(SRCDIR)manual.css manual-html
 954	$(COPY_COMMAND) $(SRCDIR)index.html manual-html
 955
 956# cleaning up
 957
 958.PHONY: clean spotless confclean testclean
 959
 960BUILD_CONFIG_FILES = chicken-config.h chicken-defaults.h chicken-install.rc chicken-uninstall.rc
 961
 962clean:
 963	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(EXE) $(PROGRAM_PREFIX)csi$(PROGRAM_SUFFIX)$(EXE) $(PROGRAM_PREFIX)csc$(PROGRAM_SUFFIX)$(EXE) \
 964	  $(CHICKEN_PROFILE_PROGRAM)$(EXE) \
 965	  $(CHICKEN_INSTALL_PROGRAM)$(EXE) \
 966	  $(CHICKEN_UNINSTALL_PROGRAM)$(EXE) \
 967	  $(CHICKEN_STATUS_PROGRAM)$(EXE) \
 968	  *$(O) \
 969	  $(CHICKEN_DO_PROGRAM)$(EXE) \
 970	  $(LIBCHICKEN_SO_FILE) \
 971	  $(PRIMARY_LIBCHICKEN) \
 972	  lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)-static$(A) \
 973	  $(IMPORT_LIBRARIES:=.import.so) $(LIBCHICKEN_IMPORT_LIBRARY) \
 974	  $(foreach lib,$(DYNAMIC_IMPORT_LIBRARIES),chicken.$(lib).import.scm) \
 975	  $(BUILD_CONFIG_FILES)
 976ifdef USES_SONAME
 977	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX).so.$(BINARYVERSION)
 978endif
 979
 980confclean:
 981	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(BUILD_CONFIG_FILES)
 982	touch config.make
 983
 984spotless: clean testclean
 985	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) $(DISTFILES) \
 986	buildid buildbranch
 987
 988testclean:
 989	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_RECURSIVE_OPTIONS) \
 990	  $(SRCDIR)tests$(SEP)*.dll \
 991	  $(SRCDIR)tests$(SEP)*.import.scm \
 992	  $(SRCDIR)tests$(SEP)*.inline \
 993	  $(SRCDIR)tests$(SEP)*.link \
 994	  $(SRCDIR)tests$(SEP)*.o \
 995	  $(SRCDIR)tests$(SEP)*.obj \
 996	  $(SRCDIR)tests$(SEP)*.out \
 997	  $(SRCDIR)tests$(SEP)*.profile \
 998	  $(SRCDIR)tests$(SEP)*.redacted \
 999	  $(SRCDIR)tests$(SEP)*.so \
 1000	  $(SRCDIR)tests$(SEP)tmp \
1001	  $(SRCDIR)tests$(SEP)tmp.c \
1002	  $(SRCDIR)tests$(SEP)empty-file \
1003	  $(SRCDIR)tests$(SEP)null \
1004	  $(SRCDIR)tests$(SEP)null.c \
1005	  $(SRCDIR)tests$(SEP)null.exe \
1006	  $(SRCDIR)tests$(SEP)test-repository \
1007	  $(SRCDIR)tests$(SEP)redact-gensyms
1008
1009# run tests
1010
1011.PHONY: check
1012
1013export PROGRAM_PREFIX
1014export PROGRAM_SUFFIX
1015
1016check: $(TARGETS)
1017	cd tests; sh runtests.sh
1018
1019# benchmark
1020
1021.PHONY: bench
1022
1023bench: $(CHICKEN_SHARED_EXECUTABLE) $(CSI_SHARED_EXECUTABLE) $(CSC_PROGRAM)$(EXE)
1024	cd tests; echo >>bench.log; date >>bench.log; sh runbench.sh 2>&1 | tee -a bench.log
1025
1026
1027# build static bootstrapping chicken
1028
1029.PHONY: boot-chicken bootclean
1030
1031STAGE1_CONFIG = PLATFORM=$(PLATFORM) PREFIX=/nowhere CONFIG= \
1032    CHICKEN=$(CHICKEN) PROGRAM_SUFFIX=-boot-stage1 STATICBUILD=1 \
1033    C_COMPILER_OPTIMIZATION_OPTIONS="$(C_COMPILER_OPTIMIZATION_OPTIONS)" BUILDING_CHICKEN_BOOT=1
1034
1035BOOT_CONFIG = PLATFORM=$(PLATFORM) PREFIX=/nowhere CONFIG= \
1036    CHICKEN=.$(SEP)chicken-boot-stage1$(EXE) PROGRAM_SUFFIX=-boot \
1037    STATICBUILD=1 C_COMPILER_OPTIMIZATION_OPTIONS="$(C_COMPILER_OPTIMIZATION_OPTIONS)"
1038
1039boot-chicken:
1040	"$(MAKE)" $(STAGE1_CONFIG) confclean
1041	"$(MAKE)" $(STAGE1_CONFIG) chicken-boot-stage1$(EXE)
1042	"$(MAKE)" $(BOOT_CONFIG) touchfiles
1043	"$(MAKE)" $(BOOT_CONFIG) chicken-boot$(EXE)
1044	"$(MAKE)" $(BOOT_CONFIG) confclean
1045
1046bootclean:
1047	-$(REMOVE_COMMAND) $(REMOVE_COMMAND_OPTIONS) \
1048	  $(SRCDIR)chicken-boot$(EXE) \
1049	  $(SRCDIR)chicken-boot-stage1$(EXE) \
1050	  $(SRCDIR)libchicken-boot$(A) \
1051	  $(SRCDIR)libchicken-boot-stage1$(A)
1052
1053.PHONY: touchfiles
1054
1055touchfiles:
1056ifdef WINDOWS_SHELL
1057	for %%x in (*.scm) do copy /b %%x +,,
1058else
1059	touch *.scm
1060endif
Trap