
ACLOCAL_AMFLAGS = -I m4

SUBDIRS = doc libthemedsupport th-scheme-utilities \
  theme-d theme-d-code tools

.PHONY : install-complete uninstall-complete \
	setup-local-config remove-local-config \
	clean-local-check distclean-local-check

THEME_D_LOCAL_CONFIG = ~/.theme-d-config

TOOLS_TO_COMPILE = check-test-compilation.scm \
  check-test-program-linking.scm \
  check-test-runs.scm \
  compile-tests.scm \
  generate-make-defs.scm \
  get-theme-d-code-dir.scm \
  get-theme-d-tools-dir.scm \
  link-test-programs.scm \
  run-test-programs.scm

confdir = /etc
conf_DATA = theme-d-config

theme-d-config : theme-d-config.in
	sed \
	-e 's|@_theme_d_guile_version@|$(MY_GUILE_VERSION)|g' \
	-e 's|@_theme_d_target_platform@|$(TARGET_PLATFORM)|g' \
	-e 's|@_theme_d_translator_dir@|$(THEME_D_TRANSLATOR_DIR)|g' \
	-e 's|@_theme_d_runtime_dir@|$(THEME_D_RUNTIME_DIR)|g' \
	-e 's|@_theme_d_lib_dir@|$(THEME_D_LIB_DIR)|g' \
	-e 's|@_theme_d_examples_dir@|$(THEME_D_EXAMPLES_DIR)|g' \
	-e 's|@_theme_d_tests_dir@|$(THEME_D_TESTS_DIR)|g' \
	-e 's|@_theme_d_tools_dir@|$(THEME_D_TOOLS_DIR)|g' \
	-e 's|@_theme_d_use_support_lib@|$(SUPPORT_LIB)|g' \
	-e 's|@_theme_d_compiler_path@|$(THEME_D_COMPILER_PATH)|g' \
	-e 's|@_theme_d_linker_path@|$(THEME_D_LINKER_PATH)|g' \
	-e 's|@_theme_d_run_path@|$(THEME_D_RUN_PATH)|g' \
	$< > $@

uninstall-local : remove-local-config

clean-local : clean-local-check

distclean-local : distclean-local-check

clean-local-check:
	-rm -f theme-d-config

distclean-local-check:
	-rm -f theme-d-config-maint

install-complete : remove-local-config install install-links

uninstall-complete : uninstall-links remove-local-config uninstall

install-links :
	-rm $(bindir)/theme-d-compile
	ln -s $(THEME_D_SCRIPT_DIR)/theme-d-compile.scm \
		$(bindir)/theme-d-compile
	-rm $(bindir)/theme-d-link
	ln -s $(THEME_D_SCRIPT_DIR)/theme-d-link.scm \
		$(bindir)/theme-d-link
	-rm $(bindir)/run-theme-d-program
	ln -s $(THEME_D_SCRIPT_DIR)/run-theme-program.scm \
		$(bindir)/run-theme-program
	-rm $(bindir)/get-theme-d-examples-dir
	ln -s $(THEME_D_SCRIPT_DIR)/get-theme-d-examples-dir.scm \
		$(bindir)/get-theme-d-examples-dir
	-rm $(bindir)/get-theme-d-tests-dir
	ln -s $(THEME_D_SCRIPT_DIR)/get-theme-d-tests-dir.scm \
		$(bindir)/get-theme-d-tests-dir
	-rm $(bindir)/get-theme-d-tools-dir
	ln -s $(THEME_D_SCRIPT_DIR)/get-theme-d-tools-dir.scm \
		$(bindir)/get-theme-d-tools-dir

uninstall-links :
	-rm $(bindir)/theme-d-compile
	-rm $(bindir)/theme-d-link
	-rm $(bindir)/run-theme-d-program
	-rm $(bindir)/get-theme-d-examples-dir
	-rm $(bindir)/get-theme-d-tests-dir
	-rm $(bindir)/get-theme-d-tools-dir

setup-local-config : theme-d-config-maint
	cp -v $< $(THEME_D_LOCAL_CONFIG)

remove-local-config :
	if [ -e $(THEME_D_LOCAL_CONFIG) ] ; then \
		rm -f $(THEME_D_LOCAL_CONFIG) ; \
	fi

compile-scheme-code :
	guild compile $(THEME_D_SCRIPT_DIR)/theme-d-compile.scm
	guild compile $(THEME_D_SCRIPT_DIR)/theme-d-link.scm
	guild compile $(THEME_D_SCRIPT_DIR)/run-theme-d-program.scm
	guild compile $(THEME_D_SCRIPT_DIR)/get-theme-d-examples-dir.scm
	guild compile $(THEME_D_SCRIPT_DIR)/get-theme-d-tests-dir.scm
	guild compile $(THEME_D_SCRIPT_DIR)/get-theme-d-tools-dir.scm
