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