Makefile.am: Make PYTHONPATH work on Mingw.
[sliver-openvswitch.git] / Makefile.am
1 # Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
2 #
3 # Copying and distribution of this file, with or without modification,
4 # are permitted in any medium without royalty provided the copyright
5 # notice and this notice are preserved.  This file is offered as-is,
6 # without warranty of any kind.
7
8 AUTOMAKE_OPTIONS = foreign subdir-objects
9 ACLOCAL_AMFLAGS = -I m4
10 SUBDIRS = datapath
11
12 AM_CPPFLAGS = $(SSL_CFLAGS)
13 AM_CPPFLAGS += -I $(top_srcdir)/include
14 AM_CPPFLAGS += -I $(top_srcdir)/lib
15 AM_CPPFLAGS += -I $(top_builddir)/lib
16
17 AM_CFLAGS = -Wstrict-prototypes
18 AM_CFLAGS += $(WARNING_FLAGS)
19
20 if NDEBUG
21 AM_CPPFLAGS += -DNDEBUG
22 AM_CFLAGS += -fomit-frame-pointer
23 endif
24
25 if WIN32
26 psep=";"
27 else
28 psep=":"
29 endif
30 # PYTHONDONTWRITEBYTECODE=yes keeps Python from creating .pyc and .pyo
31 # files.  Creating .py[co] works OK for any given version of Open
32 # vSwitch, but it causes trouble if you switch from a version with
33 # foo/__init__.py into an (older) version with plain foo.py, since
34 # foo/__init__.pyc will cause Python to ignore foo.py.
35 if INCLUDE_PYTHON_COMPAT
36 run_python = PYTHONPATH=$(top_srcdir)/python$(psep)$(top_srcdir)/python/compat$(psep)$$PYTHONPATH
37 else
38 run_python = PYTHONPATH=$(top_srcdir)/python$(psep)$$PYTHONPATH
39 endif
40 run_python += PYTHONDONTWRITEBYTECODE=yes $(PYTHON)
41
42
43 ALL_LOCAL =
44 BUILT_SOURCES =
45 CLEANFILES =
46 CLEAN_LOCAL =
47 DISTCLEANFILES =
48 PYCOV_CLEAN_FILES = build-aux/check-structs,cover
49 EXTRA_DIST = \
50         CodingStyle \
51         DESIGN \
52         FAQ \
53         INSTALL \
54         INSTALL.Debian \
55         INSTALL.Fedora \
56         INSTALL.KVM \
57         INSTALL.Libvirt \
58         INSTALL.RHEL \
59         INSTALL.SSL \
60         INSTALL.XenServer \
61         INSTALL.userspace \
62         IntegrationGuide \
63         NOTICE \
64         OPENFLOW-1.1+ \
65         PORTING \
66         README-OFTest \
67         README-gcov \
68         README-lisp \
69         REPORTING-BUGS \
70         SubmittingPatches \
71         WHY-OVS \
72         boot.sh \
73         build-aux/sodepends.pl \
74         build-aux/soexpand.pl \
75         $(MAN_FRAGMENTS) \
76         $(MAN_ROOTS)
77 bin_PROGRAMS =
78 sbin_PROGRAMS =
79 bin_SCRIPTS =
80 DIST_HOOKS =
81 dist_man_MANS =
82 dist_pkgdata_DATA =
83 dist_pkgdata_SCRIPTS =
84 dist_sbin_SCRIPTS =
85 dist_scripts_SCRIPTS =
86 dist_scripts_DATA =
87 INSTALL_DATA_LOCAL =
88 UNINSTALL_LOCAL =
89 man_MANS =
90 MAN_FRAGMENTS =
91 MAN_ROOTS =
92 noinst_DATA =
93 noinst_HEADERS =
94 noinst_LIBRARIES =
95 noinst_man_MANS =
96 noinst_PROGRAMS =
97 noinst_SCRIPTS =
98 OVSIDL_BUILT =
99 pkgdata_DATA =
100 sbin_SCRIPTS =
101 scripts_SCRIPTS =
102 scripts_DATA =
103 SUFFIXES =
104 check_DATA =
105
106 scriptsdir = $(pkgdatadir)/scripts
107
108 # This ensures that files added to EXTRA_DIST are always distributed,
109 # even if they are inside an Automake if...endif conditional block that is
110 # disabled by some particular "configure" run.  For more information, see:
111 # http://article.gmane.org/gmane.comp.sysutils.automake.general/10891
112 noinst_HEADERS += $(EXTRA_DIST)
113
114 ro_c = echo '/* -*- mode: c; buffer-read-only: t -*- */'
115 ro_shell = printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n'
116
117 SUFFIXES += .in
118 .in:
119         $(PERL) $(srcdir)/build-aux/soexpand.pl -I$(srcdir) < $< | \
120             sed \
121                 -e 's,[@]PKIDIR[@],$(PKIDIR),g' \
122                 -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
123                 -e 's,[@]DBDIR[@],$(DBDIR),g' \
124                 -e 's,[@]PERL[@],$(PERL),g' \
125                 -e 's,[@]PYTHON[@],$(PYTHON),g' \
126                 -e 's,[@]RUNDIR[@],$(RUNDIR),g' \
127                 -e 's,[@]VERSION[@],$(VERSION),g' \
128                 -e 's,[@]localstatedir[@],$(localstatedir),g' \
129                 -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
130                 -e 's,[@]sysconfdir[@],$(sysconfdir),g' \
131                 -e 's,[@]bindir[@],$(bindir),g' \
132                 -e 's,[@]sbindir[@],$(sbindir),g' \
133                 -e 's,[@]abs_top_srcdir[@],$(abs_top_srcdir),g' \
134                 -e 's,[@]ovsdbmonitordir[@],$(ovsdbmonitordir),g' \
135             > $@.tmp
136         @if head -n 1 $@.tmp | grep '#!' > /dev/null; then \
137             echo chmod +x $@.tmp; \
138             chmod +x $@.tmp; \
139         fi
140         mv $@.tmp $@
141
142 .PHONY: clean-pycov
143 clean-pycov:
144         cd $(srcdir) && rm -f $(PYCOV_CLEAN_FILES)
145 CLEAN_LOCAL += clean-pycov
146
147 # If we're checked out from a Git repository, make sure that every
148 # file that is in Git is distributed.
149 #
150 # We only enable this check when GNU make is in use because the
151 # Makefile in datapath/linux, needed to get the list of files to
152 # distribute, requires GNU make extensions.
153 if GNU_MAKE
154 ALL_LOCAL += dist-hook-git
155 dist-hook-git: distfiles
156         @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \
157           (cd datapath && $(MAKE) distfiles);                               \
158           (cat distfiles; sed 's|^|datapath/|' datapath/distfiles) |        \
159             sort -u > all-distfiles;                                        \
160           (cd $(srcdir) && git ls-files) | grep -v '\.gitignore$$' |        \
161             sort -u > all-gitfiles;                                         \
162           comm -1 -3 all-distfiles all-gitfiles > missing-distfiles;        \
163           if test -s missing-distfiles; then                                \
164             echo "The distribution is missing the following files:";        \
165             cat missing-distfiles;                                          \
166             exit 1;                                                         \
167           fi;                                                               \
168         fi
169 CLEANFILES += all-distfiles all-gitfiles missing-distfiles
170 # The following is based on commands for the Automake "distdir" target.
171 distfiles: Makefile
172         @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
173         topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
174         list='$(DISTFILES)'; \
175         for file in $$list; do echo $$file; done | \
176           sed -e "s|^$$srcdirstrip/||;t" \
177               -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t" | sort -u > $@
178 CLEANFILES += distfiles
179 endif
180 .PHONY: dist-hook-git
181
182 # Check that every .c file includes <config.h>.
183 ALL_LOCAL += config-h-check
184 config-h-check:
185         @cd $(srcdir); \
186         if test -e .git && (git --version) >/dev/null 2>&1 && \
187            git --no-pager grep -L '#include <config\.h>' `git ls-files | grep '\.c$$' | \
188                grep -vE '^datapath|^lib/sflow|^third-party'`; \
189         then \
190             echo "See above for list of violations of the rule that"; \
191             echo "every C source file must #include <config.h>."; \
192             exit 1; \
193         fi
194 .PHONY: config-h-check
195
196 # Check that certain data structures are always declared "static".
197 ALL_LOCAL += static-check
198 static-check:
199         @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
200             git --no-pager grep -n -E '^[       ]+(struct vlog_rate_limit|pthread_once_t|struct ovsthread_once).*=' $(srcdir); \
201          then \
202             echo "See above for list of violations of the rule that "; \
203             echo "certain data structures must always be 'static'"; \
204             exit 1; \
205          fi
206 .PHONY: static-check
207
208 # Check that assert.h is not used outside a whitelist of files.
209 ALL_LOCAL += check-assert-h-usage
210 check-assert-h-usage:
211         @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
212             (cd $(srcdir) && git --no-pager grep -l -E '[<]assert.h[>]') | \
213             $(EGREP) -v '^lib/(sflow_receiver|vlog).c$$|^tests/'; \
214          then \
215             echo "Files listed above unexpectedly #include <""assert.h"">."; \
216             echo "Please use ovs_assert (from util.h) instead of assert."; \
217             exit 1; \
218          fi
219 .PHONY: check-assert-h-usage
220
221 ALL_LOCAL += thread-safety-check
222 thread-safety-check:
223         @if test -e '$(srcdir)'/.git && (git --version) >/dev/null 2>&1 && \
224            grep -n -f '$(srcdir)'/build-aux/thread-safety-blacklist \
225                `git ls-files '$(srcdir)' | grep '\.[ch]$$' \
226                 | $(EGREP) -v '^datapath|^lib/sflow|^third-party'` \
227                | $(EGREP) -v ':[        ]*/?\*'; \
228         then \
229             echo "See above for list of calls to functions that are"; \
230             echo "blacklisted due to thread safety issues"; \
231             exit 1; \
232         fi
233 EXTRA_DIST += build-aux/thread-safety-blacklist
234
235 if HAVE_GROFF
236 ALL_LOCAL += manpage-check
237 manpage-check: $(man_MANS) $(dist_man_MANS) $(noinst_man_MANS)
238         @error=false; \
239         for manpage in $?; do \
240                 LANG=en_US.UTF-8 groff -w mac -w delim -w escape -w input -w missing -w tab -T utf8 -man -p -z $$manpage >$@.tmp 2>&1; \
241                 if grep warning: $@.tmp; then error=:; fi; \
242                 rm -f $@.tmp; \
243         done; \
244         if $$error; then exit 1; else echo touch $@; touch $@; fi
245 CLEANFILES += manpage-check
246 endif
247
248 include $(srcdir)/manpages.mk
249 $(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.pl
250         @$(PERL) $(srcdir)/build-aux/sodepends.pl -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp
251         @if cmp -s $(@F).tmp $@; then \
252                 touch $@; \
253                 rm -f $(@F).tmp; \
254         else \
255                 mv $(@F).tmp $@; \
256         fi
257 CLEANFILES += manpage-dep-check
258
259 dist-hook: $(DIST_HOOKS)
260 all-local: $(ALL_LOCAL)
261 clean-local: $(CLEAN_LOCAL)
262 install-data-local: $(INSTALL_DATA_LOCAL)
263 uninstall-local: $(UNINSTALL_LOCAL)
264 .PHONY: $(DIST_HOOKS) $(CLEAN_LOCAL) $(INSTALL_DATA_LOCAL) $(UNINSTALL_LOCAL)
265
266 modules_install:
267 if LINUX_ENABLED
268         cd datapath/linux && $(MAKE) modules_install
269 endif
270
271 include lib/automake.mk
272 include ofproto/automake.mk
273 include utilities/automake.mk
274 include tests/automake.mk
275 include include/automake.mk
276 include third-party/automake.mk
277 include debian/automake.mk
278 include vswitchd/automake.mk
279 include ovsdb/automake.mk
280 include rhel/automake.mk
281 include xenserver/automake.mk
282 include python/automake.mk
283 include python/compat/automake.mk
284 include tutorial/automake.mk
285 include vtep/automake.mk