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