]> git.proxmox.com Git - ovs.git/blob - Makefile.am
treewide: Get rid of "echo -n", and add a test to prevent regression.
[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 += check-echo-n
307 check-echo-n:
308 @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
309 git --no-pager grep -n 'echo'' -n' $(srcdir); \
310 then \
311 echo "See above for uses for \"echo"" -n\", which is non-POSIX"; \
312 echo "and does not work with all shells. Use \"printf\" instead."; \
313 exit 1; \
314 fi
315 .PHONY: check-echo-n
316
317 ALL_LOCAL += thread-safety-check
318 thread-safety-check:
319 @cd $(srcdir); \
320 if test -e .git && (git --version) >/dev/null 2>&1 && \
321 grep -n -f build-aux/thread-safety-blacklist \
322 `git ls-files | grep '\.[ch]$$' \
323 | $(EGREP) -v '^datapath|^lib/sflow|^third-party'` /dev/null \
324 | $(EGREP) -v ':[ ]*/?\*'; \
325 then \
326 echo "See above for list of calls to functions that are"; \
327 echo "blacklisted due to thread safety issues"; \
328 exit 1; \
329 fi
330 EXTRA_DIST += build-aux/thread-safety-blacklist
331 .PHONY: thread-safety-check
332
333 # Check that "ip" is used in preference to "ifconfig", because
334 # "ifconfig" is not installed ubiquitously anymore.
335 ALL_LOCAL += check-ifconfig
336 check-ifconfig:
337 @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
338 (cd $(srcdir) && git --no-pager grep -l -E -e 'ifconfig' | \
339 $(EGREP) -v 'Makefile.am|ovs-vsctl-bashcomp|openvswitch-custom\.te'); \
340 then \
341 echo "See above for list of files that use or reference"; \
342 echo "'ifconfig'. Please use 'ip' instead."; \
343 exit 1; \
344 fi
345 .PHONY: check-ifconfig
346
347 if HAVE_GROFF
348 ALL_LOCAL += manpage-check
349 manpage-check: $(man_MANS) $(dist_man_MANS) $(noinst_man_MANS)
350 @error=false; \
351 for manpage in $?; do \
352 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; \
353 if grep warning: $@.tmp; then error=:; fi; \
354 rm -f $@.tmp; \
355 done; \
356 if $$error; then exit 1; else touch $@; fi
357 $(AM_V_GEN) touch -c $@
358 CLEANFILES += manpage-check
359 endif
360
361 if HAVE_FLAKE8
362 ALL_LOCAL += flake8-check
363 # http://flake8.readthedocs.org/en/latest/warnings.html
364 # All warnings explicitly selected or ignored should be listed below.
365 #
366 # E***, W*** -- warnings from pep8
367 # E121 continuation line under-indented for hanging indent (only from flake8 v2.0)
368 # E123 closing bracket does not match indentation of opening bracket's line
369 # E125 continuation line with same indent as next logical line (only from flake8 v2.0)
370 # E126 continuation line over-indented for hanging indent
371 # E127 continuation line over-indented for visual indent
372 # E128 continuation line under-indented for visual indent
373 # E129 visually indented line with same indent as next logical line
374 # E131 continuation line unaligned for hanging indent
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,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.pl
397 @$(PERL) $(srcdir)/build-aux/sodepends.pl -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 ovsext: datapath-windows/ovsext.sln $(srcdir)/datapath-windows/include/OvsDpInterface.h
409 MSBuild.exe //maxcpucount datapath-windows/ovsext.sln /target:Build /property:Configuration="Win8$(VSTUDIO_CONFIG)" /property:Version="$(PACKAGE_VERSION)"
410 MSBuild.exe //maxcpucount datapath-windows/ovsext.sln /target:Build /property:Configuration="Win8.1$(VSTUDIO_CONFIG)" /property:Version="$(PACKAGE_VERSION)"
411
412 CLEAN_LOCAL += ovsext_clean
413 ovsext_clean: datapath-windows/ovsext.sln
414 MSBuild.exe //maxcpucount datapath-windows/ovsext.sln /target:Clean /property:Configuration="Win8$(VSTUDIO_CONFIG)" /property:Version="$(PACKAGE_VERSION)"
415 MSBuild.exe //maxcpucount datapath-windows/ovsext.sln /target:Clean /property:Configuration="Win8.1$(VSTUDIO_CONFIG)" /property:Version="$(PACKAGE_VERSION)"
416 endif
417 .PHONY: ovsext
418
419 clang-analyze: clean
420 @which clang scan-build >/dev/null 2>&1 || \
421 (echo "Unable to find clang/scan-build, Install clang,clang-analyzer packages"; exit 1)
422 @$(MKDIR_P) "$(srcdir)/tests/clang-analyzer-results"
423 @scan-build -o $(srcdir)/tests/clang-analyzer-results --use-cc=$(CC) $(MAKE)
424 .PHONY: clang-analyze
425
426 dist-hook: $(DIST_HOOKS)
427 all-local: $(ALL_LOCAL)
428 clean-local: $(CLEAN_LOCAL)
429 install-data-local: $(INSTALL_DATA_LOCAL)
430 uninstall-local: $(UNINSTALL_LOCAL)
431 .PHONY: $(DIST_HOOKS) $(CLEAN_LOCAL) $(INSTALL_DATA_LOCAL) $(UNINSTALL_LOCAL)
432
433 modules_install:
434 if LINUX_ENABLED
435 cd datapath/linux && $(MAKE) modules_install
436 endif
437
438 dist-docs:
439 VERSION=$(VERSION) MAKE='$(MAKE)' $(srcdir)/build-aux/dist-docs $(srcdir) $(docs)
440 .PHONY: dist-docs
441
442 include Documentation/automake.mk
443 include m4/automake.mk
444 include lib/automake.mk
445 include ofproto/automake.mk
446 include utilities/automake.mk
447 include tests/automake.mk
448 include include/automake.mk
449 include third-party/automake.mk
450 include debian/automake.mk
451 include vswitchd/automake.mk
452 include ovsdb/automake.mk
453 include rhel/automake.mk
454 include xenserver/automake.mk
455 include python/automake.mk
456 include tutorial/automake.mk
457 include vtep/automake.mk
458 include datapath-windows/automake.mk
459 include datapath-windows/include/automake.mk
460 include windows/automake.mk
461 include ovn/automake.mk
462 include selinux/automake.mk
463 include build-aux/automake.mk