AM_FCFLAGS  = $(MODPATHFLAG)$(top_builddir)/include
CLEANFILES  = *@MODEXT@ *~
SUBDIRS =

# Keep Fortran module-output flags out of libtool link mode.  Intel Fortran
# uses "-module DIR", while libtool reserves "-module" as a link-mode option.
FCLINK = $(LIBTOOL) $(AM_V_lt) --tag=FC $(AM_LIBTOOLFLAGS) \
	$(LIBTOOLFLAGS) --mode=link $(FCLD) $(FCFLAGS) \
	$(AM_LDFLAGS) $(LDFLAGS) -o $@

all: all-am copy_header

copy_header:
	@echo "Copy generated header files into $(top_builddir)/include"
	@find . -name "*@MODEXT@" -exec $(install_sh_DATA) {} $(top_builddir)/include \;
	@find . -name "*.h" -exec $(install_sh_DATA) {} $(top_builddir)/include \;

.F.f90:
	$(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) $(DEFS) $< | sed -e '/^#/d' -e '/^\s*$$/d' >$@

## for Emacs's flymake
check-syntax:
	@case "$${CHK_SOURCES}" in \
	  *.c)   $(CC) -fsyntax-only $(CFLAGS) $(AM_CFLAGS) -S ${CHK_SOURCES} ;; \
	  *.f90) $(FC) -fsyntax-only $(FCFLAGS) $(AM_FCFLAGS) -S ${CHK_SOURCES} 2>&1 \
	  | $(top_srcdir)/scripts/flymake-wrapper-gfortran.rb ;; \
	  *)	exit 1 ;\
	esac
