+LOCAL_RSYNC_EXCLUDES += --exclude '*.pyc'
+LOCAL_RSYNC_EXCLUDES += --exclude '*.png' --exclude '*.svg' --exclude '*.out'
+RSYNC_EXCLUDES := --exclude .svn --exclude .git --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
+RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
+RSYNC := rsync -a -v $(RSYNC_COND_DRY_RUN) --no-owner $(RSYNC_EXCLUDES)
+
+CLIENTS = $(shell ls clientbin/*.py)
+
+BINS = ./config/sfa-config-tty ./config/gen-sfa-cm-config.py \
+ ./sfa/server/sfa-start.py \
+ ./clientbin/sfaadmin.py \
+ $(CLIENTS)
+
+synclib: synccheck
+ +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/lib\*/python2.\*/site-packages/
+syncbin: synccheck
+ +$(RSYNC) $(BINS) $(SSHURL)/usr/bin/
+syncinit: synccheck
+ +$(RSYNC) ./init.d/sfa $(SSHURL)/etc/init.d/
+syncconfig:
+ +$(RSYNC) ./config/default_config.xml $(SSHURL)/etc/sfa/
+synctest: synccheck
+ +$(RSYNC) ./tests/ $(SSHURL)/root/tests-sfa
+syncrestart: synccheck
+ $(SSHCOMMAND) service sfa restart
+
+syncmig:
+ +$(RSYNC) ./sfa/storage/migrations $(SSHURL)/usr/share/sfa/
+
+
+# full-fledged
+sync: synclib syncbin syncinit syncconfig syncrestart
+# 99% of the time this is enough
+syncfast: synclib syncrestart
+
+.PHONY: synccheck synclib syncbin syncconfig synctest syncrestart sync syncfast
+