#
#       Makefile for mapdata
#
#       Copyright (C) 2000-2022 GFD Dennou Club. All rights reserved.
#

include ../../../Mkinclude

MAPDATAF	= coast_world.asc          border_world.asc          \
		  plate_world.asc          state_usa.asc             \
		  coast_japan.asc          pref_japan.asc
MAPDATAB	= coast_world              border_world              \
		  plate_world              state_usa                 \
		  coast_japan              pref_japan
MAPDATAI	= $(LDBASEDIR)/coast_world $(LDBASEDIR)/border_world \
		  $(LDBASEDIR)/plate_world $(LDBASEDIR)/state_usa    \
		  $(LDBASEDIR)/coast_japan $(LDBASEDIR)/pref_japan
MAPDATAFR	= coast_world_1.asc
MAPDATABR	= coast_world_1
MAPDATAIR	= $(LDBASEDIR)/coast_world_1

CVMAPD		= ./cvmapd
RMAPD1		= ./rmapd1


all: $(MAPDATAI) $(MAPDATAIR)

$(LDBASEDIR)/coast_world: coast_world
	@echo "Installing map file $? into local dcldbase directory"
	@$(CP) $? $@

$(LDBASEDIR)/border_world: border_world
	@echo "Installing map file $? into local dcldbase directory"
	@$(CP) $? $@

$(LDBASEDIR)/plate_world: plate_world
	@echo "Installing map file $? into local dcldbase directory"
	@$(CP) $? $@

$(LDBASEDIR)/state_usa: state_usa
	@echo "Installing map file $? into local dcldbase directory"
	@$(CP) $? $@

$(LDBASEDIR)/coast_japan: coast_japan
	@echo "Installing map file $? into local dcldbase directory"
	@$(CP) $? $@

$(LDBASEDIR)/pref_japan: pref_japan
	@echo "Installing map file $? into local dcldbase directory"
	@$(CP) $? $@

$(LDBASEDIR)/coast_world_1: coast_world_1
	@echo "Installing map file $? into local dcldbase directory"
	@$(CP) $? $@

coast_world: coast_world.asc $(CVMAPD)
	@echo "Creating map data $@"
	@$(RM) $@
	@echo "'$@.asc' '$@'" | $(CVMAPD)

coast_world_1: coast_world_1.asc $(CVMAPD)
	@echo "Creating map data $@"
	@$(RM) $@
	@echo "'$@.asc' '$@'" | $(CVMAPD)

border_world: border_world.asc $(CVMAPD)
	@echo "Creating map data $@"
	@$(RM) $@
	@echo "'$@.asc' '$@'" | $(CVMAPD)

plate_world: plate_world.asc $(CVMAPD)
	@echo "Creating map data $@"
	@$(RM) $@
	@echo "'$@.asc' '$@'" | $(CVMAPD)

state_usa: state_usa.asc $(CVMAPD)
	@echo "Creating map data $@"
	@$(RM) $@
	@echo "'$@.asc' '$@'" | $(CVMAPD)

coast_japan: coast_japan.asc $(CVMAPD)
	@echo "Creating map data $@"
	@$(RM) $@
	@echo "'$@.asc' '$@'" | $(CVMAPD)

pref_japan: pref_japan.asc $(CVMAPD)
	@echo "Creating map data $@"
	@$(RM) $@
	@echo "'$@.asc' '$@'" | $(CVMAPD)

$(CVMAPD): $(CVMAPD).f
	$(FC) $(FFLAGS) -o $(CVMAPD) $(CVMAPD).f

coast_world_1.asc: coast_world.asc $(RMAPD1)
	@echo "Creating sub-map data $@"
	@$(RM) $@
	@echo "'coast_world.asc' 'coast_world_1.asc'" | $(RMAPD1)

$(RMAPD1): $(RMAPD1).f
	$(FC) $(FFLAGS) -o $(RMAPD1) $(RMAPD1).f

clean:
	$(RM) *.o *~ $(CVMAPD)$(EXT) $(RMAPD1)$(EXT) core \
	$(MAPDATAB) $(MAPDATABR) $(MAPDATAFR)
