Do not seemingly #include Linux-specific headers on other platforms.
[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         WHY-OVS \
86         boot.sh \
87         build-aux/cccl \
88         build-aux/sodepends.pl \
89         build-aux/soexpand.pl \
90         $(MAN_FRAGMENTS) \
91         $(MAN_ROOTS)
92 bin_PROGRAMS =
93 sbin_PROGRAMS =
94 bin_SCRIPTS =
95 DIST_HOOKS =
96 dist_man_MANS =
97 dist_pkgdata_DATA =
98 dist_pkgdata_SCRIPTS =
99 dist_sbin_SCRIPTS =
100 dist_scripts_SCRIPTS =
101 dist_scripts_DATA =
102 INSTALL_DATA_LOCAL =
103 UNINSTALL_LOCAL =
104 man_MANS =
105 MAN_FRAGMENTS =
106 MAN_ROOTS =
107 noinst_DATA =
108 noinst_HEADERS =
109 lib_LTLIBRARIES =
110 noinst_man_MANS =
111 noinst_PROGRAMS =
112 noinst_SCRIPTS =
113 OVSIDL_BUILT =
114 pkgdata_DATA =
115 sbin_SCRIPTS =
116 scripts_SCRIPTS =
117 scripts_DATA =
118 SUFFIXES =
119 check_DATA =
120
121 scriptsdir = $(pkgdatadir)/scripts
122
123 # This ensures that files added to EXTRA_DIST are always distributed,
124 # even if they are inside an Automake if...endif conditional block that is
125 # disabled by some particular "configure" run.  For more information, see:
126 # http://article.gmane.org/gmane.comp.sysutils.automake.general/10891
127 noinst_HEADERS += $(EXTRA_DIST)
128
129 ro_c = echo '/* -*- mode: c; buffer-read-only: t -*- */'
130 ro_shell = printf '\043 Generated automatically -- do not modify!    -*- buffer-read-only: t -*-\n'
131
132 SUFFIXES += .in
133 .in:
134         $(PERL) $(srcdir)/build-aux/soexpand.pl -I$(srcdir) < $< | \
135             sed \
136                 -e 's,[@]PKIDIR[@],$(PKIDIR),g' \
137                 -e 's,[@]LOGDIR[@],$(LOGDIR),g' \
138                 -e 's,[@]DBDIR[@],$(DBDIR),g' \
139                 -e 's,[@]PERL[@],$(PERL),g' \
140                 -e 's,[@]PYTHON[@],$(PYTHON),g' \
141                 -e 's,[@]RUNDIR[@],$(RUNDIR),g' \
142                 -e 's,[@]VERSION[@],$(VERSION),g' \
143                 -e 's,[@]localstatedir[@],$(localstatedir),g' \
144                 -e 's,[@]pkgdatadir[@],$(pkgdatadir),g' \
145                 -e 's,[@]sysconfdir[@],$(sysconfdir),g' \
146                 -e 's,[@]bindir[@],$(bindir),g' \
147                 -e 's,[@]sbindir[@],$(sbindir),g' \
148                 -e 's,[@]abs_top_srcdir[@],$(abs_top_srcdir),g' \
149             > $@.tmp
150         @if head -n 1 $@.tmp | grep '#!' > /dev/null; then \
151             chmod +x $@.tmp; \
152         fi
153         $(AM_V_GEN) mv $@.tmp $@
154
155 .PHONY: clean-pycov
156 clean-pycov:
157         cd $(srcdir) && rm -f $(PYCOV_CLEAN_FILES)
158 CLEAN_LOCAL += clean-pycov
159
160 # If we're checked out from a Git repository, make sure that every
161 # file that is in Git is distributed.
162 #
163 # We only enable this check when GNU make is in use because the
164 # Makefile in datapath/linux, needed to get the list of files to
165 # distribute, requires GNU make extensions.
166 if GNU_MAKE
167 ALL_LOCAL += dist-hook-git
168 dist-hook-git: distfiles
169         @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1; then \
170           (cd datapath && $(MAKE) distfiles);                               \
171           (cat distfiles; sed 's|^|datapath/|' datapath/distfiles) |        \
172             LC_ALL=C sort -u > all-distfiles;                               \
173           (cd $(srcdir) && git ls-files) | grep -v '\.gitignore$$' |        \
174             LC_ALL=C sort -u > all-gitfiles;                                \
175           LC_ALL=C comm -1 -3 all-distfiles all-gitfiles > missing-distfiles; \
176           if test -s missing-distfiles; then                                \
177             echo "The distribution is missing the following files:";        \
178             cat missing-distfiles;                                          \
179             exit 1;                                                         \
180           fi;                                                               \
181         fi
182 CLEANFILES += all-distfiles all-gitfiles missing-distfiles
183 # The following is based on commands for the Automake "distdir" target.
184 distfiles: Makefile
185         @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
186         topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
187         list='$(DISTFILES)'; \
188         for file in $$list; do echo $$file; done | \
189           sed -e "s|^$$srcdirstrip/||;t" \
190               -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t" | \
191           LC_ALL=C sort -u > $@
192 CLEANFILES += distfiles
193 endif
194 .PHONY: dist-hook-git
195
196 # Check that every .c file includes <config.h>.
197 ALL_LOCAL += config-h-check
198 config-h-check:
199         @cd $(srcdir); \
200         if test -e .git && (git --version) >/dev/null 2>&1 && \
201            git --no-pager grep -L '#include <config\.h>' `git ls-files | grep '\.c$$' | \
202                grep -vE '^datapath|^lib/sflow|^third-party|^datapath-windows'`; \
203         then \
204             echo "See above for list of violations of the rule that"; \
205             echo "every C source file must #include <config.h>."; \
206             exit 1; \
207         fi
208 .PHONY: config-h-check
209
210 # Check for printf() type modifiers that MSVC doesn't support.
211 ALL_LOCAL += printf-check
212 printf-check:
213         @cd $(srcdir); \
214         if test -e .git && (git --version) >/dev/null 2>&1 && \
215            git --no-pager grep -n -E -e '%[-+ #0-9.*]*([ztj]|hh)' --and --not -e 'ovs_scan' `git ls-files | grep '\.[ch]$$' | \
216                grep -vE '^datapath|^lib/sflow|^third-party'`; \
217         then \
218             echo "See above for list of violations of the rule that"; \
219             echo "'z', 't', 'j', 'hh' printf() type modifiers are"; \
220             echo "forbidden.  See CodingStyle for replacements."; \
221             exit 1; \
222         fi
223 .PHONY: printf-check
224
225 # Check that certain data structures are always declared "static".
226 ALL_LOCAL += static-check
227 static-check:
228         @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
229             git --no-pager grep -n -E '^[       ]+(struct vlog_rate_limit|pthread_once_t|struct ovsthread_once).*=' $(srcdir); \
230          then \
231             echo "See above for list of violations of the rule that "; \
232             echo "certain data structures must always be 'static'"; \
233             exit 1; \
234          fi
235 .PHONY: static-check
236
237 # Check that assert.h is not used outside a whitelist of files.
238 ALL_LOCAL += check-assert-h-usage
239 check-assert-h-usage:
240         @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
241             (cd $(srcdir) && git --no-pager grep -l -E '[<]assert.h[>]') | \
242             $(EGREP) -v '^lib/(sflow_receiver|vlog).c$$|^tests/'; \
243          then \
244             echo "Files listed above unexpectedly #include <""assert.h"">."; \
245             echo "Please use ovs_assert (from util.h) instead of assert."; \
246             exit 1; \
247          fi
248 .PHONY: check-assert-h-usage
249
250 ALL_LOCAL += thread-safety-check
251 thread-safety-check:
252         @cd $(srcdir); \
253         if test -e .git && (git --version) >/dev/null 2>&1 && \
254            grep -n -f build-aux/thread-safety-blacklist \
255                `git ls-files | grep '\.[ch]$$' \
256                 | $(EGREP) -v '^datapath|^lib/sflow|^third-party'` /dev/null \
257                | $(EGREP) -v ':[        ]*/?\*'; \
258         then \
259             echo "See above for list of calls to functions that are"; \
260             echo "blacklisted due to thread safety issues"; \
261             exit 1; \
262         fi
263 EXTRA_DIST += build-aux/thread-safety-blacklist
264
265 if HAVE_GROFF
266 ALL_LOCAL += manpage-check
267 manpage-check: $(man_MANS) $(dist_man_MANS) $(noinst_man_MANS)
268         @error=false; \
269         for manpage in $?; do \
270                 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; \
271                 if grep warning: $@.tmp; then error=:; fi; \
272                 rm -f $@.tmp; \
273         done; \
274         if $$error; then exit 1; else touch $@; fi
275         $(AM_V_GEN) touch -c $@
276 CLEANFILES += manpage-check
277 endif
278
279 include $(srcdir)/manpages.mk
280 $(srcdir)/manpages.mk: $(MAN_ROOTS) build-aux/sodepends.pl
281         @$(PERL) $(srcdir)/build-aux/sodepends.pl -I. -I$(srcdir) $(MAN_ROOTS) >$(@F).tmp
282         @if cmp -s $(@F).tmp $@; then \
283                 touch $@; \
284                 rm -f $(@F).tmp; \
285         else \
286                 mv $(@F).tmp $@; \
287         fi
288 CLEANFILES += manpage-dep-check
289
290 dist-hook: $(DIST_HOOKS)
291 all-local: $(ALL_LOCAL)
292 clean-local: $(CLEAN_LOCAL)
293 install-data-local: $(INSTALL_DATA_LOCAL)
294 uninstall-local: $(UNINSTALL_LOCAL)
295 .PHONY: $(DIST_HOOKS) $(CLEAN_LOCAL) $(INSTALL_DATA_LOCAL) $(UNINSTALL_LOCAL)
296
297 modules_install:
298 if LINUX_ENABLED
299         cd datapath/linux && $(MAKE) modules_install
300 endif
301
302 include m4/automake.mk
303 include lib/automake.mk
304 include ofproto/automake.mk
305 include utilities/automake.mk
306 include tests/automake.mk
307 include include/automake.mk
308 include third-party/automake.mk
309 include debian/automake.mk
310 include vswitchd/automake.mk
311 include ovsdb/automake.mk
312 include rhel/automake.mk
313 include xenserver/automake.mk
314 include python/automake.mk
315 include python/compat/automake.mk
316 include tutorial/automake.mk
317 include vtep/automake.mk
318 include datapath-windows/automake.mk