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