/**/#
/**/#	$Header: /afs/sipb/project/sipbsrc/src/micrognu/RCS/Makefile.cpp,v 1.8 1996/11/10 03:46:23 svalente Exp $
/**/#
/**/#   Makefile for MicroEMACS.
/**/#   Is there a better way to do the rebuilds, other than using
/**/#   the links?

DESTDIR=
BINDIR=		/mit/sipb/${MACHINE}bin
MANDIR=		/mit/sipb/man
MANSECT=	1

#if defined(_AIX) || defined(sparc)
SYS	=	sysv
LIBS	=	-lcurses
#else
SYS	=	bsd
LIBS	=	-ltermcap
#endif
TTY	= termcap

/**/# CDEFS gets defines, and gets passed to lint.
/**/# CFLAGS gets flags, and doesn't get passed to lint.

/**/# Important:  Always use -DVARARGS !
/**/# The alternative is _not_ <stdarg.h>
/**/# The alternative is some awful hack that tries to increment a pointer
/**/# on the top of the stack, which does not work.

CDEFS	= -DDO_METAKEY -DSTARTUP -DVARARGS
CFLAGS	= -O $(CDEFS)
LDFLAGS	=

OBJ =	basic.o buffer.o cinfo.o display.o echo.o extend.o file.o kbd.o \
	line.o main.o match.o random.o region.o search.o symbol.o version.o \
	window.o paragraph.o prefix.o \
	word.o fileio.o spawn.o ttyio.o tty.o ttykbd.o
OSRCS = fileio.c spawn.c ttyio.c tty.c ttykbd.c
SRCS =	basic.c buffer.c cinfo.c display.c echo.c extend.c file.c kbd.c \
	line.c main.c match.c random.c region.c search.c symbol.c version.c \
	window.c word.c paragraph.c prefix.c
OINCS =	ttydef.h sysdef.h
INCS =	def.h
LNFILES= ${INCS} functions tty README TAGS systty.mods

all: uemacs

uemacs:		$(OBJ)
	cc $(LDFLAGS) -o uemacs $(OBJ) $(LIBS)

install: uemacs
	install -c -s uemacs ${DESTDIR}${BINDIR}/uemacs
	install -c uemacs.1 ${DESTDIR}${MANDIR}/man${MANSECT}/uemacs.${MANSECT}

/**/# the v arg to lint turns off all the complaints about args f, n & k.
/**/# It's a good idea to take that out and rerun make lint after getting
/**/# a clean lint, just to verify that f, n & k are the ONLY unused args.

lint: $(SRCS) $(OSRCS)
	lint -ahb $(CDEFS) $(SRCS) $(OSRCS)

$(OBJ):		def.h sysdef.h ttydef.h

sysdef.h:	sys/$(SYS)/sysdef.h	# Update links, if needed.
	/bin/rm -f sysdef.h
	/bin/ln -s sys/$(SYS)/sysdef.h .

ttydef.h:	tty/$(TTY)/ttydef.h
	/bin/rm -f ttydef.h
	/bin/ln -s tty/$(TTY)/ttydef.h .

fileio.c:	sys/$(SYS)/fileio.c
	/bin/rm -f fileio.c
	/bin/ln -s sys/$(SYS)/fileio.c .

spawn.c:	sys/$(SYS)/spawn.c
	/bin/rm -f spawn.c
	/bin/ln -s sys/$(SYS)/spawn.c .

tty.c:		tty/$(TTY)/tty.c
	/bin/rm -f tty.c
	/bin/ln -s tty/$(TTY)/tty.c .

ttyio.c:	sys/$(SYS)/ttyio.c
	/bin/rm -f ttyio.c
	/bin/ln -s sys/$(SYS)/ttyio.c .

ttykbd.c:	tty/$(TTY)/ttykbd.c
	/bin/rm -f ttykbd.c
	/bin/ln -s tty/$(TTY)/ttykbd.c .

port: $(SRCS) $(INCS)
	/bin/rm -f port
	tar cfb port 1 $?

clean:
	/bin/rm -f $(OBJ) $(OSRCS) $(OINCS) uemacs

depend: ${SRCS} ${OSRCS} ${INCS} ${OINCS}
	makedepend -v ${CFLAGS} ${SRCS} ${OSRCS}
