+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 ./systemd/sfa-setup.sh \
+ ./sfa/server/sfa-start.py \
+ ./clientbin/sfaadmin.py \
+ $(CLIENTS)
+
+synclib: synccheck
+ +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/lib\*/python2.\*/site-packages/
+synclib3: synccheck
+ +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/lib\*/python3.\*/site-packages/
+synclibdeb: synccheck
+ +$(RSYNC) --relative ./sfa/ --exclude migrations $(SSHURL)/usr/share/pyshared/
+syncmigrations:
+ +$(RSYNC) ./sfa/storage/migrations/versions/*.py $(SSHURL)/usr/share/sfa/migrations/versions/
+syncbin: synccheck
+ +$(RSYNC) $(BINS) $(SSHURL)/usr/bin/
+syncservices: synccheck
+ +$(RSYNC) ./systemd/*.service $(SSHURL)/lib/systemd/system
+ +$(RSYNC) ./systemd/sfa-setup.sh $(SSHURL)/usr/bin
+syncconfig:
+ +$(RSYNC) ./config/default_config.xml $(SSHURL)/etc/sfa/
+synctest: synccheck
+ +$(RSYNC) ./tests/ $(SSHURL)/root/tests-sfa
+syncrestart: synccheck
+ -$(SSHCOMMAND) systemctl --system daemon-reload
+ $(SSHCOMMAND) systemctl restart sfa-db
+ $(SSHCOMMAND) systemctl restart sfa-aggregate
+
+syncmig:
+ +$(RSYNC) ./sfa/storage/migrations $(SSHURL)/usr/share/sfa/
+
+
+# full-fledged
+sync: synclib syncbin syncservices syncconfig syncrestart
+syncdeb: synclibdeb syncbin syncservices syncconfig syncrestart
+# 99% of the time this is enough
+syncfast: synclib syncrestart
+
+.PHONY: synccheck synclib syncbin syncconfig synctest syncrestart sync syncfast
+
+##########
+CLIENTLIBFILES= \
+sfa/examples/miniclient.py \
+sfa/__init__.py \
+sfa/client/{sfaserverproxy,sfaclientlib,__init__}.py \
+sfa/trust/{certificate,__init__}.py \
+sfa/util/{sfalogging,faults,genicode,enumeration,__init__}.py
+
+clientlibsync:
+ @[ -d "$(CLIENTLIBTARGET)" ] || { echo "You need to set the make variable CLIENTLIBTARGET"; exit 1; }
+ rsync -av --relative $(CLIENTLIBFILES) $(CLIENTLIBTARGET)
+
+#################### convenience, for debugging only
+# make +foo : prints the value of $(foo)
+# make ++foo : idem but verbose, i.e. foo=$(foo)
+++%: varname=$(subst +,,$@)
+++%:
+ @echo "$(varname)=$($(varname))"
++%: varname=$(subst +,,$@)
++%:
+ @echo "$($(varname))"