# Makefile for ddt

# Description of conditional compilation flags
# DDTDBG
# DDTLM
# DDTNIN
# DDTBOOT - defined to get the command which invokes the boot program
# DDTCAT - defined when catting all the files together
# DDTUNIX - defined to get the UNIX a.out symbol table code
# DDTCMD - defined to include the command interpreter commands
# DDTSRC - defined to include the source debugging commands
# DDTSCRIPT - defined to include the DDT script commands

CFLAGS = -O -I. -DDDTDBG -DDDTUNIX -DDDTCMD -DDDTSRC -DDDTSCRIPT
DDTLMFLAGS = -O -I. -DDDTDBG -DDDTLM -DDDTNIN -DDDTCAT -DDDTSCRIPT -DDDTBOOT

SRC_SA = hcddt.c bpt.c script.c hc.c parse.c cmd.c ops.c val.c util.c \
	vax-mdep.c vax-lm.c symt-lm.c vax-disasm.c
OBJ_U = main.o parse.o cmd.o val.o ops.o util.o bpt.o hcddt.o symt-unix.o \
	hc.o vax-unix.o vax-disasm.o vax-mdep.o start.o script.o

# ddt_sa: $(ISYMT) $(FST) $(LIBDDT)

# $(GWLIB)/$(DDTST): isymt.o
#	cp fst.o $(FAKEDDTST)

# $(GWLIB)/$(FAKEDDTST): fst.o
#	cp fst.o $(FAKEDDTST)

all:: $(DDTST) $(FAKEDDTST) $(SCB) $(CRTDDT)
NormalLibraryObjectRule()
NormalLibraryTarget ($(GWLIB),$(DDTLIB),ddt_sa.o vax-hc.o)
	cp isymt.o $(GWLIB)/$(DDTST)
	cp fst.o $(GWLIB)/$(FAKEDDTST)
	cp scb.o $(GWLIB)/$(SCB)
	cp crtddt.o $(GWLIB)/crtddt.o

SingleProgramTarget(ddt, $(OBJ_U), /* no local lib */, /* no sys lib */)

ddt_sa.o: ddt_sa.c 
	cc -c $(DDTLMFLAGS) ddt_sa.c

ddt_sa.c: $(SRC_SA)
	cat $(SRC_SA) > ddt_sa.c
	
st.o: a.out
	nm -gn a.out | mksymt > st.s
	cc -c st.s

test: hello.o
	ld -X -e start $(GWLIB)/$(SCB) $(GWLIB)/$(CRTDDT) hello.o \
		 $(GWLIB)/$(DDTLIB) $(GWLIB)/$(CLIB) $(GWLIB)/$(DDTST) st.o

.c.s:
	cc -S $(CFLAGS) -DDDTBOOT $*.c
