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