##########################################################################
#
#	@(#)Makefile	1.14 
#
#	Copyright 1995, Willows Software Inc.
#
##########################################################################

include $(TWINDIR)/makeinclude/Makefile.$(TARGET)$(COMPILER)

#########################################################################

DEBUG_XXX       =$(TWINOPT:DBG=-DDEBUG -DTRACE) $(TWINOPT:OPT=$(CCOPTIM)) $(TWINOPT:PROF=-p)
DEBUG_XX        =$(DEBUG_XXX:PROF=)
DEBUG_X         =$(DEBUG_XX:DBG=)
DEBUG           =$(DEBUG_X:OPT=)

GFLAG_XXX       =$(TWINOPT:DBG=-g) 
GFLAG_XX        =$(GFLAG_XXX:PROF=)
GFLAG_X         =$(GFLAG_XX:DBG=)
GFLAG           =$(GFLAG_X:OPT=)

# Tags that are appended to exec and libs when installed.
APPEND_XX       =$(TWINOPT:PROF=_prof)
APPEND_X        =$(APPEND_XX:DBG=_dbg)
APPEND          =$(APPEND_X:OPT=)

COPY 	= cp

#########################################################################

# The -D$(TARGET) is only needed because the modules have conditional
# compilation based on "linux", rather than "LINUX".  Once the modules
# in this directory have been changed, remove this -D option.

CCOPTS	= -I$(TWINDIR)/$(TWINSRC) -I$(TWINDIR)/include $(TWIN_SYSINC)
CFLAGS  = $(CCOPTS) -D$(TARGET) $(PLATFORM) $(BINARY) $(GFLAG) $(DEBUG) \
	$(AUX) -DUSE_READLINE

BISONFLAGS = -p TWIN_dbg_
BISON = bison $(BISONFLAGS)
  
#########################################################################

DEBUGGEROBJ = \
	break.o db_disasm.o dbg.tab.o hash.o info.o lex.twin.o function.o \
	alias.o help.o alloca.o

DEBUGGERSRC = \
	break.c db_disasm.c dbg.tab.c hash.c info.c lex.twin.c function.c \
	alias.c help.c alloca.c

DEBUGGERHDR = \
	db_disasm.h  regpos.h alias.h

#########################################################################

all:	debugger.o

debugger.o: $(DEBUGGEROBJ) $(TWINDIR)/$(TWINSRC)/debugger.o
	$(LD) -r -o debugger.o $(DEBUGGEROBJ)
	$(COPY) debugger.o $(TWINDIR)/$(TWINSRC)/debugger.o

$(TWINDIR)/$(TWINSRC)/debugger.o:

dbg.tab.c dbg.tab.h: dbg.y
	$(BISON) -b dbg -d dbg.y

lex.twin.c: debug.l
	$(LEX) -I debug.l
	sed -e 's/yy/TWIN_dbg_/g' < lex.yy.c > lex.twin.c

clobber: 	
	rm -rf debugger.o $(DEBUGGEROBJ) dbg.tab.c dbg.tab.h lex.yy.c *~

clean:	clobber

sdiffs:
	@for f in $(DEBUGGERSRC) $(DEBUGGERHDR); do echo $$f;sdiffs $$f; done

ctags:
	ctags *.c *.h >/dev/null 2>&1

depend: $(DEBUGGERSRC)
	$(STRIP) Makedepend.$(TARGET)
	makedepend -f Makedepend.$(TARGET) $(TWIN_SYSINC) $(DEBUGGERSRC)

list:
	@for f in $(DEBUGGEROBJ); do echo $$f;done

link:	clean
	for f in $(DEBUGGEROBJ); do echo ../$$TARGET/$$EXT/$$f; ln -s ../$$TARGET/$$EXT/$$f $$f ; done 

writable:
	@ls -lrt *.[ch] |grep "\-rw"

##########################################################################
#
# Source file dependencies are located in Makedepend.$(TARGET)
#
include Makedepend.$(TARGET)

##########################################################################
#
#
# DO NOT DELETE THIS LINE -- make depend depends on it.
