
# Copyright (C) 2020, 2025 Tommi Höynälänmaa

# This file is part of Theme-D-Golf.

# You can redistribute and/or modify this file under the terms of the
# GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any
# later version.

# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.


gintrlibdir = $(LIB_DIR)/theme-d-intr

nodist_gintrlib_DATA = support.tci support.tcb \
  __intf_support.aux __impl_support.aux

linkedlibdir = $(THEME_D_TARGET_LIB_DIR)/theme-d-intr

nodist_linkedlib_DATA = __intf_support.go __impl_support.go

EXTRA_COMP_OPTIONS ?=
EXTRA_LINK_OPTIONS ?=

%.tci : %.thi
	theme-d-compile $(EXTRA_COMP_OPTIONS) -m ..: -o $@ $<

%.tcb : %.thb %.tci
	theme-d-compile $(EXTRA_COMP_OPTIONS) -m ..: -o $@ $<

__intf_support.go : support.tci
	GUILE_LOAD_PATH=../../guile-code:$$GUILE_LOAD_PATH \
	theme-d-link --module -m ..: $(EXTRA_LINK_OPTIONS) \
	-x "(g-golf)" -x "(guile-theme-d-intr support)" \
	--guile-target-path=..:../../guile-code: \
	support.tci

__intf_support.aux : __intf_support.go

__impl_support.go : support.tcb __intf_support.aux
	GUILE_LOAD_PATH=../../guile-code:$$GUILE_LOAD_PATH \
	theme-d-link --module -m ..: $(EXTRA_LINK_OPTIONS) \
	-x "(g-golf)" -x "(guile-theme-d-intr support)" \
	--guile-target-path=..:../../guile-code: \
	support.tcb

__impl_support.aux : __impl_support.go

mostlyclean-local: mostlyclean-local-check

.PHONY: mostlyclean-local-check

# Remove the intermediate files, too.

mostlyclean-local-check:
	-rm support.tci support.tcb
	-rm __intf_support.go __intf_support.aux
	-rm __impl_support.go __impl_support.aux
	-rm *.scm *.tree-il

