
#---------------------------------------------------------------------
# To make Dalek, first configure by e.g.    "config.gdb  vax".
# Then specify a pathname below for DFLAGS, but ONLY if you want Dalek
# to write a record of who/when is using it to a logging file.
# If so, make sure the file you define as USERLOG is writable by everyone.
# If you don't define a pathname here, no logging code will be generated. 
#---------------------------------------------------------------------

# On HPUX, you need to add -Ihpux to CFLAGS.
# The headers in the subdir hpux override system headers
# and tell GDB to use BSD executable file format.
# You also need to add -lGNU to CLIBS, and perhaps CC = gcc.

# On USG (System V) machines, you must make sure to setup REGEX &
# REGEX1 to point at regex.o and use the USG version of CLIBS.

# On Sunos 4.0 machines, make sure to compile *without* shared
# libraries if you want to run gdb on itself.  Make sure to compile
# any program on which you want to run gdb without shared libraries.

# If you are compiling with gcc, make sure that either 1) You use the
# -traditional flag, or 2) You have the fixed include files where gcc
# can reach them.  Otherwise the ioctl calls in inflow.c will be
# incorrectly compiled.

#CC=/bin/cc
# MIGHT NEED TO HARDCODE A PATHNAME BELOW FOR gcc.
GCC  = gcc -traditional
#	RC 7/31/89:  CC has void funptr bug in execute_command() !
#	RC 8/07/89:  However, GCC (on ivy) blows up on rxp.c with only explanation:
#		gcc -I. -g -O -c rxp.c
#		gcc: Program cc1 got fatal signal 6.

CC  = cc
#CC  = gcc -traditional  -pcc-struct-return
#CC  = gcc -traditional -fpcc-struct-return  -fwritable-strings    
#          -writable-strings is NOT part of -traditional !
#  Note that version of gcc on IVY does NOT take the "-f" option prefix!
# Also, IVY (but not iris) will still segfault even w/ -pcc-struct-return flag!

# Set this up with gcc if you have gnu ld and the loader will print out
# line numbers for undefinded refs.  
CC-LD=${CC}

# -I. for "#include <obstack.h>".  Possibly regex.h also.
CFLAGS = -I. -g   -DSTEPS_SEE_BPTS
# DFLAGS is needed by rxp.c if it monitors who is using dalek
#DFLAGS =  -DUSERLOG=\"/usr/home/debug/.LOGFILE\"
# Note the above is where we should also define GNU_MALLOC if 
# we are using any special malloc routines specified below.

#LDFLAGS = -pg


# define this to be "obstack.o" if you don't have the obstack library installed
# you must at the same time define OBSTACK1 as "obstack.o" 
# so that the dependencies work right.  Similarly with REGEX and "regex.o".
# You must define REGEX and REGEX1 on USG machines.
OBSTACK = obstack.o
OBSTACK1 = obstack.o
REGEX = 
REGEX1 =

#
# define this to be "malloc.o" if you want to use the gnu malloc routine
# (useful for debugging memory allocation problems in gdb).  Otherwise, leave
# it blank.
#GNU_MALLOC = malloc.o
# ultrix has none!   GNU_MALLOC = /usr/lib/debug/malloc.o

# Flags to be used in compiling malloc.o
# Specify range checking for storage allocation.
#MALLOC_FLAGS =
#MALLOC_FLAGS = ${CFLAGS} -Drcheck -Dbotch=fatal -DMSTATS

# for BSD
CLIBS = $(OBSTACK) $(REGEX) $(GNU_MALLOC)   -lcurses -ltermcap
# for USG
#CLIBS= $(OBSTACK) $(REGEX) $(GNU_MALLOC) -lPW

SFILES = blockframe.c breakpoint.c coffread.c command.c core.c dbxread.c \
	 environ.c eval.c expprint.c findvar.c infcmd.c inflow.c infrun.c \
	 kdb-start.c main.c printcmd.c \
	 remote.c source.c stack.c standalone.c stuff.c symmisc.c symtab.c \
	 utils.c valarith.c valops.c valprint.c values.c version.c expread.y \
	 xgdb.c

DEPFILES = default-dep.c sun3-dep.c
#DEPFILES = convex-dep.c umax-dep.c gould-dep.c default-dep.c sun3-dep.c \
	   sparc-dep.c hp9k320-dep.c news-dep.c i386-dep.c

PINSNS = vax-pinsn.c m68k-pinsn.c 
#PINSNS = gld-pinsn.c i386-pinsn.c sparc-pinsn.c vax-pinsn.c m68k-pinsn.c \
	 ns32k-pinsn.c

HFILES = command.h defs.h environ.h expression.h frame.h getpagesize.h \
	 inferior.h robotussin.h symseg.h symtab.h \
	 value.h wait.h 

OPCODES = m68k-opcode.h vax-opcode.h
#OPCODES = m68k-opcode.h pn-opcode.h sparc-opcode.h npl-opcode.h vax-opcode.h \
	  ns32k-opcode.h

MFILES = m-hp9k320.h m-i386.h m-isi.h m-merlin.h m-news.h m-npl.h m-pn.h \
	 m-sparc.h m-sun2.h m-sun3.h m-sunos4.h m-umax.h m-vax.h

POSSLIBS = obstack.h obstack.c regex.c regex.h malloc.c

TESTS = testbpt.c testfun.c testrec.c testreg.c testregs.c

OTHERS = Makefile createtags munch config.gdb ChangeLog README TAGS \
	 gdb.texinfo .gdbinit COPYING

TAGFILES = ${SFILES} ${DEPFILES} ${PINSNS} ${HFILES} ${OPCODES} ${MFILES} \
	   ${POSSLIBS}
TARFILES = ${TAGFILES} ${OTHERS}

OBS = main.o blockframe.o breakpoint.o findvar.o stack.o source.o \
    values.o eval.o valops.o valarith.o valprint.o printcmd.o \
    symtab.o symmisc.o coffread.o dbxread.o infcmd.o infrun.o remote.o \
    command.o utils.o expread.o expprint.o pinsn.o environ.o version.o

TSOBS = core.o inflow.o dep.o

NTSOBS = standalone.o

TSSTART = /lib/crt0.o

NTSSTART = kdb-start.o

RICK = rxp.o rif.o rwh.o avl.o pb.o dedit.o
WILSON = internal-functions.o event.o dataflow.o local-variables.o monitor.o


dalek : $(OBS) $(TSOBS) $(OBSTACK1) $(REGEX1) $(RICK) $(WILSON)
	munch $(OBS) $(RICK) $(WILSON) $(TSOBS) > init.c
	cc -c $(CFLAGS) init.c
	${CC-LD} $(LDFLAGS) -o dalek init.o $(OBS) $(RICK) $(WILSON) \
												$(TSOBS) $(CLIBS)



# If it can figure out the appropriate order, createtags will make sure
# that the proper m-*, *-dep, *-pinsn, and *-opcode files come first
# in the tags list.  It will attempt to do the same for dbxread.c and 
# coffread.c.  This makes using M-. on machine dependent routines much 
# easier.
#
TAGS: ${TAGFILES}
	createtags ${TAGFILES}
tags: TAGS

gdb.tar: ${TARFILES}
	rm -f gdb.tar
	mkdir dist-gdb
	cd dist-gdb ; for i in ${TARFILES} ; do ln -s ../$$i . ; done
	tar chf gdb.tar dist-gdb
	rm -rf dist-gdb

gdb.tar.Z: gdb.tar
	compress gdb.tar

clean:
	-rm ${OBS}
	-rm gdb

squeakyclean: clean
	-rm expread.tab.c

xgdb.o : xgdb.c defs.h param.h symtab.h frame.h
	$(CC) -c $(CFLAGS) xgdb.c -o $@

expread.tab.c : expread.y
	@echo 'Expect 101 shift/reduce conflicts and 1 reduce/reduce conflict.'
	yacc expread.y
	mv y.tab.c expread.tab.c

expread.o : expread.tab.c defs.h param.h symtab.h frame.h expression.h
	$(CC) -c ${CFLAGS} expread.tab.c
	mv expread.tab.o expread.o

#
# Only useful if you are using the gnu malloc routines.
#
malloc.o : malloc.c
	${CC} -c ${MALLOC_FLAGS} malloc.c

#
# dep.o depends on ALL the dep files since we don't know which one
# is really being used.
#
dep.o : ${DEPFILES} defs.h param.h frame.h inferior.h obstack.h

# pinsn.o depends on ALL the opcode printers
# since we don't know which one is really being used.
pinsn.o : ${PINSNS} defs.h param.h symtab.h obstack.h symseg.h frame.h \
	  ${OPCODES}

#
# The rest of this is a standard dependencies list (hand edited output of
# cpp -M).  It does not include dependencies of .o files on .c files.
#
blockframe.o : defs.h param.h symtab.h obstack.h symseg.h frame.h 
breakpoint.o : defs.h param.h symtab.h obstack.h symseg.h frame.h \
								breakpoint.h  pb.h more.h
	cc -c $(CFLAGS) breakpoint.c
#   RC 8/13/89:  GCC on IVY has bug w/ decode_line_1() -
#                Even using  -pcc-struct-return option, interface is wrong.

coffread.o : defs.h param.h 
command.o : command.h defs.h
core.o : defs.h  param.h
dbxread.o : param.h obstack.h defs.h symtab.h obstack.h symseg.h 
environ.o : environ.h 
eval.o : defs.h  param.h symtab.h obstack.h symseg.h value.h expression.h 
expprint.o : defs.h symtab.h obstack.h symseg.h param.h expression.h
findvar.o : defs.h param.h symtab.h obstack.h symseg.h frame.h value.h 
infcmd.o : defs.h  param.h symtab.h obstack.h symseg.h frame.h inferior.h \
	   environ.h value.h breakpoint.h
inflow.o : defs.h  param.h frame.h inferior.h
infrun.o : defs.h  param.h symtab.h obstack.h symseg.h frame.h inferior.h \
	   wait.h more.h
kdb-start.o : defs.h param.h 

# MIGHT NEED TO HARDCODE A PATHNAME BELOW FOR gcc.
main.o : defs.h  command.h param.h breakpoint.h savestate.h
	$(GCC) -Dvolatile=     -c $(CFLAGS) main.c

#   RC 7/31/89:  CC has void funptr bug in execute_command() !
#   RC 9/89   : New Ultrix sys/includes use "volatile", which gcc doesn't know.


malloc.o :  getpagesize.h
obstack.o : obstack.h 
printcmd.o :  defs.h param.h frame.h symtab.h obstack.h symseg.h value.h \
	      expression.h 
regex.o : regex.h 
remote.o : defs.h  param.h frame.h inferior.h wait.h
source.o : defs.h  symtab.h obstack.h symseg.h param.h
stack.o :  defs.h param.h symtab.h obstack.h symseg.h frame.h 
standalone.o : defs.h param.h symtab.h obstack.h symseg.h frame.h \
	       inferior.h wait.h 
symmisc.o : defs.h symtab.h obstack.h symseg.h obstack.h 
symtab.o : defs.h  symtab.h obstack.h symseg.h param.h  obstack.h more.h
utils.o : defs.h  param.h \
								breakpoint.h
valarith.o : defs.h param.h symtab.h obstack.h symseg.h value.h expression.h 
valops.o :  defs.h param.h symtab.h obstack.h symseg.h value.h frame.h \
	    inferior.h
valprint.o :  defs.h param.h symtab.h obstack.h symseg.h value.h 
values.o :  defs.h param.h symtab.h obstack.h symseg.h value.h 

robotussin.h : getpagesize.h   
symtab.h : obstack.h symseg.h 


event.o : event.c defs.h value.h expression.h symtab.h \
		event.h breakpoint.h more.h

dataflow.o : dataflow.c defs.h event.h expression.h
internal-functions.o : internal-functions.c defs.h value.h \
		symtab.h local-variables.h breakpoint.h more.h internal-functions.h
rif.o : rif.c defs.h value.h breakpoint.h
rwh.o : rwh.c defs.h value.h breakpoint.h
local-variables.o : defs.h value.h symtab.h
monitor.o : defs.h value.h symtab.h

dedit.o:  dedit.c  defs.h breakpoint.h event.h internal-functions.h pb.h \
			command.h breakpoint.h
	cc -c $(CFLAGS)   dedit.c

rxp.o:  rxp.c  defs.h value.h symtab.h expression.h breakpoint.h \
			   savestate.h more.h
	cc -c $(CFLAGS)  $(DFLAGS)  rxp.c

pb.o:   pb.c defs.h pb.h param.h more.h


