1 # Makefile for GNU binary-file utilities
2 # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
4 # This file is part of GNU binutils.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program 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
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 program_transform_name =
25 exec_prefix = $(prefix)
26 bindir = $(exec_prefix)/bin
27 libdir = $(exec_prefix)/lib
28 tooldir = $(exec_prefix)/$(target_alias)
30 datadir = $(prefix)/lib
31 mandir = $(prefix)/man
32 man1dir = $(mandir)/man1
33 man2dir = $(mandir)/man2
34 man3dir = $(mandir)/man3
35 man4dir = $(mandir)/man4
36 man5dir = $(mandir)/man5
37 man6dir = $(mandir)/man6
38 man7dir = $(mandir)/man7
39 man8dir = $(mandir)/man8
40 man9dir = $(mandir)/man9
41 infodir = $(prefix)/info
42 includedir = $(prefix)/include
43 docdir = $(datadir)/doc
47 INSTALL = `cd $(srcdir)/..;pwd`/install.sh -c
48 INSTALL_PROGRAM = $(INSTALL)
49 INSTALL_DATA = $(INSTALL)
50 INSTALL_XFORM = $(INSTALL) -t='$(program_transform_name)'
51 INSTALL_XFORM1 = $(INSTALL_XFORM) -b=.1
67 BISON = `if [ -f ../byacc/byacc ] ; then echo ../byacc/byacc ; else echo byacc ; fi`
68 # Comment these out if using lex.
70 LEX = `if [ -f ../flex/flex ] ; then echo ../flex/flex ; else echo flex ; fi`
72 # Distribution version
75 DIST_NAME=binutils-${VERSION}
77 version=`./../gcc/gcc -dumpversion`
79 # Where to find texinfo.tex to format docn with TeX
80 TEXIDIR = $(srcdir)/../texinfo
82 MANPAGES= ar nm objdump ranlib size strings strip c++filt objcopy nlmconv
85 # these two are almost the same program
89 # objcopy and strip should be the same program
95 # These should all be the same program too.
100 # This is the demangler, as a standalone program.
101 DEMANGLER_PROG=c++filt
105 PROGS = $(SIZE_PROG) $(OBJDUMP_PROG) $(NM_PROG) $(AR_PROG) $(STRINGS_PROG) $(STRIP_PROG) $(RANLIB_PROG) $(DEMANGLER_PROG) $(OBJCOPY_PROG) $(BUILD_NLMCONV)
106 STAGESTUFF = $(PROGS) *.o
107 # Files that can be generated, but should be in the distribution.
108 DISTSTUFF=arparse.c arlex.c nlmheader.c info
110 BASEDIR = $(srcdir)/..
111 BFDDIR = $(BASEDIR)/bfd
112 INCDIR = $(BASEDIR)/include
113 INCLUDES = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR)
115 #### host and target dependant Makefile fragments come in here.
118 ALL_CFLAGS = $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CFLAGS)
121 $(CC) -c $(ALL_CFLAGS) $<
124 ## Random definitions
125 # Hopefully all these may be flushed once we get configuration down pat.
127 # alloca only needed for systems which don't have it and when cc != gcc.
130 # nm tries to malloc enough space for the string table. The old GNU malloc
131 # rounds this up to a power of two (e.g. 5M becomes 8M), and so it might
132 # fail unnecessarily. I've also seen some Unix malloc's fail, even when
133 # there is enough memory. So use the new GNU malloc.
135 # Use this if the system malloc is good enough.
138 # Use the GNU getopt unless you have problems with it.
139 # The IRIS version could probably benefit from being assembled with
140 # libmalloc rather than the ordinary malloc.
141 LIBIBERTY = ../libiberty/libiberty.a
143 # Code shared by all the binutils.
144 BULIBS = bucomm.o version.o filemode.o
146 ADDL_LIBS = $(MALLOC) $(BULIBS) $(BFD) $(LIBIBERTY)
148 BFD = ../bfd/libbfd.a
149 OPCODES = ../opcodes/libopcodes.a
156 "RUNTEST=$(RUNTEST)" \
157 "RUNTEST_FLAGS=$(RUNTEST_FLAGS) \
158 SIZE=`if [ -f $$rootme/$(SIZE_PROG) ] ; then echo $$rootme/$(SIZE_PROG) ; else echo $(SIZE_PROG); fi` \
159 OBJCOPY=`if [ -f $$rootme/$(OBJCOPY_PROG) ] ; then echo $$rootme/$(OBJCOPY_PROG) ; else echo $(OBJCOPY_PROG); fi` \
160 NM=`if [ -f $$rootme/$(NM_PROG) ] ; then echo $$rootme/$(NM_PROG) ; else echo $(NM_PROG); fi` \
161 AR=`if [ -f $$rootme/$(AR_PROG) ] ; then echo $$rootme/$(AR_PROG) ; else echo $(AR_PROG); fi` \
162 OBJDUMP=`if [ -f $$rootme/$(OBJDUMP_PROG) ] ; then echo $$rootme/$(OBJDUMP_PROG) ; else echo $(OBJDUMP_PROG); fi` \
163 STRINGS=`if [ -f $$rootme/$(STRINGS_PROG) ] ; then echo $$rootme/$(STRINGS_PROG) ; else echo $(STRINGS_PROG); fi` \
164 STRIP=`if [ -f $$rootme/$(STRIP_PROG) ] ; then echo $$rootme/$(STRIP_PROG) ; else echo $(STRIP_PROG); fi` \
165 RANLIB=`if [ -f $$rootme/$(RANLIB_PROG) ] ; then echo $$rootme/$(RANLIB_PROG) ; else echo $(RANLIB_PROG); fi` \
166 DEMANGLE=`if [ -f $$rootme/$(DEMANGLER_PROG) ] ; then echo $$rootme/$(DEMANGLER_PROG) ; else echo $(DEMANGLER_PROG); fi`"
171 all: $(ADDL_LIBS) $(PROGS)
174 if [ -f testsuite/Makefile.in ]; then \
175 (rootme=`pwd`/ ; export rootme ; \
176 rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \
177 cd testsuite; $(MAKE) FLAGS_TO_PASS=$(FLAGS_TO_PASS)); \
181 rootme=`pwd`; export rootme; cd testsuite ; \
182 $(MAKE) check $(FLAGS_TO_PASS)
183 # /bin/sh $(srcdir)/sanity.sh .
186 /bin/sh $(srcdir)/sanity.sh $(bindir)
192 $(SIZE_PROG): $(ADDL_LIBS) size.o $(BFD)
193 $(CC) $(CFLAGS) $(LDFLAGS) -o $(SIZE_PROG) size.o $(ADDL_LIBS) $(EXTRALIBS)
195 $(OBJCOPY_PROG): $(ADDL_LIBS) objcopy.o not-strip.o $(BFD)
196 $(CC) $(CFLAGS) $(LDFLAGS) -o $(OBJCOPY_PROG) objcopy.o not-strip.o $(ADDL_LIBS) $(EXTRALIBS)
198 $(STRINGS_PROG): $(ADDL_LIBS) strings.o $(BFD)
199 $(CC) $(CFLAGS) $(LDFLAGS) -o $(STRINGS_PROG) strings.o $(ADDL_LIBS) $(EXTRALIBS)
201 $(STRIP_PROG): $(ADDL_LIBS) objcopy.o is-strip.o $(BFD)
202 $(CC) $(CFLAGS) $(LDFLAGS) -o $(STRIP_PROG) objcopy.o is-strip.o $(ADDL_LIBS) $(EXTRALIBS)
204 $(NM_PROG): $(ADDL_LIBS) nm.o demangle.o $(BFD)
205 $(CC) $(CFLAGS) $(LDFLAGS) -o $(NM_PROG) nm.o demangle.o $(ADDL_LIBS) $(EXTRALIBS)
207 $(OBJDUMP_PROG): $(ADDL_LIBS) objdump.o $(BFD) $(OPCODES)
208 $(CC) $(CFLAGS) $(LDFLAGS) -o $(OBJDUMP_PROG) objdump.o $(OPCODES) $(ADDL_LIBS) $(EXTRALIBS)
210 objdump.o: objdump.c config.status
211 $(CC) -c $(INCLUDES) $(HDEFINES) $(TDEFINES) $(ARCHDEFS) $(CFLAGS) $(srcdir)/objdump.c
214 echo "int xxy_us_dummy;" >dummy.c
217 echo '/*WARNING: This file is automatically generated!*/' >underscore.c
218 if [ "`$(NM) dummy.o | grep _xxy_us_dummy ; true`" != "" ]; then \
219 echo "int prepends_underscore = 1;" >>underscore.c; \
221 echo "int prepends_underscore = 0;" >>underscore.c; \
223 -rm -f dummy.c dummy.o
226 $(CC) $(INCLUDES) $(HDEFINES) $(TDEFINES) -DVERSION='"$(VERSION)"' $(CFLAGS) -c $(srcdir)/version.c
228 demangle.o: $(BASEDIR)/libiberty/cplus-dem.c
229 $(CC) -c $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CFLAGS) $(BASEDIR)/libiberty/cplus-dem.c
230 mv cplus-dem.o demangle.o
232 # For parallel compiling, depend on demangle.o so that one gets done first.
233 cplus-dem.o: $(BASEDIR)/libiberty/cplus-dem.c $(INCDIR)/getopt.h demangle.o
234 $(CC) -c -DMAIN $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CFLAGS) $(BASEDIR)/libiberty/cplus-dem.c
236 $(DEMANGLER_PROG): cplus-dem.o $(LIBIBERTY) underscore.o version.o
237 $(CC) $(CFLAGS) $(LDFLAGS) -o $(DEMANGLER_PROG) cplus-dem.o $(LIBIBERTY) $(EXTRALIBS) underscore.o version.o
239 arparse.h arparse.c: arparse.y
240 $(BISON) $(BISONFLAGS) $(srcdir)/arparse.y
241 -mv y.tab.c arparse.c
242 -mv y.tab.h arparse.h
245 $(LEX) $(LEX_OPTIONS) $(srcdir)/arlex.l
248 $(AR_PROG): $(ADDL_LIBS) ar.o arparse.o arlex.o not-ranlib.o $(BFD) arsup.o
249 $(CC) $(CFLAGS) $(LDFLAGS) -o $(AR_PROG) ar.o arparse.o arlex.o arsup.o not-ranlib.o $(ADDL_LIBS) $(EXTRALIBS)
251 $(RANLIB_PROG): $(ADDL_LIBS) ar.o is-ranlib.o arparse.o arlex.o arsup.o $(BFD)
252 $(CC) $(CFLAGS) $(LDFLAGS) -o $(RANLIB_PROG) ar.o arparse.o arlex.o arsup.o is-ranlib.o $(ADDL_LIBS) $(EXTRALIBS)
254 # This rule creates a single binary that switches between ar and ranlib
255 # by looking at argv[0]. Use this kludge to save some disk space.
256 # However, you have to install things by hand.
257 # (That is after 'make install', replace the installed ranlib by a link to ar.)
259 # Alternatively, you can install ranlib.sh as ranlib.
261 ar_with_ranlib: $(ADDL_LIBS) ar.o maybe-ranlib.o $(BFD)
262 $(CC) $(CFLAGS) $(LDFLAGS) -o $(AR_PROG) ar.o maybe-ranlib.o $(ADDL_LIBS) $(EXTRALIBS)
263 -rm -f $(RANLIB_PROG)
264 -ln $(AR_PROG) $(RANLIB_PROG)
266 # objcopy and strip in one binary that uses argv[0] to decide its action.
268 objcopy_with_strip: $(ADDL_LIBS) objcopy.o maybe-strip.o $(BFD)
269 $(CC) $(CFLAGS) $(LDFLAGS) -o $(OBJCOPY_PROG) objcopy.o maybe-strip.o $(ADDL_LIBS) $(EXTRALIBS)
271 -ln $(OBJCOPY_PROG) $(STRIP_PROG)
273 nlmheader.c: nlmheader.y
274 $(BISON) $(srcdir)/nlmheader.y
276 -mv y.tab.c nlmheader.c
279 ldname=`t='$(program_transform_name)'; echo ld | sed -e "" $$t`; \
280 $(CC) -c -DLD_NAME="\"$${ldname}\"" $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CFLAGS) $(srcdir)/nlmconv.c
282 $(NLMCONV_PROG): nlmconv.o nlmheader.o $(ADDL_LIBS) $(BFD)
283 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ nlmconv.o nlmheader.o $(ADDL_LIBS) $(EXTRALIBS)
285 # This list of dependencies was generated by doing a make with gcc -MM
286 # saving the output in a file and removing the gcc commands
287 # changing "../../devo/binutils/../bfd" to "$(BFDDIR)"
288 # removing "../../devo/binutils/"
289 # changing "../include" to "$(INCDIR)"
291 bucomm.o: bucomm.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
292 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
293 $(INCDIR)/fopen-same.h bucomm.h
294 filemode.o: filemode.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
295 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
296 $(INCDIR)/fopen-same.h
297 size.o: size.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
298 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
299 $(INCDIR)/fopen-same.h $(INCDIR)/getopt.h
300 objdump.o: objdump.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
301 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
302 $(INCDIR)/fopen-same.h $(INCDIR)/getopt.h \
303 $(INCDIR)/dis-asm.h $(INCDIR)/aout/aout64.h \
304 $(INCDIR)/elf/internal.h $(INCDIR)/aout/stab.def
305 nm.o: nm.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
306 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
307 $(INCDIR)/fopen-same.h bucomm.h $(INCDIR)/getopt.h \
308 $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
309 $(INCDIR)/aout/ranlib.h $(INCDIR)/demangle.h
310 ar.o: ar.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
311 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
312 $(INCDIR)/fopen-same.h bucomm.h $(INCDIR)/aout/ar.h \
313 $(BFDDIR)/libbfd.h arsup.h
314 arparse.o: arparse.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
315 $(INCDIR)/obstack.h arsup.h
316 arlex.o: arlex.c ./arparse.h
317 not-ranlib.o: not-ranlib.c
318 arsup.o: arsup.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
319 $(INCDIR)/obstack.h arsup.h bucomm.h
320 strings.o: strings.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
321 $(INCDIR)/obstack.h bucomm.h
322 objcopy.o: objcopy.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
323 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
324 $(INCDIR)/fopen-same.h bucomm.h
325 is-strip.o: is-strip.c
326 is-ranlib.o: is-ranlib.c
327 not-strip.o: not-strip.c
328 nlmheader.o: nlmheader.c nlmconv.h $(INCDIR)/nlm/common.h \
329 $(INCDIR)/nlm/internal.h
330 nlmconv.o: $(INCDIR)/nlm/common.h $(INCDIR)/nlm/internal.h \
331 $(BFDDIR)/libnlm.h bucomm.h
335 - mv -f $(STAGESTUFF) stage1
339 - mv -f $(STAGESTUFF) stage2
343 - mv -f $(STAGESTUFF) stage3
348 for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done
351 - (cd stage1 ; mv -f * ..)
355 - (cd stage2 ; mv -f * ..)
359 - (cd stage3 ; mv -f * ..)
362 ######################################################################
363 # DOCUMENTATION TARGETS
365 binutils.dvi: $(srcdir)/binutils.texi
366 TEXINPUTS=$(TEXIDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/binutils.texi
368 # info file for online browsing
369 binutils.info: $(srcdir)/binutils.texi
370 $(MAKEINFO) -o binutils.info $(srcdir)/binutils.texi
372 # different targets for -ms, -mm, -me
373 # Try to use a recent texi2roff. v2 was put on prep in jan91.
374 # If you want an index, see texi2roff doc for postprocessing
375 # and add -i to texi2roff invocations below.
376 # Workarounds for texi2roff-2 (probably fixed in later texi2roff's, delete
377 # corresponding -e lines when later texi2roff's are current)
378 # + @ifinfo's deleted explicitly due to texi2roff-2 bug w nested constructs.
379 # + @c's deleted explicitly because texi2roff sees texinfo commands in them
380 # + @ (that's at-BLANK) not recognized by texi2roff, turned into blank
381 # + @alphaenumerate is ridiculously new, turned into @enumerate
384 binutils.ms: $(srcdir)/binutils.texi
385 sed -e '/\\input texinfo/d' \
386 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
387 -e '/^@ifinfo/,/^@end ifinfo/d' \
391 -e 's/^@alphaenumerate/@enumerate/g' \
392 -e 's/^@end alphaenumerate/@end enumerate/g' \
393 $(srcdir)/binutils.texi | \
395 sed -e 's/---/\\(em/g' \
399 # '@noindent's removed due to texi2roff-2 mm bug; if yours is newer,
400 # try leaving them in
401 binutils.mm: $(srcdir)/binutils.texi
402 sed -e '/\\input texinfo/d' \
403 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
404 -e '/^@ifinfo/,/^@end ifinfo/d' \
409 -e 's/^@alphaenumerate/@enumerate/g' \
410 -e 's/^@end alphaenumerate/@end enumerate/g' \
411 $(srcdir)/binutils.texi | \
413 sed -e 's/---/\\(em/g' \
417 binutils.me: $(srcdir)/binutils.texi
418 sed -e '/\\input texinfo/d' \
419 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
420 -e '/^@ifinfo/,/^@end ifinfo/d' \
424 -e 's/^@alphaenumerate/@enumerate/g' \
425 -e 's/^@end alphaenumerate/@end enumerate/g' \
426 $(srcdir)/binutils.texi | \
428 sed -e 's/---/\\(em/g' \
432 ######################################################################
435 -rm -f *.o *~ \#* core binutils.?? binutils.???
437 @if [ -d testsuite ] ; then \
438 cd testsuite ; $(MAKE) $(FLAGS_TO_PASS) clean ; \
440 -rm -f $(PROGS) underscore.c
442 @if [ -d testsuite ] ; then \
443 cd testsuite ; $(MAKE) $(FLAGS_TO_PASS) distclean ; \
445 -rm -f Makefile config.status sysdep.h *.o *~ \#* core \
446 binutils.?? binutils.??s binutils.aux binutils.log binutils.toc
447 realclean: clean distclean
448 -rm -f $(DISTSTUFF) TAGS
453 etags $(INCDIR)/*.h $(srcdir)/*.[hc]
456 for i in $(PROGS) ; do \
457 $(INSTALL_XFORM) $$i $(bindir)/$$i ; \
459 for i in $(MANPAGES) ; do \
460 $(INSTALL_XFORM1) $(srcdir)/$$i.1 $(man1dir)/$$i.1 ; \
462 -if [ -d $(tooldir) ]; then \
463 if [ -d $(tooldir)/bin ] ; then true ; else mkdir $(tooldir)/bin ; fi; \
464 for i in nm strip ar ranlib; do \
465 rm -f $(tooldir)/bin/$$i; \
466 ln $(bindir)/`t='$(program_transform_name)'; echo $$i | sed -e "" $$t` $(tooldir)/bin/$$i \
467 || $(INSTALL_PROGRAM) $$i $(tooldir)/bin/$$i; \
471 # Use binutils.info as the target so that VPATH will DTRT.
472 # (Use "$<*" in case the output is multiple files, though.)
473 install-info: binutils.info
475 $(INSTALL_DATA) $$i $(infodir)/$$i ; \
482 # cvs rtag binutils-x-yy ld+utils
483 # cvs co -r binutils-x-yy ld+utils
485 # cd {HERE}; make dist [-f Makefile.in]
487 dist: $(DIST_NAME).tar.z
489 diststuff: $(DISTSTUFF)
492 cd ../..; rm -f $(DIST_NAME); ln -s devo $(DIST_NAME)
493 make diststuff -f Makefile.in
494 cd ../ld; make diststuff -f Makefile.in
495 cd ../gprof; make diststuff -f Makefile.in
496 cd ../texinfo; mv texinfo.tex ..; rm -rf *; mv ../texinfo.tex .
497 # Take out texinfo from configurable dirs
498 mv ../configure.in tmp; \
499 sed -e '/^host_tools=/s/texinfo //' <tmp >../configure.in; rm tmp
500 cd ..; chmod og=u `find . -print`
501 cd ../..; tar chf - $(DIST_NAME) | gzip >$(DIST_NAME).tar.z
502 rm -rf ../../$(DIST_NAME)
504 #-----------------------------------------------------------------------------
505 # 'STANDARD' GNU/960 TARGETS BELOW THIS POINT
507 # 'VERSION' file must be present and contain a string of the form "x.y"
508 #-----------------------------------------------------------------------------
512 echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c
515 # Dummy target to force execution of dependent targets.
519 # Target to uncomment host-specific lines in this makefile. Such lines must
520 # have the following string beginning in column 1: #__<hostname>__#
521 # Original Makefile is backed up as 'Makefile.old'.
523 # Invoke with: make make HOST=xxx
526 -@if test $(HOST)x = x ; then \
527 echo '
\aSpecify "make make HOST=???"'; \
530 grep -s "^#The next line was generated by 'make make'" Makefile; \
531 if test $$? = 0 ; then \
532 echo "
\aMakefile has already been processed with 'make make'";\
535 mv -f Makefile Makefile.old; \
536 echo "#The next line was generated by 'make make'" >Makefile ; \
537 echo "HOST=$(HOST)" >>Makefile ; \
539 sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile
541 Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
542 $(SHELL) ./config.status
544 ### Local Variables: ***
545 ### mode:fundamental ***
546 ### page-delimiter: "^#
\f" ***