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