#
# dmakefile for jed 2.x and utilities
#
# 1> dmake [jed]	; compile the jed executable
# 1> dmake makerefs	; compile makerefs
# 1> dmake pubman	; compile pubman
# 1> dmake all		; compile jed, makerefs & pubman
# 1> dmake clean	; delete machine generated files (not executables)
# 1> dmake refs		; make references for source files
#
# the directory dtmp:jed is used for storing most machine-generated files
#

EXEC = ram:jed
OD   = dtmp:jed/
SRCS = command.c commandline.c edit.c editcommands.c find.c housekeeping.c \
       initsymbols.c io.c keys.c main.c menus.c minrexx.c misc.c movement.c \
       prefs.c refs.c render.c scriptcmds.c windows.c sprintf.a stksize.a \
       varargs.a
HDRS = jed.h command.h
OBJS = $(SRCS:"*.?":"$(OD)%1.o")
PROT = $(OD)jed_protos.h
PREC = $(OD)jed.m
REV  = revision
REVOBJS = $(OD)prefs.o $(OD)windows.o

#CFLAGS = -r -mRR -I$(OD) -H$(PREC)=jed.h
#CFLAGS = -mRR -s -I$(OD) -H$(PREC)=jed.h -D DEBUG
CFLAGS = -r -mRR -s -I$(OD) -H$(PREC)=jed.h

jed : $(PROT) $(PREC) $(EXEC)

$(EXEC) : $(OBJS)
    -bumprev 2 jed_rev
    dcc $(REV).c -o $(OD)$(REV).o -c $(CFLAGS)
    cd $(OD)
    dcc $(REV).o $(OBJS:"$(OD)*.o":"%1.o") hash.o -lregexp -o $(EXEC) $(CFLAGS)
    cd

$(OBJS) : $(SRCS)
    dcc %(right) -o %(left) -c $(CFLAGS)

$(OBJS) :: $(HDRS)

$(REVOBJS) : $(REV).h

$(PROT) : $(SRCS)
    makeproto -o $(PROT) $(SRCS)

$(PREC) : $(HDRS)
    -delete $(PREC)

makerefs :
    dcc makerefs.c -o ram:makerefs -pr

# The version of DICE I used (2.06.40) has some problems with this. The
# c*.lib function LockAddr() has an absolute reference to SysBase, therefore
# screwing the residentability. To get round this simply put the files cs.lib
# and csr.lib through the libtos utility.
pubman :
    dcc pubman.c -o ram:pubman -pr -mRR

refs :
    makerefs -new .jrefs #?.[ach]

all : jed makerefs pubman

clean :
    -delete $(OD)#?
