1#Copyright 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
2
3# This file is part of GDB.
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 of the License, or
8# (at your option) 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., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19prefix = /usr/local
20
21program_transform_name =
22exec_prefix = $(prefix)
23bindir = /usr/bin
24libdir = $(exec_prefix)/lib
25tooldir = $(libdir)/$(target_alias)
26
27datadir = $(prefix)/lib
28mandir = $(prefix)/man
29man1dir = $(mandir)/man1
30man2dir = $(mandir)/man2
31man3dir = $(mandir)/man3
32man4dir = $(mandir)/man4
33man5dir = $(mandir)/man5
34man6dir = $(mandir)/man6
35man7dir = $(mandir)/man7
36man8dir = $(mandir)/man8
37man9dir = $(mandir)/man9
38infodir = $(prefix)/info
39includedir = $(prefix)/include
40docdir = $(datadir)/doc
41
42SHELL = /bin/sh
43
44xbindir = /usr/bin/X11
45xlibdir = /usr/lib/X11
46
47INSTALL = install -c
48INSTALL_PROGRAM = $(INSTALL)
49INSTALL_DATA = $(INSTALL)
50
51AR = ar
52AR_FLAGS = qv
53RANLIB = ranlib
54
55# Flags that describe where you can find the termcap library.
56# This can be overridden in the host Makefile fragment file.
57TERMCAP = -ltermcap
58
59# System V: If you compile gdb with a compiler which uses the coff
60# encapsulation feature (this is a function of the compiler used, NOT
61# of the m-?.h file selected by config.gdb), you must make sure that
62# the GNU nm is the one that is used by munch.
63
64# If you are compiling with GCC, make sure that either 1) You use the
65# -traditional flag, or 2) You have the fixed include files where GCC
66# can reach them.  Otherwise the ioctl calls in inflow.c
67# will be incorrectly compiled.  The "fixincludes" script in the gcc
68# distribution will fix your include files up.
69#CC=cc
70#CC=gcc -traditional
71CC=gcc -O2
72GCC=gcc
73
74# Directory containing source files.  Don't clean up the spacing,
75# this exact string is matched for by the "configure" script.
76srcdir = .
77
78# It is also possible that you will need to add -I/usr/include/sys to the
79# CFLAGS section if your system doesn't have fcntl.h in /usr/include (which
80# is where it should be according to Posix).
81
82BISON=yacc
83YACC=$(BISON)
84
85# Documentation (gdb.dvi) needs either GNU m4 or SysV m4;
86# Berkeley/Sun don't have quite enough.
87#M4=/usr/5bin/m4
88M4=gm4
89
90# where to find texinfo; GDB dist should include a recent one
91TEXIDIR=${srcdir}/../texinfo/fsf
92
93# where to find makeinfo, preferably one designed for texinfo-2
94MAKEINFO=makeinfo
95
96# Set this up with gcc if you have gnu ld and the loader will print out
97# line numbers for undefinded refs.
98#CC-LD=gcc -static
99CC-LD=${CC}
100
101# Where is the "include" directory?  Traditionally ../include or ./include
102INCLUDE_DIR =  ${srcdir}/../include
103INCLUDE_DEP = $$(INCLUDE_DIR)
104
105# Where is the source dir for the MMALLOC library? Traditionally ../mmalloc
106# or ./mmalloc  (When we want the binary library built from it, we use
107# ${MMALLOC_DIR}${subdir}.)
108# Note that mmalloc can still be used on systems without mmap().
109# To use your system malloc, comment out the following defines.
110MMALLOC_DIR = ${srcdir}/../mmalloc
111MMALLOC_DEP = $$(MMALLOC_DIR)
112MMALLOC_LIB = ./../mmalloc${subdir}/libmmalloc.a
113# To use your system malloc, uncomment MMALLOC_DISABLE.
114#MMALLOC_DISABLE = -DNO_MMALLOC
115# To use mmalloc but disable corruption checking, uncomment MMALLOC_CHECK
116#MMALLOC_CHECK = -DNO_MMALLOC_CHECK
117MMALLOC_CFLAGS = ${MMALLOC_CHECK} ${MMALLOC_DISABLE}
118
119# Where is the source dir for the BFD library?  Traditionally ../bfd or ./bfd
120# (When we want the binary library built from it, we use ${BFD_DIR}${subdir}.)
121BFD_DIR =  ${srcdir}/../bfd
122BFD_DEP = $$(BFD_DIR)
123BFD_LIB = ./../bfd${subdir}/libbfd.a
124
125# Where is the source dir for the READLINE library?  Traditionally in .. or .
126# (For the binary library built from it, we use ${READLINE_DIR}${subdir}.)
127READLINE_DIR = ${srcdir}/../readline
128READLINE_DEP = $$(READLINE_DIR)
129RL_LIB = ./../readline${subdir}/libreadline.a
130
131# All the includes used for CFLAGS and for lint.
132# -I. for config files.
133# -I${srcdir} possibly for regex.h also.
134INCLUDE_CFLAGS = -I. -I${srcdir} -I$(INCLUDE_DIR)
135
136# M{H,T}_CFLAGS, if defined, has host- and target-dependent CFLAGS
137# from the config/ directory.
138GLOBAL_CFLAGS = ${MT_CFLAGS} ${MH_CFLAGS}
139#PROFILE_CFLAGS = -pg
140
141# CFLAGS is specifically reserved for setting from the command line
142# when running make.  I.E.  "make USER_CFLAGS=-Wmissing-prototypes".
143CFLAGS = -g
144# INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros.
145INTERNAL_CFLAGS = ${CFLAGS} ${GLOBAL_CFLAGS} ${PROFILE_CFLAGS} ${MMALLOC_CFLAGS} ${INCLUDE_CFLAGS} ${USER_CFLAGS}
146# None of the things in CFLAGS will do any harm, and on some systems
147#  (e.g. SunOS4) it is important to use the MH_CFLAGS.
148LDFLAGS = $(CFLAGS)
149
150# Where is the "-liberty" library, containing getopt and obstack?
151LIBIBERTY_DIR = ${srcdir}/../libiberty
152LIBIBERTY = ./../libiberty${subdir}/libiberty.a
153
154# Where is the "-lopcodes" library, with (some of) the opcode tables and
155# disassemblers?
156OPCODES = ./../opcodes${subdir}/libopcodes.a
157
158# The config/mh-* file must define REGEX and REGEX1 on USG machines.
159# If your sysyem is missing alloca(), or, more likely, it's there but
160# it doesn't work, define ALLOCA & ALLOCA1 too.
161
162# Libraries and corresponding dependencies for compiling gdb.
163# {X,T}M_CLIBS, defined in *config files, have host- and target-dependent libs.
164# TERMCAP comes after readline, since readline depends on it.
165CLIBS = ${BFD_LIB} ${RL_LIB} ${TERMCAP} ${OPCODES} ${MMALLOC_LIB} ${LIBIBERTY} \
166	${XM_CLIBS} ${TM_CLIBS} ${NAT_CLIBS}
167CDEPS = ${XM_CDEPS} ${TM_CDEPS} ${NAT_CDEPS} \
168	${BFD_LIB} ${RL_LIB}            ${OPCODES} ${MMALLOC_LIB} ${LIBIBERTY}
169
170ADD_FILES = ${REGEX} ${ALLOCA}  ${XM_ADD_FILES} ${TM_ADD_FILES} ${NAT_ADD_FILES}
171ADD_DEPS = ${REGEX1} ${ALLOCA1} ${XM_ADD_FILES} ${TM_ADD_FILES} ${NAT_ADD_FILES}
172
173VERSION = 4.7
174DIST=gdb
175
176LINT=/usr/5bin/lint
177LINTFLAGS= -I${BFD_DIR}
178
179# Host and target-dependent makefile fragments come in here.
180####
181# End of host and target-dependent makefile fragments
182LBL_SRC = kcore.c remote-sl.c remote-fp.c kernel.c cmdparse.c
183LBL_OBJ = $(LBL_SRC:.c=.o)
184
185#SYMREADERS = dbxread.c coffread.c elfread.c dwarfread.c \
186#		xcoffread.c stabsread.c mipsread.c
187SYMREADERS = dbxread.c stabsread.c
188SYMREADOBJ = $(SYMREADERS:.c=.o)
189
190FLAGS_TO_PASS = \
191	"against=$(against)" \
192	"AR=$(AR)" \
193	"AR_FLAGS=$(AR_FLAGS)" \
194	"CC=$(CC)" \
195	"CFLAGS=$(CFLAGS) $(MT_CFLAGS)" \
196	"RANLIB=$(RANLIB)" \
197	"MAKEINFO=$(MAKEINFO)" \
198	"INSTALL=$(INSTALL)" \
199	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
200	"INSTALL_DATA=$(INSTALL_DATA)" \
201	"BISON=$(BISON)"
202
203# Source files in the main directory.
204# Files which are included via a config/* Makefile fragment
205# should *not* be specified here; they're in "ALLDEPFILES".
206SFILES_MAINDIR = \
207	blockframe.c breakpoint.c command.c core.c demangle.c \
208	environ.c eval.c expprint.c findvar.c infcmd.c inflow.c infrun.c \
209	main.c printcmd.c gdbtypes.c \
210	remote.c source.c stack.c symmisc.c symtab.c symfile.c \
211	utils.c valarith.c valops.c valprint.c values.c c-exp.y m2-exp.y \
212	mem-break.c target.c \
213	$(SYMREADERS) \
214	ieee-float.c language.c parse.c buildsym.c objfiles.c \
215	minsyms.c maint.c \
216	$(LBL_SRC) xgdb.c
217
218# Source files in subdirectories (which will be handled separately by
219#  'make gdb.tar.Z').
220# Files which are included via a config/* Makefile fragment
221# should *not* be specified here; they're in "ALLDEPFILES".
222SFILES_SUBDIR = \
223	 ${srcdir}/vx-share/dbgRpcLib.h \
224	 ${srcdir}/vx-share/ptrace.h \
225	 ${srcdir}/vx-share/reg.h \
226	 ${srcdir}/vx-share/vxTypes.h \
227	 ${srcdir}/vx-share/vxWorks.h \
228	 ${srcdir}/vx-share/wait.h \
229	 ${srcdir}/vx-share/xdr_ld.h \
230	 ${srcdir}/vx-share/xdr_ptrace.h \
231	 ${srcdir}/vx-share/xdr_rdb.h \
232	 ${srcdir}/vx-share/xdr_regs.h \
233	 ${srcdir}/nindy-share/b.out.h \
234	 ${srcdir}/nindy-share/block_io.h \
235	 ${srcdir}/nindy-share/coff.h \
236	 ${srcdir}/nindy-share/demux.h \
237	 ${srcdir}/nindy-share/env.h \
238	 ${srcdir}/nindy-share/stop.h \
239	 ${srcdir}/nindy-share/ttycntl.h
240
241# Non-source files in subdirs, that should go into gdb.tar.Z.
242NONSRC_SUBDIR = \
243	 ${srcdir}/nindy-share/Makefile \
244	 ${srcdir}/nindy-share/VERSION \
245	 ${srcdir}/nindy-share/README \
246	 ${srcdir}/vx-share/README
247
248# All source files that go into linking GDB, except config-specified files.
249SFILES = $(SFILES_MAINDIR) $(SFILES_SUBDIR)
250
251# All source files that lint should look at
252LINTFILES = $(SFILES) $(YYFILES) init.c
253
254# Any additional files specified on these lines should also be added to
255# the OTHERS = definition below, so they go in the tar files.
256SFILES_STAND = $(SFILES) standalone.c
257SFILES_KGDB  = $(SFILES) stuff.c kdb-start.c
258
259# Header files that are not named in config/* Makefile fragments go here.
260HFILES=	breakpoint.h buildsym.h call-cmds.h command.h defs.h \
261	environ.h expression.h frame.h gdbcmd.h gdbcore.h gdbtypes.h \
262	gdb-stabs.h ieee-float.h inferior.h language.h \
263	minimon.h objfiles.h parser-defs.h partial-stab.h \
264	serial.h signals.h solib.h symfile.h symtab.h stabsread.h \
265	target.h terminal.h xcoffsolib.h value.h \
266	tm-68k.h tm-hppa.h tm-i960.h tm-sparc.h tm-sunos.h tm-sysv4.h \
267	xm-m68k.h xm-sparc.h xm-sysv4.h xm-vax.h \
268	nm-i386bsd.h nm-i386mach.h nm-i386sco.h nm-i386v.h nm-i386v4.h nm-irix3.h \
269	nm-irix4.h nm-linux.h nm-m88k.h nm-mips.h nm-news.h nm-rs6000.h \
270	nm-sun2.h nm-sun3.h nm-sun386.h nm-sun4os4.h nm-trash.h \
271	nm-ultra3.h nm-hppab.h nm-hppah.h nm-umax.h nm-sysv4.h
272
273REMOTE_EXAMPLES = m68k-stub.c i386-stub.c sparc-stub.c rem-multi.shar
274
275POSSLIBS_MAINDIR = regex.c regex.h alloca.c
276POSSLIBS = $(POSSLIBS_MAINDIR)
277
278TESTS = testbpt.c testfun.c testrec.c testreg.c testregs.c
279
280OTHERS = Makefile.in depend alldeps.mak createtags munch configure.in \
281	 ChangeLog ChangeLog-9091 ChangeLog-3.x gdb.1 refcard.ps \
282	 README TODO TAGS NEWS Projects \
283	 .gdbinit COPYING $(YYFILES) \
284	 copying.c Convex.notes copying.awk \
285	 saber.suppress standalone.c stuff.c kdb-start.c \
286	 putenv.c gcc.patch XGDB-README
287
288# Subdirectories of gdb, which should be included in their entirety in
289# gdb-xxx.tar.Z:
290TARDIRS = doc # tests
291
292# GDB "info" files, which should be included in their entirety
293INFOFILES = gdb.info*
294
295DEPFILES= ${TDEPFILES} ${XDEPFILES} ${NATDEPFILES}
296
297SOURCES=$(SFILES) $(ALLDEPFILES) $(YYFILES)
298TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS}
299TAGFILES_MAINDIR = $(SFILES_MAINDIR) $(ALLDEPFILES_MAINDIR) \
300             ${HFILES} ${ALLPARAM} ${POSSLIBS_MAINDIR}
301TARFILES = ${TAGFILES_MAINDIR} ${OTHERS} ${REMOTE_EXAMPLES}
302
303OBS = version.o main.o blockframe.o breakpoint.o findvar.o stack.o source.o \
304    values.o eval.o valops.o valarith.o valprint.o printcmd.o \
305    symtab.o symfile.o symmisc.o infcmd.o infrun.o remote.o \
306    command.o utils.o expprint.o environ.o gdbtypes.o \
307    copying.o $(DEPFILES) mem-break.o target.o \
308    ieee-float.o putenv.o parse.o language.o $(YYOBJ) \
309    buildsym.o objfiles.o minsyms.o maint.o demangle.o \
310    $(SYMREADOBJ) core.o \
311    $(LBL_OBJ)
312
313RAPP_OBS = rgdb.o rudp.o rserial.o serial.o udp.o $(XDEPFILES)
314
315TSOBS = inflow.o
316
317NTSOBS = standalone.o
318
319TSSTART = /lib/crt0.o
320
321NTSSTART = kdb-start.o
322
323SUBDIRS = doc
324
325# For now, shortcut the "configure GDB for fewer languages" stuff.
326YYFILES = c-exp.tab.c m2-exp.tab.c
327YYOBJ = c-exp.tab.o m2-exp.tab.o
328
329# Prevent Sun make from putting in the machine type.  Setting
330# TARGET_ARCH to nothing works for SunOS 3, 4.0, but not for 4.1.
331.c.o:
332	${CC} -c ${INTERNAL_CFLAGS} $<
333
334all: gdb
335	$(MAKE) subdir_do DO=all "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
336check:
337info: force
338	$(MAKE) subdir_do DO=info "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
339install-info: force
340	$(MAKE) subdir_do DO=install-info "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
341clean-info: force
342	$(MAKE) subdir_do DO=clean-info "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
343
344install.xgdb: xgdb
345	rm -f $(xbindir)/xgdb
346	install xgdb $(xbindir)
347	install Xgdb.ad $(xlibdir)/app-defaults/Xgdb
348
349gdb.z:gdb.1
350	nroff -man $(srcdir)/gdb.1 | col -b > gdb.t
351	pack gdb.t ; rm -f gdb.t
352	mv gdb.t.z gdb.z
353
354install: gdb
355	install -s gdb /usr/contrib/bin
356
357init.c: $(srcdir)/munch $(OBS) $(TSOBS)
358	$(srcdir)/munch ${MUNCH_DEFINE} $(OBS) $(TSOBS) > init.c
359
360xinit.c: $(srcdir)/munch $(OBS) $(TSOBS) xgdb.o
361	rm -f xinit.c
362	./munch ${MUNCH_DEFINE} $(OBS) $(TSOBS) xgdb.o > xinit.c
363
364xgdb: $(OBS) $(TSOBS) xgdb.o xinit.o ${ADD_DEPS}
365	$(CC-LD) $(LDFLAGS) -o xgdb xinit.o xgdb.o \
366		$(OBS) $(TSOBS) $(ADD_FILES) $(CLIBS) $(LOADLIBES) \
367		-lXaw -lXmu -lXt -lXext -lX11 -lXwchar -lX11
368
369gdb: $(OBS) $(TSOBS) ${ADD_DEPS} ${CDEPS} init.o
370	${CC-LD} $(GLOBAL_CFLAGS) $(LDFLAGS) -o gdb \
371	  init.o $(OBS) $(TSOBS) $(ADD_FILES) $(CLIBS) $(LOADLIBES)
372
373saber_gdb: $(SFILES) $(DEPFILES) copying.c version.c
374	#setopt load_flags $(CFLAGS) -I$(BFD_DIR) -DHOST_SYS=SUN4_SYS
375	#load ./init.c $(SFILES)
376	#unload ${srcdir}/c-exp.y ${srcdir}/m2-exp.y ${srcdir}/vx-share/*.h
377	#unload ${srcdir}/nindy-share/[A-Z]*
378	#load c-exp.tab.c m2-exp.tab.c
379	#load copying.c version.c
380	#load ../opcodes/libopcodes.a
381	#load ../libiberty/libiberty.a
382	#load ../bfd/libbfd.a
383	#load ../readline/libreadline.a
384	#load ../mmalloc/libmmalloc.a
385	#load -ltermcap
386	#load `echo " "$(DEPFILES) | sed -e 's/\.o/.c/g' -e 's, , ../,g'`
387	echo "Load .c corresponding to:" $(DEPFILES)
388
389
390# This is useful when debugging GDB, because some Unix's don't let you run GDB
391# on itself without copying the executable.  So "make gdb1" will make
392# gdb and put a copy in gdb1, and you can run it with "gdb gdb1".
393# Removing gdb1 before the copy is the right thing if gdb1 is open
394# in another process.
395gdb1: gdb
396	rm -f gdb1
397	cp gdb gdb1
398
399# This is a remote stub which runs under unix and starts up an
400# inferior process.  This is at least useful for debugging GDB's
401# remote support.
402rapp: $(RAPP_OBS)
403	rm -f rapp_init.c
404	${srcdir}/munch ${MUNCH_DEFINE} ${RAPP_OBS} > rapp_init.c
405	${CC-LD} $(LDFLAGS) -o $@ rapp_init.c $(RAPP_OBS)
406
407# Support for building Makefile out of configured pieces, automatically
408# generated dependencies, etc.  alldeps.mak is a file that contains
409# "make" variable definitions for all ALLDEPFILES, ALLDEPFILES_MAINDIR,
410# ALLDEPFILES_SUBDIR, ALLPARAM, and ALLCONFIG, all cadged from the current
411# contents of the config subdirectory.
412
413alldeps.mak: ${srcdir}/config
414	rm -f alldeps.mak alldeps.tmp allparam.tmp allconfig.tmp
415	for i in `ls -d ${srcdir}/config/*.m[ht]` ; do \
416	  echo $$i >>allconfig.tmp; \
417	  awk <$$i ' \
418	    $$1 == "TDEPFILES=" || $$1 == "XDEPFILES=" \
419		|| $$1 == "NATDEPFILES=" { \
420	      for (i = 2; i <= NF; i++) \
421	        print $$i >> "alldeps.tmp" ; \
422            } \
423	    $$1 == "TM_FILE=" || $$1 == "XM_FILE=" || $$1 == "NAT_FILE" { \
424	      print $$2 >> "allparam.tmp" }' ; \
425	done
426	sort <alldeps.tmp | uniq | \
427	  sed -e 's/arm-convert.o/arm-convert.s/' \
428	      -e 's!^Onindy.o!nindy-share/Onindy.c!' \
429	      -e 's!^nindy.o!nindy-share/nindy.c!' \
430	      -e 's!ttybreak.o!nindy-share/ttybreak.c!' \
431	      -e 's!ttyflush.o!nindy-share/ttyflush.c!' \
432	      -e 's!xdr_ld.o!vx-share/xdr_ld.c!' \
433	      -e 's!xdr_ptrace.o!vx-share/xdr_ptrace.c!' \
434	      -e 's!xdr_rdb.o!vx-share/xdr_rdb.c!' \
435	      -e 's!xdr_regs.o!vx-share/xdr_regs.c!' \
436	      -e 's/\.o/.c/' \
437	    >alldeps2.tmp
438	echo '# Start of "alldeps.mak" definitions' \
439	    >>alldeps.mak;
440	echo 'ALLDEPFILES = $$(ALLDEPFILES_MAINDIR) $$(ALLDEPFILES_SUBDIR)' \
441	    >>alldeps.mak;
442	grep -v / alldeps2.tmp | \
443	  awk 'BEGIN {printf "ALLDEPFILES_MAINDIR="} \
444	    NR == 0 {printf $$0;} \
445	    NR != 0 {printf "\\\n" $$0} \
446	    END {printf "\n\n"}' >>alldeps.mak;
447	grep / alldeps2.tmp | \
448	  awk 'BEGIN {printf "ALLDEPFILES_SUBDIR="} \
449	    NR == 0 {printf $$0;} \
450	    NR != 0 {printf "\\\n" $$0} \
451	    END {printf "\n\n"}' >>alldeps.mak;
452	sort <allparam.tmp | uniq | awk 'BEGIN {printf "ALLPARAM="} \
453	    NR == 0 {printf $$0;} \
454	    NR != 0 {printf "\\\n" $$0} \
455	    END {printf "\n\n"}' >>alldeps.mak;
456	sort <allconfig.tmp | uniq | awk 'BEGIN {printf "ALLCONFIG="} \
457	    NR == 0 {printf $$0;} \
458	    NR != 0 {printf "\\\n" $$0} \
459	    END {printf "\n\n"}' >>alldeps.mak;
460	echo '# End of "alldeps.mak" definitions' \
461	    >>alldeps.mak;
462	rm -f alldeps.tmp alldeps2.tmp allparam.tmp allconfig.tmp
463
464# The sed script makes everything which depends on {x,t}m.h depend on
465# config.status as well, in case someone reconfigures gdb out from
466# under an already compiled gdb.
467depend: $(SOURCES) Makefile.in
468	@echo Ignore errors about non-existent system-supplied include files
469	@echo for systems other than the one you are using.
470	@echo Also ignore parse errors in valops.c, and any errors in
471	@echo arm-convert.s.
472	touch xm.h tm.h
473	-$(GCC) -MM -nostdinc -I/usr/include $(CFLAGS) -I$(BFD_DIR) \
474	  -I${READLINE_DIR} $(INCLUDE_CFLAGS) \
475	  `ls $(SOURCES) | grep -v '\.[hy]$$' | \
476	  sort -u` >depend.tmp
477# If running in srcdir, translate "./foo.c" into "$srcdir/foo.c" except
478# for xm.h and tm.h.  This allows the same "depend" file to be used
479# by the various subdirectories.
480	if [ "${srcdir}" = "." ] ; then \
481	  <depend.tmp sed \
482	    -e 's; ./xm.h; xm.h;g'  \
483	    -e 's; ./tm.h; tm.h;g'  \
484	    -e 's; \./; $${srcdir}/;g'  \
485	    -e 's; vx-share/; $${srcdir}/vx-share/;g'  \
486	    -e 's; nindy-share/; $${srcdir}/nindy-share/;g'  \
487	    >depend.tm2; \
488	  rm depend.tmp; \
489	  mv depend.tm2 depend.tmp; \
490	fi
491	<depend.tmp sed \
492	  -e 's; [xt]m.h;& config.status;g'  \
493	  -e 's; $(INCLUDE_DIR)/; $(INCLUDE_DEP)/;g'  \
494	  -e 's; $(READLINE_DIR)/; $(READLINE_DEP)/;g'  \
495	  -e 's; [a-z0-9./]*bfd/; $(BFD_DEP)/;g'  \
496	  -e 's; ./xm.h; xm.h config.status;g'  \
497	  -e 's; ./tm.h; tm.h config.status;g'  \
498	  >depend
499	rm depend.tmp
500
501config.status:
502	@echo "You must configure gdb.  Look at the README file for details."
503	@false
504
505# This checks the configure.in file versus the config/ directory.
506config-check: config-check-hosts config-check-targets
507config-check-hosts:
508	grep gdb_host= ${srcdir}/configure.in | \
509		sed -e 's/.*gdb_host=//' -e 's/ ;;$$/.mh/' | sort -u >HOSTconf.o
510	(cd ${srcdir}/config; ls *.mh) >HOSTdir.o
511	diff -u HOSTconf.o HOSTdir.o
512
513config-check-targets:
514	grep gdb_target= ${srcdir}/configure.in | \
515		sed -e 's/.*gdb_target=//' -e 's/ ;;$$/.mh/' | sort -u >TARGconf.o
516	(cd ${srcdir}/config; ls *.mt) >TARGdir.o
517	diff -u HOSTconf.o HOSTdir.o
518
519# These are not generated by "make depend" because they only are there
520# for some machines.
521# But these rules don't do what we want; we want to hack the foo.o: tm.h
522# dependency to do the right thing.
523tm-isi.h tm-sun3.h tm-news.h tm-hp300bsd.h tm-altos.h: tm-68k.h
524tm-hp300hpux.h tm-sun2.h tm-3b1.h: tm-68k.h
525xm-news1000.h: xm-news.h
526xm-i386-sv32.h: xm-i386.h
527tm-i386gas.h: tm-i386.h
528xm-sun4os4.h: xm-sparc.h
529tm-sun4os4.h: tm-sparc.h
530xm-vaxult.h: xm-vax.h
531xm-vaxbsd.h: xm-vax.h
532
533kdb: $(NTSSTART) $(OBS) $(NTSOBS) ${ADD_DEPS} ${CDEPS}
534	rm -f init.c
535	$(srcdir)/munch ${MUNCH_DEFINE} $(OBS) $(NTSOBS) > init.c
536	$(CC) $(LDFLAGS) -c init.c $(CLIBS)
537	ld -o kdb $(NTSSTART) $(OBS) $(NTSOBS) init.o $(ADD_FILES) \
538	  -lc $(CLIBS)
539
540# Put the proper machine-specific files first.
541# createtags will edit the .o in DEPFILES into .c
542TAGS: ${TAGFILES}
543	$(srcdir)/createtags $(TM_FILE) ${XM_FILE} ${NAT_FILE} \
544			     $(DEPFILES) ${TAGFILES}
545tags: TAGS
546
547# Making distributions of GDB and friends.
548
549# Make a directory `proto-gdb.dir' that contains an image of the GDB
550# directory of the distribution, built up with symlinks.
551make-proto-gdb.dir: force_update
552	$(MAKE) $(MFLAGS) -f Makefile.in setup-to-dist
553	$(MAKE) $(MFLAGS) -f Makefile    make-proto-gdb-1
554
555# Make a tar file containing the GDB directory of the distribution.
556gdb.tar.Z: force_update
557	$(MAKE) $(MFLAGS) -f Makefile.in setup-to-dist
558	$(MAKE) $(MFLAGS) -f Makefile.in gdb-$(VERSION).tar.Z
559
560# Update the "alldeps.mak" file in a source directory.
561update-alldeps: force_update
562	../configure none -norecursion
563	rm -f alldeps.mak
564	$(MAKE) $(MFLAGS) alldeps.mak
565
566# Update the "depend" and "alldeps.mak" files in a source directory.
567# We update alldeps.mak first, since it is used to generate the list
568# of files to be checked for dependencies.
569update-depend: update-alldeps force_update
570	../configure none -norecursion
571	rm -f depend
572	$(MAKE) $(MFLAGS) depend
573
574# Set up the GDB source directory for distribution, by building all files that
575# are products of other files.
576setup-to-dist: update-depend force_update
577	../configure none
578	(cd doc; $(MAKE) $(MFLAGS) gdbVN.m4)
579	$(MAKE) $(MFLAGS) gdb.info
580	$(MAKE) $(MFLAGS) refcard.ps
581
582# Build a tar file from a proto-gdb.dir.
583gdb-$(VERSION).tar.Z: force_update
584	rm -f gdb.tar gdb-$(VERSION).tar.Z
585	$(MAKE) $(MFLAGS) -f Makefile    make-proto-gdb-1
586	ln -s proto-gdb.dir $(DIST)
587	tar chf - $(DIST) | compress >gdb-$(VERSION).tar.Z
588	rm -rf $(DIST) proto-gdb.dir
589
590# Build a proto-gdb.dir after GDB has been set up for distribution.
591# This stuff must be run in `Makefile', not `Makefile.in`; we use the makefile
592# built in the setup-to-dist process, since it defines things like ALLCONFIG
593# and ALLDEPFILES, that we need.
594make-proto-gdb-1: ${TARFILES} ${TARDIRS} gdb.info
595	rm -rf proto-gdb.dir
596	mkdir proto-gdb.dir
597	cd proto-gdb.dir ; for i in ${TARFILES} ; do ln -s ../$$i . ; done
598	cd proto-gdb.dir ; ln -s ../${INFOFILES} .
599	cd proto-gdb.dir ; for i in ${TARDIRS}; do \
600	  mkdir $$i; cd $$i; \
601	  ln -s ../../$$i/* .; \
602	  rm -rf SCCS CVS.adm RCS config.status; \
603	  if test -f Makefile.in; then rm Makefile; else true; fi; done
604	mkdir proto-gdb.dir/config
605	cd proto-gdb.dir/config ; \
606	  for i in $(ALLCONFIG) ; do ln -s ../../$$i ../$$i ; done
607	mkdir proto-gdb.dir/vx-share proto-gdb.dir/nindy-share
608	cd proto-gdb.dir/config ; \
609	  for i in $(SFILES_SUBDIR) $(NONSRC_SUBDIR) $(ALLDEPFILES_SUBDIR); \
610	    do ln -s ../../$$i ../$$i ; done
611	chmod og=u `find . -print`
612
613clean:
614	rm -f *.o ${ADD_FILES} *~
615	rm -f init.c version.c
616	rm -f gdb core gdb.tar gdb.tar.Z make.log
617	rm -f gdb[0-9]
618	rm -f xgdb.o xgdb
619	@$(MAKE) subdir_do DO=clean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
620
621distclean: clean c-exp.tab.c m2-exp.tab.c TAGS
622	rm -f tm.h xm.h config.status
623	rm -f y.output yacc.acts yacc.tmp
624	rm -f ${TESTS} Makefile depend
625	@$(MAKE) subdir_do DO=distclean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
626
627realclean: clean
628	rm -f c-exp.tab.c m2-exp.tab.c TAGS
629	rm -f tm.h xm.h config.status
630	rm -f Makefile depend
631	@$(MAKE) subdir_do DO=realclean "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS)
632
633STAGESTUFF=${OBS} ${TSOBS} ${NTSOBS} ${ADD_FILES} init.c init.o version.c gdb
634
635subdir_do: force
636	@for i in $(DODIRS); do \
637		if [ -d ./$$i ] ; then \
638			if (cd ./$$i; \
639				$(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \
640			else exit 1 ; fi ; \
641		else true ; fi ; \
642	done
643
644Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
645	$(SHELL) ./config.status
646
647force:
648
649# Documentation!
650# GDB QUICK REFERENCE (TeX dvi file, CM fonts)
651refcard.dvi: $(srcdir)/doc/refcard.tex
652	( cd ./doc; $(MAKE) refcard.dvi $(FLAGS_TO_PASS) )
653	mv ./doc/refcard.dvi .
654
655# GDB QUICK REFERENCE (PostScript output, common PS fonts)
656refcard.ps: $(srcdir)/doc/refcard.tex
657	( cd ./doc; $(MAKE) refcard.ps $(FLAGS_TO_PASS) )
658	mv ./doc/refcard.ps .
659
660# GDB MANUAL: TeX dvi file
661gdb.dvi: ./doc/gdb-all.texi
662	( cd ./doc; $(MAKE) M4=$(M4) gdb.dvi $(FLAGS_TO_PASS) )
663	mv ./doc/gdb.dvi .
664
665# GDB MANUAL: info file
666gdb.info: ./doc/gdb-all.texi
667	( cd ./doc; $(MAKE) M4=$(M4) gdb.info $(FLAGS_TO_PASS) )
668	mv ./doc/gdb.info* .
669
670./doc/gdb-all.texi:
671	(cd ./doc; $(MAKE) M4=$(M4) gdb-all.texi $(FLAGS_TO_PASS) )
672
673# Make copying.c from COPYING
674copying.c: ${srcdir}/COPYING ${srcdir}/copying.awk
675	awk -f ${srcdir}/copying.awk < ${srcdir}/COPYING > copying.c
676
677version.c: Makefile
678	echo 'char *version = "$(VERSION)";' >version.c
679
680# c-exp.tab.c is generated in target dir from c-exp.y if it doesn't exist
681# in srcdir, then compiled in target dir to c-exp.tab.o.
682# Remove bogus decls for malloc/realloc/free which conflict with everything
683# else.
684c-exp.tab.o: c-exp.tab.c
685c-exp.tab.c: $(srcdir)/c-exp.y
686	@echo 'Expect 4 shift/reduce conflicts.'
687	${YACC} $(srcdir)/c-exp.y
688	-sed -e '/extern.*malloc/d' \
689	     -e '/extern.*realloc/d' \
690	     -e '/extern.*free/d' \
691	  < y.tab.c > c-exp.tab.c
692	-rm y.tab.c
693
694# m2-exp.tab.c is generated in target dir from m2-exp.y if it doesn't exist
695# in srcdir, then compiled in target dir to m2-exp.tab.o.
696m2-exp.tab.o: m2-exp.tab.c
697m2-exp.tab.c: $(srcdir)/m2-exp.y
698	${YACC} $(srcdir)/m2-exp.y
699	-sed -e '/extern.*malloc/d' \
700	     -e '/extern.*realloc/d' \
701	     -e '/extern.*free/d' \
702	  < y.tab.c > m2-exp.tab.c
703	-rm y.tab.c
704
705xgdb.o: defs.h symtab.h frame.h
706
707main.o:	${srcdir}/main.c
708	${CC} -c ${INTERNAL_CFLAGS} -I${READLINE_DIR} $<
709
710# The symbol-file readers have dependencies on BFD header files.
711dbxread.o: ${srcdir}/dbxread.c
712	${CC} -c ${INTERNAL_CFLAGS} -I$(BFD_DIR) ${srcdir}/dbxread.c
713
714coffread.o: ${srcdir}/coffread.c
715	${CC} -c ${INTERNAL_CFLAGS} -I$(BFD_DIR) ${srcdir}/coffread.c
716
717mipsread.o: ${srcdir}/mipsread.c
718	${CC} -c ${INTERNAL_CFLAGS} -I$(BFD_DIR) ${srcdir}/mipsread.c
719
720elfread.o: ${srcdir}/elfread.c
721	${CC} -c ${INTERNAL_CFLAGS} -I$(BFD_DIR) ${srcdir}/elfread.c
722
723dwarfread.o: ${srcdir}/dwarfread.c
724	${CC} -c ${INTERNAL_CFLAGS} -I$(BFD_DIR) ${srcdir}/dwarfread.c
725
726stabsread.o: ${srcdir}/stabsread.c
727	${CC} -c ${INTERNAL_CFLAGS} -I$(BFD_DIR) ${srcdir}/stabsread.c
728
729xcoffread.o: ${srcdir}/xcoffread.c
730	${CC} -c ${INTERNAL_CFLAGS} -I$(BFD_DIR) ${srcdir}/xcoffread.c
731
732xcoffexec.o: ${srcdir}/xcoffexec.c
733	${CC} -c ${INTERNAL_CFLAGS} -I$(BFD_DIR) ${srcdir}/xcoffexec.c
734
735# Drag in the files that are in another directory.
736
737xdr_ld.o: ${srcdir}/vx-share/xdr_ld.c
738	${CC} -c ${INTERNAL_CFLAGS} ${srcdir}/vx-share/xdr_ld.c
739
740xdr_ptrace.o: ${srcdir}/vx-share/xdr_ptrace.c
741	${CC} -c ${INTERNAL_CFLAGS} ${srcdir}/vx-share/xdr_ptrace.c
742
743xdr_rdb.o: ${srcdir}/vx-share/xdr_rdb.c
744	${CC} -c ${INTERNAL_CFLAGS} ${srcdir}/vx-share/xdr_rdb.c
745
746xdr_regs.o: ${srcdir}/vx-share/xdr_regs.c
747	${CC} -c ${INTERNAL_CFLAGS} ${srcdir}/vx-share/xdr_regs.c
748
749nindy.o: ${srcdir}/nindy-share/nindy.c
750	${CC} -c ${INTERNAL_CFLAGS} -DSTRIP='"$(tooldir)/bin/strip"' \
751		${srcdir}/nindy-share/nindy.c
752
753Onindy.o: ${srcdir}/nindy-share/Onindy.c
754	${CC} -c ${INTERNAL_CFLAGS} ${srcdir}/nindy-share/Onindy.c
755
756ttybreak.o: ${srcdir}/nindy-share/ttybreak.c
757	${CC} -c ${INTERNAL_CFLAGS} ${srcdir}/nindy-share/ttybreak.c
758
759ttyflush.o: ${srcdir}/nindy-share/ttyflush.c
760	${CC} -c ${INTERNAL_CFLAGS} ${srcdir}/nindy-share/ttyflush.c
761
762lint: $(LINTFILES)
763	$(LINT) $(INCLUDE_CFLAGS) $(LINTFLAGS) $(LINTFILES) \
764	   `echo ${DEPFILES} | sed 's/\.o /\.c /g'
765
766gdb.cxref: $(SFILES)
767	cxref -I. $(SFILES) >gdb.cxref
768
769force_update:
770
771# GNU Make has an annoying habit of putting *all* the Makefile variables
772# into the environment, unless you include this target as a circumvention.
773# Rumor is that this will be fixed (and this target can be removed)
774# in GNU Make 4.0.
775.NOEXPORT:
776
777# This is the end of "Makefile.in".  When built into "Makefile"
778# by the configure script, two things are added below this point:
779# 	alldeps.mak -- defintions of all files that are used in
780#			host- or target-dependent configurations
781#	depend -- what .o files depend on what .c and .h files,
782#			for all configurations.
783
784
785