From dd27ca7d9ed5adf0cd94e4dde7cad15a89bb28dd Mon Sep 17 00:00:00 2001
From: "Marcus M. Darden" <mmdarden@umich.edu>
Date: Sat, 3 Feb 2018 23:40:04 -0500
Subject: [PATCH] Add support for syncing from Macs to CAEN.

New target 'mac2caen' relies on SSH multiplexing, and an open SSH session
to keep files synced FROM Mac TO CAEN.
---
 Makefile | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/Makefile b/Makefile
index 40e27dd..0e7d277 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,12 @@ PATH := /usr/um/gcc-6.2.0/bin:$(PATH)
 LD_LIBRARY_PATH := /usr/um/gcc-6.2.0/lib64
 LD_RUN_PATH := /usr/um/gcc-6.2.0/lib64
 
+# This is the path from the CAEN home folder to where projects will be
+# uploaded. (eg. /home/mmdarden/eecs281/project1)
+# Change this if you prefer a different path.
+# REMOTE_BASEDIR  := w18/eecs281    # /home/mmdarden/w18/eecs281/project0
+REMOTE_BASEDIR  := eecs281
+
 # TODO
 # Change EXECUTABLE to match the command name given in the project spec.
 EXECUTABLE 	= executable
@@ -138,6 +144,35 @@ $(FULL_SUBMITFILE): $(FULL_SUBMITFILES)
 partialsubmit: $(PARTIAL_SUBMITFILE)
 fullsubmit: $(FULL_SUBMITFILE)
 
+mac2caen: REMOTE_PATH:="${REMOTE_BASEDIR}/$$(basename `pwd`)"
+mac2caen:
+	@echo "Build time: `date`" > rsync.log
+	@open rsync.log
+# Make target directory on CAEN server
+	@echo "Making remote target directory ... ${REMOTE_PATH}" \
+	  >> rsync.log
+	@ssh login.engin.umich.edu \
+	  "mkdir -p ${REMOTE_PATH}" \
+	  >> rsync.log
+# Synchronize local files into target directory on CAEN
+	@echo "Synchronizing local files to CAEN ..." \
+	  >> rsync.log
+	@rsync \
+	  -av \
+	  --delete \
+      --exclude '.git*' \
+      --exclude 'rsync.log' \
+	  --exclude '.DS_Store' \
+      --filter=":- .gitignore" \
+	  ./ \
+	  "login.engin.umich.edu:${REMOTE_PATH}/" \
+	  >> rsync.log
+# Do remote builds
+	@echo "Making remote executables with \"make all\" ..." \
+	  >> rsync.log
+	@ssh login.engin.umich.edu "cd ${REMOTE_PATH} && make all" \
+	  >> rsync.log
+
 define MAKEFILE_HELP
 EECS281 Advanced Makefile Help
 * This Makefile uses advanced techniques, for more information:
@@ -176,6 +211,13 @@ EECS281 Advanced Makefile Help
     A) Matches current autograder style grading tests
     B) Usage:
            $$ make static
+
+* Mac to CAEN upload support
+    A) Requires an .ssh/config file with SSH Multiplexing enabled and an
+       open SSH connection.
+    B) Edit the REMOTE_BASEDIR variable if default is not preferred.
+    C) Usage:
+           $$ make mac2caen
 endef
 export MAKEFILE_HELP
 
-- 
GitLab