More migration to AC_LIBSOURCES/AC_LIBOBJ.
[platform/upstream/coreutils.git] / lib / Makefile.am
1 ## Makefile for gnulib/lib                              -*-Makefile-*-
2
3 # Copyright (C) 1995-2005 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
22 noinst_PROGRAMS = t-fpending
23 LDADD = $(noinst_LIBRARIES)
24
25 AM_CPPFLAGS = -I.. -I$(srcdir)
26 DEFS += -DLIBDIR=\"$(libdir)\"
27
28 libfetish_a_SOURCES = \
29   allocsa.c allocsa.h \
30   dev-ino.h \
31   diacrit.c diacrit.h \
32   dup-safer.c \
33   euidaccess.h \
34   exit.h \
35   fcntl-safer.h \
36   fopen-safer.c \
37   full-read.c full-read.h \
38   full-write.c full-write.h \
39   gettext.h \
40   localcharset.c localcharset.h \
41   mbswidth.c mbswidth.h \
42   open-safer.c \
43   readtokens0.c readtokens0.h \
44   regex.h \
45   root-dev-ino.c root-dev-ino.h \
46   stat-macros.h \
47   stdio-safer.h \
48   time_r.c time_r.h \
49   unicodeio.c unicodeio.h \
50   unistd-safer.h \
51   version-etc.c version-etc.h version-etc-fsf.c \
52   xalloc-die.c \
53   xfts.c xfts.h \
54   xgetcwd.c xgetcwd.h \
55   xgethostname.c xgethostname.h \
56   xmemcoll.c xmemcoll.h \
57   xreadlink.c xreadlink.h \
58   xstrndup.c xstrndup.h \
59   xstrtod.c xstrtod.h \
60   xstrtoimax.c \
61   xstrtol.c xstrtol.h \
62   xstrtoul.c \
63   xstrtoumax.c
64
65 libfetish_a_SOURCES += \
66   printf-args.h \
67   printf-parse.h \
68   vasprintf.h \
69   vasnprintf.h
70
71 libfetish_a_LIBADD = $(LIBOBJS) $(ALLOCA)
72 libfetish_a_DEPENDENCIES = $(libfetish_a_LIBADD)
73
74 lib_OBJECTS = $(libfetish_a_OBJECTS)
75
76
77 BUILT_SOURCES = getdate.c
78 CLEANFILES =
79 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
80 MOSTLYCLEANFILES =
81 SUFFIXES =
82
83 EXTRA_DIST = getdate.c config.charset ref-add.sin ref-del.sin \
84   getndelim2.c getndelim2.h
85
86 # We need the following in order to install a simple file in $(libdir)
87 # which is shared with other installed packages. We use a list of referencing
88 # packages so that "make uninstall" will remove the file if and only if it
89 # is not used by another installed package.
90 # On systems with glibc-2.1 or newer, the file is redundant, therefore we
91 # avoid installing it.
92
93 all-local: charset.alias ref-add.sed ref-del.sed
94
95 charset_alias = $(DESTDIR)$(libdir)/charset.alias
96 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
97 install-exec-local: all-local
98         test $(GLIBC21) != no || $(mkinstalldirs) $(DESTDIR)$(libdir)
99         if test -f $(charset_alias); then \
100           sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
101           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
102           rm -f $(charset_tmp) ; \
103         else \
104           if test $(GLIBC21) = no; then \
105             sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
106             $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
107             rm -f $(charset_tmp) ; \
108           fi ; \
109         fi
110
111 uninstall-local: all-local
112         if test -f $(charset_alias); then \
113           sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
114           if grep '^# Packages using this file: $$' $(charset_tmp) \
115               > /dev/null; then \
116             rm -f $(charset_alias); \
117           else \
118             $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
119           fi; \
120           rm -f $(charset_tmp); \
121         fi
122
123 charset.alias: config.charset
124         $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@
125         mv t-$@ $@
126
127 SUFFIXES += .sed .sin
128 .sin.sed:
129         sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@
130         mv t-$@ $@
131
132 CLEANFILES += charset.alias ref-add.sed ref-del.sed
133
134 BUILT_SOURCES += $(STDBOOL_H)
135 EXTRA_DIST += stdbool_.h
136 MOSTLYCLEANFILES += stdbool.h stdbool.ht
137 # Create stdbool.h on systems that lack a working one.
138 stdbool.h: stdbool_.h
139         sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' $(srcdir)/stdbool_.h > $@t
140         mv $@t $@
141
142 BUILT_SOURCES += $(ALLOCA_H)
143 EXTRA_DIST += alloca_.h
144
145 # We need the following in order to create an <alloca.h> when the system
146 # doesn't have one that works with the given compiler.
147 all-local $(lib_OBJECTS): $(ALLOCA_H)
148 alloca.h: alloca_.h
149         cp $(srcdir)/alloca_.h $@-t
150         mv $@-t $@
151 MOSTLYCLEANFILES += alloca.h alloca.h-t
152
153 BUILT_SOURCES += $(FNMATCH_H)
154 EXTRA_DIST += fnmatch_.h fnmatch_loop.c
155
156 # We need the following in order to create an <fnmatch.h> when the system
157 # doesn't have one that supports the required API.
158 all-local $(lib_OBJECTS): $(FNMATCH_H)
159 fnmatch.h: fnmatch_.h
160         cp $(srcdir)/fnmatch_.h $@-t
161         mv $@-t $@
162 MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
163
164 BUILT_SOURCES += $(GETOPT_H)
165 EXTRA_DIST += getopt_.h getopt_int.h
166
167 check: unit-test
168
169 .PHONY: unit-test
170 unit-test: t-fpending
171         ./t-fpending > /dev/null
172
173 # We need the following in order to create an <getopt.h> when the system
174 # doesn't have one that works with the given compiler.
175 all-local $(lib_OBJECTS): $(GETOPT_H)
176 getopt.h: getopt_.h
177         cp $(srcdir)/getopt_.h $@-t
178         mv $@-t $@
179 MOSTLYCLEANFILES += getopt.h getopt.h-t