3 # Copyright (C) 1990, 1991, 1992, 1995 Free Software Foundation
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.
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.
16 # You should have received a copy of the GNU Library General Public
17 # License along with libiberty; see the file COPYING.LIB. If
18 # not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
22 # This file was written, and is maintained by K. Richard Pixley
26 # Makefile for libiberty directory
33 exec_prefix = $(prefix)
34 bindir = $(exec_prefix)/bin
35 libdir = $(exec_prefix)/lib
37 datadir = $(prefix)/lib
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
52 docdir = $(datadir)/doc
56 # Multilib support variables.
65 INSTALL_PROGRAM = $(INSTALL)
66 INSTALL_DATA = $(INSTALL)
82 TARGETLIB = libiberty.a
85 NEEDED_LIST = lneeded-list
87 # HOST_OFILES contains the list of objects that should be in the
88 # library (in addition to the REQUIRED_OFILES and EXTRA_OFILES).
89 # A configuration may override this with a fixed list a object files
90 # names (hard to maintain), or some other way to generate a list.
91 HOST_OFILES=`cat needed-list`
93 # Extra targets that the top-level target depends on.
94 # Specifically, what needs to be made before HOST_OFILES can be used.
95 # Can be empty if HOST_OFILES is just a list of file names.
98 # A configuration can specify extra .o files that should be included,
99 # even if they are in libc. (Perhaps the libc version is buggy.)
102 # Flags to pass to a recursive make.
105 "AR_FLAGS=$(AR_FLAGS)" \
108 "LIBCFLAGS=$(LIBCFLAGS)" \
109 "EXTRA_OFILES=$(EXTRA_OFILES)" \
110 "HDEFINES=$(HDEFINES)" \
111 "LDFLAGS=$(LDFLAGS)" \
112 "LOADLIBES=$(LOADLIBES)" \
113 "PICFLAG=$(PICFLAG)" \
117 all: stamp-picdir $(TARGETLIB) required-list
118 @if [ "$(RULE1)" != "not-used" ]; then \
119 $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all; \
123 .PHONY: check installcheck
127 #### Host, target, and site specific Makefile fragments come in here.
130 INCDIR=$(srcdir)/$(MULTISRCTOP)../include
132 COMPILE.c = $(CC) -c $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES)
134 test -z "$(PICFLAG)" || \
135 $(COMPILE.c) $(PICFLAG) $< -o pic/$@
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:
143 # Include files that are in this directory.
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 = alloca.c argv.c basename.c bcmp.c bcopy.c bzero.c \
149 clock.c concat.c cplus-dem.c fdmatch.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 \
153 obstack.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 concat.o cplus-dem.o fdmatch.o \
161 getopt.o getopt1.o getruntime.o hex.o \
162 floatformat.o obstack.o spaces.o strerror.o strsignal.o \
163 vasprintf.o xatexit.o xexit.o xmalloc.o xstrdup.o xstrerror.o
165 # Do we want/need any config overrides?
168 STAGESTUFF = $(TARGETLIB) *.o
170 INSTALL_DEST = libdir
171 install: install_to_$(INSTALL_DEST)
173 install_to_libdir: all
174 $(INSTALL_DATA) $(TARGETLIB) $(libdir)/$(TARGETLIB).n
175 ( cd $(libdir) ; $(RANLIB) $(libdir)/$(TARGETLIB).n )
176 mv -f $(libdir)/$(TARGETLIB).n $(libdir)$(MULTISUBDIR)/$(TARGETLIB)
177 @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
179 install_to_tooldir: all
180 $(INSTALL_DATA) $(TARGETLIB) $(tooldir)/lib/$(TARGETLIB).n
181 ( cd $(tooldir) ; $(RANLIB) $(tooldir)/lib/$(TARGETLIB).n )
182 mv -f $(tooldir)/lib/$(TARGETLIB).n $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB)
183 @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
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.
190 needed-list: stamp-picdir $(NEEDED_LIST)
191 cp $(NEEDED_LIST) needed-list
193 lneeded-list: $(EXTRA_OFILES) needed.awk errors
196 for i in `awk -f needed.awk <errors` $(EXTRA_OFILES) ; do \
202 echo $$f >>lneeded-list
204 # Generate an awk script that looks for functions in functions.def
206 needed.awk: $(srcdir)/functions.def Makefile
207 echo "# !Automatically generated from $(srcdir)/functions.def"\
208 "- DO NOT EDIT!" >needed.awk
209 grep '^DEF(' < $(srcdir)/functions.def \
210 | sed -e '/DEF/s|DEF.\([^,]*\).*|/\1/ { printf "\1.o " }|' \
213 config.h: $(CONFIG_H)
214 cp $(CONFIG_H) config.h
216 lconfig.h: needed2.awk errors
217 echo "/* !Automatically generated from $(srcdir)/functions.def"\
218 "- DO NOT EDIT! */" >lconfig.h
219 awk -f needed2.awk <errors >>lconfig.h
221 # Generate an awk script that looks for variables in functions.def
223 needed2.awk: $(srcdir)/functions.def Makefile
224 echo "# !Automatically generated from $(srcdir)/functions.def"\
225 "- DO NOT EDIT!" >needed2.awk
226 grep '^DEFVAR(' < $(srcdir)/functions.def \
227 | sed -e '/DEFVAR/s|DEFVAR.\([^,]*\).*|/\1/ { printf "#ifndef NEED_\1\\n#define NEED_\1\\n#endif\\n" }|' \
229 grep '^DEFFUNC(' < $(srcdir)/functions.def \
230 | sed -e '/DEFFUNC/s|DEFFUNC.\([^,]*\).*|/\1/ { printf "#ifndef NEED_\1\\n#define NEED_\1\\n#endif\\n" }|' \
233 dummy.o: $(srcdir)/dummy.c $(srcdir)/functions.def
234 $(CC) -c $(CFLAGS) -I. -I$(INCDIR) $(HDEFINES) $(srcdir)/dummy.c 2>/dev/null
236 errors: dummy.o $(EXTRA_OFILES)
237 -($(ERRORS_CC) -o dummy $(CFLAGS) $(LDFLAGS) $(ERRORS_LDFLAGS) dummy.o $(EXTRA_OFILES) $(LOADLIBES)) >errors 2>&1 || true
239 # required-list is used when building a shared bfd/opcodes/libiberty library.
240 required-list: Makefile
241 echo $(REQUIRED_OFILES) > required-list
243 $(HOST_OFILES) $(REQUIRED_OFILES) : config.h
246 $(RULE1): $(REQUIRED_OFILES) $(DO_ALSO) .always.
247 @$(MAKE) RULE1=not-used RULE2=$(TARGETLIB) $(FLAGS_TO_PASS) \
248 "HOST_OFILES=$(HOST_OFILES)"
250 # Rule invoked by recursive make in $(RULE1).
252 $(RULE2): $(REQUIRED_OFILES) $(HOST_OFILES)
254 $(AR) $(AR_FLAGS) $(TARGETLIB) \
255 $(REQUIRED_OFILES) $(HOST_OFILES)
256 $(RANLIB) $(TARGETLIB)
259 if [ -n "$(PICFLAG)" ] && [ ! -d pic ]; then \
267 .PHONY: all etags tags ls clean stage1 stage2 .always.
271 TAGS: $(CFILES) $(HFILES)
272 etags `for i in $(HFILES) $(CFILES); do echo $(srcdir)/$$i ; done`
274 # The standalone demangler (c++filt) has been moved to binutils.
276 @echo "The standalone demangler, now named c++filt, is now"
277 @echo "a part of binutils."
281 @echo Makefile $(HFILES) $(CFILES)
283 # Need to deal with profiled libraries, too.
286 rm -rf *.o pic core errs \#* *.E a.out
287 rm -f needed.awk needed2.awk errors dummy needed-list config.h
288 rm -f $(CONFIG_H) $(NEEDED_LIST) stamp-picdir
289 @$(MULTICLEAN) multi-clean DO=mostlyclean
291 rm -f *.a required-list
292 @$(MULTICLEAN) multi-clean DO=clean
294 rm -f *~ Makefile config.status alloca-conf.h xhost-mkfrag TAGS
295 @$(MULTICLEAN) multi-clean DO=distclean
296 maintainer-clean realclean: distclean
300 Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
301 $(SHELL) ./config.status
303 argv.o: $(INCDIR)/libiberty.h
304 basename.o: $(INCDIR)/libiberty.h
305 concat.o: $(INCDIR)/libiberty.h
306 cplus-dem.o: $(INCDIR)/demangle.h
307 fdmatch.o: $(INCDIR)/libiberty.h
308 getopt.o: $(INCDIR)/getopt.h
309 getopt1.o: $(INCDIR)/getopt.h
310 getruntime.o: $(INCDIR)/libiberty.h
311 hex.o: $(INCDIR)/libiberty.h
312 floatformat.o: $(INCDIR)/floatformat.h
313 obstack.o: $(INCDIR)/obstack.h
314 spaces.o: $(INCDIR)/libiberty.h
315 strerror.o: $(INCDIR)/libiberty.h
316 strsignal.o: $(INCDIR)/libiberty.h
317 xatexit.o: $(INCDIR)/libiberty.h
318 xexit.o: $(INCDIR)/libiberty.h
319 xmalloc.o: $(INCDIR)/libiberty.h
320 xstrdup.o: $(INCDIR)/libiberty.h
321 xstrerror.o: $(INCDIR)/libiberty.h