# This is the 'master makefile' for each project. 'new_project.csh' takes it
# and copies it into the top-level of the new project directory. Doing this, 
# it also renames it to 'Makefile':
#
#         cp Makefile-project $1/Makefile 
#
# This file is an outline, describing how you could automate many, many tasks
# that concern your work. There's no need to do this, neither is there a way 
# that I could predict what this file needs to look like for everyone's 
# problems. Take it as a guideline and play with it. Add rules you think are
# necessary, and delete the ones that are obsolete for you.

#--- directory where all the maps are stored
MAP_DIR     := ./gmt

#--- information for webupdate, username, hostname, target directory, directory to pull data from
#--- customize to your settings
USER        := ronni
HOST        := fairweather.gps.alaska.edu
REMOTE_WWW  := /export/ftpweb/htdocs/PROJECT-NAME
REMOTE_DATA := /gps/data/NEAsia2.5_timeseries/ 

#--- flags for make (don't tell me which directory you enter) comment this line
#    and uncomment the next to see the difference.
M_FLAGS     := --no-print-directory
#M_FLAGS    :=

#--- creates the whole project (here only the maps), think about how you
#    could add a 'backup' rule, or something else that could be done 
#    (e.g. web publishing).
all: maps
	@echo "done."

#--- call 'make all' in MAP_DIR directory, see there for further documentation
maps:
	@echo 'updating all maps in '$(MAP_DIR)
	@make $(M_FLAGS) -C $(MAP_DIR) all

#--- start your work day: 
#	1. update local copy of repository
#	2. get updated data
#	3. rerun make all to make sure we look at up-to-date maps
#this could theoretically go into the startup script of the machine for all projects
start-day:
	svn update
	rsync -avz --include="*/" --include="BEZ*" --include="BZ*" --exclude="*" $(USER)@$(HOST):$(REMOTE_DATA) ./data
	@make $(M_FLAGS) all
	
#--- start your work day: 
#	1. commit changes you made to project locally to repository
#	2. backup your data (well, that's kinda funky here)
#this could theoretically go into the shutdown script of the machine for all projects
end-day:
	svn commit
	rsync -avz --include="*/" --include="BEZ*" --include="BZ*" --exclude="*" ./data/ ronni@fairweather.gps.alaska.edu:/tmp

#--- assumes destination folder was created by user at some point
webupdate:
	rsync -r ./www $(USER)@$(HOST):$(REMOTE_WWW)

clean:
	@make $(M_FLAGS) -C $(MAP_DIR) clean

