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