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