review packaging for f37 (1/n)
[plcapi.git] / Makefile
1 #
2 # (Re)builds Python metafiles (__init__.py) and documentation
3 #
4 # Mark Huang <mlhuang@cs.princeton.edu>
5 # Copyright (C) 2005 The Trustees of Princeton University
6 #
7
8 # python-pycurl and python-psycopg2 avail. from fedora 5
9 # we used to ship our own version of psycopg2 and pycurl, for fedora4
10 # starting with 5.0, support for these two modules is taken out
11
12 # Other stuff - doc not implicit, it's redone by myplc-docs
13
14 # autoconf compatible variables
15 DESTDIR := /
16 datadir := /usr/share
17 bindir := /usr/bin
18
19 PWD := $(shell pwd)
20
21 all:
22         python3 setup.py build
23
24 install: install-python install-phpxmlrpc
25
26 install-python:
27         pip install --target $(DESTDIR)/$(datadir)/plc_api .
28         # it's important that plcsh sits in /usr/share/plc_api
29         # and not under bin/ so that python can find the PLC/ modules
30         mv $(DESTDIR)/$(datadir)/plc_api/bin/plcsh $(DESTDIR)/$(datadir)/plc_api
31         # python3 setup.py install \
32         #     --install-purelib=$(DESTDIR)/$(datadir)/plc_api \
33         #     --install-scripts=$(DESTDIR)/$(datadir)/plc_api \
34         #     --install-data=$(DESTDIR)/$(datadir)/plc_api
35
36 # phpxmlrpc is a git subtree; we just ship all its contents
37 # under /usr/share/plc_api/php/phpxmlrpc
38 install-phpxmlrpc:
39         mkdir -p $(DESTDIR)/$(datadir)/plc_api/php/phpxmlrpc/
40         rsync --exclude .git -ai php/phpxmlrpc/ $(DESTDIR)/$(datadir)/plc_api/php/phpxmlrpc/
41
42 clean:
43         find . -name '*.pyc' | xargs rm -f
44         python3 setup.py clean && rm -rf build
45
46 index:
47         echo "This step is obsolete"
48
49 ##########
50
51 force:
52
53 .PHONY: all install force clean index tags
54
55 #################### devel tools
56 tags:
57         find . '(' -name '*.py' -o -name '*.sql' -o -name '*.php' -o -name Makefile -o -name '[0-9][0-9][0-9]*' ')' | fgrep -v '.git/' | xargs etags
58
59 .PHONY: tags
60
61 ########## sync
62 # 2 forms are supported
63 # (*) if your plc root context has direct ssh access:
64 # make sync PLC=private.one-lab.org
65 # (*) otherwise, for test deployments, use on your testmaster
66 # $ run export
67 # and cut'n paste the export lines before you run make sync
68
69 ifdef PLC
70 SSHURL:=root@$(PLC):/
71 SSHCOMMAND:=ssh root@$(PLC)
72 else
73 ifdef PLCHOSTLXC
74 SSHURL:=root@$(PLCHOSTLXC):/vservers/$(GUESTNAME)
75 SSHCOMMAND:=ssh root@$(PLCHOSTLXC) ssh -o StrictHostKeyChecking=no -o LogLevel=quiet $(GUESTHOSTNAME)
76 endif
77 endif
78
79 LOCAL_RSYNC_EXCLUDES    := --exclude '*.pyc' --exclude Accessors_site.py
80 RSYNC_EXCLUDES          := --exclude '*~' --exclude TAGS $(LOCAL_RSYNC_EXCLUDES)
81 RSYNC_COND_DRY_RUN      := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
82 RSYNC                   := rsync -ai $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
83
84 sync:
85 ifeq (,$(SSHURL))
86         @echo "sync: I need more info from the command line, e.g."
87         @echo "  make sync PLC=boot.planetlab.eu"
88         @echo "  make sync PLCHOSTLXC=.. GUESTHOSTNAME=.. GUESTNAME=.."
89         @exit 1
90 else
91         +$(RSYNC) plcsh PLC planetlab5.sql migrations php $(SSHURL)/usr/share/plc_api/
92         +$(RSYNC) db-config.d/ $(SSHURL)/etc/planetlab/db-config.d/
93         +$(RSYNC) plc.d/ $(SSHURL)/etc/plc.d/
94         +$(RSYNC) apache/plc.wsgi $(SSHURL)/usr/share/plc_api/apache/
95         $(SSHCOMMAND) systemctl restart plc
96 endif
97
98 #################### convenience, for debugging only
99 # make +foo : prints the value of $(foo)
100 # make ++foo : idem but verbose, i.e. foo=$(foo)
101 ++%: varname=$(subst +,,$@)
102 ++%:
103         @echo "$(varname)=$($(varname))"
104 +%: varname=$(subst +,,$@)
105 +%:
106         @echo "$($(varname))"