#
# Makefile.in -- changed by Bruno Haible, 9 May 1995
#
# Master Makefile for the GNU readline library.
# Copyright (C) 1994 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

srcdir = .
VPATH = .

prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
mandir = $(prefix)/man
man1dir = $(mandir)/man1

SHELL = /bin/sh

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

RANLIB = ar s
AR = ar
RM = del
CP = copy
MV = ren

CC = gcc
CFLAGS = -g -O
READLINE_DEFINES = -DHAVE_CONFIG_H
LDFLAGS = 

# For libraries which include headers from other libraries.
INCLUDES = -I. -I$(srcdir)

CPPFLAGS = $(READLINE_DEFINES) $(INCLUDES)

PICFLAG=        -pic    # -fpic for some versions of gcc
SHLIB_OPTS=	-assert pure-text -ldl	# -Bshareable for some versions of gcc
MAJOR=		2
MINOR=		.0

.SUFFIXES:	.so
.c.o:
	$(CC) -c $(CPPFLAGS) $(CFLAGS) $<

.c.so:
	-mv $*.o z$*.o
	$(CC) -c $(PICFLAG) $(CPPFLAGS) $(CFLAGS) $< 
	mv $*.o $@
	-mv z$*.o $*.o

# The name of the main library target.
LIBRARY_NAME = libreadline.a
SHARED_READLINE = libreadline.so.$(MAJOR)$(MINOR)
SHARED_HISTORY = libhistory.so.$(MAJOR)$(MINOR)
SHARED_LIBS = $(SHARED_READLINE) $(SHARED_HISTORY)

# The C code source files for this library.
CSOURCES = $(srcdir)readline.c $(srcdir)funmap.c $(srcdir)keymaps.c \
	   $(srcdir)vi_mode.c $(srcdir)parens.c $(srcdir)rltty.c \
	   $(srcdir)complete.c $(srcdir)bind.c $(srcdir)isearch.c \
	   $(srcdir)display.c $(srcdir)signals.c $(srcdir)emacs_keymap.c \
	   $(srcdir)vi_keymap.c $(srcdir)history.c $(srcdir)tilde.c \
	   $(srcdir)xmalloc.c

# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h \
	   posixstat.h tilde.h rlconf.h

INSTALLED_HEADERS = readline.h chardefs.h keymaps.h history.h

OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
	  rltty.o complete.o bind.o isearch.o display.o signals.o \
	  history.o tilde.o xmalloc.o

SHARED_OBJ = readline.so vi_mode.so funmap.so keymaps.so parens.so search.so \
	  rltty.so complete.so bind.so isearch.so display.so signals.so \
	  history.so tilde.so xmalloc.so

# The texinfo files which document this library.
DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
DOCOBJECT = doc/readline.dvi
DOCSUPPORT = doc/Makefile
DOCUMENTATION = $(DOCSOURCE) $(DOCOBJECT) $(DOCSUPPORT)

SUPPORT = Makefile ChangeLog $(DOCSUPPORT) examples/[-a-z.]*

SOURCES  = $(CSOURCES) $(HSOURCES) $(DOCSOURCE)

THINGS_TO_TAR = $(SOURCES) $(SUPPORT)

##########################################################################

all: libreadline.a libhistory.a
shared: $(SHARED_LIBS)

libreadline.a: $(OBJECTS)
	$(RM) $@
	$(AR) rc $@ $(OBJECTS)
	-$(RANLIB) $@

libhistory.a: history.o
	$(RM) $@
	$(AR) rc $@ history.o
	-$(RANLIB) $@

$(SHARED_READLINE):	$(SHARED_OBJ)
	$(RM) $@
	ld $(SHLIB_OPTS) -o $@ $(SHARED_OBJ)

$(SHARED_HISTORY):	history.so
	$(RM) $@
	ld $(SHLIB_OPTS) -o $@ history.so

documentation: force
	[ ! -d doc ] && mkdir doc
	(if [ -d doc ]; then cd doc; $(MAKE) $(MFLAGS); fi)

force:

install: installdirs libreadline.a
	$(INSTALL_DATA) $(INSTALLED_HEADERS) $(incdir)/readline
	-$(MV) $(libdir)/libreadline.a $(libdir)/libreadline.old
	$(INSTALL_DATA) libreadline.a $(libdir)/libreadline.a
	-$(RANLIB) -t $(libdir)/libreadline.a

installdirs:
	[ ! -d $(incdir)/readline ] && { \
	  mkdir $(incdir)/readline && chmod 755 $(incdir)/readline; }
	[ ! -d $(libdir) ] && mkdir $(libdir)

uninstall:
	[ -n "$(incdir)" ] && cd $(incdir)/readline && \
		$(RM) $(INSTALLED_HEADERS)
	[ -n "$(libdir)" ] && cd $(libdir) && \
		$(RM) libreadline.a libreadline.old $(SHARED_LIBS)

clean::
	$(RM) $(OBJECTS) *.a $(SHARED_OBJ) $(SHARED_LIBS)
	(if [ -d doc ]; then cd doc; $(MAKE) $(MFLAGS) $@; fi)

readline: readline.h rldefs.h chardefs.h
readline: $(OBJECTS)
	$(CC) $(CFLAGS) $(CPPFLAGS) $(READLINE_DEFINES) \
	  $(LOCAL_INCLUDES) -DTEST -o readline readline.c vi_mode.o funmap.o \
	  keymaps.o -ltermcap

info:
install-info:
dvi:
check:
installcheck:

tags:	force
	etags $(CSOURCES) $(HSOURCES)

TAGS:	force
	ctags -x $(CSOURCES) $(HSOURCES) > $@

Makefile: config.status $(srcdir)/Makefile.in
	$(SHELL) config.status

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

configure: configure.in            ## Comment-me-out in distribution
	cd $(srcdir); autoconf     ## Comment-me-out in distribution
config.h.in: configure.in          ## Comment-me-out in distribution
	cd $(srcdir); autoheader   ## Comment-me-out in distribution

mostlyclean: clean

distclean maintainer-clean: clean
	$(RM) Makefile config.status stamp-config

# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

# Dependencies

readline.o: $(srcdir)/readline.c readline.h rldefs.h rlconf.h chardefs.h keymaps.h history.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/readline.c

vi_mode.o:  $(srcdir)/vi_mode.c rldefs.h rlconf.h readline.h history.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/vi_mode.c

funmap.o:   $(srcdir)/funmap.c readline.h rlconf.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/funmap.c

keymaps.o:  $(srcdir)/keymaps.c $(srcdir)/emacs_keymap.c $(srcdir)/vi_keymap.c keymaps.h chardefs.h rlconf.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/keymaps.c

history.o: $(srcdir)/history.c history.h memalloc.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/history.c

isearch.o: $(srcdir)/isearch.c memalloc.h readline.h history.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/isearch.c

search.o: $(srcdir)/search.c memalloc.h readline.h history.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/search.c

display.o: $(srcdir)/display.c readline.h history.h rldefs.h rlconf.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/display.c

complete.o: $(srcdir)/complete.c readline.h rldefs.h rlconf.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/complete.c

rltty.o: $(srcdir)/rltty.c rldefs.h rlconf.h readline.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/rltty.c

bind.o: $(srcdir)/bind.c rldefs.h rlconf.h readline.h history.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/bind.c

signals.o: $(srcdir)/signals.c rldefs.h rlconf.h readline.h history.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/signals.c

parens.o: $(srcdir)/parens.c readline.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/parens.c

tilde.o: $(srcdir)/tilde.c tilde.h
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/tilde.c

xmalloc.o: $(srcdir)/xmalloc.c
	$(CC) -c $(CFLAGS) $(INCLUDES) $(READLINE_DEFINES) $(srcdir)/xmalloc.c

