#= Makefile for dcpam6/bin
#
# Authors::   Shin-ichi Takehiro
# Version::   $Id: Makefile,v 1.10 2025/09/18 10:00:00 takepiro Exp $
# Tag Name::  $Name:  $
# Copyright:: Copyright (C) GFD Dennou Club, 2004-2025. All rights reserved.
# License::   See COPYRIGHT[link:../../COPYRIGHT]
#
######################################################################
#
#== Settings

DIRDEPTH=..
INCLUDEFILE = $(DIRDEPTH)/Config.mk
include $(INCLUDEFILE)

prefix=$(DESTDIR)
libdir=$(prefix)/lib
includedir=$(prefix)/include


TARGETS = dcpamconfig dcpamfrt
TARGETS_ZONAL = dcpamzonalconfig dcpamfrt
TARGETS_MPI = dcpammpiconfig dcpamfrt

# End Settings
######################################################################

######################################################################
#== Rules

all: $(TARGETS)

zonal: $(TARGETS_ZONAL)

mpi: $(TARGETS_MPI)

# include $(DIRDEPTH)/rules.make

clean.all: clean clean.bin

clean:
	-$(RM) *~ *.bak

clean.bin:
	-$(RM) *~ $(TARGETS) $(TARGETS_ZONAL) $(TARGETS_MPI)

dcpamconfig: dcpamconfiggen.sh
	FC=$(FC) \
	MPIFC=$(MPIFC) \
	FCFLAGS="$(MODPATHFLAG)${includedir} $(FCFLAGS)" \
	LDFLAGS="$(LDFLAGS) -L${libdir}" \
	LDLIBS="-l$(LIBNAME) $(LDLIBS)" \
	VERSION="$(PACKAGE_NAME)$(PACKAGE_VERSION)" \
	PREFIX=$(DESTDIR) \
	sh dcpamconfiggen.sh $@
	chmod +x $@

dcpamzonalconfig: dcpamconfiggen.sh
	FC=$(FC) \
	MPIFC=$(MPIFC) \
	FCFLAGS="$(MODPATHFLAG)${includedir}-zonal $(FCFLAGS) -DAXISYMMETRY" \
	LDFLAGS="$(LDFLAGS) -L${libdir}" \
	LDLIBS="-l$(ZONALLIBNAME) $(LDLIBS)" \
	VERSION="$(PACKAGE_NAME)$(PACKAGE_VERSION)" \
	PREFIX=$(DESTDIR) \
	sh dcpamconfiggen.sh $@
	chmod +x $@

dcpammpiconfig: dcpamconfiggen.sh
	FC=$(FC) \
	MPIFC=$(MPIFC) \
	FCFLAGS="$(MODPATHFLAG)${includedir}-mpi $(FCFLAGS) -DLIB_MPI" \
	LDFLAGS="$(LDFLAGS) -L${libdir}" \
	LDLIBS="-l$(MPILIBNAME) $(LDLIBS)" \
	VERSION="$(PACKAGE_NAME)$(PACKAGE_VERSION)" \
	PREFIX=$(DESTDIR) \
	sh dcpamconfiggen.sh $@
	chmod +x $@

dcpamfrt: dcpamfrtgen.sh
	PREFIX=$(DESTDIR) \
	VERSION="$(PACKAGE_NAME)$(PACKAGE_VERSION)" \
	sh dcpamfrtgen.sh $@
	chmod +x $@

install:
	test -d $(INSTBINDIR) || $(INSTALLDIR) $(INSTBINDIR)
	@-if test $(INSTBINDIR) != $(BINDIR); then \
		$(CP) $(TARGETS) $(INSTBINDIR); fi

