310c879b37605e323b2b115fb5bc8e6860612883
[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   hash-pjw.c hash-pjw.h \
22   __fpending.h \
23   addext.c \
24   argmatch.c argmatch.h \
25   backupfile.c backupfile.h \
26   basename.c \
27   bumpalloc.h \
28   canon-host.c \
29   closeout.c closeout.h \
30   diacrit.c diacrit.h \
31   dirname.c dirname.h \
32   dirfd.h \
33   dup-safer.c \
34   exclude.c exclude.h \
35   filemode.c filemode.h \
36   fnmatch.h \
37   fopen-safer.c \
38   fsusage.h \
39   full-write.c full-write.h \
40   getline.h \
41   getpagesize.h \
42   getstr.c getstr.h \
43   getugroups.c \
44   group-member.h \
45   gtod.h \
46   hard-locale.c hard-locale.h \
47   human.c human.h \
48   idcache.c \
49   isdir.c \
50   lchown.h \
51   linebuffer.c linebuffer.h \
52   localcharset.c \
53   long-options.c long-options.h \
54   makepath.c makepath.h \
55   mbswidth.c mbswidth.h \
56   md5.c md5.h \
57   memcasecmp.c memcasecmp.h \
58   memcoll.c memcoll.h \
59   modechange.c modechange.h \
60   mountlist.h \
61   nanosleep.h \
62   path-concat.c path-concat.h \
63   pathmax.h \
64   physmem.c physmem.h \
65   quote.c quote.h \
66   quotearg.c quotearg.h \
67   readtokens.c readtokens.h \
68   readutmp.h \
69   regex.h \
70   safe-read.c safe-read.h \
71   same.c same.h \
72   save-cwd.c save-cwd.h \
73   savedir.c savedir.h \
74   sha.c sha.h \
75   stdio-safer.h \
76   stripslash.c \
77   strverscmp.h \
78   unicodeio.c unicodeio.h \
79   unistd-safer.h \
80   userspec.c \
81   version-etc.c version-etc.h \
82   xalloc.h \
83   xgetcwd.c \
84   xgethostname.c \
85   xmalloc.c \
86   xreadlink.c xreadlink.h \
87   xstrdup.c \
88   xstrtod.c xstrtod.h \
89   xstrtol.c xstrtol.h \
90   xstrtoul.c \
91   xstrtoimax.c \
92   xstrtoumax.c \
93   yesno.c
94
95 libfetish_a_LIBADD = @LIBOBJS@ @ALLOCA@
96 libfetish_a_DEPENDENCIES = $(libfetish_a_LIBADD)
97
98
99 BUILT_SOURCES = getdate.c lstat.c stat.c unlocked-io.h
100 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
101 DISTCLEANFILES = lstat.c stat.c unlocked-io.h
102
103 EXTRA_DIST = xstat.in config.charset ref-add.sin ref-del.sin gen-uio
104 lstat.c: xstat.in
105         sed \
106           -e '/@IGNORE@/d' \
107           -e 's/@xstat@/lstat/g' \
108           -e '/_LSTAT_ONLY@/d' \
109           -e '/@BEGIN_STAT_ONLY@/,/@END_STAT_ONLY@/d' \
110           $(srcdir)/xstat.in > $@-t
111         mv $@-t $@
112
113 stat.c: xstat.in
114         sed \
115           -e '/@IGNORE@/d' \
116           -e 's/@xstat@/stat/g' \
117           -e '/_STAT_ONLY@/d' \
118           -e '/@BEGIN_LSTAT_ONLY@/,/@END_LSTAT_ONLY@/d' \
119           $(srcdir)/xstat.in > $@-t
120         mv $@-t $@
121
122 Makefile: $(BUILT_SOURCES)
123
124
125 # The following is needed in order to install a simple file in $(libdir)
126 # which is shared with other installed packages. We use a list of referencing
127 # packages so that "make uninstall" will remove the file if and only if it
128 # is not used by another installed package.
129 # On systems with glibc-2.1 or newer, the file is redundant, therefore we
130 # avoid installing it.
131
132 all-local: charset.alias ref-add.sed ref-del.sed lstat.c stat.c unlocked-io.h
133
134 charset_alias = $(DESTDIR)$(libdir)/charset.alias
135 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
136 install-exec-local: all-local
137         $(mkinstalldirs) $(DESTDIR)$(libdir)
138         if test -f $(charset_alias); then \
139           sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
140           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
141           rm -f $(charset_tmp) ; \
142         else \
143           if test @GLIBC21@ = no; then \
144             sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
145             $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
146             rm -f $(charset_tmp) ; \
147           fi ; \
148         fi
149
150 uninstall-local: all-local
151         if test -f $(charset_alias); then \
152           sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
153           if grep '^# Packages using this file: $$' $(charset_tmp) \
154               > /dev/null; then \
155             rm -f $(charset_alias); \
156           else \
157             $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
158           fi; \
159           rm -f $(charset_tmp); \
160         fi
161
162 charset.alias: config.charset
163         $(SHELL) $(srcdir)/config.charset '@host@' > t-$@
164         mv t-$@ $@
165
166 SUFFIXES = .sed .sin
167 .sin.sed:
168         sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > $@-t
169         mv $@-t $@
170
171 CLEANFILES = charset.alias ref-add.sed ref-del.sed
172
173 ###############################################
174
175 # FIXME: CAUTION this list is a duplicate of one in ../Makefile.cfg.
176 io_functions = \
177   clearerr feof ferror fflush fgets fputc fputs \
178   fread fwrite getc getchar putc putchar
179
180 unlocked-io.h: $(srcdir)/gen-uio Makefile.am
181         srcdir=$(srcdir) $(SHELL) $(srcdir)/gen-uio $(io_functions) > $@t
182         mv $@t $@