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