# makefile.in is the makefile template for vile on unix systems.
# makefile is generated from makefile.in by running configure.
#
# If you edit makefile, your changes will be lost when you run configure
# again.  See the file INSTALL from instructions on how to configure, make,
# and install vile/xvile.
#
# The command/name/key/function bindings are defined in the file "cmdtbl".
# The mktbls program parses this to produce nebind.h, nename.h, neproto.h and
# nefunc.h, which are used by the rest of the build.
#
# Buffer/window modes are defined in the file "modetbl".
# The mktbls program parses this to produce nemode.h, which is included in
# 'estruct.h'.
#
# The version number is found near the top of edef.h, and is displayed with
# the ":version" command, or by invoking vile with "-V".
#
# Paul Fox
#
# gnu autoconf support by kevin buettner, 5/94
# original makefile for uemacs: Adam Fritz July 30,1987  (do you recognize it?)
#
# $Header: /usr/build/vile/vile/RCS/makefile.in,v 1.117 1998/10/02 01:04:17 tom Exp $
#

#### Start of system configuration section. ####

srcdir = @srcdir@
srcdir_sl = @srcdir@/
VPATH  = @srcdir@

CC		= @CC@
CPP		= @CPP@
LINK		= @LINK_PREFIX@ $(CC) $(CFLAGS)
INSTALL		= @INSTALL@
INSTALL_PROGRAM	= @INSTALL_PROGRAM@
INSTALL_DATA	= @INSTALL_DATA@

EXTRA_CFLAGS	= @EXTRA_CFLAGS@
CFLAGS		= @CFLAGS@ $(EXTRA_CFLAGS)
LIBS		= @LIBS@
LINT		= @LINT@

x		= @PROG_EXT@

X_CFLAGS	= @X_CFLAGS@
X_LIBS		= @X_LIBS@

SCREEN		= @SCREEN@
TARGET		= @TARGET@$x

PERL		= @PERL@
PERLLIB		= @perl_lib_path@

prefix		= @prefix@
exec_prefix	= @exec_prefix@

manext		= 1
bindir		= @bindir@
datadir		= @datadir@/vile
perldir		= $(datadir)/perl
mandir		= @mandir@/man$(manext)

#### End of system configuration section. ####

SHELL		= /bin/sh
RM              = rm -f

QUOTDEFS	= -DVILE_STARTUP_PATH=\"@VILE_STARTUP_PATH@\"
CPPFLAGS	= -I. -I$(srcdir) $(X_CFLAGS) \
		-DHAVE_CONFIG_H @CPPFLAGS@

LDFLAGS		= @IMAKE_LOADFLAGS@

INSTALL_DIRS    = $(bindir) $(datadir) $(mandir) @EXTRA_INSTALL_DIRS@

.SUFFIXES: .c .i .o

.c.i:
@RULE_CC@
	@ECHO_CC@$(CPP) -C $(CPPFLAGS) $(QUOTDEFS) $< >$@
.c.o:
@RULE_CC@
	@ECHO_CC@$(CC) -c $(CPPFLAGS) $(QUOTDEFS) $(CFLAGS) -DHELP_LOC=\"$(datadir)/\" $<

# All of the makefiles which should be preserved and distributed
UNIXMAKIN = makefile.in				# for use with configure
VMSMAK =   descrip.mms vmsbuild.com		# on VMS
TURBOMAK = makefile.tbc				# on DOS or OS/2, TURBO C or Borland C
WATMAK =   makefile.wat				# on DOS, using Watcom C/386
MSCMAK =	# still waiting for this one	# on DOS, using Microsoft C
DJGPPMAK = makefile.djg				# on DOS, DJGCC v1.09
NTMAK = makefile.wnt				# on Windows/NT
BCCNTMAK = makefile.blc				# Borland C on Windows/NT
OS2MAK = makefile.icc				# OS/2, (IBM C Set ++ 2.x)
EMXMAK = makefile.emx config.emx		# OS/2, (EMX with gcc)

MAKFILES = \
	$(UNIXMAKIN) \
	$(VMSMAK) \
	$(TURBOMAK) \
	$(WATMAK) \
	$(DJGPPMAK) \
	$(MSCMAK) \
	$(BORMAK) \
	$(NTMAK) \
	$(BCCNTMAK) \
	$(OS2MAK) \
	$(EMXMAK)

ALLTOOLS = $(MAKFILES) mktbls.c cmdtbl modetbl \
	configure config_h.in \
	install.sh mkdirs.sh \
	configure.in aclocal.m4

# these are normal editable headers
HDRS = \
	api.h \
	btree.h \
	chgdfunc.h \
	dirstuff.h \
	edef.h \
	estruct.h \
	os2keys.h \
	proto.h \
	pscreen.h \
	tcap.h \
	trace.h

SCREENS = \
	ansi.c \
	borland.c \
	ibmpc.c \
	ntconio.c \
	ntwinio.c \
	os2vio.c \
	tcap.c \
	vmsvt.c \
	x11.c

# other source code, some used in other makefiles, some useful tools,
#  some possibly obsolete
PERL_SRC = \
	$(srcdir)/perl/glob2re.pl \
	$(srcdir)/perl/hgrep.pl \
	$(srcdir)/perl/hilite.pl \
	$(srcdir)/perl/manfilt.pl \
	$(srcdir)/perl/search.pl \
	$(srcdir)/perl/shell.pl \
	$(srcdir)/perl/syntax.pl \
	$(srcdir)/perl/tailf.pl \
	$(srcdir)/perl/visit.pl

MACRO_SRC = \
	$(srcdir)/macros/manpage.rc \
	$(srcdir)/macros/pictmode.rc \
	$(srcdir)/macros/digraphs.rc

OTHERSRC = \
	c-filt.c \
	c-filt.flx \
	djhandl.c \
	gppconio.c \
	manfilt.c \
	os2pipe.c \
	pas-filt.c \
	vms2unix.c \
	vmspipe.c

# documentation, such as it is
DOCS =	\
	doc/config.doc \
	doc/hilite.doc \
	doc/macros.doc \
	doc/menus.doc \
	doc/modes.doc \
	doc/oleauto.doc \
	doc/perl.doc \
	doc/visvile.doc \
	doc/w32modes.doc \
	vile.1 \
	vile.hlp

# miscellaneous text files
TEXTFILES = README README.PC \
	INSTALL CHANGES \
	CHANGES.R7 CHANGES.R6 CHANGES.R5 CHANGES.R4 CHANGES.R3 \
	buglist revlist patchlev.h COPYING

VILESRC = main.c api.c basic.c bind.c btree.c buffer.c crypt.c csrch.c \
	display.c dumbterm.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 isearch.c itbuff.c lckfiles.c line.c map.c \
	modes.c msgs.c npopen.c oneliner.c opers.c path.c random.c \
	regexp.c region.c search.c select.c spawn.c tags.c \
	tbuff.c termio.c undo.c version.c \
	watch.c window.c word.c wordmov.c

ALLSRC = $(VILESRC) $(SCREENS) $(OTHERSRC) $(HDRS)

# this is for work-in-progress files being shared among developers
#  which don't need to go into general releases yet.
DEVELOPER_ONLY = NOTES.X11 empty.rc mktbls.bat \
	trace.c trace.h \
	fakevms.c fakevms.h

# these are the files that go to everyone
DISTFILES = $(ALLTOOLS) $(ALLSRC) $(DOCS) $(TEXTFILES)

# these are the files that go to coders
DEV_DISTFILES = $(DISTFILES) $(DEVELOPER_ONLY)

SRC = $(SCREEN).c $(VILESRC)

MKTBLS = ./mktbls$x

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

# built from perl.xs
BUILTSRCS = perl.c

# The following are optional (non-core):
#	btree.o
#	crypt.o
#	npopen.o
#	spawn.o
OBJ = $(SCREEN).o \
	main.o api.o basic.o bind.o buffer.o csrch.o \
	display.o dumbterm.o eval.o exec.o externs.o fences.o file.o \
	filec.o fileio.o finderr.o glob.o globals.o \
	history.o input.o insert.o isearch.o itbuff.o lckfiles.o line.o map.o \
	modes.o msgs.o oneliner.o opers.o path.o random.o \
	regexp.o region.o search.o select.o tags.o \
	tbuff.o termio.o undo.o version.o \
	watch.o window.o word.o wordmov.o @EXTRAOBJS@

ALL =	$(TARGET) vile-manfilt$x vile-c-filt$x vile-pas-filt$x vile-crypt$x
all:	$(ALL)

$(TARGET): $(BUILTHDRS) $(OBJ)
	-mv $(TARGET) o$(TARGET)
	@ECHO_LD@$(LINK) $(LDFLAGS) -o $@ $(OBJ) $(X_LIBS) $(LIBS)

vile.man: vile.1
	nroff -man vile.1 | col -b >vile.man

vile-manfilt$x : manfilt.o
	@ECHO_LD@$(LINK) $(LDFLAGS) -o $@ manfilt.o

vile-c-filt$x : c-filt.o
	@ECHO_LD@$(LINK) $(LDFLAGS) -o $@ c-filt.o

vile-pas-filt$x : pas-filt.o
	@ECHO_LD@$(LINK) $(LDFLAGS) -o $@ pas-filt.o

vile-crypt$x : $(srcdir)/crypt.c
	@ECHO_LD@$(CC) -DSTANDALONE $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \
	    -o $@ $(srcdir)/crypt.c

vile-perl-api.pod: perl.xs
	perl -lne 'print if s/^\s{1,2}#\s{0,1}//' $(srcdir)/perl.xs > $@

vile-perl-api.doc: vile-perl-api.pod
	pod2text vile-perl-api.pod > $@

vile-perl-api.html: vile-perl-api.pod
	pod2html vile-perl-api.pod > $@

vile-perl-api.man: vile-perl-api.pod
	pod2man vile-perl-api.pod > $@

nebind.h \
nefkeys.h \
neexec.h \
nefunc.h \
neproto.h \
nename.h :	cmdtbl $(MKTBLS)
	$(MKTBLS) $(srcdir)/cmdtbl

nefsms.h \
nevars.h \
nemode.h:	modetbl $(MKTBLS)
	$(MKTBLS) $(srcdir)/modetbl

$(MKTBLS):  $(srcdir)/mktbls.c
	@ECHO_LD@$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \
	    -o $(MKTBLS)  $(srcdir)/mktbls.c

check: $(TARGET)
	@echo Sorry, no batch tests available.

INSTALL_PERL_DIRS = $(perldir)
INSTALL_PERL_FILES = \
	$(perldir)/glob2re.pl \
	$(perldir)/hgrep.pl \
	$(perldir)/hilite.pl \
	$(perldir)/manfilt.pl \
	$(perldir)/search.pl \
	$(perldir)/shell.pl \
	$(perldir)/syntax.pl \
	$(perldir)/tailf.pl \
	$(perldir)/visit.pl

INSTALL_FILES = \
	$(bindir)/$(TARGET) \
	$(bindir)/vile-manfilt$x \
	$(bindir)/vile-c-filt$x \
	$(bindir)/vile-pas-filt$x \
	$(bindir)/vile-crypt$x \
	$(mandir)/$(TARGET).$(manext) \
	$(datadir)/vile.hlp @EXTRA_INSTALL_FILES@

install: $(INSTALL_DIRS) \
	$(INSTALL_FILES)
	@echo 'Completed installation.'

install-perl : $(INSTALL_PERL_DIRS) $(INSTALL_PERL_FILES)

installdirs: $(INSTALL_DIRS)

uninstall:
	-$(RM) $(INSTALL_FILES)

# The makefile is technically dependent upon the config.status file, but
# gmake gets overly ambitious and remakes the makefile too often.
makefile: makefile.in
	if test ! -f config.status; then $(SHELL) ./configure; fi
	$(SHELL) ./config.status

# defining this target, though technically (i think) correct, causes
#  the make to fail on machines which don't have autoconf, i.e. most of them.
#configure: configure.in aclocal.m4
#	autoconf

config.status: configure
	$(SHELL) ./config.status --recheck

mostlyclean:
	-$(RM) *.[oi] o$(TARGET) $(BUILTHDRS) $(BUILTSRCS) $(MKTBLS) \
	    core *~ *.BAK

clean: mostlyclean
	-$(RM) $(ALL)

distclean: clean
	-$(RM) makefile config.status config.cache config.log config.h

realclean: distclean
	-$(RM) tags TAGS vile-perl-api.* pod2html-*

lint: $(BUILTHDRS)
	$(LINT) $(CPPFLAGS) $(SRC) $(LIBS)
	$(LINT) $(CPPFLAGS) mktbls.c
	$(LINT) $(CPPFLAGS) c-filt.c
	$(LINT) $(CPPFLAGS) pas-filt.c
	$(LINT) $(CPPFLAGS) manfilt.c

tags:
	ctags $(SRC) $(HDRS)

TAGS:
	etags $(SRC) $(HDRS)

dotags:
	dotags $(SRC) $(HDRS)

#	 this builds vile-N.Ndev.tar.gz, including all development files
devtarball:	$(DEV_DISTFILES) /tmp/vilevers release_warnings
	echo vile-`cat /tmp/vilevers` > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	SRCDIR=. ;\
	test $(srcdir) = "\@srcdir\@" && SRCDIR=$(srcdir) ;\
	for file in $(DEV_DISTFILES); do \
	  ln $$SRCDIR/$$file `cat .fname` \
	    || { echo copying $$file instead; cp -p $$file `cat .fname`; }; \
	done
#	tar -cf - `cat .fname` | gzip >`cat .fname`dev.tar.gz
	gtar -czf `cat .fname`dev.tar.gz `cat .fname`
	@echo Created `cat .fname`dev.tar.gz
	rm -rf `cat .fname` .fname

#	 this builds vile-N.N.tar.gz, for general release
tarball:	$(DISTFILES) /tmp/vilevers release_warnings
	echo vile-`cat /tmp/vilevers` > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	SRCDIR=. ;\
	test $(srcdir) = "\@srcdir\@" && SRCDIR=$(srcdir) ;\
	for file in $(DISTFILES); do \
	  ln $$SRCDIR/$$file `cat .fname` \
	    || { echo copying $$file instead; cp -p $$file `cat .fname`; }; \
	done
	gtar -czf `cat .fname`.tar.gz `cat .fname`
	@echo Created `cat .fname`.tar.gz
	rm -rf `cat .fname` .fname

#	 this builds vileN.Nshar, for general release
bigsharball: $(DISTFILES) /tmp/vilevers release_warnings
	vilevers=`cat /tmp/vilevers`; \
	shar -spgf@foxharp.boston.ma.us -nvile$${vilevers} \
	    -o vile$${vilevers}shar README `ls $(DISTFILES) | \
	    sed '/^README$$/d'` ; \
	mv vile$${vilevers}shar.01 vile$${vilevers}shar	; \
	echo Created vile$${vilevers}shar


# shar args: add -a for archive headers, add -s pgf@site.net for "submitted-by"
multisharball: $(DISTFILES) /tmp/vilevers
	[ -d shardir ] || mkdir shardir
	vilevers=`cat /tmp/vilevers`; \
	shar -x -a -spgf@foxharp.boston.ma.us -nvile$${vilevers} -L60 \
			-o shardir/vileshar `ls $(DISTFILES)`

multicsharball: $(DISTFILES) /tmp/vilevers
	[ -d cshardir ] || mkdir cshardir
	vilevers=`cat /tmp/vilevers`; \
	shar -p -nvile$${vilevers} -L60 -o cshardir/vileshar \
		-C `ls $(DISTFILES)`

zipfile: $(DISTFILES) /tmp/vilevers
	vilevers=`cat /tmp/vilevers | sed 's/\.//'`; \
	zip -k vile$${vilevers}s.zip $(DISTFILES) ;\
	echo Created vile$${vilevers}s.zip

# DOS builds...
DOSBINARIES = README README.PC vile.hlp vile.exe

binzip_djg: $(DOSBINARIES) go32.exe /tmp/vilevers
	vilevers=`cat /tmp/vilevers | sed 's/\.//'`; \
	zip -k vile$${vilevers}b.zip $(DOSBINARIES) go32.exe ;\
	echo Created vile$${vilevers}b.zip

binzip_wat: $(DOSBINARIES) dos4gw.exe /tmp/vilevers
	vilevers=`cat /tmp/vilevers | sed 's/\.//'`; \
	zip -k vile$${vilevers}b.zip $(DOSBINARIES) dos4gw.exe ;\
	echo Created vile$${vilevers}b.zip

patch:	/tmp/vilevers
	@orevlistrev=`rlog -h revlist | egrep head: | cut -f2 -d'.'`	;\
	orevlistrev=1.`expr $$orevlistrev - 1`				;\
	ovilevers=`cat /tmp/vilevers | cut -f2 -d'.'`			;\
	ovilemajor=`cat /tmp/vilevers | cut -f1 -d'.'`			;\
	ovilevers=$$ovilemajor.`expr $$ovilevers - 1`			;\
	echo Previous version is $$ovilevers				;\
	vilevers=`cat /tmp/vilevers`					;\
	co -p$$orevlistrev revlist |					 \
	while read file filerev						;\
	do								 \
	  rcsdiff -c -u -r$$filerev $$file 2>/dev/null || true		;\
	done  >patch$$ovilevers-$$vilevers 				;\
	echo Created patch$$ovilevers-$$vilevers

dpatch:
	co -p$(PATCH_AGAINST) revlist |			 		 \
	while read file filerev						;\
	do								 \
	  rcsdiff -c -u -r$$filerev $$file 2>/dev/null || true		;\
	done  >patchREL-CUR 						;\
	echo Created patchREL-CUR

/tmp/vilevers: ALWAYS
	@expr "`egrep 'version\[\].*' edef.h`" : \
		'.* \([0-9][0-9]*\.[0-9].*\)".*' >/tmp/vilevers
	@echo Current version is `cat /tmp/vilevers`

release_warnings:
	@echo
	@echo 'Do you need to rebuild the revlist????  top comment is:'
	@rlog revlist | sed -n -e '/date/,/---------/p' | \
		sed -n '/date\|------------/!p' | sed -e 's/^/	/' -e 1q
	@echo 'or maybe date the CHANGES file?  it says:'
	@sed -n -e '/Changes/s/^/	/p' -e '2q' CHANGES
	@echo 'or maybe update the version info in edef.h?  it contains:'
	@sed -n -e '/.*decl_init.*version.*,/s//	/p' edef.h
	@echo 'how about the README?  it contains:'
	@sed -n -e '/version/s/^/	/p' -e '3q' README
	@echo 'or in vile.hlp?  it has:'
	@sed -n -e '/.*Getting along with vile	*/s//	/p' -e '5q' vile.hlp
	@echo 'or in vmsbuild.com?  it has:'
	@sed -n -e '/Identification=/s/^.*Vile \([^"]*\)["]*/	\1/p' vmsbuild.com
	@echo 'did you reset patchlev.h?'
	@sed -n -e 's/^/	/' -e '/PATCH/p' patchlev.h
	@echo -n "Hit return to continue..."
	@read a

rcsdiffrw:
	@-for x in `$(MAKE) -f makefile.in rw`	;\
	do	\
		echo 		;\
		echo $$x	;\
		echo =========	;\
		rcsdiff -u $$x	;\
	done 2>&1		;\
	echo			;\
	echo all done

# dump a list of the important files
list:
	@ls $(DEV_DISTFILES)

devonlylist:
	@ls $(DEVELOPER_ONLY)

# make a list of RCS revisions.  don't include the revlist itself
nrevlist:
	for f in `$(MAKE) -f makefile.in list  | egrep -v revlist`	;\
	do								\
		rev=`rlog -h $$f | egrep head: | cut -f2 -d' '`		;\
		echo "$$f	$$rev"					;\
	done >/tmp/vile_revlist
	mv /tmp/vile_revlist nrevlist

# dump a list of files that may have changed since last backup
rw:
	@ls -l $(DEV_DISTFILES) |\
		egrep '^[^l].w' | \
		sed 's;.* ;;'   # strip to last space

populate:
	for file in $(DEV_DISTFILES); do \
	test -f $$file || co $$file ;\
	done

perl.c: $(srcdir)/perl.xs $(srcdir)/ptypemap
	$(PERL) $(PERLLIB)/ExtUtils/xsubpp \
		-typemap $(PERLLIB)/ExtUtils/typemap \
		-typemap ptypemap \
		$(srcdir)/perl.xs > $@

$(OBJ): estruct.h nemode.h edef.h neproto.h proto.h config.h

api.o:		api.h
bind.o:		nefunc.h btree.h
btree.o:	btree.h
eval.o:		nevars.h
exec.o:		neexec.h nefunc.h
externs.o:	nebind.h nename.h neproto.h nefunc.h
filec.o:	dirstuff.h
glob.o:		dirstuff.h
globals.o:	nefunc.h
main.o:		chgdfunc.h nevars.h
modes.o:	chgdfunc.h nefsms.h
opers.o:	nefunc.h
path.o:		dirstuff.h
perl.o:		api.h
random.o:	nefunc.h
select.o:	nefunc.h
spawn.o:	nefunc.h
tags.o:		btree.h
tcap.o:		tcap.h
termio.o:	nefunc.h
version.o:	patchlev.h
word.o:		nefunc.h
x11.o:		nefunc.h

# dependency-rules for install/installdirs
$(bindir)/$(TARGET):       $(TARGET)
	$(INSTALL_PROGRAM) $(TARGET) $@
$(bindir)/vile-manfilt$x : vile-manfilt$x
	$(INSTALL_PROGRAM) vile-manfilt$x $@
$(bindir)/vile-c-filt$x :  vile-c-filt$x
	$(INSTALL_PROGRAM) vile-c-filt$x $@
$(bindir)/vile-pas-filt$x : vile-pas-filt$x
	$(INSTALL_PROGRAM) vile-pas-filt$x $@
$(bindir)/vile-crypt$x :   vile-crypt$x
	$(INSTALL_PROGRAM) vile-crypt$x $@

$(mandir)/vile.$(manext):  $(srcdir)/vile.1
	$(INSTALL_DATA)    $(srcdir)/vile.1 $@
$(mandir)/xvile.$(manext): $(srcdir)/vile.1
	$(INSTALL_DATA)    $(srcdir)/vile.1 $@

$(datadir)/vile.hlp:       $(srcdir)/vile.hlp
	$(INSTALL_DATA)    $(srcdir)/vile.hlp $@

$(perldir)/glob2re.pl:     $(srcdir)/perl/glob2re.pl
	$(INSTALL_DATA)    $(srcdir)/perl/glob2re.pl $@
$(perldir)/hgrep.pl:       $(srcdir)/perl/hgrep.pl
	$(INSTALL_DATA)    $(srcdir)/perl/hgrep.pl $@
$(perldir)/hilite.pl:      $(srcdir)/perl/hilite.pl
	$(INSTALL_DATA)    $(srcdir)/perl/hilite.pl $@
$(perldir)/manfilt.pl:     $(srcdir)/perl/manfilt.pl
	$(INSTALL_DATA)    $(srcdir)/perl/manfilt.pl $@
$(perldir)/search.pl:      $(srcdir)/perl/search.pl
	$(INSTALL_DATA)    $(srcdir)/perl/search.pl $@
$(perldir)/shell.pl:       $(srcdir)/perl/shell.pl
	$(INSTALL_DATA)    $(srcdir)/perl/shell.pl $@
$(perldir)/syntax.pl:      $(srcdir)/perl/syntax.pl
	$(INSTALL_DATA)    $(srcdir)/perl/syntax.pl $@
$(perldir)/tailf.pl:       $(srcdir)/perl/tailf.pl
	$(INSTALL_DATA)    $(srcdir)/perl/tailf.pl $@
$(perldir)/visit.pl:       $(srcdir)/perl/visit.pl
	$(INSTALL_DATA)    $(srcdir)/perl/visit.pl $@

$(INSTALL_DIRS):
	$(SHELL) ${srcdir}/mkdirs.sh $@

ALWAYS:

