Update Red Hat Copyright Notices
[nbdkit.git] / common / utils / Makefile.am
blobf28c8d2f080dfe8a2a6cc72c539a8fd50ce88e8c
1 # nbdkit
2 # Copyright Red Hat
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
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
30 # SUCH DAMAGE.
32 include $(top_srcdir)/common-rules.mk
34 EXTRA_DIST = windows-errors.txt
36 noinst_LTLIBRARIES = libutils.la
38 libutils_la_SOURCES = \
39         cleanup.c \
40         cleanup-nbdkit.c \
41         cleanup.h \
42         const-string-vector.h \
43         environ.c \
44         exit-with-parent.c \
45         exit-with-parent.h \
46         full-rw.c \
47         quote.c \
48         nbdkit-string.h \
49         string-vector.h \
50         utils.c \
51         utils.h \
52         vector.c \
53         vector.h \
54         windows-compat.h \
55         windows-compat.c \
56         windows-errors.c \
57         $(NULL)
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 \
63         $(NULL)
64 libutils_la_CFLAGS = \
65         $(WARNINGS_CFLAGS) \
66         $(PTHREAD_CFLAGS) \
67         $(NULL)
68 libutils_la_LIBADD = \
69         $(PTHREAD_LIBS) \
70         $(NULL)
72 # Generate the code to map Winsock errors to errno codes.
73 BUILT_SOURCES = windows-errors.c
74 windows-errors.c: windows-errors.txt
75         @rm -f $@ $@-t
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
83         @echo 'int' >> $@-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
88         @$(SED) -e '/^#/d' \
89                -e '/^$$/d' \
90                -e 's/\(.*\)[[:space:]][[:space:]]*\(.*\)/#if defined(\1) \&\& defined(\2)\n\
91     case \1: return \2;\n\
92 \#endif/' \
93         < $< >> $@-t
94         @echo '    default:' >> $@-t
95         @echo '    return err > 10000 && err < 10025 ? err - 10000 : EINVAL;' >> $@-t
96         @echo '    }' >> $@-t
97         @echo '}' >> $@-t
98         @echo '#endif /* WIN32 */' >> $@-t
99         mv $@-t $@
100         chmod -w $@
102 # Unit tests.
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 = \
109         -I$(srcdir) \
110         -I$(top_srcdir)/common/replacements \
111         -I$(top_srcdir)/common/include \
112         $(NULL)
113 test_quotes_CFLAGS = $(WARNINGS_CFLAGS)
114 test_quotes_LDADD = \
115         $(top_builddir)/common/replacements/libcompat.la \
116         $(NULL)
118 test_vector_SOURCES = test-vector.c vector.c vector.h bench.h
119 test_vector_CPPFLAGS = \
120         -I$(srcdir) \
121         -I$(top_srcdir)/common/replacements \
122         -I$(top_srcdir)/common/include \
123         $(NULL)
124 test_vector_CFLAGS = $(WARNINGS_CFLAGS)
125 test_vector_LDADD = \
126         $(top_builddir)/common/replacements/libcompat.la \
127         $(NULL)
129 bench: test-vector
130         NBDKIT_BENCH=1 ./test-vector