getopt.c: Update to latest FSF version.
[gcc.git] / libiberty / Makefile.in
1 #
2 # Makefile
3 # Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation
4 #
5 # This file is part of the libiberty library.
6 # Libiberty is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Library General Public
8 # License as published by the Free Software Foundation; either
9 # version 2 of the License, or (at your option) any later version.
10 #
11 # Libiberty is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Library General Public License for more details.
15 #
16 # You should have received a copy of the GNU Library General Public
17 # License along with libiberty; see the file COPYING.LIB. If not,
18 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
20 #
21
22 # This file was written, and is maintained by K. Richard Pixley
23 # <rich@cygnus.com>.
24
25 #
26 # Makefile for libiberty directory
27 #
28
29 srcdir = .
30
31 prefix = /usr/local
32
33 exec_prefix = $(prefix)
34 bindir = $(exec_prefix)/bin
35 libdir = $(exec_prefix)/lib
36
37 datadir = $(prefix)/share
38
39 mandir = $(prefix)/man
40 man1dir = $(mandir)/man1
41 man2dir = $(mandir)/man2
42 man3dir = $(mandir)/man3
43 man4dir = $(mandir)/man4
44 man5dir = $(mandir)/man5
45 man6dir = $(mandir)/man6
46 man7dir = $(mandir)/man7
47 man8dir = $(mandir)/man8
48 man9dir = $(mandir)/man9
49 infodir = $(prefix)/info
50 includedir = $(prefix)/include
51
52 SHELL = /bin/sh
53
54 # Multilib support variables.
55 MULTISRCTOP =
56 MULTIBUILDTOP =
57 MULTIDIRS =
58 MULTISUBDIR =
59 MULTIDO = true
60 MULTICLEAN = true
61
62 INSTALL = install -c
63 INSTALL_PROGRAM = $(INSTALL)
64 INSTALL_DATA = $(INSTALL)
65
66 AR = ar
67 AR_FLAGS = rc
68
69 ERRORS_CC = $(CC)
70 CC = cc
71 CFLAGS = -g
72 LIBCFLAGS = $(CFLAGS)
73 MAKEINFO = makeinfo
74 RANLIB = ranlib
75
76 PICFLAG =
77
78 MAKEOVERRIDES =
79
80 TARGETLIB = libiberty.a
81
82 CONFIG_H = lconfig.h
83 NEEDED_LIST = lneeded-list
84
85 # HOST_OFILES contains the list of objects that should be in the
86 # library (in addition to the REQUIRED_OFILES and EXTRA_OFILES).
87 # A configuration may override this with a fixed list a object files
88 # names (hard to maintain), or some other way to generate a list.
89 HOST_OFILES=`cat needed-list`
90
91 # Extra targets that the top-level target depends on.
92 # Specifically, what needs to be made before HOST_OFILES can be used.
93 # Can be empty if HOST_OFILES is just a list of file names.
94 DO_ALSO = needed-list
95
96 # A configuration can specify extra .o files that should be included,
97 # even if they are in libc. (Perhaps the libc version is buggy.)
98 EXTRA_OFILES =
99
100 # Flags to pass to a recursive make.
101 FLAGS_TO_PASS = \
102 "AR=$(AR)" \
103 "AR_FLAGS=$(AR_FLAGS)" \
104 "CC=$(CC)" \
105 "CFLAGS=$(CFLAGS)" \
106 "LIBCFLAGS=$(LIBCFLAGS)" \
107 "EXTRA_OFILES=$(EXTRA_OFILES)" \
108 "HDEFINES=$(HDEFINES)" \
109 "INSTALL=$(INSTALL)" \
110 "INSTALL_DATA=$(INSTALL_DATA)" \
111 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
112 "LDFLAGS=$(LDFLAGS)" \
113 "LOADLIBES=$(LOADLIBES)" \
114 "RANLIB=$(RANLIB)" \
115 "SHELL=$(SHELL)"
116
117 all: stamp-picdir $(TARGETLIB) required-list
118 @if [ "$(RULE1)" != "not-used" ]; then \
119 $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all; \
120 else true; \
121 fi
122
123 .PHONY: check installcheck
124 check installcheck:
125
126
127 #### Host, target, and site specific Makefile fragments come in here.
128 ###
129
130 INCDIR=$(srcdir)/$(MULTISRCTOP)../include
131
132 COMPILE.c = $(CC) -c $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES)
133 .c.o:
134 test x"$(enable_shared)" != xyes || \
135 $(COMPILE.c) $(PICFLAG) $< -o pic/$@
136 $(COMPILE.c) $<
137
138 # The default target just invokes make recursively.
139 # However, the automatic configuration (in config/mh_default).
140 # first causes it to figure out the objects missing in libc.
141 info install-info clean-info dvi:
142
143 # Include files that are in this directory.
144 HFILES =
145
146 # NOTE: If you add new files to the library, add them to this list
147 # (alphabetical), and add them to REQUIRED_OFILES or 'functions.def'.
148 CFILES = asprintf.c alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c bzero.c \
149 choose-temp.c clock.c concat.c cplus-dem.c fdmatch.c fnmatch.c \
150 getcwd.c getopt.c getopt1.c getpagesize.c getruntime.c \
151 floatformat.c hex.c index.c insque.c \
152 memchr.c memcmp.c memcpy.c memmove.c memset.c objalloc.c \
153 obstack.c pexecute.c random.c rename.c rindex.c sigsetmask.c spaces.c \
154 strcasecmp.c strncasecmp.c \
155 strchr.c strdup.c strerror.c strrchr.c strsignal.c \
156 strstr.c strtod.c strtol.c strtoul.c tmpnam.c \
157 vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c waitpid.c \
158 xatexit.c xexit.c xmalloc.c xstrdup.c xstrerror.c
159 # These are always included in the library.
160 REQUIRED_OFILES = argv.o basename.o choose-temp.o concat.o cplus-dem.o \
161 fdmatch.o fnmatch.o getopt.o getopt1.o getruntime.o hex.o \
162 floatformat.o objalloc.o obstack.o pexecute.o spaces.o strerror.o \
163 strsignal.o xatexit.o xexit.o xmalloc.o xstrdup.o xstrerror.o
164
165 # Do we want/need any config overrides?
166 #
167
168 STAGESTUFF = $(TARGETLIB) *.o
169
170 INSTALL_DEST = libdir
171 install: install_to_$(INSTALL_DEST)
172
173 install_to_libdir: all
174 $(INSTALL_DATA) $(TARGETLIB) $(libdir)$(MULTISUBDIR)/$(TARGETLIB).n
175 ( cd $(libdir)$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB).n )
176 mv -f $(libdir)$(MULTISUBDIR)/$(TARGETLIB).n $(libdir)$(MULTISUBDIR)/$(TARGETLIB)
177 @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
178
179 install_to_tooldir: all
180 $(INSTALL_DATA) $(TARGETLIB) $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB).n
181 ( cd $(tooldir)/lib$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB).n )
182 mv -f $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB).n $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB)
183 @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
184
185 # The default configuration adds to libiberty all those functions that are
186 # missing in libc. More precisely, it includes whatever $(CC) fails to find.
187 # Then a sed+awk combination translates the ld error messages into
188 # a list of .o files.
189
190 stamp-needed: stamp-picdir $(NEEDED_LIST)
191 cp $(NEEDED_LIST) needed-tmp
192 $(SHELL) $(srcdir)/$(MULTISRCTOP)../move-if-change needed-tmp needed-list
193 touch stamp-needed
194
195 needed-list: stamp-needed ; @true
196
197 lneeded-list: $(EXTRA_OFILES) needed.awk errors
198 rm -f lneeded-list
199 f=""; \
200 for i in `awk -f needed.awk <errors` $(EXTRA_OFILES) ; do \
201 case " $$f " in \
202 *" $$i "*) ;; \
203 *) f="$$f $$i" ;; \
204 esac ; \
205 done ; \
206 case $$f in \
207 *alloca.o*) f="$$f xmalloc.o xexit.o" ;; \
208 esac ; \
209 echo $$f >>lneeded-list
210
211 # Generate an awk script that looks for functions in functions.def
212
213 needed.awk: $(srcdir)/functions.def Makefile
214 echo "# !Automatically generated from $(srcdir)/functions.def"\
215 "- DO NOT EDIT!" >needed.awk
216 grep '^DEF(' < $(srcdir)/functions.def \
217 | sed -e '/DEF/s|DEF.\([^,]*\).*|/\1/ { printf "\1.o " }|' \
218 >>needed.awk
219
220 stamp-config: $(CONFIG_H)
221 cp $(CONFIG_H) config.tmp
222 $(SHELL) $(srcdir)/$(MULTISRCTOP)../move-if-change config.tmp config.h
223 touch stamp-config
224
225 config.h: stamp-config ; @true
226
227 lconfig.h: needed2.awk errors
228 echo "/* !Automatically generated from $(srcdir)/functions.def"\
229 "- DO NOT EDIT! */" >lconfig.h
230 awk -f needed2.awk <errors >>lconfig.h
231
232 # Generate an awk script that looks for variables in functions.def
233
234 needed2.awk: $(srcdir)/functions.def Makefile
235 echo "# !Automatically generated from $(srcdir)/functions.def"\
236 "- DO NOT EDIT!" >needed2.awk
237 grep '^DEFVAR(' < $(srcdir)/functions.def \
238 | sed -e '/DEFVAR/s|DEFVAR.\([^,]*\).*|/\1/ { printf "#ifndef NEED_\1\\n#define NEED_\1\\n#endif\\n" }|' \
239 >>needed2.awk
240 grep '^DEFFUNC(' < $(srcdir)/functions.def \
241 | sed -e '/DEFFUNC/s|DEFFUNC.\([^,]*\).*|/\1/ { printf "#ifndef NEED_\1\\n#define NEED_\1\\n#endif\\n" }|' \
242 >>needed2.awk
243
244 dummy.o: $(srcdir)/dummy.c $(srcdir)/functions.def
245 $(CC) -c $(CFLAGS) -I. -I$(INCDIR) $(HDEFINES) $(srcdir)/dummy.c 2>/dev/null
246
247 errors: dummy.o $(EXTRA_OFILES)
248 -($(ERRORS_CC) -o dummy $(CFLAGS) $(LDFLAGS) $(ERRORS_LDFLAGS) dummy.o $(EXTRA_OFILES) $(LOADLIBES)) >errors 2>&1 || true
249
250 # required-list is used when building a shared bfd/opcodes/libiberty library.
251 required-list: Makefile
252 echo $(REQUIRED_OFILES) > required-list
253
254 $(HOST_OFILES) $(REQUIRED_OFILES) : config.h
255
256 RULE1 = $(TARGETLIB)
257 $(RULE1): $(REQUIRED_OFILES) $(DO_ALSO) .always.
258 @$(MAKE) RULE1=not-used RULE2=$(TARGETLIB) $(FLAGS_TO_PASS) \
259 "HOST_OFILES=$(HOST_OFILES)"
260
261 # Rule invoked by recursive make in $(RULE1).
262 RULE2 = not-used
263 $(RULE2): $(REQUIRED_OFILES) $(HOST_OFILES)
264 rm -rf $(TARGETLIB)
265 $(AR) $(AR_FLAGS) $(TARGETLIB) \
266 $(REQUIRED_OFILES) $(HOST_OFILES)
267 $(RANLIB) $(TARGETLIB)
268
269 stamp-picdir:
270 if [ x"$(enable_shared)" = xyes ] && [ ! -d pic ]; then \
271 mkdir pic; \
272 else true; fi
273 touch stamp-picdir
274
275 .always.:
276 # Do nothing.
277
278 .PHONY: all etags tags ls clean stage1 stage2 .always.
279
280 etags tags: TAGS
281
282 TAGS: $(CFILES) $(HFILES)
283 etags `for i in $(HFILES) $(CFILES); do echo $(srcdir)/$$i ; done`
284
285 # The standalone demangler (c++filt) has been moved to binutils.
286 demangle:
287 @echo "The standalone demangler, now named c++filt, is now"
288 @echo "a part of binutils."
289 @false
290
291 ls:
292 @echo Makefile $(HFILES) $(CFILES)
293
294 # Need to deal with profiled libraries, too.
295
296 mostlyclean:
297 rm -rf *.o pic core errs \#* *.E a.out
298 rm -f needed.awk needed2.awk errors dummy needed-list config.h stamp-*
299 rm -f $(CONFIG_H) $(NEEDED_LIST) stamp-picdir
300 @$(MULTICLEAN) multi-clean DO=mostlyclean
301 clean: mostlyclean
302 rm -f *.a required-list tmpmulti.out
303 @$(MULTICLEAN) multi-clean DO=clean
304 distclean: clean
305 @$(MULTICLEAN) multi-clean DO=distclean
306 rm -f *~ Makefile config.status alloca-conf.h xhost-mkfrag TAGS multilib.out
307 maintainer-clean realclean: distclean
308
309 force:
310
311 Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
312 $(SHELL) ./config.status
313
314 argv.o: $(INCDIR)/libiberty.h
315 basename.o: $(INCDIR)/libiberty.h
316 concat.o: $(INCDIR)/libiberty.h
317 cplus-dem.o: $(INCDIR)/demangle.h
318 fdmatch.o: $(INCDIR)/libiberty.h
319 fnmatch.o: $(INCDIR)/fnmatch.h
320 getopt.o: $(INCDIR)/getopt.h
321 getopt1.o: $(INCDIR)/getopt.h
322 getruntime.o: $(INCDIR)/libiberty.h
323 hex.o: $(INCDIR)/libiberty.h
324 floatformat.o: $(INCDIR)/floatformat.h
325 objalloc.o: $(INCDIR)/objalloc.h
326 obstack.o: $(INCDIR)/obstack.h
327 pexecute.o: $(INCDIR)/libiberty.h
328 spaces.o: $(INCDIR)/libiberty.h
329 strerror.o: $(INCDIR)/libiberty.h
330 strsignal.o: $(INCDIR)/libiberty.h
331 xatexit.o: $(INCDIR)/libiberty.h
332 xexit.o: $(INCDIR)/libiberty.h
333 xmalloc.o: $(INCDIR)/libiberty.h
334 xstrdup.o: $(INCDIR)/libiberty.h
335 xstrerror.o: $(INCDIR)/libiberty.h