(libfetish_a_SOURCES): Add full-write.h.
[gnulib.git] / lib / Makefile.am
1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
2
3 AUTOMAKE_OPTIONS = ../src/ansi2knr
4
5 noinst_LIBRARIES = libfetish.a
6
7 INCLUDES = -I.. -I$(srcdir) -I../intl
8 DEFS = -DLIBDIR=\"$(libdir)\" @DEFS@
9
10 ## Put relatively complex files at the beginning of the list so
11 ## that parallel compiles finish a tiny bit sooner.  I don't see
12 ## a way to make regex.c appear earlier in the list, since it's
13 ## added by automake, but on systems with an up to date GNU libc,
14 ## regex.c isn't even compiled.
15 libfetish_a_SOURCES = \
16   getdate.h getdate.y \
17   posixtm.c posixtm.h \
18   strftime.c \
19   getopt.c getopt.h getopt1.c \
20   hash.c hash.h \
21   __fpending.h \
22   addext.c \
23   argmatch.c argmatch.h \
24   backupfile.c backupfile.h \
25   basename.c \
26   bumpalloc.h \
27   canon-host.c \
28   closeout.c closeout.h \
29   diacrit.c diacrit.h \
30   dirname.c dirname.h \
31   dup-safer.c \
32   exclude.c exclude.h \
33   filemode.c filemode.h \
34   fnmatch.h \
35   fopen-safer.c \
36   fsusage.h \
37   full-write.c full-write.h \
38   getline.h \
39   getpagesize.h \
40   getstr.c getstr.h \
41   getugroups.c \
42   group-member.h \
43   gtod.h \
44   hard-locale.c hard-locale.h \
45   human.c human.h \
46   idcache.c \
47   isdir.c \
48   lchown.h \
49   linebuffer.c linebuffer.h \
50   localcharset.c \
51   long-options.c long-options.h \
52   makepath.c makepath.h \
53   mbswidth.c mbswidth.h \
54   md5.c md5.h \
55   memcasecmp.c memcasecmp.h \
56   memcoll.c memcoll.h \
57   modechange.c modechange.h \
58   mountlist.h \
59   nanosleep.h \
60   path-concat.c path-concat.h \
61   pathmax.h \
62   physmem.c physmem.h \
63   quote.c quote.h \
64   quotearg.c quotearg.h \
65   readtokens.c readtokens.h \
66   readutmp.h \
67   regex.h \
68   safe-read.c safe-read.h \
69   same.c same.h \
70   save-cwd.c save-cwd.h \
71   savedir.c savedir.h \
72   sha.c sha.h \
73   stdio-safer.h \
74   stripslash.c \
75   strtoxmax.c \
76   strverscmp.h \
77   unicodeio.c unicodeio.h \
78   unistd-safer.h \
79   userspec.c \
80   version-etc.c version-etc.h \
81   xalloc.h \
82   xgetcwd.c \
83   xgethostname.c \
84   xmalloc.c \
85   xstrdup.c \
86   xstrtod.c xstrtod.h \
87   xstrtol.c xstrtol.h \
88   xstrtoul.c \
89   xstrtoimax.c \
90   xstrtoumax.c \
91   yesno.c
92
93 libfetish_a_LIBADD = @LIBOBJS@ @ALLOCA@
94 libfetish_a_DEPENDENCIES = $(libfetish_a_LIBADD)
95
96
97 BUILT_SOURCES = getdate.c lstat.c stat.c unlocked-io.h
98 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
99 DISTCLEANFILES = lstat.c stat.c unlocked-io.h
100
101 EXTRA_DIST = xstat.in config.charset ref-add.sin ref-del.sin unlocked-io.hin
102 lstat.c: xstat.in
103         sed \
104           -e '/@IGNORE@/d' \
105           -e 's/@xstat@/lstat/g' \
106           -e '/_LSTAT_ONLY@/d' \
107           -e '/@BEGIN_STAT_ONLY@/,/@END_STAT_ONLY@/d' \
108           $(srcdir)/xstat.in > $@-t
109         mv $@-t $@
110
111 stat.c: xstat.in
112         sed \
113           -e '/@IGNORE@/d' \
114           -e 's/@xstat@/stat/g' \
115           -e '/_STAT_ONLY@/d' \
116           -e '/@BEGIN_LSTAT_ONLY@/,/@END_LSTAT_ONLY@/d' \
117           $(srcdir)/xstat.in > $@-t
118         mv $@-t $@
119
120
121 # The following is needed in order to install a simple file in $(libdir)
122 # which is shared with other installed packages. We use a list of referencing
123 # packages so that "make uninstall" will remove the file if and only if it
124 # is not used by another installed package.
125 # On systems with glibc-2.1 or newer, the file is redundant, therefore we
126 # avoid installing it.
127
128 all-local: charset.alias ref-add.sed ref-del.sed lstat.c stat.c unlocked-io.h
129
130 charset_alias = $(DESTDIR)$(libdir)/charset.alias
131 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
132 install-exec-local: all-local
133         $(mkinstalldirs) $(DESTDIR)$(libdir)
134         if test -f $(charset_alias); then \
135           sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
136           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
137           rm -f $(charset_tmp) ; \
138         else \
139           if test @GLIBC21@ = no; then \
140             sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
141             $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
142             rm -f $(charset_tmp) ; \
143           fi ; \
144         fi
145
146 uninstall-local: all-local
147         if test -f $(charset_alias); then \
148           sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
149           if grep '^# Packages using this file: $$' $(charset_tmp) \
150               > /dev/null; then \
151             rm -f $(charset_alias); \
152           else \
153             $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
154           fi; \
155           rm -f $(charset_tmp); \
156         fi
157
158 charset.alias: config.charset
159         $(SHELL) $(srcdir)/config.charset '@host@' > t-$@
160         mv t-$@ $@
161
162 SUFFIXES = .sed .sin
163 .sin.sed:
164         sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > $@-t
165         mv $@-t $@
166
167 CLEANFILES = charset.alias ref-add.sed ref-del.sed
168
169 ###############################################
170
171 # FIXME: CAUTION this list is a duplicate of one in ../Makefile.cfg.
172 io_functions = \
173   clearerr feof ferror fflush fgets fputc fputs \
174   fread fwrite getc getchar putc putchar
175
176 a_z=abcdefghijklmnopqrstuvwxyz
177 A_Z=ABCDEFGHIJKLMNOPQRSTUVWXYZ
178
179 unlocked-io.h: $(srcdir)/unlocked-io.hin Makefile.am
180         tmp=t$$$$;                                                      \
181         for f in $(io_functions); do                                    \
182           u=`echo $$f|tr $(a_z) $(A_Z)`;                                \
183           echo "#  if HAVE_$${u}_UNLOCKED"              ;               \
184           echo "#   undef $$f"                          ;               \
185           echo "#   define $$f(S) $${f}_unlocked (S)"   ;               \
186           echo '#  endif'                               ;               \
187         done > $$tmp;                                                   \
188         sed '/^@replace_this@$$/r '$$tmp $(srcdir)/unlocked-io.hin      \
189           | sed '/^@replace_this@$$/d'                                  \
190           > $@t;                                                        \
191         rm -f $$tmp;                                                    \
192         mv $@t $@