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