From cefa56d51d6227c35797c24fd895ef1e41ebb43b Mon Sep 17 00:00:00 2001
From: "Marcus M. Darden" <mmdarden@umich.edu>
Date: Tue, 28 Apr 2020 16:37:13 -0400
Subject: [PATCH] Clean up the sync2caen build target

Prior to this change, the remote path wasn't created safely and the
rsync command used would upload build artifacts to the remote.
---
 Makefile | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 05ba4e5..0ee100d 100644
--- a/Makefile
+++ b/Makefile
@@ -43,8 +43,8 @@ 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
+# REMOTE_PATH := eecs281_$(EXECUTABLE)_sync  # /home/mmdarden/eecs281_proj0_sync
+REMOTE_PATH := eecs281_$(EXECUTABLE)_sync
 
 # designate which compiler to use
 CXX         = g++
@@ -165,18 +165,23 @@ $(FULL_SUBMITFILE): $(FULL_SUBMITFILES)
 partialsubmit: identifier $(PARTIAL_SUBMITFILE)
 fullsubmit: identifier $(FULL_SUBMITFILE)
 
-sync2caen: REMOTE_PATH := ${REMOTE_BASEDIR}_${EXECUTABLE}_sync
+# REMOTE_PATH has default definition above
 sync2caen:
 	# Synchronize local files into target directory on CAEN
 	rsync \
       -av \
+      --delete \
+      --exclude '*.o' \
+      --exclude '$(EXECUTABLE)' \
+      --exclude '$(EXECUTABLE)_debug' \
+      --exclude '$(EXECUTABLE)_profile' \
       --exclude '.git*' \
       --exclude '.vs*' \
       --exclude '*.code-workspace' \
       --filter=":- .gitignore" \
       "."/ \
-      "login.engin.umich.edu:'${REMOTE_PATH}/'"
-	echo "Files synced to CAEN at ~/${REMOTE_PATH}/"
+      "login.engin.umich.edu:'$(REMOTE_PATH)/'"
+	echo "Files synced to CAEN at ~/$(REMOTE_PATH)/"
 
 define MAKEFILE_HELP
 EECS281 Advanced Makefile Help
-- 
GitLab