Accommodate new getaddrinfo implementation in gnulib.
[platform/upstream/coreutils.git] / lib / Makefile.am
1 ## Makefile for gnulib/lib                              -*-Makefile-*-
2
3 # Copyright (C) 1995-2006 Free Software Foundation, Inc.
4
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2, or (at your option)
8 ## any later version.
9
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
14
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 ## 02110-1301, USA.
19
20 AM_CFLAGS = $(WARNING_CFLAGS) $(WERROR_CFLAGS)
21
22 noinst_LIBRARIES = libcoreutils.a
23
24 noinst_PROGRAMS = t-fpending
25 LDADD = $(noinst_LIBRARIES)
26
27 AM_CPPFLAGS = -I.. -I$(srcdir)
28 DEFS += -DLIBDIR=\"$(libdir)\"
29
30 libcoreutils_a_SOURCES = \
31   allocsa.c allocsa.h \
32   base64.c base64.h \
33   buffer-lcm.c buffer-lcm.h \
34   euidaccess.h \
35   exit.h \
36   full-read.c full-read.h \
37   full-write.c full-write.h \
38   getaddrinfo.h \
39   gettext.h \
40   inet_ntop.h \
41   localcharset.c localcharset.h \
42   mbchar.h \
43   mbswidth.c mbswidth.h \
44   mbuiter.h \
45   readtokens0.c readtokens0.h \
46   setenv.h \
47   snprintf.h \
48   strcase.h \
49   strnlen1.c strnlen1.h \
50   strstr.h \
51   unicodeio.c unicodeio.h \
52   verify.h \
53   wcwidth.h \
54   xalloc-die.c \
55   xgethostname.c xgethostname.h \
56   xmemcoll.c xmemcoll.h \
57   xmemxfrm.c xmemxfrm.h \
58   xstrndup.c xstrndup.h \
59   xstrtoimax.c \
60   xstrtoumax.c
61
62 libcoreutils_a_SOURCES += \
63   printf-args.h \
64   printf-parse.h \
65   vasprintf.h \
66   vasnprintf.h
67
68 libcoreutils_a_LIBADD = $(LIBOBJS) $(ALLOCA)
69
70 lib_OBJECTS = $(libcoreutils_a_OBJECTS)
71
72
73 BUILT_SOURCES = getdate.c
74 CLEANFILES =
75 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
76 MOSTLYCLEANDIRS =
77 MOSTLYCLEANFILES =
78 SUFFIXES =
79
80 EXTRA_DIST = getdate.c config.charset ref-add.sin ref-del.sin \
81   getndelim2.c getndelim2.h
82
83 # We need the following in order to install a simple file in $(libdir)
84 # which is shared with other installed packages. We use a list of referencing
85 # packages so that "make uninstall" will remove the file if and only if it
86 # is not used by another installed package.
87 # On systems with glibc-2.1 or newer, the file is redundant, therefore we
88 # avoid installing it.
89
90 all-local: charset.alias ref-add.sed ref-del.sed
91
92 charset_alias = $(DESTDIR)$(libdir)/charset.alias
93 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
94 install-exec-local: all-local
95         test $(GLIBC21) != no || $(mkinstalldirs) $(DESTDIR)$(libdir)
96         if test -f $(charset_alias); then \
97           sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
98           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
99           rm -f $(charset_tmp) ; \
100         else \
101           if test $(GLIBC21) = no; then \
102             sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
103             $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
104             rm -f $(charset_tmp) ; \
105           fi ; \
106         fi
107
108 uninstall-local: all-local
109         if test -f $(charset_alias); then \
110           sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
111           if grep '^# Packages using this file: $$' $(charset_tmp) \
112               > /dev/null; then \
113             rm -f $(charset_alias); \
114           else \
115             $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
116           fi; \
117           rm -f $(charset_tmp); \
118         fi
119
120 charset.alias: config.charset
121         $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@
122         mv t-$@ $@
123
124 SUFFIXES += .sed .sin
125 .sin.sed:
126         sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@
127         mv t-$@ $@
128
129 CLEANFILES += charset.alias ref-add.sed ref-del.sed
130
131 BUILT_SOURCES += $(STDBOOL_H)
132 EXTRA_DIST += stdbool_.h
133 MOSTLYCLEANFILES += stdbool.h stdbool.h-t
134 # Create stdbool.h on systems that lack a working one.
135 stdbool.h: stdbool_.h
136         sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > $@-t
137         mv $@-t $@
138
139 BUILT_SOURCES += $(STDINT_H)
140 EXTRA_DIST += stdint_.h
141
142 # We need the following in order to create <stdint.h> when the system
143 # doesn't have one that works with the given compiler.
144 stdint.h: stdint_.h
145         sed -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
146             -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
147             -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
148             -e 's|@''ABSOLUTE_STDINT_H''@|$(ABSOLUTE_STDINT_H)|g' \
149             -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
150             -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
151             -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
152             -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
153             -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
154             -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
155             -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
156             -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
157             -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
158             -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
159             -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
160             -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
161             -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
162             -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
163             -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
164             -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
165             -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
166             < $(srcdir)/stdint_.h > $@-t
167         mv $@-t $@
168 MOSTLYCLEANFILES += stdint.h stdint.h-t
169
170 BUILT_SOURCES += $(ALLOCA_H)
171 EXTRA_DIST += alloca_.h
172
173 # We need the following in order to create an <alloca.h> when the system
174 # doesn't have one that works with the given compiler.
175 all-local $(lib_OBJECTS): $(ALLOCA_H)
176 alloca.h: alloca_.h
177         cp $(srcdir)/alloca_.h $@-t
178         mv $@-t $@
179 MOSTLYCLEANFILES += alloca.h alloca.h-t
180
181 BUILT_SOURCES += $(FNMATCH_H)
182 EXTRA_DIST += fnmatch_.h fnmatch_loop.c
183
184 # We need the following in order to create an <fnmatch.h> when the system
185 # doesn't have one that supports the required API.
186 all-local $(lib_OBJECTS): $(FNMATCH_H)
187 fnmatch.h: fnmatch_.h
188         cp $(srcdir)/fnmatch_.h $@-t
189         mv $@-t $@
190 MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
191
192 BUILT_SOURCES += $(GETOPT_H)
193 EXTRA_DIST += getopt_.h getopt_int.h
194
195 BUILT_SOURCES += $(ARPA_INET_H)
196
197 # We need the following in order to create <arpa/inet.h> when the system
198 # doesn't have one.
199 arpa/inet.h:
200         test -d arpa || mkdir arpa
201         echo '#include <sys/socket.h>' >$@-t
202         mv $@-t $@
203 MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t
204 MOSTLYCLEANDIRS += arpa
205
206 BUILT_SOURCES += $(SYS_SOCKET_H)
207 EXTRA_DIST += socket_.h
208
209 BUILT_SOURCES += $(NETINET_IN_H)
210
211 # We need the following in order to create <netinet/in.h> when the system
212 # doesn't have one.
213 netinet/in.h:
214         test -d netinet || mkdir netinet
215         echo '#include <sys/socket.h>' >$@-t
216         mv $@-t $@
217 MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t
218 MOSTLYCLEANDIRS += netinet
219
220 # We need the following in order to create <sys/socket.h> when the system
221 # doesn't have one that works with the given compiler.
222 sys/socket.h: socket_.h
223         test -d sys || mkdir sys
224         cp $(srcdir)/socket_.h $@-t
225         mv $@-t $@
226 MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
227 MOSTLYCLEANDIRS += sys
228
229 check: unit-test
230
231 .PHONY: unit-test
232 unit-test: t-fpending
233         ./t-fpending > /dev/null
234
235 # We need the following in order to create an <getopt.h> when the system
236 # doesn't have one that works with the given compiler.
237 all-local $(lib_OBJECTS): $(GETOPT_H)
238 getopt.h: getopt_.h
239         cp $(srcdir)/getopt_.h $@-t
240         mv $@-t $@
241 MOSTLYCLEANFILES += getopt.h getopt.h-t