python: Fix "make distcheck" error on version.py.
[sliver-openvswitch.git] / python / automake.mk
1 run_python = PYTHONPATH=$(top_srcdir)/python:$$PYTHON_PATH $(PYTHON)
2
3 ovstest_pyfiles = \
4         python/ovstest/__init__.py \
5         python/ovstest/args.py \
6         python/ovstest/rpcserver.py \
7         python/ovstest/tcp.py \
8         python/ovstest/udp.py \
9         python/ovstest/util.py
10
11 ovs_pyfiles = \
12         python/ovs/__init__.py \
13         python/ovs/daemon.py \
14         python/ovs/db/__init__.py \
15         python/ovs/db/data.py \
16         python/ovs/db/error.py \
17         python/ovs/db/idl.py \
18         python/ovs/db/parser.py \
19         python/ovs/db/schema.py \
20         python/ovs/db/types.py \
21         python/ovs/fatal_signal.py \
22         python/ovs/json.py \
23         python/ovs/jsonrpc.py \
24         python/ovs/ovsuuid.py \
25         python/ovs/poller.py \
26         python/ovs/process.py \
27         python/ovs/reconnect.py \
28         python/ovs/socket_util.py \
29         python/ovs/stream.py \
30         python/ovs/timeval.py \
31         python/ovs/unixctl.py \
32         python/ovs/util.py \
33         python/ovs/version.py \
34         python/ovs/vlog.py
35
36 PYFILES = $(ovs_pyfiles) python/ovs/dirs.py $(ovstest_pyfiles)
37 EXTRA_DIST += $(PYFILES)
38 PYCOV_CLEAN_FILES += $(PYFILES:.py=.py,cover)
39
40 if HAVE_PYTHON
41 nobase_pkgdata_DATA = $(ovs_pyfiles) $(ovstest_pyfiles)
42 ovs-install-data-local:
43         $(MKDIR_P) python/ovs
44         (echo "import os" && \
45          echo 'PKGDATADIR = os.environ.get("OVS_PKGDATADIR", """$(pkgdatadir)""")' && \
46          echo 'RUNDIR = os.environ.get("OVS_RUNDIR", """@RUNDIR@""")' && \
47          echo 'LOGDIR = os.environ.get("OVS_LOGDIR", """@LOGDIR@""")' && \
48          echo 'BINDIR = os.environ.get("OVS_BINDIR", """$(bindir)""")') \
49                 > python/ovs/dirs.py.tmp
50         $(MKDIR_P) $(DESTDIR)$(pkgdatadir)/python/ovs
51         $(INSTALL_DATA) python/ovs/dirs.py.tmp $(DESTDIR)$(pkgdatadir)/python/ovs/dirs.py
52         rm python/ovs/dirs.py.tmp
53 else
54 ovs-install-data-local:
55         @:
56 endif
57 install-data-local: ovs-install-data-local
58
59 UNINSTALL_LOCAL += ovs-uninstall-local
60 ovs-uninstall-local:
61         rm -f $(DESTDIR)$(pkgdatadir)/python/ovs/dirs.py
62
63 ALL_LOCAL += $(srcdir)/python/ovs/version.py
64 $(srcdir)/python/ovs/version.py: config.status
65         $(ro_shell) > $(@F).tmp
66         echo 'VERSION = "$(VERSION)"' >> $(@F).tmp
67         if [ "$(BUILDNR)" != "0" ]; \
68             then echo 'BUILDNR = "+build$(BUILDNR)"' >> $(@F).tmp; \
69             else echo 'BUILDNR = ""' >> $(@F).tmp; \
70         fi
71         if cmp -s $(@F).tmp $@; then touch $@; rm $(@F).tmp; else mv $(@F).tmp $@; fi