build: Add travis continuous integration support
[cascardo/ovs.git] / Makefile.am
1 # Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 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
15 if WIN32
16 AM_CPPFLAGS += -I $(top_srcdir)/include/windows
17 AM_CPPFLAGS += -I $(top_srcdir)/datapath-windows/include
18 AM_CPPFLAGS += $(PTHREAD_INCLUDES)
19 AM_LDFLAGS += $(PTHREAD_LDFLAGS)
20 endif
21
22 AM_CPPFLAGS += -I $(top_srcdir)/include
23 AM_CPPFLAGS += -I $(top_builddir)/include
24 AM_CPPFLAGS += -I $(top_srcdir)/lib
25 AM_CPPFLAGS += -I $(top_builddir)/lib
26
27 AM_CPPFLAGS += $(SSL_INCLUDES)
28
29 AM_CFLAGS = -Wstrict-prototypes
30 AM_CFLAGS += $(WARNING_FLAGS)
31
32 if NDEBUG
33 AM_CPPFLAGS += -DNDEBUG
34 AM_CFLAGS += -fomit-frame-pointer
35 endif
36
37 if WIN32
38 psep=";"
39 else
40 psep=":"
41 endif
42 # PYTHONDONTWRITEBYTECODE=yes keeps Python from creating .pyc and .pyo
43 # files.  Creating .py[co] works OK for any given version of Open
44 # vSwitch, but it causes trouble if you switch from a version with
45 # foo/__init__.py into an (older) version with plain foo.py, since
46 # foo/__init__.pyc will cause Python to ignore foo.py.
47 if INCLUDE_PYTHON_COMPAT
48 run_python = PYTHONPATH=$(top_srcdir)/python$(psep)$(top_srcdir)/python/compat$(psep)$$PYTHONPATH
49 else
50 run_python = PYTHONPATH=$(top_srcdir)/python$(psep)$$PYTHONPATH
51 endif
52 run_python += PYTHONDONTWRITEBYTECODE=yes $(PYTHON)
53
54
55 ALL_LOCAL =
56 BUILT_SOURCES =
57 CLEANFILES =
58 CLEAN_LOCAL =
59 DISTCLEANFILES =
60 PYCOV_CLEAN_FILES = build-aux/check-structs,cover
61 EXTRA_DIST = \
62         CONTRIBUTING \
63         CodingStyle \
64         DESIGN \
65         FAQ \
66         INSTALL \
67         INSTALL.Debian \
68         INSTALL.DPDK \
69         INSTALL.Fedora \
70         INSTALL.KVM \
71         INSTALL.Libvirt \
72         INSTALL.NetBSD \
73         INSTALL.RHEL \
74         INSTALL.SSL \
75         INSTALL.XenServer \
76         INSTALL.userspace \
77         INSTALL.Windows \
78         IntegrationGuide \
79         NOTICE \
80         OPENFLOW-1.1+ \
81         PORTING \
82         README-lisp \
83         REPORTING-BUGS \
84         TODO \
85         .travis.yml \
86         .travis/build.sh \
87         .travis/prepare.sh \
88         WHY-OVS \
89         boot.sh \
90         build-aux/cccl \
91         build-aux/sodepends.pl \
92         build-aux/soexpand.pl \
93         $(MAN_FRAGMENTS) \
94         $(MAN_ROOTS)
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 INSTALL_DATA_LOCAL =
106 UNINSTALL_LOCAL =
107 man_MANS =
108 MAN_FRAGMENTS =
109 MAN_ROOTS =
110 noinst_DATA =
111 noinst_HEADERS =
112 lib_LTLIBRARIES =
113 noinst_man_MANS =
114 noinst_PROGRAMS =
115 noinst_SCRIPTS =
116 OVSIDL_BUILT =
117 pkgdata_DATA =
118 sbin_SCRIPTS =
119 scripts_SCRIPTS =
120 scripts_DATA =
121 SUFFIXES =
122 check_DATA =
123
124 scriptsdir = $(pkgdatadir)/scripts
125
126 # This ensures that files added to EXTRA_DIST are always distributed,
127 # even if they are inside an Automake if...endif conditional block that is
128 # disabled by some particular "configure" run.  For more information, see:
129 # http://article.gmane.org/gmane.comp.sysutils.automake.general/10891
130 noinst_HEADERS += $(EXTRA_DIST)
131
132 ro_c = echo '/* -*- mode: c; buffer-read-only: t -*- */'
133 ro_shell = printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n'
134
135 SUFFIXES += .in
136 .in:
137         $(PERL) $(srcdir)/build-aux/soexpand.pl -I$(srcdir) < $< | \
138             sed \
139                 -e 's,[@]PKIDIR[@],$(PKIDIR),g' \
140                 -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
141                 -e 's,[@]DBDIR[@],$(DBDIR),g' \
142                 -e 's,[@]PERL[@],$(PERL),g' \
143                 -e 's,[@]PYTHON[@],$(PYTHON),g' \
144                 -e 's,[@]RUNDIR[@],$(RUNDIR),g' \
145                 -e 's,[@]VERSION[@],$(VERSION),g' \
146                 -e 's,[@]localstatedir[@],$(localstatedir),g' \
147                 -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
148                 -e 's,[@]sysconfdir[@],$(sysconfdir),g' \
149                 -e 's,[@]bindir[@],$(bindir),g' \
150                 -e 's,[@]sbindir[@],$(sbindir),g' \
151                 -e 's,[@]abs_top_srcdir[@],$(abs_top_srcdir),g' \
152             > $@.tmp
153         @if head -n 1 $@.tmp | grep '#!' > /dev/null; then \
154             chmod +x $@.tmp; \
155         fi
156         $(AM_V_GEN) mv $@.tmp $@
157
158 .PHONY: clean-pycov
159 clean-pycov:
160         cd $(srcdir) && rm -f $(PYCOV_CLEAN_FILES)
161 CLEAN_LOCAL += clean-pycov
162
163 # If we're checked out from a Git repository, make sure that every
164 # file that is in Git is distributed.
165 #
166 # We only enable this check when GNU make is in use because the
167 # Makefile in datapath/linux, needed to get the list of files to
168 # distribute, requires GNU make extensions.
169 if GNU_MAKE
170 ALL_LOCAL += dist-hook-git
171 dist-hook-git: distfiles
172         @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \
173           (cd datapath && $(MAKE) distfiles);                               \
174           (cat distfiles; sed 's|^|datapath/|' datapath/distfiles) |        \
175             LC_ALL=C sort -u > all-distfiles;                               \
176           (cd $(srcdir) && git ls-files) | grep -v '\.gitignore$$' |        \
177             LC_ALL=C sort -u > all-gitfiles;                                \
178           LC_ALL=C comm -1 -3 all-distfiles all-gitfiles > missing-distfiles; \
179           if test -s missing-distfiles; then                                \
180             echo "The distribution is missing the following files:";        \
181             cat missing-distfiles;                                          \
182             exit 1;                                                         \
183           fi;                                                               \
184         fi
185 CLEANFILES += all-distfiles all-gitfiles missing-distfiles
186 # The following is based on commands for the Automake "distdir" target.
187 distfiles: Makefile
188         @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
189         topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
190         list='$(DISTFILES)'; \
191         for file in $$list; do echo $$file; done | \
192           sed -e "s|^$$srcdirstrip/||;t" \
193               -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t" | \
194           LC_ALL=C sort -u > $@
195 CLEANFILES += distfiles
196 endif
197 .PHONY: dist-hook-git
198
199 # Check that every .c file includes <config.h>.
200 ALL_LOCAL += config-h-check
201 config-h-check:
202         @cd $(srcdir); \
203         if test -e .git && (git --version) >/dev/null 2>&1 && \
204            git --no-pager grep -L '#include <config\.h>' `git ls-files | grep '\.c$$' | \
205                grep -vE '^datapath|^lib/sflow|^third-party|^datapath-windows'`; \
206         then \
207             echo "See above for list of violations of the rule that"; \
208             echo "every C source file must #include <config.h>."; \
209             exit 1; \
210         fi
211 .PHONY: config-h-check
212
213 # Check for printf() type modifiers that MSVC doesn't support.
214 ALL_LOCAL += printf-check
215 printf-check:
216         @cd $(srcdir); \
217         if test -e .git && (git --version) >/dev/null 2>&1 && \
218            git --no-pager grep -n -E -e '%[-+ #0-9.*]*([ztj]|hh)' --and --not -e 'ovs_scan' `git ls-files | grep '\.[ch]$$' | \
219                grep -vE '^datapath|^lib/sflow|^third-party'`; \
220         then \
221             echo "See above for list of violations of the rule that"; \
222             echo "'z', 't', 'j', 'hh' printf() type modifiers are"; \
223             echo "forbidden.  See CodingStyle for replacements."; \
224             exit 1; \
225         fi
226 .PHONY: printf-check
227
228 # Check that certain data structures are always declared "static".
229 ALL_LOCAL += static-check
230 static-check:
231         @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
232             git --no-pager grep -n -E '^[       ]+(struct vlog_rate_limit|pthread_once_t|struct ovsthread_once).*=' $(srcdir); \
233          then \
234             echo "See above for list of violations of the rule that "; \
235             echo "certain data structures must always be 'static'"; \
236             exit 1; \
237          fi
238 .PHONY: static-check
239
240 # Check that assert.h is not used outside a whitelist of files.
241 ALL_LOCAL += check-assert-h-usage
242 check-assert-h-usage:
243         @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
244             (cd $(srcdir) && git --no-pager grep -l -E '[<]assert.h[>]') | \
245             $(EGREP) -v '^lib/(sflow_receiver|vlog).c$$|^tests/'; \
246          then \
247             echo "Files listed above unexpectedly #include <""assert.h"">."; \
248             echo "Please use ovs_assert (from util.h) instead of assert."; \
249             exit 1; \
250          fi
251 .PHONY: check-assert-h-usage
252
253 ALL_LOCAL += thread-safety-check
254 thread-safety-check:
255         @cd $(srcdir); \
256         if test -e .git && (git --version) >/dev/null 2>&1 && \
257            grep -n -f build-aux/thread-safety-blacklist \
258                `git ls-files | grep '\.[ch]$$' \
259                 | $(EGREP) -v '^datapath|^lib/sflow|^third-party'` /dev/null \
260                | $(EGREP) -v ':[        ]*/?\*'; \
261         then \
262             echo "See above for list of calls to functions that are"; \
263             echo "blacklisted due to thread safety issues"; \
264             exit 1; \
265         fi
266 EXTRA_DIST += build-aux/thread-safety-blacklist
267
268 if HAVE_GROFF
269 ALL_LOCAL += manpage-check
270 manpage-check: $(man_MANS) $(dist_man_MANS) $(noinst_man_MANS)
271         @error=false; \
272         for manpage in $?; do \
273                 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; \
274                 if grep warning: $@.tmp; then error=:; fi; \
275                 rm -f $@.tmp; \
276         done; \
277         if $$error; then exit 1; else touch $@; fi
278         $(AM_V_GEN) touch -c $@
279 CLEANFILES += manpage-check
280 endif
281
282 include $(srcdir)/manpages.mk
283 $(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.pl
284         @$(PERL) $(srcdir)/build-aux/sodepends.pl -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp
285         @if cmp -s $(@F).tmp $@; then \
286                 touch $@; \
287                 rm -f $(@F).tmp; \
288         else \
289                 mv $(@F).tmp $@; \
290         fi
291 CLEANFILES += manpage-dep-check
292
293 dist-hook: $(DIST_HOOKS)
294 all-local: $(ALL_LOCAL)
295 clean-local: $(CLEAN_LOCAL)
296 install-data-local: $(INSTALL_DATA_LOCAL)
297 uninstall-local: $(UNINSTALL_LOCAL)
298 .PHONY: $(DIST_HOOKS) $(CLEAN_LOCAL) $(INSTALL_DATA_LOCAL) $(UNINSTALL_LOCAL)
299
300 modules_install:
301 if LINUX_ENABLED
302         cd datapath/linux && $(MAKE) modules_install
303 endif
304
305 include m4/automake.mk
306 include lib/automake.mk
307 include ofproto/automake.mk
308 include utilities/automake.mk
309 include tests/automake.mk
310 include include/automake.mk
311 include third-party/automake.mk
312 include debian/automake.mk
313 include vswitchd/automake.mk
314 include ovsdb/automake.mk
315 include rhel/automake.mk
316 include xenserver/automake.mk
317 include python/automake.mk
318 include python/compat/automake.mk
319 include tutorial/automake.mk
320 include vtep/automake.mk
321 include datapath-windows/automake.mk
322 include datapath-windows/include/automake.mk