(libcoreutils_a_SOURCES): Add xmemxfrm.c, xmemxfrm.h.
[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   localcharset.c localcharset.h \
41   mbchar.h \
42   mbswidth.c mbswidth.h \
43   mbuiter.h \
44   readtokens0.c readtokens0.h \
45   setenv.h \
46   strcase.h \
47   strnlen1.c strnlen1.h \
48   strstr.h \
49   unicodeio.c unicodeio.h \
50   verify.h \
51   wcwidth.h \
52   xalloc-die.c \
53   xgethostname.c xgethostname.h \
54   xmemcoll.c xmemcoll.h \
55   xmemxfrm.c xmemxfrm.h \
56   xstrndup.c xstrndup.h \
57   xstrtoimax.c \
58   xstrtoumax.c
59
60 libcoreutils_a_SOURCES += \
61   printf-args.h \
62   printf-parse.h \
63   vasprintf.h \
64   vasnprintf.h
65
66 libcoreutils_a_LIBADD = $(LIBOBJS) $(ALLOCA)
67
68 lib_OBJECTS = $(libcoreutils_a_OBJECTS)
69
70
71 BUILT_SOURCES = getdate.c
72 CLEANFILES =
73 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
74 MOSTLYCLEANFILES =
75 SUFFIXES =
76
77 EXTRA_DIST = getdate.c config.charset ref-add.sin ref-del.sin \
78   getndelim2.c getndelim2.h
79
80 # We need the following in order to install a simple file in $(libdir)
81 # which is shared with other installed packages. We use a list of referencing
82 # packages so that "make uninstall" will remove the file if and only if it
83 # is not used by another installed package.
84 # On systems with glibc-2.1 or newer, the file is redundant, therefore we
85 # avoid installing it.
86
87 all-local: charset.alias ref-add.sed ref-del.sed
88
89 charset_alias = $(DESTDIR)$(libdir)/charset.alias
90 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
91 install-exec-local: all-local
92         test $(GLIBC21) != no || $(mkinstalldirs) $(DESTDIR)$(libdir)
93         if test -f $(charset_alias); then \
94           sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
95           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
96           rm -f $(charset_tmp) ; \
97         else \
98           if test $(GLIBC21) = no; then \
99             sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
100             $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
101             rm -f $(charset_tmp) ; \
102           fi ; \
103         fi
104
105 uninstall-local: all-local
106         if test -f $(charset_alias); then \
107           sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
108           if grep '^# Packages using this file: $$' $(charset_tmp) \
109               > /dev/null; then \
110             rm -f $(charset_alias); \
111           else \
112             $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
113           fi; \
114           rm -f $(charset_tmp); \
115         fi
116
117 charset.alias: config.charset
118         $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@
119         mv t-$@ $@
120
121 SUFFIXES += .sed .sin
122 .sin.sed:
123         sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@
124         mv t-$@ $@
125
126 CLEANFILES += charset.alias ref-add.sed ref-del.sed
127
128 BUILT_SOURCES += $(STDBOOL_H)
129 EXTRA_DIST += stdbool_.h
130 MOSTLYCLEANFILES += stdbool.h stdbool.h-t
131 # Create stdbool.h on systems that lack a working one.
132 stdbool.h: stdbool_.h
133         sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > $@-t
134         mv $@-t $@
135
136 BUILT_SOURCES += $(STDINT_H)
137 EXTRA_DIST += stdint_.h
138
139 # We need the following in order to create <stdint.h> when the system
140 # doesn't have one that works with the given compiler.
141 stdint.h: stdint_.h
142         sed -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
143             -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
144             -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
145             -e 's|@''ABSOLUTE_STDINT_H''@|$(ABSOLUTE_STDINT_H)|g' \
146             -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
147             -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
148             -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
149             -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
150             -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
151             -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
152             -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
153             -e 's/@''HAVE_SIGNED_SIG_ATOMIC_T''@/$(HAVE_SIGNED_SIG_ATOMIC_T)/g' \
154             -e 's/@''SIG_ATOMIC_T_SUFFIX''@/$(SIG_ATOMIC_T_SUFFIX)/g' \
155             -e 's/@''BITSIZEOF_SIZE_T''@/$(BITSIZEOF_SIZE_T)/g' \
156             -e 's/@''SIZE_T_SUFFIX''@/$(SIZE_T_SUFFIX)/g' \
157             -e 's/@''BITSIZEOF_WCHAR_T''@/$(BITSIZEOF_WCHAR_T)/g' \
158             -e 's/@''HAVE_SIGNED_WCHAR_T''@/$(HAVE_SIGNED_WCHAR_T)/g' \
159             -e 's/@''WCHAR_T_SUFFIX''@/$(WCHAR_T_SUFFIX)/g' \
160             -e 's/@''BITSIZEOF_WINT_T''@/$(BITSIZEOF_WINT_T)/g' \
161             -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
162             -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
163             < $(srcdir)/stdint_.h > $@-t
164         mv $@-t $@
165 MOSTLYCLEANFILES += stdint.h stdint.h-t
166
167 BUILT_SOURCES += $(ALLOCA_H)
168 EXTRA_DIST += alloca_.h
169
170 # We need the following in order to create an <alloca.h> when the system
171 # doesn't have one that works with the given compiler.
172 all-local $(lib_OBJECTS): $(ALLOCA_H)
173 alloca.h: alloca_.h
174         cp $(srcdir)/alloca_.h $@-t
175         mv $@-t $@
176 MOSTLYCLEANFILES += alloca.h alloca.h-t
177
178 BUILT_SOURCES += $(FNMATCH_H)
179 EXTRA_DIST += fnmatch_.h fnmatch_loop.c
180
181 # We need the following in order to create an <fnmatch.h> when the system
182 # doesn't have one that supports the required API.
183 all-local $(lib_OBJECTS): $(FNMATCH_H)
184 fnmatch.h: fnmatch_.h
185         cp $(srcdir)/fnmatch_.h $@-t
186         mv $@-t $@
187 MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
188
189 BUILT_SOURCES += $(GETOPT_H)
190 EXTRA_DIST += getopt_.h getopt_int.h
191
192 check: unit-test
193
194 .PHONY: unit-test
195 unit-test: t-fpending
196         ./t-fpending > /dev/null
197
198 # We need the following in order to create an <getopt.h> when the system
199 # doesn't have one that works with the given compiler.
200 all-local $(lib_OBJECTS): $(GETOPT_H)
201 getopt.h: getopt_.h
202         cp $(srcdir)/getopt_.h $@-t
203         mv $@-t $@
204 MOSTLYCLEANFILES += getopt.h getopt.h-t