(unit-test): New target.
[platform/upstream/coreutils.git] / lib / Makefile.am
1 ## Makefile for gnulib/lib                              -*-Makefile-*-
2
3 # Copyright (C) 1995-2004 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., 59 Temple Place - Suite 330, Boston, MA
18 ## 02111-1307, USA.
19
20 noinst_LIBRARIES = libfetish.a
21 noinst_PROGRAMS = t-fpending
22
23 AM_CPPFLAGS = -I.. -I$(srcdir)
24 DEFS += -DLIBDIR=\"$(libdir)\"
25
26 ## Put relatively complex files at the beginning of the list so
27 ## that parallel compiles finish a tiny bit sooner.  I don't see
28 ## a way to make regex.c appear earlier in the list, since it's
29 ## added by automake, but on systems with an up to date GNU libc,
30 ## regex.c isn't even compiled.
31 libfetish_a_SOURCES = \
32   acl.h acl.c \
33   getdate.h getdate.y \
34   posixtm.c posixtm.h \
35   posixver.c posixver.h \
36   strftime.c strftime.h \
37   hash.c hash.h \
38   hash-pjw.c hash-pjw.h \
39   __fpending.h \
40   allocsa.c allocsa.h \
41   argmatch.c argmatch.h \
42   backupfile.c backupfile.h \
43   basename.c \
44   c-strtod.c c-strtod.h c-strtold.c \
45   canon-host.c \
46   canonicalize.c canonicalize.h \
47   chdir-long.c chdir-long.h \
48   cloexec.c cloexec.h \
49   closeout.c closeout.h \
50   cycle-check.c cycle-check.h \
51   dev-ino.h \
52   diacrit.c diacrit.h \
53   dirname.c dirname.h \
54   dirfd.h \
55   dup-safer.c \
56   euidaccess.h \
57   exclude.c exclude.h \
58   exit.h \
59   exitfail.c exitfail.h \
60   fcntl-safer.h \
61   filemode.c filemode.h \
62   file-type.c file-type.h \
63   fopen-safer.c \
64   fsusage.h \
65   fts.c fts_.h \
66   full-read.c full-read.h \
67   full-write.c full-write.h \
68   getcwd.h \
69   getline.h \
70   getpagesize.h \
71   getpass.h \
72   gettime.c \
73   gettext.h \
74   getugroups.c \
75   group-member.h \
76   hard-locale.c hard-locale.h \
77   human.c human.h \
78   idcache.c \
79   imaxtostr.c \
80   lchown.h \
81   linebuffer.c linebuffer.h \
82   localcharset.c localcharset.h \
83   long-options.c long-options.h \
84   makepath.c makepath.h \
85   mbswidth.c mbswidth.h \
86   md5.c md5.h \
87   memcasecmp.c memcasecmp.h \
88   memcoll.c memcoll.h \
89   mempcpy.h \
90   modechange.c modechange.h \
91   mountlist.h \
92   offtostr.c \
93   openat.h \
94   open-safer.c \
95   path-concat.c path-concat.h \
96   pathmax.h \
97   physmem.c physmem.h \
98   quote.c quote.h \
99   quotearg.c quotearg.h \
100   readtokens0.c readtokens0.h \
101   readtokens.c readtokens.h \
102   readutmp.h \
103   regex.h \
104   root-dev-ino.c root-dev-ino.h \
105   safe-read.c safe-read.h \
106   safe-write.c safe-write.h \
107   same.c same.h \
108   save-cwd.c save-cwd.h \
109   savedir.c savedir.h \
110   setenv.h \
111   settime.c \
112   sha1.c sha1.h \
113   sig2str.h \
114   stat-macros.h \
115   stdio-safer.h \
116   stripslash.c \
117   strdup.h \
118   strndup.h \
119   strverscmp.h \
120   time_r.c time_r.h \
121   timespec.h \
122   umaxtostr.c \
123   unicodeio.c unicodeio.h \
124   unistd-safer.h \
125   unlocked-io.h \
126   userspec.c userspec.h \
127   utimecmp.c utimecmp.h \
128   utimens.c utimens.h \
129   version-etc.c version-etc.h \
130   xalloc.h \
131   xalloc-die.c \
132   xfts.c xfts.h \
133   xgetcwd.c xgetcwd.h \
134   xgethostname.c xgethostname.h \
135   xmalloc.c \
136   xmemcoll.c xmemcoll.h \
137   xnanosleep.c xnanosleep.h \
138   xreadlink.c xreadlink.h \
139   xstrndup.c xstrndup.h \
140   xstrtod.c xstrtod.h \
141   xstrtoimax.c \
142   xstrtol.c xstrtol.h \
143   xstrtoul.c \
144   xstrtoumax.c \
145   yesno.c yesno.h
146
147 libfetish_a_SOURCES += \
148   printf-args.h \
149   printf-parse.h \
150   vasprintf.h \
151   vasnprintf.h
152
153 libfetish_a_LIBADD = $(LIBOBJS) $(ALLOCA)
154 libfetish_a_DEPENDENCIES = $(libfetish_a_LIBADD)
155
156 lib_OBJECTS = $(libfetish_a_OBJECTS)
157
158
159 BUILT_SOURCES = getdate.c
160 CLEANFILES =
161 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
162 MOSTLYCLEANFILES =
163 SUFFIXES =
164
165 EXTRA_DIST = config.charset ref-add.sin ref-del.sin \
166   getndelim2.c getndelim2.h \
167   inttostr.c inttostr.h
168
169 # We need the following in order to install a simple file in $(libdir)
170 # which is shared with other installed packages. We use a list of referencing
171 # packages so that "make uninstall" will remove the file if and only if it
172 # is not used by another installed package.
173 # On systems with glibc-2.1 or newer, the file is redundant, therefore we
174 # avoid installing it.
175
176 all-local: charset.alias ref-add.sed ref-del.sed
177
178 charset_alias = $(DESTDIR)$(libdir)/charset.alias
179 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
180 install-exec-local: all-local
181         test $(GLIBC21) != no || $(mkinstalldirs) $(DESTDIR)$(libdir)
182         if test -f $(charset_alias); then \
183           sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
184           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
185           rm -f $(charset_tmp) ; \
186         else \
187           if test $(GLIBC21) = no; then \
188             sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
189             $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
190             rm -f $(charset_tmp) ; \
191           fi ; \
192         fi
193
194 uninstall-local: all-local
195         if test -f $(charset_alias); then \
196           sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
197           if grep '^# Packages using this file: $$' $(charset_tmp) \
198               > /dev/null; then \
199             rm -f $(charset_alias); \
200           else \
201             $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
202           fi; \
203           rm -f $(charset_tmp); \
204         fi
205
206 charset.alias: config.charset
207         $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@
208         mv t-$@ $@
209
210 SUFFIXES += .sed .sin
211 .sin.sed:
212         sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@
213         mv t-$@ $@
214
215 CLEANFILES += charset.alias ref-add.sed ref-del.sed
216
217 BUILT_SOURCES += $(STDBOOL_H)
218 EXTRA_DIST += stdbool_.h
219 MOSTLYCLEANFILES += stdbool.h stdbool.ht
220 # Create stdbool.h on systems that lack a working one.
221 stdbool.h: stdbool_.h
222         sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' $(srcdir)/stdbool_.h > $@t
223         mv $@t $@
224
225 BUILT_SOURCES += $(ALLOCA_H)
226 EXTRA_DIST += alloca_.h
227
228 # We need the following in order to create an <alloca.h> when the system
229 # doesn't have one that works with the given compiler.
230 all-local $(lib_OBJECTS): $(ALLOCA_H)
231 alloca.h: alloca_.h
232         cp $(srcdir)/alloca_.h $@-t
233         mv $@-t $@
234 MOSTLYCLEANFILES += alloca.h alloca.h-t
235
236 BUILT_SOURCES += $(FNMATCH_H)
237 EXTRA_DIST += fnmatch_.h fnmatch_loop.c
238
239 # We need the following in order to create an <fnmatch.h> when the system
240 # doesn't have one that supports the required API.
241 all-local $(lib_OBJECTS): $(FNMATCH_H)
242 fnmatch.h: fnmatch_.h
243         cp $(srcdir)/fnmatch_.h $@-t
244         mv $@-t $@
245 MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
246
247 BUILT_SOURCES += $(GETOPT_H)
248 EXTRA_DIST += getopt_.h getopt_int.h
249
250 check: unit-test
251
252 unit-test:
253         ./t-fpending > /dev/null
254
255 # We need the following in order to create an <getopt.h> when the system
256 # doesn't have one that works with the given compiler.
257 all-local $(lib_OBJECTS): $(GETOPT_H)
258 getopt.h: getopt_.h
259         cp $(srcdir)/getopt_.h $@-t
260         mv $@-t $@
261 MOSTLYCLEANFILES += getopt.h getopt.h-t