###############################################################################
#
# File:         makefile
# RCS:          $Header: $
# Description:  Makefile for building Emacs under MSDOS with DJGPP
# Author:       Darryl Okahata
# Created:      Tue Jun  8 21:59:31 1993
# Modified:     Tue Aug 17 23:04:40 1993 (darrylo@home) darrylo@hostigos
# Language:     N/A
# Package:      N/A
#
# (C) Copyright 1993, Darryl Okahata, all rights reserved.
#
###############################################################################

# The following paths must use FORWARD slashes:
DJGPP_LIB_DIR=e:/djgpp/lib

# DESQview/X support...
#DJGPP_XLIB_DIR=$(DJGPP_LIB_DIR)
DJGPP_XLIB_DIR=c:/gcc/dvx/lib

# For debugging, use:
CFLAGS= -g
# For production code, use:
CFLAGS= -O

DEBUGDEFINES= -Drcheck -DDEBUG_EMACS
DEFINES= -I. -DDVX -Demacs -DHAVE_CONFIG_H $(DEBUGDEFINES)

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

CC=gcc

.c.o:
	$(CC) -c $(CFLAGS) $(DEFINES) -o $@ $<


dot = .
lispdir = $(dot)$(dot)/lisp/
etcdir = $(dot)$(dot)/etc/
libdir = $(dot)$(dot)/lib-src/

XSRC = xfaces.c xfns.c xmenu.c xrdb.c xselect.c xterm.c
XOBJ = dvx/xfaces.o dvx/xfns.o dvx/xmenu.o dvx/xrdb.o dvx/xselect.o dvx/xterm.o
XLIB = -L$(DJGPP_XLIB_DIR) -L../oldXmenu -lXmenu -lX -lsys -lc

environobj =

# oemacs.s can't be in the following list
src=    dispnew.c frame.c scroll.c xdisp.c window.c \
	term.c cm.c $(XSRC) \
	emacs.c keyboard.c macros.c keymap.c sysdep.c \
	buffer.c filelock.c insdel.c marker.c \
	interval.c textprop.c \
	minibuf.c fileio.c dired.c filemode.c \
	cmds.c casetab.c casefiddle.c indent.c search.c \
	regex.c undo.c \
	alloc.c data.c doc.c editfns.c callint.c \
	eval.c floatfns.c fns.c print.c lread.c \
	abbrev.c syntax.c unexec.c mocklisp.c bytecode.c \
	process.c callproc.c $(environobj) \
	doprnt.c getloada.c \
	dosfns.c pwd.c mktemp.c \
	pc-term.c pc-faces.c dvxfns.c

obj=    dvx/dispnew.o dvx/frame.o dvx/scroll.o dvx/xdisp.o dvx/window.o \
	dvx/term.o dvx/cm.o $(XOBJ) \
	dvx/emacs.o dvx/keyboard.o dvx/macros.o dvx/keymap.o dvx/sysdep.o \
	dvx/buffer.o dvx/filelock.o dvx/insdel.o dvx/marker.o \
	dvx/interval.o dvx/textprop.o \
	dvx/minibuf.o dvx/fileio.o dvx/dired.o dvx/filemode.o \
	dvx/cmds.o dvx/casetab.o dvx/casefiddle.o dvx/indent.o dvx/search.o \
	dvx/regex.o dvx/undo.o \
	dvx/alloc.o dvx/data.o dvx/doc.o dvx/editfns.o dvx/callint.o \
	dvx/eval.o dvx/floatfns.o dvx/fns.o dvx/print.o dvx/lread.o \
	dvx/abbrev.o dvx/syntax.o dvx/unexec.o dvx/mocklisp.o dvx/bytecode.o \
	dvx/process.o dvx/callproc.o $(environobj) \
	dvx/doprnt.o dvx/getloada.o \
	dvx/dosfns.o dvx/pwd.o dvx/mktemp.o \
	dvx/oemacs.o dvx/pc-term.o dvx/pc-faces.o dvx/dvxfns.o

termcapobj = dvx/termcap.o dvx/tparam.o

mallocobj = # dvx/gmalloc.o dvx/vm-limit.o

otherobj= dvx/firstfil.o $(termcapobj) dvx/lastfile.o $(mallocobj)

lisp= \
	${lispdir}abbrev.elc \
	${lispdir}buff-menu.elc \
	${lispdir}byte-run.elc \
	${lispdir}c-mode.elc \
	${lispdir}files.elc \
	${lispdir}fill.elc \
	${lispdir}float-sup.elc \
	${lispdir}help.elc \
	${lispdir}indent.elc \
	${lispdir}isearch.elc \
	${lispdir}lisp-mode.elc \
	${lispdir}lisp.elc \
	${lispdir}loaddefs.el \
	${lispdir}map-ynp.elc \
	${lispdir}page.elc \
	${lispdir}paragraphs.elc \
	${lispdir}paths.el \
	${lispdir}register.elc \
	${lispdir}replace.elc \
	${lispdir}simple.elc \
	${lispdir}startup.elc \
	${lispdir}subr.elc \
	${lispdir}text-mode.elc \
	${lispdir}vc-hooks.elc \
	${lispdir}window.elc \
	${lispdir}nonstd/oemacs.elc \
	${lispdir}nonstd/demacs.elc \
	${lispdir}nonstd/dos-fns.elc

all: dvx doc emacs

dvx:
	mkdir dvx

doc:	$(etcdir)DOC

$(etcdir)DOC: ..\lib-src\make-doc.exe $(src) $(lisp)
	>erf *.c $(lisp)
#	>erf $(src) $(lisp)
	..\lib-src\make-doc -o ..\etc\doc @erf

temacs:   $(obj) $(otherobj) dvx/crt0.o
	>lrf dvx/crt0.o $(obj) $(otherobj)
	>>lrf -L$(DJGPP_LIB_DIR) -lpc -lm -lc $(XLIB)
	ld -e __start -o temacs @lrf

stripped: emacs
	strip emacs
	aout2exe emacs

emacs:	temacs $(etcdir)DOC
	go32 temacs -batch -l loadup.el dump

emacs.exe:	emacs
	aout2exe emacs

dvx/crt0.o : crt0.c config.h
	$(CC) -c $(CFLAGS) -o dvx/crt0.o  crt0.c

# Don't compile keyboard.c with optimization
dvx/keyboard.o: keyboard.c
	$(CC) -c $(DEFINES) -o dvx/keyboard.o keyboard.c

dvx/oemacs.o: oemacs.s
	$(CC) -c $(CFLAGS) -o dvx/oemacs.o oemacs.s

install:	emacs.exe ..\bin.dvx
	copy emacs.exe ..\bin.dvx

clean:
	-del dvx\*.o
	-del *.err
	-del temacs.exe
	-del temacs.map
	-del erf
	-del lrf
	-del temacs
	-del emacs

###############################################################################
# DEPENDENCIES (DO NOT CHANGE THIS LINE OR ANYTHING PAST IT)
dvx/abbrev.o:	abbrev.c config.h lisp.h commands.h buffer.h window.h
dvx/alloc.o:	alloc.c config.h lisp.h intervals.h puresize.h buffer.h window.h frame.h blockinput.h syssignal.h
dvx/alloca.o:	alloca.c config.h
dvx/buffer.o:	buffer.c config.h lisp.h intervals.h window.h commands.h buffer.h syntax.h indent.h blockinput.h
dvx/bytecode.o:	bytecode.c config.h lisp.h buffer.h syntax.h
dvx/callint.o:	callint.c config.h lisp.h buffer.h commands.h keyboard.h window.h mocklisp.h
dvx/callproc.o:	callproc.c config.h lisp.h commands.h buffer.h paths.h process.h syssignal.h
dvx/casefidd.o:	casefidd.c config.h lisp.h buffer.h commands.h syntax.h
dvx/casetab.o:	casetab.c config.h lisp.h buffer.h
dvx/cm.o:	cm.c config.h cm.h termhooks.h
dvx/cmds.o:	cmds.c config.h lisp.h commands.h buffer.h syntax.h
dvx/crt0.o:	crt0.c config.h
dvx/data.o:	data.c config.h lisp.h puresize.h buffer.h syssignal.h
dvx/director.o:	director.c dosdir.h dpmi.h
dvx/dired.o:	dired.c config.h dosdir.h ndir.h lisp.h buffer.h commands.h regex.h
dvx/dispnew.o:	dispnew.c config.h lisp.h termchar.h termopts.h termhooks.h cm.h dispextern.h buffer.h frame.h window.h commands.h disptab.h indent.h systty.h systime.h xterm.h
dvx/doc.o:	doc.c config.h lisp.h buffer.h keyboard.h
dvx/doprnt.o:	doprnt.c 
dvx/dosfns.o:	dosfns.c config.h dpmi.h lisp.h frame.h buffer.h termchar.h dosfns.h pccompat.h
dvx/dpmi.o:	dpmi.c dpmi.h
dvx/dvxfns.o:	dvxfns.c config.h
dvx/editfns.o:	editfns.c config.h pwd.h lisp.h intervals.h buffer.h window.h systime.h
dvx/emacs.o:	emacs.c config.h lisp.h commands.h intervals.h systty.h syssignal.h termchar.h
dvx/eval.o:	eval.c config.h lisp.h blockinput.h commands.h keyboard.h
dvx/fileio.o:	fileio.c config.h lisp.h dosfns.h pwd.h config.h lisp.h intervals.h buffer.h window.h systime.h
dvx/filelock.o:	filelock.c config.h pwd.h lisp.h paths.h buffer.h
dvx/filemode.o:	filemode.c config.h
dvx/firstfil.o:	firstfil.c 
dvx/fixpath.o:	fixpath.c 
dvx/floatfns.o:	floatfns.c config.h lisp.h syssignal.h
dvx/fns.o:	fns.c config.h lisp.h commands.h buffer.h keyboard.h intervals.h
dvx/frame.o:	frame.c config.h lisp.h frame.h buffer.h window.h termhooks.h commands.h keyboard.h
dvx/getloada.o:	getloada.c config.h
dvx/gmalloc.o:	gmalloc.c config.h lisp.h getpagesize.h
dvx/hftctl.o:	hftctl.c 
dvx/indent.o:	indent.c config.h lisp.h buffer.h indent.h frame.h window.h termchar.h termopts.h disptab.h
dvx/insdel.o:	insdel.c config.h lisp.h intervals.h buffer.h window.h blockinput.h
dvx/interval.o:	interval.c config.h lisp.h intervals.h buffer.h
dvx/keyboard.o:	keyboard.c config.h termchar.h termopts.h lisp.h termhooks.h macros.h frame.h window.h commands.h buffer.h disptab.h dispextern.h keyboard.h intervals.h blockinput.h syssignal.h systty.h systime.h
dvx/keymap.o:	keymap.c config.h lisp.h commands.h buffer.h keyboard.h termhooks.h blockinput.h
dvx/lastfile.o:	lastfile.c 
dvx/link.o:	link.c 
dvx/lread.o:	lread.c config.h lisp.h buffer.h paths.h commands.h keyboard.h termhooks.h
dvx/macros.o:	macros.c config.h lisp.h macros.h commands.h buffer.h window.h
dvx/marker.o:	marker.c config.h lisp.h buffer.h
dvx/minibuf.o:	minibuf.c config.h lisp.h commands.h buffer.h dispextern.h frame.h window.h syntax.h
dvx/mktemp.o:	mktemp.c 
dvx/mocklisp.o:	mocklisp.c config.h lisp.h buffer.h
dvx/pc-faces.o:	pc-faces.c config.h lisp.h buffer.h dispextern.h frame.h window.h pc-term.h pc-rgb.h
dvx/pc-term.o:	pc-term.c config.h lisp.h dispextern.h termhooks.h termopts.h termchar.h frame.h systime.h dosfns.h pccompat.h disptab.h pc-term.h
dvx/pre-crt0.o:	pre-crt0.c 
dvx/prefix-a.o:	prefix-a.c 
dvx/print.o:	print.c config.h lisp.h buffer.h frame.h window.h process.h dispextern.h termchar.h intervals.h
dvx/process.o:	process.c config.h systime.h systty.h lisp.h window.h buffer.h process.h termhooks.h termopts.h commands.h frame.h syssignal.h lisp.h systime.h termopts.h
dvx/pwd.o:	pwd.c pwd.h
dvx/ralloc.o:	ralloc.c config.h lisp.h config.h getpagesize.h
dvx/random.o:	random.c 
dvx/regex.o:	regex.c config.h lisp.h buffer.h syntax.h regex.h
dvx/scroll.o:	scroll.c config.h termchar.h lisp.h dispextern.h frame.h
dvx/search.o:	search.c config.h lisp.h syntax.h buffer.h commands.h blockinput.h regex.h
dvx/sunfns.o:	sunfns.c config.h lisp.h window.h buffer.h termhooks.h
dvx/syntax.o:	syntax.c config.h lisp.h commands.h buffer.h syntax.h
dvx/sysdep.o:	sysdep.c config.h lisp.h blockinput.h systty.h frame.h window.h termhooks.h termchar.h termopts.h dispextern.h process.h ndir.h syssignal.h systime.h pccompat.h dosfns.h pccompat.h dpmi.h
dvx/term.o:	term.c config.h termchar.h termopts.h cm.h lisp.h frame.h disptab.h termhooks.h keyboard.h
dvx/termcap.o:	termcap.c config.h
dvx/terminfo.o:	terminfo.c 
dvx/textprop.o:	textprop.c config.h lisp.h intervals.h buffer.h
dvx/tparam.o:	tparam.c config.h
dvx/undo.o:	undo.c config.h lisp.h buffer.h
dvx/unexec.o:	unexec.c config.h getpagesize.h
dvx/vm-limit.o:	vm-limit.c config.h lisp.h mem-limits.h
dvx/window.o:	window.c config.h lisp.h buffer.h frame.h window.h commands.h indent.h termchar.h disptab.h keyboard.h
dvx/xdisp.o:	xdisp.c config.h lisp.h frame.h window.h termchar.h dispextern.h buffer.h indent.h commands.h macros.h disptab.h termhooks.h
dvx/xfaces.o:	xfaces.c config.h lisp.h xterm.h buffer.h dispextern.h frame.h blockinput.h window.h
dvx/xfns.o:	xfns.c config.h lisp.h xterm.h frame.h window.h buffer.h dispextern.h keyboard.h blockinput.h bitmaps/gray.xbm
dvx/xmenu.o:	xmenu.c config.h lisp.h frame.h window.h keyboard.h blockinput.h xterm.h dispextern.h ../oldXMenu/XMenu.h
dvx/xrdb.o:	xrdb.c config.h
dvx/xselect.o:	xselect.c config.h lisp.h termhooks.h xterm.h dispextern.h frame.h blockinput.h
dvx/xterm.o:	xterm.c config.h lisp.h blockinput.h xterm.h systty.h systime.h dispextern.h termhooks.h termopts.h termchar.h sink.h sinkmask.h gnu.h frame.h disptab.h buffer.h window.h
