]> git.proxmox.com Git - mirror_ovs.git/blob - Makefile.am
dpif-netdev: Fix a couple of coding style issues.
[mirror_ovs.git] / Makefile.am
1 # Copyright (C) 2007-2017 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_LDFLAGS = $(SSL_LDFLAGS)
14 AM_LDFLAGS += $(OVS_LDFLAGS)
15
16 if WIN32
17 AM_CPPFLAGS += -I $(top_srcdir)/include/windows
18 AM_CPPFLAGS += -I $(top_srcdir)/datapath-windows/include
19 AM_CPPFLAGS += $(PTHREAD_INCLUDES)
20 AM_CPPFLAGS += $(MSVC_CFLAGS)
21 AM_LDFLAGS += $(PTHREAD_LDFLAGS)
22 AM_LDFLAGS += $(MSVC64_LDFLAGS)
23 endif
24
25 AM_CPPFLAGS += -I $(top_srcdir)/include
26 AM_CPPFLAGS += -I $(top_builddir)/include
27 AM_CPPFLAGS += -I $(top_srcdir)/lib
28 AM_CPPFLAGS += -I $(top_builddir)/lib
29
30 AM_CPPFLAGS += $(SSL_INCLUDES)
31
32 AM_CFLAGS = -Wstrict-prototypes
33 AM_CFLAGS += $(WARNING_FLAGS)
34 AM_CFLAGS += $(OVS_CFLAGS)
35
36 if DPDK_NETDEV
37 AM_CFLAGS += -D_FILE_OFFSET_BITS=64
38 DPDKSTRIP_FLAGS = --dpdk
39 else
40 DPDKSTRIP_FLAGS = --nodpdk
41 endif
42
43 if NDEBUG
44 AM_CPPFLAGS += -DNDEBUG
45 AM_CFLAGS += -fomit-frame-pointer
46 endif
47
48 AM_CTAGSFLAGS = $(OVS_CTAGS_IDENTIFIERS_LIST)
49
50 if WIN32
51 psep=";"
52 else
53 psep=":"
54 endif
55 # PYTHONDONTWRITEBYTECODE=yes keeps Python from creating .pyc and .pyo
56 # files. Creating .py[co] works OK for any given version of Open
57 # vSwitch, but it causes trouble if you switch from a version with
58 # foo/__init__.py into an (older) version with plain foo.py, since
59 # foo/__init__.pyc will cause Python to ignore foo.py.
60 run_python = \
61 PYTHONPATH=$(top_srcdir)/python$(psep)$$PYTHONPATH \
62 PYTHONDONTWRITEBYTECODE=yes $(PYTHON)
63
64 ALL_LOCAL =
65 BUILT_SOURCES =
66 CLEANFILES =
67 CLEAN_LOCAL =
68 DISTCLEANFILES =
69 PYCOV_CLEAN_FILES = build-aux/check-structs,cover
70
71 EXTRA_DIST = \
72 AUTHORS.rst \
73 CONTRIBUTING.rst \
74 MAINTAINERS.rst \
75 README.rst \
76 NOTICE \
77 .travis.yml \
78 .travis/linux-build.sh \
79 .travis/linux-prepare.sh \
80 .travis/osx-build.sh \
81 .travis/osx-prepare.sh \
82 appveyor.yml \
83 boot.sh \
84 build-aux/cccl \
85 build-aux/cksum-schema-check \
86 build-aux/calculate-schema-cksum \
87 build-aux/dist-docs \
88 build-aux/dpdkstrip.pl \
89 build-aux/sodepends.pl \
90 build-aux/soexpand.pl \
91 build-aux/xml2nroff \
92 $(MAN_FRAGMENTS) \
93 $(MAN_ROOTS) \
94 Vagrantfile \
95 Vagrantfile-FreeBSD \
96 .mailmap
97 bin_PROGRAMS =
98 sbin_PROGRAMS =
99 bin_SCRIPTS =
100 DIST_HOOKS =
101 dist_man_MANS =
102 dist_pkgdata_DATA =
103 dist_pkgdata_SCRIPTS =
104 dist_sbin_SCRIPTS =
105 dist_scripts_SCRIPTS =
106 dist_scripts_DATA =
107 INSTALL_DATA_LOCAL =
108 UNINSTALL_LOCAL =
109 man_MANS =
110 MAN_FRAGMENTS =
111 MAN_ROOTS =
112 noinst_DATA =
113 noinst_HEADERS =
114 lib_LTLIBRARIES =
115 noinst_LTLIBRARIES =
116 noinst_man_MANS =
117 noinst_PROGRAMS =
118 noinst_SCRIPTS =
119 OVSIDL_BUILT =
120 pkgdata_DATA =
121 sbin_SCRIPTS =
122 scripts_SCRIPTS =
123 completion_SCRIPTS =
124 scripts_DATA =
125 SUFFIXES =
126 check_DATA =
127 check_SCRIPTS =
128 pkgconfig_DATA =
129 FLAKE8_PYFILES =
130
131 scriptsdir = $(pkgdatadir)/scripts
132 completiondir = $(sysconfdir)/bash_completion.d
133 pkgconfigdir = $(libdir)/pkgconfig
134
135 # This ensures that files added to EXTRA_DIST are always distributed,
136 # even if they are inside an Automake if...endif conditional block that is
137 # disabled by some particular "configure" run. For more information, see:
138 # http://article.gmane.org/gmane.comp.sysutils.automake.general/10891
139 noinst_HEADERS += $(EXTRA_DIST)
140
141 ro_c = echo '/* -*- mode: c; buffer-read-only: t -*- */'
142 ro_shell = printf '\043 Generated automatically -- do not modify! -*- buffer-read-only: t -*-\n'
143
144 SUFFIXES += .in
145 .in:
146 $(AM_V_GEN)$(PERL) $(srcdir)/build-aux/soexpand.pl -I$(srcdir) < $< | \
147 $(PERL) $(srcdir)/build-aux/dpdkstrip.pl $(DPDKSTRIP_FLAGS) | \
148 sed \
149 -e 's,[@]PKIDIR[@],$(PKIDIR),g' \
150 -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
151 -e 's,[@]DBDIR[@],$(DBDIR),g' \
152 -e 's,[@]PERL[@],$(PERL),g' \
153 -e 's,[@]PYTHON[@],$(PYTHON),g' \
154 -e 's,[@]RUNDIR[@],$(RUNDIR),g' \
155 -e 's,[@]VERSION[@],$(VERSION),g' \
156 -e 's,[@]localstatedir[@],$(localstatedir),g' \
157 -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
158 -e 's,[@]sysconfdir[@],$(sysconfdir),g' \
159 -e 's,[@]bindir[@],$(bindir),g' \
160 -e 's,[@]sbindir[@],$(sbindir),g' \
161 -e 's,[@]abs_builddir[@],$(abs_builddir),g' \
162 -e 's,[@]abs_top_srcdir[@],$(abs_top_srcdir),g' \
163 > $@.tmp
164 @if head -n 1 $@.tmp | grep '#!' > /dev/null; then \
165 chmod +x $@.tmp; \
166 fi
167 $(AM_V_at) mv $@.tmp $@
168
169 SUFFIXES += .xml
170 %: %.xml
171 $(AM_V_GEN)$(run_python) $(srcdir)/build-aux/xml2nroff $< > $@.tmp \
172 -I $(srcdir) \
173 --version=$(VERSION) \
174 PKIDIR='$(PKIDIR)' \
175 LOGDIR='$(LOGDIR)' \
176 DBDIR='$(DBDIR)' \
177 PERL='$(PERL)' \
178 PYTHON='$(PYTHON)' \
179 RUNDIR='$(RUNDIR)' \
180 VERSION='$(VERSION)' \
181 localstatedir='$(localstatedir)' \
182 pkgdatadir='$(pkgdatadir)' \
183 sysconfdir='$(sysconfdir)' \
184 bindir='$(bindir)' \
185 sbindir='$(sbindir)'
186 $(AM_v_at)mv $@.tmp $@
187
188 clean-pycov:
189 cd $(srcdir) && rm -f $(PYCOV_CLEAN_FILES)
190 CLEAN_LOCAL += clean-pycov
191 .PHONY: clean-pycov
192
193 # If we're checked out from a Git repository, make sure that every
194 # file that is in Git is distributed.
195 ALL_LOCAL += dist-hook-git
196 dist-hook-git: distfiles
197 @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \
198 (cd datapath && $(MAKE) distfiles); \
199 (cat distfiles; sed 's|^|datapath/|' datapath/distfiles) | \
200 LC_ALL=C sort -u > all-distfiles; \
201 (cd $(srcdir) && git ls-files) | grep -v '\.gitignore$$' | \
202 LC_ALL=C sort -u > all-gitfiles; \
203 LC_ALL=C comm -1 -3 all-distfiles all-gitfiles > missing-distfiles; \
204 if test -s missing-distfiles; then \
205 echo "The following files are in git but not the distribution:"; \
206 cat missing-distfiles; \
207 exit 1; \
208 fi; \
209 if LC_ALL=C grep '\.gitignore$$' all-distfiles; then \
210 echo "See above for list of files that are distributed but"; \
211 echo "should not be."; \
212 exit 1; \
213 fi \
214 fi
215 CLEANFILES += all-distfiles all-gitfiles missing-distfiles
216 # The following is based on commands for the Automake "distdir" target.
217 distfiles: Makefile
218 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
219 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
220 list='$(DISTFILES)'; \
221 for file in $$list; do echo $$file; done | \
222 sed -e "s|^$$srcdirstrip/||;t" \
223 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t" | \
224 LC_ALL=C sort -u > $@
225 CLEANFILES += distfiles
226 .PHONY: dist-hook-git
227
228 # Check that every .c file includes <config.h>.
229 ALL_LOCAL += config-h-check
230 config-h-check:
231 @cd $(srcdir); \
232 if test -e .git && (git --version) >/dev/null 2>&1 && \
233 git --no-pager grep -L '#include <config\.h>' `git ls-files | grep '\.c$$' | \
234 grep -vE '^datapath|^lib/sflow|^third-party|^datapath-windows|^python'`; \
235 then \
236 echo "See above for list of violations of the rule that"; \
237 echo "every C source file must #include <config.h>."; \
238 exit 1; \
239 fi; \
240 if grep '#include' include/openvswitch/*.h | \
241 grep -vE '(<.*>)|("openvswitch)|("openflow)'; \
242 then \
243 echo "See above for list of violations of the rule that"; \
244 echo "public openvswitch header file should not include internal library."; \
245 exit 1; \
246 fi
247 .PHONY: config-h-check
248
249 # Check for printf() type modifiers that MSVC doesn't support.
250 ALL_LOCAL += printf-check
251 printf-check:
252 @cd $(srcdir); \
253 if test -e .git && (git --version) >/dev/null 2>&1 && \
254 git --no-pager grep -n -E -e '%[-+ #0-9.*]*([ztj]|hh)' --and --not -e 'ovs_scan' `git ls-files | grep '\.[ch]$$' | \
255 grep -vE '^datapath|^lib/sflow|^third-party'`; \
256 then \
257 echo "See above for list of violations of the rule that"; \
258 echo "'z', 't', 'j', 'hh' printf() type modifiers are"; \
259 echo "forbidden. See coding-style.rst for replacements."; \
260 exit 1; \
261 fi
262 .PHONY: printf-check
263
264 # Check that certain data structures are always declared "static".
265 ALL_LOCAL += static-check
266 static-check:
267 @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
268 git --no-pager grep -n -E '^[ ]+(struct vlog_rate_limit|pthread_once_t|struct ovsthread_once).*=' $(srcdir); \
269 then \
270 echo "See above for list of violations of the rule that "; \
271 echo "certain data structures must always be 'static'"; \
272 exit 1; \
273 fi
274 .PHONY: static-check
275
276 # Check that assert.h is not used outside a whitelist of files.
277 ALL_LOCAL += check-assert-h-usage
278 check-assert-h-usage:
279 @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
280 (cd $(srcdir) && git --no-pager grep -l -E '[<]assert.h[>]') | \
281 $(EGREP) -v '^lib/(sflow_receiver|vlog).c$$|^tests/'; \
282 then \
283 echo "Files listed above unexpectedly #include <""assert.h"">."; \
284 echo "Please use ovs_assert (from util.h) instead of assert."; \
285 exit 1; \
286 fi
287 .PHONY: check-assert-h-usage
288
289 # Check that LITTLE_ENDIAN and BIG_ENDIAN are not used unless BYTE_ORDER is
290 # also mentioned. (<endian.h> always defines the former two constants. They
291 # must be compared to BYTE_ORDER to get the machine's correct endianness. But
292 # it is better to use WORDS_BIGENDIAN.)
293 ALL_LOCAL += check-endian
294 check-endian:
295 @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
296 (cd $(srcdir) && git --no-pager grep -l -E \
297 -e 'BIG_ENDIAN|LITTLE_ENDIAN' --and --not -e 'BYTE_ORDER' | \
298 $(EGREP) -v '^datapath/'); \
299 then \
300 echo "See above for list of files that misuse LITTLE""_ENDIAN"; \
301 echo "or BIG""_ENDIAN. Please use WORDS_BIGENDIAN instead."; \
302 exit 1; \
303 fi
304 .PHONY: check-endian
305
306 ALL_LOCAL += thread-safety-check
307 thread-safety-check:
308 @cd $(srcdir); \
309 if test -e .git && (git --version) >/dev/null 2>&1 && \
310 grep -n -f build-aux/thread-safety-blacklist \
311 `git ls-files | grep '\.[ch]$$' \
312 | $(EGREP) -v '^datapath|^lib/sflow|^third-party'` /dev/null \
313 | $(EGREP) -v ':[ ]*/?\*'; \
314 then \
315 echo "See above for list of calls to functions that are"; \
316 echo "blacklisted due to thread safety issues"; \
317 exit 1; \
318 fi
319 EXTRA_DIST += build-aux/thread-safety-blacklist
320 .PHONY: thread-safety-check
321
322 # Check that "ip" is used in preference to "ifconfig", because
323 # "ifconfig" is not installed ubiquitously anymore.
324 ALL_LOCAL += check-ifconfig
325 check-ifconfig:
326 @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
327 (cd $(srcdir) && git --no-pager grep -l -E -e 'ifconfig' | \
328 $(EGREP) -v 'Makefile.am|ovs-vsctl-bashcomp|openvswitch-custom\.te'); \
329 then \
330 echo "See above for list of files that use or reference"; \
331 echo "'ifconfig'. Please use 'ip' instead."; \
332 exit 1; \
333 fi
334 .PHONY: check-ifconfig
335
336 if HAVE_GROFF
337 ALL_LOCAL += manpage-check
338 manpage-check: $(man_MANS) $(dist_man_MANS) $(noinst_man_MANS)
339 @error=false; \
340 for manpage in $?; do \
341 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; \
342 if grep warning: $@.tmp; then error=:; fi; \
343 rm -f $@.tmp; \
344 done; \
345 if $$error; then exit 1; else touch $@; fi
346 $(AM_V_GEN) touch -c $@
347 CLEANFILES += manpage-check
348 endif
349
350 if HAVE_FLAKE8
351 ALL_LOCAL += flake8-check
352 # http://flake8.readthedocs.org/en/latest/warnings.html
353 # All warnings explicitly selected or ignored should be listed below.
354 #
355 # E***, W*** -- warnings from pep8
356 # E121 continuation line under-indented for hanging indent (only from flake8 v2.0)
357 # E123 closing bracket does not match indentation of opening bracket's line
358 # E125 continuation line with same indent as next logical line (only from flake8 v2.0)
359 # E126 continuation line over-indented for hanging indent
360 # E127 continuation line over-indented for visual indent
361 # E128 continuation line under-indented for visual indent
362 # E129 visually indented line with same indent as next logical line
363 # E131 continuation line unaligned for hanging indent
364 # W503 line break before binary operator
365 # F*** -- warnings native to flake8
366 # F811 redefinition of unused <name> from line <N> (only from flake8 v2.0)
367 # D*** -- warnings from flake8-docstrings plugin
368 # H*** -- warnings from flake8 hacking plugin (custom style checks beyond PEP8)
369 # H231 Python 3.x incompatible 'except x,y:' construct
370 # H232 Python 3.x incompatible octal 077 should be written as 0o77
371 # H233 Python 3.x incompatible use of print operator
372 # H238 old style class declaration, use new style (inherit from `object`)
373 FLAKE8_SELECT = H231,H232,H233,H238
374 FLAKE8_IGNORE = E121,E123,E125,E126,E127,E128,E129,E131,W503,F811,D,H,I
375 flake8-check: $(FLAKE8_PYFILES)
376 $(FLAKE8_WERROR)$(AM_V_GEN) \
377 src='$^' && \
378 flake8 $$src --select=$(FLAKE8_SELECT) $(FLAKE8_FLAGS) && \
379 flake8 $$src --ignore=$(FLAKE8_IGNORE) $(FLAKE8_FLAGS) && \
380 touch $@
381 endif
382 CLEANFILES += flake8-check
383
384 include $(srcdir)/manpages.mk
385 $(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.pl
386 @$(PERL) $(srcdir)/build-aux/sodepends.pl -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp
387 @if cmp -s $(@F).tmp $@; then \
388 touch $@; \
389 rm -f $(@F).tmp; \
390 else \
391 mv $(@F).tmp $@; \
392 fi
393 CLEANFILES += manpage-dep-check
394
395 if VSTUDIO_DDK
396 ALL_LOCAL += ovsext
397 ovsext: datapath-windows/ovsext.sln $(srcdir)/datapath-windows/include/OvsDpInterface.h
398 MSBuild.exe //maxcpucount datapath-windows/ovsext.sln /target:Build /property:Configuration="Win8$(VSTUDIO_CONFIG)" /property:Version="$(PACKAGE_VERSION)"
399 MSBuild.exe //maxcpucount datapath-windows/ovsext.sln /target:Build /property:Configuration="Win8.1$(VSTUDIO_CONFIG)" /property:Version="$(PACKAGE_VERSION)"
400
401 CLEAN_LOCAL += ovsext_clean
402 ovsext_clean: datapath-windows/ovsext.sln
403 MSBuild.exe //maxcpucount datapath-windows/ovsext.sln /target:Clean /property:Configuration="Win8$(VSTUDIO_CONFIG)" /property:Version="$(PACKAGE_VERSION)"
404 MSBuild.exe //maxcpucount datapath-windows/ovsext.sln /target:Clean /property:Configuration="Win8.1$(VSTUDIO_CONFIG)" /property:Version="$(PACKAGE_VERSION)"
405 endif
406 .PHONY: ovsext
407
408 clang-analyze: clean
409 @which clang scan-build >/dev/null 2>&1 || \
410 (echo "Unable to find clang/scan-build, Install clang,clang-analyzer packages"; exit 1)
411 @$(MKDIR_P) "$(srcdir)/tests/clang-analyzer-results"
412 @scan-build -o $(srcdir)/tests/clang-analyzer-results --use-cc=$(CC) $(MAKE)
413 .PHONY: clang-analyze
414
415 dist-hook: $(DIST_HOOKS)
416 all-local: $(ALL_LOCAL)
417 clean-local: $(CLEAN_LOCAL)
418 install-data-local: $(INSTALL_DATA_LOCAL)
419 uninstall-local: $(UNINSTALL_LOCAL)
420 .PHONY: $(DIST_HOOKS) $(CLEAN_LOCAL) $(INSTALL_DATA_LOCAL) $(UNINSTALL_LOCAL)
421
422 modules_install:
423 if LINUX_ENABLED
424 cd datapath/linux && $(MAKE) modules_install
425 endif
426
427 dist-docs:
428 VERSION=$(VERSION) MAKE='$(MAKE)' $(srcdir)/build-aux/dist-docs $(srcdir) $(docs)
429 .PHONY: dist-docs
430
431 include Documentation/automake.mk
432 include m4/automake.mk
433 include lib/automake.mk
434 include ofproto/automake.mk
435 include utilities/automake.mk
436 include tests/automake.mk
437 include include/automake.mk
438 include third-party/automake.mk
439 include debian/automake.mk
440 include vswitchd/automake.mk
441 include ovsdb/automake.mk
442 include rhel/automake.mk
443 include xenserver/automake.mk
444 include python/automake.mk
445 include tutorial/automake.mk
446 include vtep/automake.mk
447 include datapath-windows/automake.mk
448 include datapath-windows/include/automake.mk
449 include windows/automake.mk
450 include ovn/automake.mk
451 include selinux/automake.mk
452 include build-aux/automake.mk