(stdbool.h): Resurrect the 'sed' that goes along with '#if !@HAVE_BOOL@".
[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., 51 Franklin Street, Fifth Floor, Boston, MA
18 ## 02110-1301, USA.
19
20 noinst_LIBRARIES = libcoreutils.a
21
22 noinst_PROGRAMS = t-fpending
23 LDADD = $(noinst_LIBRARIES)
24
25 AM_CPPFLAGS = -I.. -I$(srcdir)
26 DEFS += -DLIBDIR=\"$(libdir)\"
27
28 libcoreutils_a_SOURCES = \
29   allocsa.c allocsa.h \
30   buffer-lcm.c buffer-lcm.h \
31   euidaccess.h \
32   exit.h \
33   fprintftime.c fprintftime.h \
34   full-read.c full-read.h \
35   full-write.c full-write.h \
36   getaddrinfo.h \
37   gettext.h \
38   localcharset.c localcharset.h \
39   mbchar.h \
40   mbswidth.c mbswidth.h \
41   mbuiter.h \
42   readtokens0.c readtokens0.h \
43   strcase.h \
44   strnlen1.c strnlen1.h \
45   strstr.h \
46   time_r.c time_r.h \
47   unicodeio.c unicodeio.h \
48   verify.h \
49   xalloc-die.c \
50   xgethostname.c xgethostname.h \
51   xmemcoll.c xmemcoll.h \
52   xstrndup.c xstrndup.h \
53   xstrtoimax.c \
54   xstrtoumax.c
55
56 libcoreutils_a_SOURCES += \
57   printf-args.h \
58   printf-parse.h \
59   vasprintf.h \
60   vasnprintf.h
61
62 libcoreutils_a_LIBADD = $(LIBOBJS) $(ALLOCA)
63
64 lib_OBJECTS = $(libcoreutils_a_OBJECTS)
65
66
67 BUILT_SOURCES = getdate.c
68 CLEANFILES =
69 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
70 MOSTLYCLEANFILES =
71 SUFFIXES =
72
73 EXTRA_DIST = getdate.c config.charset ref-add.sin ref-del.sin \
74   getndelim2.c getndelim2.h
75
76 # We need the following in order to install a simple file in $(libdir)
77 # which is shared with other installed packages. We use a list of referencing
78 # packages so that "make uninstall" will remove the file if and only if it
79 # is not used by another installed package.
80 # On systems with glibc-2.1 or newer, the file is redundant, therefore we
81 # avoid installing it.
82
83 all-local: charset.alias ref-add.sed ref-del.sed
84
85 charset_alias = $(DESTDIR)$(libdir)/charset.alias
86 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
87 install-exec-local: all-local
88         test $(GLIBC21) != no || $(mkinstalldirs) $(DESTDIR)$(libdir)
89         if test -f $(charset_alias); then \
90           sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
91           $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
92           rm -f $(charset_tmp) ; \
93         else \
94           if test $(GLIBC21) = no; then \
95             sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
96             $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
97             rm -f $(charset_tmp) ; \
98           fi ; \
99         fi
100
101 uninstall-local: all-local
102         if test -f $(charset_alias); then \
103           sed -f ref-del.sed $(charset_alias) > $(charset_tmp); \
104           if grep '^# Packages using this file: $$' $(charset_tmp) \
105               > /dev/null; then \
106             rm -f $(charset_alias); \
107           else \
108             $(INSTALL_DATA) $(charset_tmp) $(charset_alias); \
109           fi; \
110           rm -f $(charset_tmp); \
111         fi
112
113 charset.alias: config.charset
114         $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@
115         mv t-$@ $@
116
117 SUFFIXES += .sed .sin
118 .sin.sed:
119         sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@
120         mv t-$@ $@
121
122 CLEANFILES += charset.alias ref-add.sed ref-del.sed
123
124 BUILT_SOURCES += $(STDBOOL_H)
125 EXTRA_DIST += stdbool_.h
126 MOSTLYCLEANFILES += stdbool.h stdbool.h-t
127 # Create stdbool.h on systems that lack a working one.
128 stdbool.h: stdbool_.h
129         sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > $@-t
130         mv $@-t $@
131
132 BUILT_SOURCES += $(ALLOCA_H)
133 EXTRA_DIST += alloca_.h
134
135 # We need the following in order to create an <alloca.h> when the system
136 # doesn't have one that works with the given compiler.
137 all-local $(lib_OBJECTS): $(ALLOCA_H)
138 alloca.h: alloca_.h
139         cp $(srcdir)/alloca_.h $@-t
140         mv $@-t $@
141 MOSTLYCLEANFILES += alloca.h alloca.h-t
142
143 BUILT_SOURCES += $(FNMATCH_H)
144 EXTRA_DIST += fnmatch_.h fnmatch_loop.c
145
146 # We need the following in order to create an <fnmatch.h> when the system
147 # doesn't have one that supports the required API.
148 all-local $(lib_OBJECTS): $(FNMATCH_H)
149 fnmatch.h: fnmatch_.h
150         cp $(srcdir)/fnmatch_.h $@-t
151         mv $@-t $@
152 MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
153
154 BUILT_SOURCES += $(GETOPT_H)
155 EXTRA_DIST += getopt_.h getopt_int.h
156
157 check: unit-test
158
159 .PHONY: unit-test
160 unit-test: t-fpending
161         ./t-fpending > /dev/null
162
163 # We need the following in order to create an <getopt.h> when the system
164 # doesn't have one that works with the given compiler.
165 all-local $(lib_OBJECTS): $(GETOPT_H)
166 getopt.h: getopt_.h
167         cp $(srcdir)/getopt_.h $@-t
168         mv $@-t $@
169 MOSTLYCLEANFILES += getopt.h getopt.h-t