#
# Copyright  (C)  2022 Jörg Behrens <behrens@dkrz.de>
#                      Moritz Hanke <hanke@dkrz.de>
#                      Thomas Jahns <jahns@dkrz.de>
#
# Author: Jörg Behrens <behrens@dkrz.de>
#         Moritz Hanke <hanke@dkrz.de>
#         Thomas Jahns <jahns@dkrz.de>
#
# Maintainer: Jörg Behrens <behrens@dkrz.de>
#             Moritz Hanke <hanke@dkrz.de>
#             Thomas Jahns <jahns@dkrz.de>
# URL: https://dkrz-sw.gitlab-pages.dkrz.de/yaxt/
#
# Redistribution and use in source and binary forms, with or without
# modification, are  permitted provided that the following conditions are
# met:
#
# Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# Neither the name of the DKRZ GmbH nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

xtincludedir = $(includedir)/xt

nodist_include_HEADERS = yaxt.h yaxt.hpp
nodist_xtinclude_HEADERS =  $(xtinclude_HEADERS) xt/xt_exchanger.h

SUBDIRS = . f90
DIST_SUBDIRS = f90 .

libyaxt_c_srcdir = ../src
$(libyaxt_c_srcdir)/xtinclude_Makefile.inc:
	cd $(libyaxt_c_srcdir) ; if test -r Makefile ; then \
	  exec $(MAKE) xtinclude_Makefile.inc ; fi

@am__include@ @am__quote@$(libyaxt_c_srcdir)/xtinclude_Makefile.inc@am__quote@ # am--include-marker

yaxt.h: Makefile $(libyaxt_c_srcdir)/xtinclude_Makefile.inc
	$(AM_V_GEN)( echo '/* license */' ; echo '#ifndef YAXT_H' ; echo '#define YAXT_H' ; \
	printf '%s\n' $(xtinclude_HEADERS) \
	| sed -n -e '/\.h$$/s@.*@#include <&>@p' ; \
	echo '#endif' \
	) >$@.$$$$.tmp ; \
	if test ! -f $@ || ! cmp $@ $@.$$$$.tmp >/dev/null ; then \
	mv $@.$$$$.tmp $@ ; else rm $@.$$$$.tmp ; fi

yaxt.hpp: Makefile $(libyaxt_c_srcdir)/xtinclude_Makefile.inc
	$(AM_V_GEN)( echo '/* license */' ; echo '#ifndef YAXT_HPP' ; echo '#define YAXT_HPP' ; \
	printf '%s\n' $(xtinclude_HEADERS) \
	| sed -n -e '/\.hpp$$/s@.*@#include <&>@p' ; \
	echo '#endif' \
	) >$@.$$$$.tmp ; \
	if test ! -f $@ || ! cmp $@ $@.$$$$.tmp >/dev/null ; then \
	mv $@.$$$$.tmp $@ ; else rm $@.$$$$.tmp ; fi

xt/.dir_stamp:
	$(AM_V_GEN)$(MKDIR_P) xt && touch xt/.dir_stamp

xtinclude_HEADERS_h_stamp = $(xtinclude_HEADERS:.h=.h.stamp)
xtinclude_HEADERS_stamp = $(xtinclude_HEADERS_h_stamp:.hpp=.hpp.stamp)

$(xtinclude_HEADERS_stamp): ../include/config.h \
	$(top_srcdir)/scripts/header2installheader.pl xt/.dir_stamp
	$(AM_V_GEN) headerbasedir=`test -f '$(libyaxt_c_srcdir)/$(@:.stamp= )' || echo '$(srcdir)/'` ; \
	  $(PERL) -I$(top_srcdir)/scripts \
	  $(top_srcdir)/scripts/header2installheader.pl \
	  --config-header=../include/config.h \
	  --srcdir=$$headerbasedir$(libyaxt_c_srcdir) \
	  --c-sizeof-int=$(C_SIZEOF_INT) \
	  --c-sizeof-long=$(C_SIZEOF_LONG) \
	  --c-sizeof-long-long=$(C_SIZEOF_LONG_LONG) \
	  --c-char-is-`test $(C_CHAR_IS_UNSIGNED) = 0 || echo un`signed \
	  `expr "$@" : '.*\.hpp.stamp$$' >/dev/null && echo --write-hpp-header` \
	  --dstdir=. \
	  $$headerbasedir$(libyaxt_c_srcdir)/$(@:.stamp=) && touch $@

xt/xt_exchanger.h.stamp: ../include/config.h \
	$(top_srcdir)/scripts/header2installheader.pl xt/.dir_stamp
	$(AM_V_GEN) srcfile=`echo "$(@:.stamp=)" | cut -c 4-` \
	  headerbasedir=`test -f '$(libyaxt_c_srcdir)/$$srcfile' || echo '$(srcdir)/'` ; \
	  $(PERL) -I$(top_srcdir)/scripts \
	  $(top_srcdir)/scripts/header2installheader.pl \
	  --config-header=../include/config.h \
	  --srcdir=$$headerbasedir$(libyaxt_c_srcdir) \
	  --c-sizeof-int=$(C_SIZEOF_INT) \
	  --c-sizeof-long=$(C_SIZEOF_LONG) \
	  --c-sizeof-long-long=$(C_SIZEOF_LONG_LONG) \
	  --c-char-is-`test $(C_CHAR_IS_UNSIGNED) = 0 || echo un`signed \
	  `expr "$@" : '.*\.hpp.stamp$$' >/dev/null && echo --write-hpp-header` \
	  --dstdir=xt \
	  "$$headerbasedir$(libyaxt_c_srcdir)/$$srcfile"

xt/xt_exchanger.h: xt/xt_exchanger.h.stamp
$(xtinclude_HEADERS) xt/xt_exchanger.h:
	@test -e "$@" || { rm -f "$@.stamp" ; $(MAKE) "$@.stamp" ; }

all-local: $(xtinclude_HEADERS_stamp)

clean-local:
	rm -rf xt yaxt.h yaxt.hpp

distclean-local:
	-test "$(abs_builddir)" = "$(abs_srcdir)" || rmdir f90

uninstall-local:
	rm -rf "$(DESTDIR)$(xtincludedir)"

#
# Local Variables:
# coding: utf-8
# show-trailing-whitespace: t
# End:
#
