#
# makefile for vile on WIN32 using Borland C++
#
# $Id: makefile.blc,v 1.25 2009/12/24 09:17:59 tom Exp $
#
# Tested with
#	Borland C++ 5.5.1
#	make 5.2
#
.autodepend

ICON = vile

TARGET = vile
SCREEN = ntconio
DISP_DEF = -DDISP_NTCONS=1
LDFLAGS = -v -tWM -tWC
EXTRA = $(EXTRA) dumbterm.obj
RESFILE =

# Use
#	make -Dwinvile
!ifdef  winvile
TARGET = winvile
SCREEN = ntwinio
DISP_DEF = -DDISP_NTWIN=1
LDFLAGS = -v -tWM -tW
RESFILE = $(TARGET).res
EXTRA = $(EXTRA) makeargv.obj
!endif

CFLAGS = -v -tWM -w-par -DWIN32_LEAN_AND_MEAN -DOPT_LOCALE=1 -Dscrn_chosen $(DISP_DEF) -I.

# Use
#	make -Dtrace
!ifdef	trace
CFLAGS = $(CFLAGS) -DOPT_TRACE=1
EXTRA = $(EXTRA) trace.obj
!endif

CC = bcc32

# these are normal editable headers
HDRS = estruct.h edef.h proto.h dirstuff.h

# these headers are built by the mktbls program from the information in cmdtbl
# and in modetbl
BUILTHDRS = \
	nebind.h \
	nefkeys.h \
	nefsms.h \
	nefunc.h \
	nemode.h \
	nename.h \
	neproto.h \
	nevars.h

SRC = 	main.c $(SCREEN).c \
	basic.c bind.c blist.c btree.c buffer.c \
	charsets.c csrch.c display.c eightbit.c \
	eval.c exec.c externs.c \
	fences.c file.c filec.c \
	fileio.c finderr.c glob.c globals.c history.c \
	input.c insert.c itbuff.c isearch.c \
	line.c modes.c msgs.c nullterm.c oneliner.c opers.c \
	path.c random.c regexp.c \
	region.c search.c select.c spawn.c statevar.c \
	tags.c tbuff.c termio.c ucrypt.c undo.c vl_ctype.c \
	version.c w32cmd.c w32cbrd.c w32misc.c w32oo.cpp w32pipe.c \
	wcwidth.c window.c word.c wordmov.c map.c

OBJ = 	main.obj $(SCREEN).obj \
	basic.obj bind.obj blist.obj btree.obj buffer.obj \
      	charsets.obj csrch.obj display.obj eightbit.obj \
	eval.obj exec.obj externs.obj \
	fences.obj file.obj filec.obj \
	fileio.obj finderr.obj glob.obj globals.obj history.obj \
	input.obj insert.obj itbuff.obj isearch.obj \
	line.obj modes.obj msgs.obj nullterm.obj oneliner.obj opers.obj \
	path.obj random.obj regexp.obj \
	region.obj search.obj select.obj spawn.obj statevar.obj \
	tags.obj tbuff.obj termio.obj ucrypt.obj undo.obj vl_ctype.obj \
	version.obj w32cmd.obj w32cbrd.obj w32misc.obj w32oo.obj w32pipe.obj \
	wcwidth.obj window.obj word.obj wordmov.obj map.obj $(EXTRA)

.c.obj:
	$(CC) $(CFLAGS) -c $<

.cpp.obj:
	$(CC) $(CFLAGS) -c $<

all :		$(TARGET).exe

sources :	$(BUILTHDRS)

$(TARGET).exe: 	$(BUILTHDRS) $(OBJ) $(RESFILE)
	$(CC) $(LDFLAGS) -e$(TARGET).exe @&&!
$(OBJ)
!
!ifdef winvile
	brc32 $(RESFILE)
!endif

nebind.h \
nefkeys.h \
neexec.h \
nefunc.h \
neproto.h :	nename.h

nename.h :	cmdtbl mktbls.exe
	mktbls.exe cmdtbl

nefsms.h \
nevars.h :	nemode.h

nemode.h :	modetbl mktbls.exe
	mktbls.exe modetbl

mktbls.exe:  mktbls.c
	$(CC) $(CFLAGS) mktbls.c

clean:
	- del *.bak
	- del *.map
	- del *.tds
	- del *.res
	- del *.exe
	- del *.obj
	- del ne*.h

VILEHDRS = $(BUILTHDRS) estruct.h

api.obj :	$(VILEHDRS)	api.h
$(SCREEN).obj :	$(VILEHDRS)	winvile.h pscreen.h patchlev.h
basic.obj :	$(VILEHDRS)
bind.obj :	$(VILEHDRS)
blist.obj :	$(VILEHDRS)	blist.h
btree.obj :	$(VILEHDRS)	btree.h
buffer.obj :	$(VILEHDRS)
charsets.obj :	$(VILEHDRS)
csrch.obj :	$(VILEHDRS)
display.obj :	$(VILEHDRS)	pscreen.h
eightbit.obj :	$(VILEHDRS)
eval.obj :	$(VILEHDRS)
exec.obj :	$(VILEHDRS)
externs.obj :	$(VILEHDRS)
fences.obj :	$(VILEHDRS)
file.obj :	$(VILEHDRS)
filec.obj :	$(VILEHDRS)	dirstuff.h
fileio.obj :	$(VILEHDRS)
finderr.obj :	$(VILEHDRS)
glob.obj :	$(VILEHDRS)	dirstuff.h
globals.obj :	$(VILEHDRS)
history.obj :	$(VILEHDRS)
input.obj :	$(VILEHDRS)
insert.obj :	$(VILEHDRS)
isearch.obj :	$(VILEHDRS)
itbuff.obj :	$(VILEHDRS)
line.obj :	$(VILEHDRS)
main.obj :	$(VILEHDRS)	chgdfunc.h 
map.obj :	$(VILEHDRS)
modes.obj :	$(VILEHDRS)	chgdfunc.h 
msgs.obj :	$(VILEHDRS)
nullterm.obj :	$(VILEHDRS)
oneliner.obj :	$(VILEHDRS)
opers.obj :	$(VILEHDRS)
path.obj :	$(VILEHDRS)	dirstuff.h
perl.obj :	$(VILEHDRS)	api.h
random.obj :	$(VILEHDRS)	dirstuff.h
regexp.obj :	$(VILEHDRS)
region.obj :	$(VILEHDRS)
search.obj :	$(VILEHDRS)
select.obj :	$(VILEHDRS)
spawn.obj :	$(VILEHDRS)
statevar.obj :	$(VILEHDRS)	patchlev.h
tags.obj :	$(VILEHDRS)	btree.h
tbuff.obj :	$(VILEHDRS)
termio.obj :	$(VILEHDRS)
trace.obj :	$(VILEHDRS)
ucrypt.obj :	$(VILEHDRS)
undo.obj :	$(VILEHDRS)
version.obj :	$(VILEHDRS)	patchlev.h
vl_ctype.obj :	$(VILEHDRS)	vl_ctype.h
w32cbrd.obj :	$(VILEHDRS)
w32cmd.obj :	$(VILEHDRS)	winvile.h
w32ole.obj :	$(VILEHDRS)	w32ole.h winviletlb.h w32reg.h
w32misc.obj :	$(VILEHDRS)
w32oo.obj :	$(VILEHDRS)	dirstuff.h
w32pipe.obj :	$(VILEHDRS)
w32reg.obj :	$(VILEHDRS)	w32reg.h
wcwidth.obj :	$(VILEHDRS)
window.obj :	$(VILEHDRS)
word.obj :	$(VILEHDRS)
wordmov.obj :	$(VILEHDRS)

wvwrap.obj :	w32reg.h w32ole.h winviletlb.h

winvile.res :	winvile.rc winvile.h
	$(RC) -32 -I$(MAKEDIR)\..\include -DVILE_ICON="$(ICON).ico" -Iicons winvile.rc
