4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # * Neither the name of Red Hat nor the names of its contributors may be
16 # used to endorse or promote products derived from this software without
17 # specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
20 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
23 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 include $(top_srcdir)/common-rules.mk
34 EXTRA_DIST = windows-errors.txt
36 noinst_LTLIBRARIES = libutils.la
38 libutils_la_SOURCES = \
42 const-string-vector.h \
58 libutils_la_CPPFLAGS = \
59 -I$(top_srcdir)/include \
60 -I$(top_builddir)/include \
61 -I$(top_srcdir)/common/include \
62 -I$(top_srcdir)/common/replacements \
64 libutils_la_CFLAGS = \
68 libutils_la_LIBADD = \
72 # Generate the code to map Winsock errors to errno codes.
73 BUILT_SOURCES = windows-errors.c
74 windows-errors.c: windows-errors.txt
76 @echo '/* Generated from windows-errors.txt */' > $@-t
77 @echo '#include <nbdkit-plugin.h>' >> $@-t
78 @echo '#ifdef WIN32' >> $@-t
79 @echo '#include <winsock2.h>' >> $@-t
80 @echo '#include <ws2tcpip.h>' >> $@-t
81 @echo '#include <windows.h>' >> $@-t
82 @echo '#include <errno.h>' >> $@-t
84 @echo 'translate_winsock_error (const char *fn, int err) {' >> $@-t
85 # Always log the original error.
86 @echo ' nbdkit_debug ("%s: winsock error %d", fn, err);' >> $@-t
87 @echo ' switch (err) {' >> $@-t
90 -e 's/\(.*\)[[:space:]][[:space:]]*\(.*\)/#if defined(\1) \&\& defined(\2)\n\
91 case \1: return \2;\n\
94 @echo ' default:' >> $@-t
95 @echo ' return err > 10000 && err < 10025 ? err - 10000 : EINVAL;' >> $@-t
98 @echo '#endif /* WIN32 */' >> $@-t
104 TESTS = test-quotes test-vector
105 check_PROGRAMS = test-quotes test-vector
107 test_quotes_SOURCES = test-quotes.c quote.c utils.h
108 test_quotes_CPPFLAGS = \
110 -I$(top_srcdir)/common/replacements \
111 -I$(top_srcdir)/common/include \
113 test_quotes_CFLAGS = $(WARNINGS_CFLAGS)
114 test_quotes_LDADD = \
115 $(top_builddir)/common/replacements/libcompat.la \
118 test_vector_SOURCES = test-vector.c vector.c vector.h bench.h
119 test_vector_CPPFLAGS = \
121 -I$(top_srcdir)/common/replacements \
122 -I$(top_srcdir)/common/include \
124 test_vector_CFLAGS = $(WARNINGS_CFLAGS)
125 test_vector_LDADD = \
126 $(top_builddir)/common/replacements/libcompat.la \
130 NBDKIT_BENCH=1 ./test-vector