# makefile for Gambit interpreter.

# Copyright (c) 1994-2018 by Marc Feeley, All Rights Reserved.

herefromroot = gsi
rootfromhere = ..
SUBDIRS =

PACKAGE_SHORTNAME = @PACKAGE_SHORTNAME@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_TARNAME = @PACKAGE_TARNAME@

@SET_MAKE@

srcdir = @srcdir@
VPATH = @srcdir@
srcdirpfx = @srcdirpfx@

C_COMPILER = @C_COMPILER_MF@
C_PREPROC = @C_PREPROC_MF@
FLAGS_OBJ = @FLAGS_OBJ_MF@
FLAGS_DYN = @FLAGS_DYN_MF@
FLAGS_LIB = @FLAGS_LIB_MF@
FLAGS_EXE = @FLAGS_EXE_MF@
FLAGS_OPT = @FLAGS_OPT_MF@
FLAGS_OPT_RTS = @FLAGS_OPT_RTS_MF@
DEFS = @DEFS@
LIBS = @LIBS@

GAMBITLIB_DEFS = @GAMBITLIB_DEFS_MF@
LIB_PREFIX = @LIB_PREFIX@
LIB_VERSION_SUFFIX = @LIB_VERSION_SUFFIX@
LIB_MAJOR_VERSION_SUFFIX = @LIB_MAJOR_VERSION_SUFFIX@

LIB_EXTENSION = @LIB_EXTENSION@
GAMBITLIB = @GAMBITLIB@
GAMBITGSCLIB = @GAMBITGSCLIB@
GAMBITGSILIB = @GAMBITGSILIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_LIB = @INSTALL_LIB@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
LN_S = @LN_S@
RANLIB = @RANLIB@
AR = @AR@
RC = @RC@
GIT = @GIT@
HG = @HG@

prefix = @prefix@
exec_prefix = @exec_prefix@
includedir = @includedir@
libdir = @libdir@
bindir = @bindir@
docdir = @docdir@
infodir = @infodir@
emacsdir = @emacsdir@
libexecdir = @libexecdir@
datarootdir = @datarootdir@
datadir = @datadir@
htmldir = @htmldir@
dvidir = @dvidir@
pdfdir = @pdfdir@
psdir = @psdir@
localedir = @localedir@
mandir = @mandir@

.SUFFIXES:
.SUFFIXES: .scm .c @obj@

LIBRARIES_SCM =

LIBRARY = $(LIB_PREFIX)$(GAMBITGSILIB)$(LIB_EXTENSION)
LIBRARY_NORMAL_C =
LIBRARY_NORMAL_CPP =
LIBRARY_NORMAL_H =
LIBRARY_NORMAL_O =
LIBRARY_NORMAL_O_PLUS =
LIBRARY_NORMAL_O_COMMA =
LIBRARY_NORMAL_SOURCES = $(LIBRARY_NORMAL_C) $(LIBRARY_NORMAL_CPP) \
$(LIBRARY_NORMAL_H)
LIBRARY_MODULES = _gsilib
LIBRARY_MODULES_SCM = _gsilib.scm
LIBRARY_MODULES_C = _gsilib.c
LIBRARY_MODULES_O = _gsilib@obj@
LIBRARY_MODULES_O_PLUS = +_gsilib@obj@
LIBRARY_MODULES_O_COMMA = _gsilib@obj@
LIBRARY_MODULES_O_IN_COMPILE_ORDER = _gsilib@obj@
LIBRARY_OBJECTS = $(LIBRARY_NORMAL_O) \
$(LIBRARY_MODULES_O) _$(GAMBITGSILIB)@obj@
LIBRARY_OBJECTS_PLUS = $(LIBRARY_NORMAL_O_PLUS) \
$(LIBRARY_MODULES_O_PLUS) +_$(GAMBITGSILIB)@obj@
LIBRARY_OBJECTS_COMMA = $(LIBRARY_NORMAL_O_COMMA),\
$(LIBRARY_MODULES_O_COMMA),_$(GAMBITGSILIB)@obj@
LIBRARY_OBJECTS_IN_COMPILE_ORDER = $(LIBRARY_MODULES_O_IN_COMPILE_ORDER) \
$(LIBRARY_NORMAL_O_IN_COMPILE_ORDER) _$(GAMBITGSILIB)@obj@

LIBRARIES = $(LIBRARY)$(LIB_VERSION_SUFFIX)

MAKE_LIBRARY_LIBS = $(rootfromhere)/lib/$(LIB_PREFIX)$(GAMBITLIB)$(LIB_EXTENSION)
MAKE_LIBRARY_FOR_INSTALL_LIBS = @MAKE_LIBRARY_FOR_INSTALL_LIBS@

EXECUTABLE = gsi@exe@
EXECUTABLE_INSTALLED = @ENABLE_INTERPRETER_NAME@@exe@
EXECUTABLE_NORMAL_C =
EXECUTABLE_NORMAL_CPP =
EXECUTABLE_NORMAL_H =
EXECUTABLE_NORMAL_O =
EXECUTABLE_NORMAL_O_PLUS =
EXECUTABLE_NORMAL_O_COMMA =
EXECUTABLE_NORMAL_SOURCES = $(EXECUTABLE_NORMAL_C) $(EXECUTABLE_NORMAL_CPP) \
$(EXECUTABLE_NORMAL_H)
EXECUTABLE_MODULES = _gsi
EXECUTABLE_MODULES_SCM = _gsi.scm
EXECUTABLE_MODULES_C = _gsi.c
EXECUTABLE_MODULES_O = _gsi@obj@
EXECUTABLE_MODULES_O_PLUS = +_gsi@obj@
EXECUTABLE_MODULES_O_COMMA = _gsi@obj@
EXECUTABLE_MODULES_O_IN_COMPILE_ORDER = _gsi@obj@
EXECUTABLE_OBJECTS = $(EXECUTABLE_NORMAL_O) \
$(EXECUTABLE_MODULES_O) _gsi_@obj@
EXECUTABLE_OBJECTS_PLUS = $(EXECUTABLE_NORMAL_O_PLUS) \
$(EXECUTABLE_MODULES_O_PLUS) +_gsi_@obj@
EXECUTABLE_OBJECTS_COMMA = $(EXECUTABLE_NORMAL_O_COMMA),\
$(EXECUTABLE_MODULES_O_COMMA),_gsi_@obj@
EXECUTABLE_OBJECTS_IN_COMPILE_ORDER = $(EXECUTABLE_MODULES_O_IN_COMPILE_ORDER) \
$(EXECUTABLE_NORMAL_O_IN_COMPILE_ORDER) _gsi_@obj@

LINK_LIBS = $(LIBRARY) $(rootfromhere)/lib/$(LIB_PREFIX)$(GAMBITLIB)$(LIB_EXTENSION)
LINK_FOR_INSTALL_LIBS = @LINK_FOR_INSTALL_GSI_LIBS@

MODULES_SCM = $(LIBRARY_MODULES_SCM) $(EXECUTABLE_MODULES_SCM)
MODULES_C = $(LIBRARY_MODULES_C) $(EXECUTABLE_MODULES_C)
OBJECTS = $(LIBRARY_OBJECTS) $(EXECUTABLE_OBJECTS)

RCFILES = makefile.in main.scm $(MODULES_SCM)

GENDISTFILES = $(MODULES_C) _$(GAMBITGSILIB).c _gsi_.c

DISTFILES = $(RCFILES) $(GENDISTFILES)

INSTFILES_LIB_DATA = _$(GAMBITGSILIB).c $(LIBRARIES_SCM)

GAMBITDIR_INCLUDE = $(srcdirpfx)$(rootfromhere)/include
GAMBITDIR_LIB = $(srcdirpfx)$(rootfromhere)/lib
GAMBITDIR_LIB_GSI = $(srcdirpfx)$(rootfromhere)/gsi
GAMBITDIR_LIB_GSC = $(srcdirpfx)$(rootfromhere)/gsc

BUILD_OBJ_OUTPUT_FILENAME = $*@obj@
BUILD_OBJ_CC_OPTIONS =  -I$(srcdir) $(DEFS)
BUILD_OBJ_INPUT_FILENAMES = $(srcdirpfx)$*.c

BUILD_EXE_OUTPUT_FILENAME = $(EXECUTABLE)
BUILD_EXE_CC_OPTIONS =
BUILD_EXE_LD_OPTIONS_PRELUDE =
BUILD_EXE_INPUT_FILENAMES = $(EXECUTABLE_OBJECTS)
BUILD_EXE_LD_OPTIONS = $(LIBRARY)

PRELUDE_OPT = -prelude "@RTLIB_COND_EXPAND_FEATURES@(\#\#include\"$(srcdirpfx)../lib/header.scm\")"

all:

all-pre: $(LIBRARY) $(EXECUTABLE)

all-post: deselect-gen-for-commit

$(LIBRARY): $(LIBRARY_OBJECTS_IN_COMPILE_ORDER)
	rm -f "$(LIBRARY)$(LIB_VERSION_SUFFIX)" "$(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX)" "$(LIBRARY)"
	@MAKE_LIBRARY@
	if test "$(LIB_VERSION_SUFFIX)" != ""; then \
	  $(LN_S) "$(LIBRARY)$(LIB_VERSION_SUFFIX)" "$(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX)"; \
	  $(LN_S) "$(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX)" "$(LIBRARY)"; \
	fi

_$(GAMBITGSILIB).c: $(LIBRARY_MODULES_C) $(rootfromhere)/lib/_gambit.c
	@SETDLPATHBOOT@ $(rootfromhere)/gsc-boot -:~~bin=$(srcdirpfx)$(rootfromhere)/bin,~~lib=$(srcdirpfx)$(rootfromhere)/lib,~~include=$(srcdirpfx)$(rootfromhere)/include -f @COMPILATION_OPTIONS@ $(PRELUDE_OPT) -warnings -link -l $(srcdirpfx)$(rootfromhere)/lib/_gambit -o $@ -preload $(LIBRARY_MODULES_C)

$(EXECUTABLE): $(EXECUTABLE_OBJECTS_IN_COMPILE_ORDER) $(LINK_LIBS)
	@BUILD_EXE@

_gsi_.c: $(EXECUTABLE_MODULES_C) _$(GAMBITGSILIB).c
	@SETDLPATHBOOT@ $(rootfromhere)/gsc-boot -:~~bin=$(srcdirpfx)$(rootfromhere)/bin,~~lib=$(srcdirpfx)$(rootfromhere)/lib,~~include=$(srcdirpfx)$(rootfromhere)/include -f @COMPILATION_OPTIONS@ $(PRELUDE_OPT) -warnings -link -l _$(GAMBITGSILIB) -o $@ -preload $(EXECUTABLE_MODULES_C)

_gsi@obj@: _gsi.c
	@BUILD_OBJ@

_gsi_@obj@: _gsi_.c
	@BUILD_OBJ@

.c@obj@:
	@BUILD_OBJ@ -D___LIBRARY

.scm.c:
	@SETDLPATHBOOT@ $(rootfromhere)/gsc-boot -:~~bin=$(srcdirpfx)$(rootfromhere)/bin,~~lib=$(srcdirpfx)$(rootfromhere)/lib,~~include=$(srcdirpfx)$(rootfromhere)/include -f @COMPILATION_OPTIONS@ $(PRELUDE_OPT) -warnings -c $(srcdirpfx)$*.scm

_gsi.c: $(srcdirpfx)$(rootfromhere)/gsi/main.scm

$(MODULES_C): \
$(srcdirpfx)$(rootfromhere)/lib/header.scm \
$(srcdirpfx)$(rootfromhere)/lib/gambit\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_gambit\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_kernel\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_system\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_num\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_std\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_eval\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_io\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_nonstd\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_thread\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_repl\#.scm \
$(srcdirpfx)$(rootfromhere)/lib/_define-syntax.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax-boot.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax-case-xform-boot.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax-case-xform.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax-common.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax-pattern.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax-rules-xform.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax-template.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax-xform-boot.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax-xform.scm \
$(srcdirpfx)$(rootfromhere)/lib/_syntax.scm \
$(srcdirpfx)$(rootfromhere)/lib/_with-syntax-boot.scm

$(MODULES_O): $(srcdirpfx)$(rootfromhere)/include/gambit.h

bootstrap-pre:

bootstrap-post:
	if test "@ENABLE_SHARED@" = "yes"; then \
	  cp $(LIBRARY)$(LIB_VERSION_SUFFIX) $(rootfromhere)/$(LIBRARY)$(LIB_VERSION_SUFFIX); \
	  if test "$(LIB_VERSION_SUFFIX)" != ""; then \
	    cd $(rootfromhere); \
	    $(LN_S) "$(LIBRARY)$(LIB_VERSION_SUFFIX)" "$(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX)"; \
	    $(LN_S) "$(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX)" "$(LIBRARY)"; \
	  fi \
	fi

install-pre:

install-post: all
	c_bindir="$(DESTDIR)$(prefix)/bin"; \
	i_bindir="$(DESTDIR)$(bindir)"; \
	t_bindir="$$i_bindir"; \
	c_libdir="$(DESTDIR)$(prefix)/lib"; \
	i_libdir="$(DESTDIR)$(libdir)"; \
	t_libdir="$$i_libdir"; \
	$(srcdirpfx)$(rootfromhere)/mkidirs "$$i_bindir" "$$i_libdir"; \
	if test "@ENABLE_SYMLINKS@" = "yes"; then \
	  $(srcdirpfx)$(rootfromhere)/mkidirs "$$c_bindir" "$$c_libdir"; \
	  t_bindir="$$c_bindir"; \
	  t_libdir="$$c_libdir"; \
	fi; \
	$(INSTALL_DATA) "$(srcdirpfx)_$(GAMBITGSILIB).c" "$$t_libdir/_$(GAMBITGSILIB).c"; \
	@MAKE_LIBRARY_FOR_INSTALL@; \
	for file in $(LIBRARIES); do \
	  $(INSTALL_LIB) "$$file" "$$t_libdir/$$file"; \
	  @FIXLIB@ "$$t_libdir/$$file"; \
	done; \
	if test "$(LIB_VERSION_SUFFIX)" != ""; then \
	  (cd "$$t_libdir" && $(LN_S) "$(LIBRARY)$(LIB_VERSION_SUFFIX)" "$(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX)" && $(LN_S) "$(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX)" "$(LIBRARY)"); \
	fi; \
	@LINK_FOR_INSTALL@; \
	$(INSTALL_PROGRAM) "$(EXECUTABLE)" "$$t_bindir/$(EXECUTABLE_INSTALLED)"; \
	if test "$$t_libdir" != "$$i_libdir"; then \
	  r_libdir=`$(rootfromhere)/relpath "$$t_libdir" "$$i_libdir" @ENABLE_MULTIPLE_VERSIONS@`; \
	  for file in _$(GAMBITGSILIB).c $(LIBRARY)$(LIB_VERSION_SUFFIX); do \
	    (cd "$$i_libdir" && $(LN_S) "$$r_libdir$$file" "$$file"); \
	  done; \
	fi; \
	if test "$$t_bindir" != "$$i_bindir"; then \
	  r_bindir=`$(rootfromhere)/relpath "$$t_bindir" "$$i_bindir" @ENABLE_MULTIPLE_VERSIONS@`; \
	  for file in $(EXECUTABLE_INSTALLED); do \
	    (cd "$$i_bindir" && $(LN_S) "$$r_bindir$$file" "$$file"); \
	  done; \
	fi

uninstall-pre:

uninstall-post:
	c_bindir="$(DESTDIR)$(prefix)/bin"; \
	i_bindir="$(DESTDIR)$(bindir)"; \
	t_bindir="$$i_bindir"; \
	c_libdir="$(DESTDIR)$(prefix)/lib"; \
	i_libdir="$(DESTDIR)$(libdir)"; \
	t_libdir="$$i_libdir"; \
	if test "@ENABLE_SYMLINKS@" = "yes"; then \
	  t_bindir="$$c_bindir"; \
	  t_libdir="$$c_libdir"; \
	fi; \
	for file in $(INSTFILES_LIB_DATA) $(LIBRARIES) $(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX) $(LIBRARY); do \
	  rm -f "$$t_libdir/$$file"; \
	done; \
	if test "$$t_libdir" != "$$i_libdir"; then \
	  for file in $(INSTFILES_LIB_DATA) $(LIBRARIES) $(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX) $(LIBRARY); do \
	    rm -f "$$i_libdir/$$file"; \
	  done; \
	fi; \
	rm -f "$$t_bindir/$(EXECUTABLE_INSTALLED)"; \
	if test "$$t_bindir" != "$$i_bindir"; then \
	  for file in $(EXECUTABLE_INSTALLED); do \
	    rm -f "$$i_bindir/$$file"; \
	  done; \
	fi; \
	rmdir "$$t_libdir" 2> /dev/null; \
	if test "$$t_libdir" != "$$i_libdir"; then \
	  rmdir "$$i_libdir" 2> /dev/null; \
	fi; \
	rmdir "$$t_bindir" 2> /dev/null; \
	if test "$$t_bindir" != "$$i_bindir"; then \
	  rmdir "$$i_bindir" 2> /dev/null; \
	fi

select-gen-for-commit-pre:

select-gen-for-commit-post:
	if [ -e $(rootfromhere)/.git ]; then $(RC) update-index --no-skip-worktree $(GENDISTFILES); fi

deselect-gen-for-commit-pre:

deselect-gen-for-commit-post:
	if [ -e $(rootfromhere)/.git ]; then $(RC) update-index --skip-worktree $(GENDISTFILES); fi

mostlyclean-pre:

mostlyclean-post:
	rm -f $(OBJECTS) $(LIBRARY)$(LIB_VERSION_SUFFIX) $(LIBRARY)$(LIB_MAJOR_VERSION_SUFFIX) $(LIBRARY) $(EXECUTABLE)

clean-pre: mostlyclean-pre

clean-post: mostlyclean-post
	rm -f *.da *.bb *.bbg *.gcov *.gcno *.gcda

distclean-pre: clean-pre

distclean-post: clean-post

bootclean-pre: distclean-pre

bootclean-post: distclean-post
	rm -f $(GENDISTFILES)

realclean-pre: bootclean-pre

realclean-post: bootclean-post
	rm -f makefile

rc-setup-pre:
	$(RC) add $(RCFILES) $(GENDISTFILES)

rc-setup-post:

dist-pre dist-devel-pre:
	mkdir $(rootfromhere)/$(PACKAGE_TARNAME)/$(herefromroot)
	chmod 777 $(rootfromhere)/$(PACKAGE_TARNAME)/$(herefromroot)
	@echo "  Copying distribution files:"
	@for file in $(DISTFILES); do \
	  echo "    $(herefromroot)/$$file"; \
	  ln $(srcdirpfx)$$file $(rootfromhere)/$(PACKAGE_TARNAME)/$(herefromroot) 2> /dev/null \
	    || cp -p $(srcdirpfx)$$file $(rootfromhere)/$(PACKAGE_TARNAME)/$(herefromroot); \
	done

dist-post dist-devel-post:

all-recursive bootstrap-recursive install-recursive uninstall-recursive select-gen-for-commit-recursive deselect-gen-for-commit-recursive mostlyclean-recursive clean-recursive distclean-recursive bootclean-recursive realclean-recursive rc-setup-recursive dist-recursive dist-devel-recursive:
	@if test -n "$(SUBDIRS)"; then \
	  for subdir in ""$(SUBDIRS); do \
	    target=`echo $@ | sed 's/-recursive//'`; \
	    echo making $$target in $$subdir; \
	    (cd $$subdir && $(MAKE) $$target) || exit 1; \
	  done \
	fi

all: all-post

all-post: all-recursive

all-recursive: all-pre

bootstrap: bootstrap-post

bootstrap-post: bootstrap-recursive

bootstrap-recursive: bootstrap-pre

install: install-post

install-post: install-recursive

install-recursive: install-pre

uninstall: uninstall-post

uninstall-post: uninstall-recursive

uninstall-recursive: uninstall-pre

select-gen-for-commit: select-gen-for-commit-post

select-gen-for-commit-post: select-gen-for-commit-recursive

select-gen-for-commit-recursive: select-gen-for-commit-pre

deselect-gen-for-commit: deselect-gen-for-commit-post

deselect-gen-for-commit-post: deselect-gen-for-commit-recursive

deselect-gen-for-commit-recursive: deselect-gen-for-commit-pre

mostlyclean: mostlyclean-post

mostlyclean-post: mostlyclean-recursive

mostlyclean-recursive: mostlyclean-pre

clean: clean-post

clean-post: clean-recursive

clean-recursive: clean-pre

distclean: distclean-post

distclean-post: distclean-recursive

distclean-recursive: distclean-pre

bootclean: bootclean-post

bootclean-post: bootclean-recursive

bootclean-recursive: bootclean-pre

realclean: realclean-post

realclean-post: realclean-recursive

realclean-recursive: realclean-pre

rc-setup: rc-setup-post

rc-setup-post: rc-setup-recursive

rc-setup-recursive: rc-setup-pre

dist: dist-post

dist-post: dist-recursive

dist-recursive: dist-pre

dist-devel: dist-devel-post

dist-devel-post: dist-devel-recursive

dist-devel-recursive: dist-devel-pre

makefile: makefile.in $(rootfromhere)/config.status
	cd $(rootfromhere) && CONFIG_FILES=$(herefromroot)/$@ CONFIG_HEADERS= ./config.status

# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
