1 # Makefile for GNU binary-file utilities
2 # Copyright (C) 1992, 1993 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/fsf
82 MANPAGES= ar nm objdump ranlib size strings strip c++filt objcopy
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
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.
119 $(CC) -c $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CFLAGS) $<
122 ## Random definitions
123 # Hopefully all these may be flushed once we get configuration down pat.
125 # alloca only needed for systems which don't have it and when cc != gcc.
128 # nm tries to malloc enough space for the string table. The old GNU malloc
129 # rounds this up to a power of two (e.g. 5M becomes 8M), and so it might
130 # fail unnecessarily. I've also seen some Unix malloc's fail, even when
131 # there is enough memory. So use the new GNU malloc.
134 # Use the GNU getopt unless you have problems with it.
135 # The IRIS version could probably benefit from being assembled with
136 # libmalloc rather than the ordinary malloc.
137 LIBIBERTY = ../libiberty/libiberty.a
139 # Code shared by all the binutils.
140 BULIBS = bucomm.o version.o filemode.o
142 ADDL_LIBS = $(MALLOC) $(BULIBS) $(BFD) $(LIBIBERTY)
144 BFD = ../bfd/libbfd.a
145 OPCODES = ../opcodes/libopcodes.a
152 "RUNTEST=$(RUNTEST)" \
153 "RUNTESTFLAGS=$(RUNTESTFLAGS) \
154 SIZE=`if [ -f $$rootme/$(SIZE_PROG) ] ; then echo $$rootme/$(SIZE_PROG) ; else echo $(SIZE_PROG); fi` \
155 OBJCOPY=`if [ -f $$rootme/$(OBJCOPY_PROG) ] ; then echo $$rootme/$(OBJCOPY_PROG) ; else echo $(OBJCOPY_PROG); fi` \
156 NM=`if [ -f $$rootme/$(NM_PROG) ] ; then echo $$rootme/$(NM_PROG) ; else echo $(NM_PROG); fi` \
157 AR=`if [ -f $$rootme/$(AR_PROG) ] ; then echo $$rootme/$(AR_PROG) ; else echo $(AR_PROG); fi` \
158 OBJDUMP=`if [ -f $$rootme/$(OBJDUMP_PROG) ] ; then echo $$rootme/$(OBJDUMP_PROG) ; else echo $(OBJDUMP_PROG); fi` \
159 STRINGS=`if [ -f $$rootme/$(STRINGS_PROG) ] ; then echo $$rootme/$(STRINGS_PROG) ; else echo $(STRINGS_PROG); fi` \
160 STRIP=`if [ -f $$rootme/$(STRIP_PROG) ] ; then echo $$rootme/$(STRIP_PROG) ; else echo $(STRIP_PROG); fi` \
161 RANLIB=`if [ -f $$rootme/$(RANLIB_PROG) ] ; then echo $$rootme/$(RANLIB_PROG) ; else echo $(RANLIB_PROG); fi` \
162 DEMANGLE=`if [ -f $$rootme/$(DEMANGLER_PROG) ] ; then echo $$rootme/$(DEMANGLER_PROG) ; else echo $(DEMANGLER_PROG); fi`"
167 all: $(ADDL_LIBS) $(PROGS)
170 if [ -f testsuite/Makefile.in ]; then \
171 (rootme=`pwd`/ ; export rootme ; \
172 rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \
173 cd testsuite; $(MAKE) FLAGS_TO_PASS=$(FLAGS_TO_PASS)); \
177 rootme=`pwd`; export rootme; cd testsuite ; \
178 $(MAKE) check $(FLAGS_TO_PASS)
179 # /bin/sh $(srcdir)/sanity.sh .
182 /bin/sh $(srcdir)/sanity.sh $(bindir)
188 $(SIZE_PROG): $(ADDL_LIBS) size.o $(BFD)
189 $(CC) $(LDFLAGS) -o $(SIZE_PROG) size.o $(ADDL_LIBS) $(EXTRALIBS)
191 $(OBJCOPY_PROG): $(ADDL_LIBS) objcopy.o not-strip.o $(BFD)
192 $(CC) $(LDFLAGS) -o $(OBJCOPY_PROG) objcopy.o not-strip.o $(ADDL_LIBS) $(EXTRALIBS)
194 $(STRINGS_PROG): $(ADDL_LIBS) strings.o $(BFD)
195 $(CC) $(LDFLAGS) -o $(STRINGS_PROG) strings.o $(ADDL_LIBS) $(EXTRALIBS)
197 $(STRIP_PROG): $(ADDL_LIBS) objcopy.o is-strip.o $(BFD)
198 $(CC) $(LDFLAGS) -o $(STRIP_PROG) objcopy.o is-strip.o $(ADDL_LIBS) $(EXTRALIBS)
200 $(NM_PROG): $(ADDL_LIBS) nm.o demangle.o $(BFD)
201 $(CC) $(LDFLAGS) -o $(NM_PROG) nm.o demangle.o $(ADDL_LIBS) $(EXTRALIBS)
203 $(OBJDUMP_PROG): $(ADDL_LIBS) objdump.o $(BFD) $(OPCODES)
204 $(CC) $(LDFLAGS) -o $(OBJDUMP_PROG) objdump.o $(OPCODES) $(ADDL_LIBS) $(EXTRALIBS)
206 objdump.o: objdump.c config.status
207 $(CC) -c $(INCLUDES) $(HDEFINES) $(TDEFINES) $(ARCHDEFS) $(CFLAGS) $(srcdir)/objdump.c
210 echo "int xxy_us_dummy;" >dummy.c
213 echo '/*WARNING: This file is automatically generated!*/' >underscore.c
214 if [ "`$(NM) dummy.o | grep _xxy_us_dummy ; true`" != "" ]; then \
215 echo "int prepends_underscore = 1;" >>underscore.c; \
217 echo "int prepends_underscore = 0;" >>underscore.c; \
219 -rm -f dummy.c dummy.o
222 $(CC) $(INCLUDES) $(HDEFINES) $(TDEFINES) -DVERSION='"$(VERSION)"' $(CFLAGS) -c $(srcdir)/version.c
224 demangle.o: $(BASEDIR)/libiberty/cplus-dem.c
225 $(CC) -c $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CFLAGS) $(BASEDIR)/libiberty/cplus-dem.c
226 mv cplus-dem.o demangle.o
228 # For parallel compiling, depend on demangle.o so that one gets done first.
229 cplus-dem.o: $(BASEDIR)/libiberty/cplus-dem.c $(INCDIR)/getopt.h demangle.o
230 $(CC) -c -DMAIN $(INCLUDES) $(HDEFINES) $(TDEFINES) $(CFLAGS) $(BASEDIR)/libiberty/cplus-dem.c
232 $(DEMANGLER_PROG): cplus-dem.o $(LIBIBERTY) underscore.o version.o
233 $(CC) $(LDFLAGS) -o $(DEMANGLER_PROG) cplus-dem.o $(LIBIBERTY) $(EXTRALIBS) underscore.o version.o
236 $(BISON) $(BISONFLAGS) $(srcdir)/arparse.y
237 -mv y.tab.c arparse.c
238 -mv y.tab.h arparse.h
241 $(LEX) $(LEX_OPTIONS) $(srcdir)/arlex.l
244 $(AR_PROG): $(ADDL_LIBS) ar.o arparse.o arlex.o not-ranlib.o $(BFD) arsup.o
245 $(CC) $(LDFLAGS) -o $(AR_PROG) ar.o arparse.o arlex.o arsup.o not-ranlib.o $(ADDL_LIBS) $(EXTRALIBS)
247 $(RANLIB_PROG): $(ADDL_LIBS) ar.o is-ranlib.o arparse.o arlex.o arsup.o $(BFD)
248 $(CC) $(LDFLAGS) -o $(RANLIB_PROG) ar.o arparse.o arlex.o arsup.o is-ranlib.o $(ADDL_LIBS) $(EXTRALIBS)
250 # This rule creates a single binary that switches between ar and ranlib
251 # by looking at argv[0]. Use this kludge to save some disk space.
252 # However, you have to install things by hand.
253 # (That is after 'make install', replace the installed ranlib by a link to ar.)
255 # Alternatively, you can install ranlib.sh as ranlib.
257 ar_with_ranlib: $(ADDL_LIBS) ar.o maybe-ranlib.o $(BFD)
258 $(CC) $(LDFLAGS) -o $(AR_PROG) ar.o maybe-ranlib.o $(ADDL_LIBS) $(EXTRALIBS)
259 -rm -f $(RANLIB_PROG)
260 -ln $(AR_PROG) $(RANLIB_PROG)
262 # objcopy and strip in one binary that uses argv[0] to decide its action.
264 objcopy_with_strip: $(ADDL_LIBS) objcopy.o maybe-strip.o $(BFD)
265 $(CC) $(LDFLAGS) -o $(OBJCOPY_PROG) objcopy.o maybe-strip.o $(ADDL_LIBS) $(EXTRALIBS)
267 -ln $(OBJCOPY_PROG) $(STRIP_PROG)
269 nlmheader.c: nlmheader.y
270 $(BISON) $(srcdir)/nlmheader.y
272 -mv y.tab.c nlmheader.c
274 $(NLMCONV_PROG): nlmconv.o nlmheader.o $(ADDL_LIBS) $(BFD)
275 $(CC) $(LDFLAGS) -o $@ nlmconv.o nlmheader.o $(ADDL_LIBS) $(EXTRALIBS)
277 # This list of dependencies was generated by doing a make with gcc -MM
278 # saving the output in a file and removing the gcc commands
279 # changing "../../devo/binutils/../bfd" to "$(BFDDIR)"
280 # removing "../../devo/binutils/"
281 # changing "../include" to "$(INCDIR)"
283 bucomm.o: bucomm.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
284 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
285 $(INCDIR)/fopen-same.h
286 filemode.o: filemode.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
287 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
288 $(INCDIR)/fopen-same.h
289 size.o: size.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
290 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
291 $(INCDIR)/fopen-same.h $(INCDIR)/getopt.h
292 objdump.o: objdump.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
293 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
294 $(INCDIR)/fopen-same.h $(INCDIR)/getopt.h \
295 $(INCDIR)/dis-asm.h $(INCDIR)/aout/aout64.h \
296 $(INCDIR)/elf/internal.h $(INCDIR)/aout/stab.def
297 nm.o: nm.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
298 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
299 $(INCDIR)/fopen-same.h bucomm.h $(INCDIR)/getopt.h \
300 $(INCDIR)/aout/stab_gnu.h $(INCDIR)/aout/stab.def \
301 $(INCDIR)/aout/ranlib.h $(INCDIR)/demangle.h
302 ar.o: ar.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
303 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
304 $(INCDIR)/fopen-same.h bucomm.h $(INCDIR)/aout/ar.h \
305 $(BFDDIR)/libbfd.h arsup.h
306 arparse.o: arparse.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
307 $(INCDIR)/obstack.h arsup.h
308 arlex.o: arlex.c ./arparse.h
309 not-ranlib.o: not-ranlib.c
310 arsup.o: arsup.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
311 $(INCDIR)/obstack.h arsup.h bucomm.h
312 strings.o: strings.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
313 $(INCDIR)/obstack.h bucomm.h
314 objcopy.o: objcopy.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \
315 $(INCDIR)/obstack.h ../bfd/sysdep.h $(BFDDIR)/hosts/std-host.h \
316 $(INCDIR)/fopen-same.h bucomm.h
317 is-strip.o: is-strip.c
318 is-ranlib.o: is-ranlib.c
319 not-strip.o: not-strip.c
320 nlmheader.o: nlmheader.c nlmconv.h $(INCDIR)/nlm/common.h \
321 $(INCDIR)/nlm/internal.h
322 nlmconv.o: nlmconv.c nlmconv.h $(INCDIR)/nlm/common.h \
323 $(INCDIR)/nlm/internal.h $(BFDDIR)/libnlm.h bucomm.h
327 - mv -f $(STAGESTUFF) stage1
331 - mv -f $(STAGESTUFF) stage2
335 - mv -f $(STAGESTUFF) stage3
340 for i in $(STAGESTUFF) ; do cmp $$i $(against)/$$i ; done
343 - (cd stage1 ; mv -f * ..)
347 - (cd stage2 ; mv -f * ..)
351 - (cd stage3 ; mv -f * ..)
354 ######################################################################
355 # DOCUMENTATION TARGETS
357 binutils.dvi: $(srcdir)/binutils.texi
358 $(TEXI2DVI) $(srcdir)/binutils.texi
360 # info file for online browsing
361 binutils.info: $(srcdir)/binutils.texi
362 $(MAKEINFO) -o binutils.info $(srcdir)/binutils.texi
364 # different targets for -ms, -mm, -me
365 # Try to use a recent texi2roff. v2 was put on prep in jan91.
366 # If you want an index, see texi2roff doc for postprocessing
367 # and add -i to texi2roff invocations below.
368 # Workarounds for texi2roff-2 (probably fixed in later texi2roff's, delete
369 # correspondint -e lines when later texi2roff's are current)
370 # + @ifinfo's deleted explicitly due to texi2roff-2 bug w nested constructs.
371 # + @c's deleted explicitly because texi2roff sees texinfo commands in them
372 # + @ (that's at-BLANK) not recognized by texi2roff, turned into blank
373 # + @alphaenumerate is ridiculously new, turned into @enumerate
376 binutils.ms: $(srcdir)/binutils.texi
377 sed -e '/\\input texinfo/d' \
378 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
379 -e '/^@ifinfo/,/^@end ifinfo/d' \
383 -e 's/^@alphaenumerate/@enumerate/g' \
384 -e 's/^@end alphaenumerate/@end enumerate/g' \
385 $(srcdir)/binutils.texi | \
387 sed -e 's/---/\\(em/g' \
391 # '@noindent's removed due to texi2roff-2 mm bug; if yours is newer,
392 # try leaving them in
393 binutils.mm: $(srcdir)/binutils.texi
394 sed -e '/\\input texinfo/d' \
395 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
396 -e '/^@ifinfo/,/^@end ifinfo/d' \
401 -e 's/^@alphaenumerate/@enumerate/g' \
402 -e 's/^@end alphaenumerate/@end enumerate/g' \
403 $(srcdir)/binutils.texi | \
405 sed -e 's/---/\\(em/g' \
409 binutils.me: $(srcdir)/binutils.texi
410 sed -e '/\\input texinfo/d' \
411 -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \
412 -e '/^@ifinfo/,/^@end ifinfo/d' \
416 -e 's/^@alphaenumerate/@enumerate/g' \
417 -e 's/^@end alphaenumerate/@end enumerate/g' \
418 $(srcdir)/binutils.texi | \
420 sed -e 's/---/\\(em/g' \
424 ######################################################################
427 -rm -f *.o *~ \#* core binutils.?? binutils.???
429 -rm -f $(PROGS) underscore.c
431 -rm -f Makefile config.status sysdep.h
433 -rm -f $(DISTSTUFF) TAGS
438 etags $(INCDIR)/*.h $(srcdir)/*.[hc]
441 for i in $(PROGS) ; do \
442 $(INSTALL_XFORM) $$i $(bindir)/$$i ; \
444 for i in $(MANPAGES) ; do \
445 $(INSTALL_XFORM1) $(srcdir)/$$i.1 $(man1dir)/$$i.1 ; \
447 -if [ -d $(tooldir) ]; then \
448 if [ -d $(tooldir)/bin ] ; then true ; else mkdir $(tooldir)/bin ; fi; \
449 for i in nm strings strip ar ranlib; do \
450 rm -f $(tooldir)/bin/$$i; \
451 ln $(bindir)/`t='$(program_transform_name)'; echo $$i | sed -e "" $$t` $(tooldir)/bin/$$i \
452 || $(INSTALL_PROGRAM) $$i $(tooldir)/bin/$$i; \
457 for i in *.info* ; do \
458 $(INSTALL_DATA) $$i $(infodir)/$$i ; \
465 # cvs rtag binutils-x-yy ld+utils
466 # cvs co -r binutils-x-yy ld+utils
468 # cd {HERE}; make dist [-f Makefile.in]
470 dist: $(DIST_NAME).tar.z
472 diststuff: $(DISTSTUFF)
475 cd ../..; rm -f $(DIST_NAME); ln -s devo $(DIST_NAME)
476 make diststuff -f Makefile.in
477 cd ../ld; make diststuff -f Makefile.in
478 cd ../gprof; make diststuff -f Makefile.in
479 cd ../texinfo; mv texinfo.tex ..; rm -rf *; mv ../texinfo.tex .
480 # Take out texinfo from configurable dirs
481 mv ../configure.in tmp; \
482 sed -e '/^host_tools=/s/texinfo //' <tmp >../configure.in; rm tmp
483 cd ..; chmod og=u `find . -print`
484 cd ../..; tar chf - $(DIST_NAME) | gzip >$(DIST_NAME).tar.z
485 rm -rf ../../$(DIST_NAME)
487 #-----------------------------------------------------------------------------
488 # 'STANDARD' GNU/960 TARGETS BELOW THIS POINT
490 # 'VERSION' file must be present and contain a string of the form "x.y"
491 #-----------------------------------------------------------------------------
495 echo "char ${TARG}_ver[]= \"${TARG} `cat VERSION`, `date`\";" > ver960.c
498 # Dummy target to force execution of dependent targets.
502 # Target to uncomment host-specific lines in this makefile. Such lines must
503 # have the following string beginning in column 1: #__<hostname>__#
504 # Original Makefile is backed up as 'Makefile.old'.
506 # Invoke with: make make HOST=xxx
509 -@if test $(HOST)x = x ; then \
510 echo '
\aSpecify "make make HOST=???"'; \
513 grep -s "^#The next line was generated by 'make make'" Makefile; \
514 if test $$? = 0 ; then \
515 echo "
\aMakefile has already been processed with 'make make'";\
518 mv -f Makefile Makefile.old; \
519 echo "#The next line was generated by 'make make'" >Makefile ; \
520 echo "HOST=$(HOST)" >>Makefile ; \
522 sed "s/^#__$(HOST)__#//" < Makefile.old >>Makefile
524 Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
525 $(SHELL) ./config.status
527 ### Local Variables: ***
528 ### mode:fundamental ***
529 ### page-delimiter: "^#
\f" ***