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