1eb576c23d3672c9895c7cf747af6ed91a2398bd
[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 \
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   strverscmp.h \
76   unicodeio.c unicodeio.h \
77   unistd-safer.h \
78   userspec.c \
79   version-etc.c version-etc.h \
80   xalloc.h \
81   xgetcwd.c \
82   xgethostname.c \
83   xmalloc.c \
84   xstrdup.c \
85   xstrtod.c xstrtod.h \
86   xstrtol.c xstrtol.h \
87   xstrtoul.c \
88   xstrtoimax.c \
89   xstrtoumax.c \
90   yesno.c
91
92 libfetish_a_LIBADD = @LIBOBJS@ @ALLOCA@
93 libfetish_a_DEPENDENCIES = $(libfetish_a_LIBADD)
94
95
96 BUILT_SOURCES = getdate.c lstat.c stat.c unlocked-io.h
97 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
98 DISTCLEANFILES = lstat.c stat.c unlocked-io.h
99
100 EXTRA_DIST = xstat.in config.charset ref-add.sin ref-del.sin unlocked-io.hin
101 lstat.c: xstat.in
102         sed \
103           -e '/@IGNORE@/d' \
104           -e 's/@xstat@/lstat/g' \
105           -e '/_LSTAT_ONLY@/d' \
106           -e '/@BEGIN_STAT_ONLY@/,/@END_STAT_ONLY@/d' \
107           $(srcdir)/xstat.in > $@-t
108         mv $@-t $@
109
110 stat.c: xstat.in
111         sed \
112           -e '/@IGNORE@/d' \
113           -e 's/@xstat@/stat/g' \
114           -e '/_STAT_ONLY@/d' \
115           -e '/@BEGIN_LSTAT_ONLY@/,/@END_LSTAT_ONLY@/d' \
116           $(srcdir)/xstat.in > $@-t
117         mv $@-t $@
118
119
120 # The following is needed in order to install a simple file in $(libdir)
121 # which is shared with other installed packages. We use a list of referencing
122 # packages so that "make uninstall" will remove the file if and only if it
123 # is not used by another installed package.
124 # On systems with glibc-2.1 or newer, the file is redundant, therefore we
125 # avoid installing it.
126
127 all-local: charset.alias ref-add.sed ref-del.sed lstat.c stat.c unlocked-io.h
128
129 charset_alias = $(DESTDIR)$(libdir)/charset.alias
130 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
131 install-exec-local: all-local
132         $(mkinstalldirs) $(DESTDIR)$(libdir)
133         if test -f $(charset_alias); then \
134           sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
135           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
136           rm -f $(charset_tmp) ; \
137         else \
138           if test @GLIBC21@ = no; then \
139             sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
140             $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
141             rm -f $(charset_tmp) ; \
142           fi ; \
143         fi
144
145 uninstall-local: all-local
146         if test -f $(charset_alias); then \
147           sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
148           if grep '^# Packages using this file: $$' $(charset_tmp) \
149               > /dev/null; then \
150             rm -f $(charset_alias); \
151           else \
152             $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
153           fi; \
154           rm -f $(charset_tmp); \
155         fi
156
157 charset.alias: config.charset
158         $(SHELL) $(srcdir)/config.charset '@host@' > t-$@
159         mv t-$@ $@
160
161 SUFFIXES = .sed .sin
162 .sin.sed:
163         sed -e '/^#/d' -e 's/@''PACKAGE''@/@PACKAGE@/g' $< > $@-t
164         mv $@-t $@
165
166 CLEANFILES = charset.alias ref-add.sed ref-del.sed
167
168 ###############################################
169
170 # FIXME: CAUTION this list is a duplicate of one in ../Makefile.cfg.
171 io_functions = \
172   clearerr feof ferror fflush fgets fputc fputs \
173   fread fwrite getc getchar putc putchar
174
175 a_z=abcdefghijklmnopqrstuvwxyz
176 A_Z=ABCDEFGHIJKLMNOPQRSTUVWXYZ
177
178 unlocked-io.h: $(srcdir)/unlocked-io.hin Makefile.am
179         tmp=t$$$$;                                                      \
180         for f in $(io_functions); do                                    \
181           u=`echo $$f|tr $(a_z) $(A_Z)`;                                \
182           echo "#  if HAVE_$${u}_UNLOCKED"              ;               \
183           echo "#   undef $$f"                          ;               \
184           echo "#   define $$f(S) $${f}_unlocked (S)"   ;               \
185           echo '#  endif'                               ;               \
186         done > $$tmp;                                                   \
187         sed '/^@replace_this@$$/r '$$tmp $(srcdir)/unlocked-io.hin      \
188           | sed '/^@replace_this@$$/d'                                  \
189           > $@t;                                                        \
190         rm -f $$tmp;                                                    \
191         mv $@t $@