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