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