# Makefile for simple curses-based menu interface.
#
# $Id: Makefile,v 1.4 96/05/15 15:11:53 lee Exp $

PWD=menu

# PERFORMANCE makes curses go faster on some platforms.
# Don't ask why it isn't the default, no-one remembers.
EXTRA=-I../h -DPERFORMANCE

OPT=-O -g
DEFS= -DASCIITRACE -UBSD -DSYSV
WHICHDBM=sdbm
# change the next three lines to be the same as the lq-text definitions.
# DBMLIBS=$(INSTALLDIR_LIB)/libsdbm.a
DBMLIBS=

# define bcopy here as bcopy.o if you need it.
# don't use memcpy instead, as memcpy doesn't handle overlapping
# regions of memory.
BCOPY=

# DBMLIBS=-lndbm -linet # 386/ix with hbtcpip provides a good bcopy()

CFLAGS= $(OPT) $(DEFS) -UBSD -DSYSV $(GCCF) -D$(WHICHDBM) $(EXTRA)
CC=/usr/5bin/cc
# TERMCAP=-L/usr/5lib -lcurses -ltermlib
CURSES=-lcurses -ltermcap
TERMCAP=-ltermcap # unused
RANLIB=ranlib

TEXT=lqtext
PROG=m # a simple example of using the library...
PROGOBJS=example.o
PROGSRC=example.c
BININSTALL=install -s -c -m $(MODE)
SHINSTALL=install -c -m $(MODE)
# a copy of install is included in the utils directory.

# DESTDIR=/home/lee/lqtext/bin
MODE=755
LIAMLIB=../liblqutil/liblqutil.a ../liblqerror/liblqerror.a
LQTEXTLIB=../liblqtext/liblqtext.a
MENULIB=liblqmenu.a

PROGS=$(PROG) $(TEXT) # removed by make clean

OBJS=menu.o error.o stringbox.o OldCurses.o
SRCS=menu.c error.c stringbox.c OldCurses.c

# m is a test for the tiny menu library.

all: $(TEXT) # m

install: $(MENULIB) $(TEXT)
	$(BININSTALL) $(TEXT) $(DESTDIR)/$(TEXT)

$(TEXT): text.o $(LQTEXTLIB) $(LIAMLIB) $(MENULIB) $(BCOPY)
	$(CC) $(CFLAGS) -o $(TEXT) text.o $(BCOPY) \
	$(MENULIB) $(LQTEXTLIB) $(DBMLIBS) $(LIAMLIB) $(CURSES)

$(MENULIB): $(OBJS)
	rm -f $(MENULIB)
	ar rv $(MENULIB) $(OBJS)
	$(RANLIB) $(MENULIB)

$(PROG): $(PROGOBJS)
	$(CC) $(CFLAGS) -o $(PROG) $(OBJS) $(PROGOBJS) $(BCOPY) $(CURSES)

lint$(PROG): $(OBJS) $(SRCS) $(PROGSRCS)
	lint $(CFLAGS) $(SRCS) $(CURSES) 2>&1 | tee lint$(PROG)

# Tidy should leave the final executables, but otherwise remove all
# generated files
tidy:
	/bin/rm -f *.o core make.log .mk m.log

# Clean should revert to a distribution state as far as possible
clean:
	/bin/rm -f *.o core *.a $(PROGS) $(CHARGEN) make.log .mk m.log

text.o: text.c
	$(CC) $(CFLAGS) $(TEXTINC) -c text.c


depend:
	chmod +w Makefile
	mkdep $(CFLAGS) *.c

 
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.

OldCurses.o: OldCurses.c 
OldCurses.o: oldcurses.h
error.o: error.c 
error.o: internal.h error.h
example.o: example.c 
example.o: oldcurses.h menu.h internal.h error.h
menu.o: menu.c 
menu.o: ../h/globals.h ../h/port.h ../h/wordrules.h
menu.o: ../h/api.h ../h/port2.h 
menu.o: oldcurses.h menu.h internal.h error.h
stringbox.o: stringbox.c 
stringbox.o: oldcurses.h menu.h
stringbox.o: error.h internal.h
text.o: text.c 
text.o: oldcurses.h 
text.o: ../h/globals.h ../h/port.h ../h/wordrules.h ../h/api.h ../h/port2.h
text.o: menu.h error.h 
text.o: ../h/fileinfo.h ../h/wordinfo.h
text.o: ../h/wordplace.h ../h/wordrules.h ../h/pblock.h ../h/phrase.h
text.o: ../h/emalloc.h ../h/liblqtext.h 
text.o: ../h/lqconfig.h ../h/chartype.h

# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
