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