#
# makefile for vile.  
# The defs for what system this is really running on are in estruct.h.
#  Be sure to edit that, to define your system.
# The command/name/key/function bindings are defined in the file "cmdtbl". The
#  mktbls program parses this to produce nebind.h, nename.h, and nefunc.h,
#  which are used by the rest of the build.
#
#  The version number (currently three) is found near the top of
#  edef.h, and is displayed with the '*' and ":version" commands.
# 		Paul Fox
#
# original makefile for uemacs:	Adam Fritz	July 30,1987
#


# To change screen driver modules, change SCREEN below, and edit estruct.h to
#  make sure the correct one is #defined as "1", and the others all as "0"
# If you use tcap.c, you'll need libtermcap.a too.
# If you use x11.c,  you'll need libX11.a too.

SCREEN = tcap
LIBS = -ltermcap
#LIBS=-lcurses		# for AIX
TARGET = vile

#SCREEN = x11
#LIBS = -lX11
#TARGET = xvile



# install to DESTDIR1 if it's writable, else DESTDIR2
DESTDIR1 = /usr/local/bin
DESTDIR2 = $(HOME)/bin

REMOTE=towno!pgf

# for the mips
#CFLAGS = -g -systype sysv

#CFLAGS = -O
#CFLAGS = -g
CC=cc


# All of the makefiles which should be preserved
MAKEFILES = makefile make.ini
HEADER_BUILDER = ./mktbls

ALLTOOLS = $(MAKEFILES)

# this stuff lives in the shorten subdirectory.  It was lifted from the
#	GNU emacs distribution.  See the file COPYING for more info.
#SHORTSTUFF = shorten/COPYING \
#	shorten/names.c \
#	shorten/dups.c \
#	shorten/defines.c \
#	shorten/header.h \
#	shorten/reserved \
#	shorten/special

# these are normal editable headers
HDRS = estruct.h epath.h evar.h edef.h

# these headers are built by the mktbls program from the information in cmdtbl
BUILTHDRS = nebind.h nefunc.h nename.h 

ALLHDRS = $(HDRS)

# All the C files which should be saved
#  (including tools, like mktbls.c, unused screen drivers, etc.)
CSRCac = ansi.c at386.c basic.c bind.c buffer.c crypt.c csrch.c
CSRCde = dg10.c display.c eval.c exec.c
CSRCfh = file.c fileio.c finderr.c globals.c hp110.c hp150.c
CSRCim = ibmpc.c input.c isearch.c line.c main.c mktbls.c
CSRCnr = news.c npopen.c opers.c oneliner.c random.c regexp.c region.c
CSRCst = search.c spawn.c st520.c tags.c tcap.c termio.c tipc.c
CSRCuz = undo.c vmalloc.c vmsvt.c vt52.c window.c word.c wordmov.c x11.c z309.c

CSRC = $(CSRCac) $(CSRCde) $(CSRCfh) $(CSRCim) $(CSRCnr) \
	$(CSRCst) $(CSRCuz)

# non-C source code
OTHERSRC = z100bios.asm news.cps

# text and data files
TEXTFILES = README CHANGES cmdtbl vile.hlp buglist readme.news

ALLSRC = $(CSRC) $(OTHERSRC)

EVERYTHING = $(ALLTOOLS) $(ALLHDRS) $(ALLSRC) $(TEXTFILES) $(SHORTSTUFF)

SRC = npopen.c finderr.c main.c buffer.c $(SCREEN).c termio.c display.c \
	word.c wordmov.c window.c spawn.c \
	region.c search.c random.c isearch.c line.c \
	input.c fileio.c exec.c file.c eval.c \
	crypt.c bind.c basic.c opers.c undo.c csrch.c tags.c \
	vmalloc.c globals.c oneliner.c regexp.c

OBJ = npopen.o finderr.o main.o buffer.o $(SCREEN).o termio.o display.o \
	word.o wordmov.o window.o spawn.o \
	region.o search.o random.o isearch.o line.o \
	input.o fileio.o exec.o file.o eval.o \
	crypt.o bind.o basic.o opers.o undo.o csrch.o tags.o \
	vmalloc.o globals.o oneliner.o regexp.o

all: $(TARGET)

$(TARGET) : $(BUILTHDRS) $(OBJ) makefile
	-mv $(TARGET) o$(TARGET)
	$(CC) $(CFLAGS) -o $(TARGET) $(OBJ) $(LIBS)
#	$(CC) -Bstatic $(CFLAGS) -o $(TARGET) $(OBJ) $(LIBS)

saber_src:
	#load $(CFLAGS) $(SRC) $(LIBS)

saber_obj: $(OBJ)
	#load $(CFLAGS) $(OBJ) $(LIBS)

#.c.src:
#	#load $(CFLAGS) $<
#.o.obj:
#	#load $(CFLAGS) $<
#
#SUFFIXES: .c .h .o .src .obj


$(BUILTHDRS): cmdtbl $(HEADER_BUILDER)
	./$(HEADER_BUILDER) cmdtbl

# install to DESTDIR1 if it's writable, else DESTDIR2
install:
	@[ -x $(TARGET) ] || (echo must make $(TARGET) first && exit 1)
	[ -w $(DESTDIR1) ] && dest=$(DESTDIR1) || dest=$(DESTDIR2) ;\
	mv $$dest/$(TARGET) $$dest/o$(TARGET) ;\
	cp $(TARGET) $$dest ;\
	test -f vile.hlp && /bin/rm -f $$dest/vile.hlp ;\
	cp vile.hlp $$dest ;\
	chmod 0644 $$dest/vile.hlp 

compr-shar:
	[ -d cshardir ] || mkdir cshardir
#	add -a for archive headers, add -s pgf@cayman.com for submitted-by
	shar -p -nvile -L55 -o cshardir/vileshar \
		-T README -C `ls $(EVERYTHING) | sed /README/d`

shar:
	[ -d shardir ] || mkdir shardir
#	add -a for archive headers, add -s pgf@cayman.com for submitted-by
	shar -x -a -spgf@cayman.com -nVile -L55 \
			-o shardir/vileshar `ls $(EVERYTHING)`

bigshar:
	shar -spgf@cayman.com -nVile \
		-o vileBIGshar README `ls $(EVERYTHING) | sed /README/d`

# only uucp things changed since last time
uuto:
	uuto `ls -t $(EVERYTHING) uutodone | sed '/uutodone/q'` $(REMOTE)
	date >uutodone

floppy:
	ls $(EVERYTHING) | oo

# you don't want to know...
dosscript:
	(								\
	echo echo on							;\
	for x in `ls -t $(EVERYTHING) dosback.bat | sed '/dosback.bat/q'` ;\
	do								\
		echo copy u:$$x a:					;\
	done 								;\
	#echo quit							;\
	) >tmp.bat
	ud < tmp.bat >dosback.bat
	/bin/rm -f tmp.bat
	#-dos
	#>dosback.bat
	
newdosfloppy:
	touch 0101010170 dosback.bat

# dump a list of the important files
list:
	@ls $(EVERYTHING) | more

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

no-write:
	chmod -w $(EVERYTHING)

update:
	nupdatefile.pl -r $(EVERYTHING)

tagfile:
	dotags $(SRC) $(HDRS)

lint:	$(SRC)
	#lint -hbvxac $(SRC) >lint.out 
	lint  $(SRC) >lint.out 

clean:
	rm -f *.o o$(TARGET) $(BUILTHDRS) $(HEADER_BUILDER) news.h core *~ *.BAK

clobber: clean
	rm -f $(TARGET)

news.h: news.cps
	cps news.cps

print:
	pr makefile $(HDRS) $(SRC) | lpr

depend:	 $(SRC) $(HDRS) $(BUILTHDRS)
	mv -f makefile makefile.orig
	(sed -e '/^#DEPENDS/,$$d' makefile.orig ; \
		echo "#DEPENDS" ; \
		$(CC) -M $(CFLAGS) $? ) > makefile

populate: $(EVERYTHING)

$(EVERYTHING):
	co -r$(revision) $@

# you need this if SHORTNAMES is 0 in estruct.h
# estruct.h: shorten/remap.h

shorten/remap.h:
	cd shorten; $(MAKE) remap.h

# $Log: makefile,v $
# Revision 1.34  1992/03/07  10:25:58  pgf
# AIX support (needs -lcurses)
#
# Revision 1.33  1992/03/01  18:41:31  pgf
# moved target define
#
# Revision 1.32  1992/02/17  08:48:49  pgf
# keep copy of current executable during install
#
# Revision 1.31  1991/12/30  23:15:04  pgf
# rename the product of bigshar
#
# Revision 1.30  1991/11/27  10:17:21  pgf
# changes to dos backup target
#
# Revision 1.29  1991/11/16  18:35:08  pgf
# dropped the file locking files -- they didn't work, and were only
# compatible with other's running vile
#
# Revision 1.28  1991/11/13  20:09:27  pgf
# X11 changes, from dave lemke
#
# Revision 1.27  1991/11/07  02:00:32  pgf
# lint cleanup
#
# Revision 1.26  1991/11/01  14:56:51  pgf
# took tags file out of the distribution
#
# Revision 1.25  1991/11/01  14:20:24  pgf
# a little bit more saber support
#
# Revision 1.24  1991/10/28  14:19:46  pgf
# took out some old junk, moved the changelog down low
#
# Revision 1.23  1991/10/27  01:47:14  pgf
# switched from regex to regexp
#
# Revision 1.22  1991/10/24  13:03:48  pgf
# added regex.c
#
# Revision 1.21  1991/10/23  12:05:37  pgf
# added bigshar, and put ./ in front of mktbls rule -- there seems
# to be a bug in some makes that drops the ./ in the HEADER_BUILDER
# variable
#
# Revision 1.20  1991/10/22  14:36:01  pgf
# added the CHANGES file
#
# Revision 1.19  1991/10/10  12:20:26  pgf
# added vmalloc.o dependencies
#
# Revision 1.18  1991/09/27  02:49:30  pgf
# initial saber support
#
# Revision 1.17  1991/08/10  01:24:28  pgf
# added update target, and
# removed the BUILTHDRS list
#
# Revision 1.16  1991/08/07  11:56:58  pgf
# added RCS log entries
#
# revision 1.15
# date: 1991/08/07 02:10:53;
# removed './' from files in dependencies
# 
# revision 1.14
# date: 1991/08/06 16:19:55;
# added populate rule, and "revision" arg to co rule
# 
# revision 1.13
# date: 1991/08/06 16:09:42;
# fixed "rw" rule
# 
# revision 1.12
# date: 1991/08/06 14:45:14;
# commented out shortnames stuff, and
# added "co" rule
# 
# revision 1.11
# date: 1991/06/28 10:52:36;
# exclude built headers from come lists
# 
# revision 1.10
# date: 1991/06/16 17:29:07;
# fixed install rules, so I don't have to change it at home
# 
# revision 1.9
# date: 1991/06/04 16:00:40;
# switch to -L for shar'ing
# 
# revision 1.8
# date: 1991/06/04 13:12:25;
# cleanup for release of version three
# 
# revision 1.7
# date: 1991/04/08 13:11:17;
# added 'rw' target, and make some dos backup changes
# 
# revision 1.6
# date: 1991/04/04 09:38:12;
# new REMOTE address
# 
# revision 1.5
# date: 1990/12/06 18:53:14;
# fixed compr-shar entry, commented out remap.h target
# 
# revision 1.4
# date: 1990/12/03 12:01:37;
# comment change
# 
# revision 1.3
# date: 1990/10/03 16:09:30;
# shortened "shortnames" to "shorten" !
# 
# revision 1.2
# date: 1990/10/01 12:32:23;
# added shortnames directory
# 
# revision 1.1
# date: 1990/09/21 10:25:38;
# initial vile RCS revision
#
#DEPENDS
npopen.o : npopen.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h /usr/include/signal.h /usr/include/sys/types.h \
  /usr/include/errno.h /usr/include/sys/param.h 
finderr.o : finderr.c estruct.h edef.h /usr/include/string.h 
main.o : main.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  /usr/include/signal.h /usr/include/sys/types.h nefunc.h nebind.h nename.h \
  edef.h /usr/include/string.h 
buffer.o : buffer.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h 
tcap.o : tcap.c /usr/include/stdio.h /usr/include/limits.h estruct.h edef.h \
  /usr/include/string.h /usr/include/signal.h /usr/include/sys/types.h 
termio.o : termio.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h /usr/include/errno.h /usr/include/signal.h \
  /usr/include/sys/types.h /usr/include/fcntl.h /usr/include/sys/termios.h 
display.o : display.c /usr/include/stdio.h /usr/include/limits.h \
  /usr/include/varargs.h estruct.h edef.h /usr/include/string.h \
  /usr/include/signal.h /usr/include/sys/types.h /usr/include/termio.h \
  /usr/include/termios.h 
word.o : word.c /usr/include/stdio.h /usr/include/limits.h estruct.h edef.h \
  /usr/include/string.h 
wordmov.o : wordmov.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h 
window.o : window.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h 
spawn.o : spawn.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h /usr/include/signal.h /usr/include/sys/types.h 
region.o : region.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h 
search.o : search.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h 
random.o : random.c /usr/include/stdio.h /usr/include/limits.h \
  /usr/include/string.h estruct.h edef.h /usr/include/signal.h \
  /usr/include/sys/types.h /usr/include/sys/time.h /usr/include/time.h \
  /usr/include/sys/param.h 
isearch.o : isearch.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h 
line.o : line.c /usr/include/stdio.h /usr/include/limits.h estruct.h edef.h \
  /usr/include/string.h 
input.o : input.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h 
fileio.o : fileio.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h /usr/include/sys/types.h \
  /usr/include/sys/stat.h /usr/include/errno.h /usr/include/fcntl.h 
exec.o : exec.c /usr/include/stdio.h /usr/include/limits.h estruct.h edef.h \
  /usr/include/string.h 
file.o : file.c /usr/include/stdio.h /usr/include/limits.h \
  /usr/include/strings.h /usr/include/string.h estruct.h edef.h 
eval.o : eval.c /usr/include/stdio.h /usr/include/limits.h estruct.h edef.h \
  /usr/include/string.h evar.h 
crypt.o : crypt.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h 
bind.o : bind.c /usr/include/stdio.h /usr/include/limits.h estruct.h edef.h \
  /usr/include/string.h epath.h 
basic.o : basic.c /usr/include/stdio.h /usr/include/limits.h estruct.h \
  edef.h /usr/include/string.h 
opers.o : opers.c estruct.h edef.h /usr/include/string.h 
undo.o : undo.c estruct.h edef.h /usr/include/string.h 
csrch.o : csrch.c estruct.h edef.h /usr/include/string.h 
tags.o : tags.c estruct.h edef.h /usr/include/string.h 
vmalloc.o : vmalloc.c estruct.h edef.h /usr/include/string.h 
globals.o : globals.c estruct.h edef.h /usr/include/string.h \
  /usr/include/stdio.h /usr/include/limits.h 
oneliner.o : oneliner.c estruct.h edef.h /usr/include/string.h \
  /usr/include/stdio.h /usr/include/limits.h 
regexp.o : regexp.c /usr/include/stdio.h /usr/include/limits.h \
  /usr/include/string.h estruct.h edef.h 
