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