##
##  Unix makefile for editline library.
##

##  Set your options:
##	-D_POSIX_SOURCE		build under a POSIX compliant system.

##  Non-POSIX systems must deal with the following:
##	-DHAVE_TCGETATTR	Have tcgetattr(), tcsetattr().
##	-DNEED_PERROR		Don't have perror() (used in testit)
##	-DUSE_DIRENT		Use <dirent.h>, not <sys/dir.h>?


##  General options for all systems:
##	-DANSI_ARROWS		ANSI arrows keys work like emacs.
##	-DHIST_SIZE=n		History size.
##	-DUNIQUE_HISTORY	Don't save command if same as last one.
##	-DUSE_TERMCAP		Use the termcap library for terminal size
##				see LDFLAGS, below, if you set this.

DEFS	= -DSYS_UNIX=1 -DUSE_DIRENT=1 -DANSI_ARROWS=1 \
	-DHIST_SIZE=25 -DUNIQUE_HISTORY=1

##  Set your C compiler:
WARN	= -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings \
	-Wunused -Wcomment -Wswitch
#CC	= cc $(WARN)
#CC	= checkergcc $(WARN)
CFLAGS	:= $(CFLAGS) $(DEFS)
#CFLAGS	= -g $(DEFS) -O

##  If you have -DUSE_TERMCAP, set this as appropriate:
#LDFLAGS = -ltermlib
LDFLAGS = -ltermcap

##  Set ranlib as appropriate:
RANLIB	= ranlib
#RANLIB	= echo

##  End of configuration.

SOURCES	= editline.c complete.c sysunix.c
OBJECTS	= editline.o complete.o sysunix.o
SHARFILES =	README Makefile editline.3 editline.h unix.h editline.c \
		complete.c sysunix.c testit.c \
		Make.os9 os9.h sysos9.c

all:		libedit.a

testit:		testit.c libedit.a
	$(CC) $(CFLAGS) -o testit testit.c libedit.a $(LDFLAGS)

shar:		$(SHARFILES)
	shar $(SHARFILES) >shar

complete.o : complete.c editline.h unix.h 

editline.o : editline.c editline.h unix.h edlproto.h 

sysunix.o : sysunix.c editline.h unix.h 

clean:
	rm -f *.[oa] testit foo core tags lint lint.all a.out shar

dep:	
	cc -MMD $(CFLAGS) $(SOURCES)

lint:
	lint -p $(DEFS) $(SOURCES) >lint.all

libedit.a:	$(OBJECTS)
	@rm -f $@
	ar r $@ $(OBJECTS)
	$(RANLIB) $@

