#
# Makefile
#   Copyright (C) 1990, 1991, 1992 Free Software Foundation
#
# This file 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 of the License, 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.  */
#

#
# Makefile for readline and history libraries.
#

# Modified by Klaus Gebhardt, 1995

CC = gcc $(CFLAGS)

%.o : %.c ; $(CC) -c $< -o $@
%.obj : %.c ; $(CC) -c $< -o $@ -Zomf

%.imp : %.def ; emximp -o $@ $<
%.a : %.imp ; emximp -o $@ $<
%.lib : %.imp ; emximp -o $@ $<

READLINE_DEFINES = -DHAVE_CONFIG_H
OFLAGS = -m486 -O3 -malign-loops=2 -malign-jumps=2 -malign-functions=2 
DEBUG_FLAGS = $(OFLAGS) -mprobe -DOS2
INCL_FLAGS = -I.
CFLAGS = $(DEBUG_FLAGS) $(LOCAL_INCLUDES) $(INCL_FLAGS) $(READLINE_DEFINES)
LIBS = -lxmalloc -ltermcap
ZFLAGS = -Zdll -Zomf -Zcrtdll

CSOURCES = readline.c funmap.c keymaps.c vi_mode.c parens.c search.c \
	rltty.c complete.c bind.c isearch.c display.c signals.c \
	emacs_keymap.c vi_keymap.c history.c tilde.c setctype.c

HSOURCES1 = readline.h keymaps.h chardefs.h
HSOURCES2 = rldefs.h history.h tilde.h
HSOURCES = $(HSOURCES1) $(HSOURCES2)

EXEDEP = readline.c xmalloc.obj readline.lib

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

all: readline.a readline.lib readline.dll

readline.imp: readline.def
readline.a: readline.imp
readline.lib: readline.imp

readline.dll: readline.def $(OBJECTS)
	gcc -o readline.dll readline.def $(OBJECTS) $(LIBS) $(ZFLAGS)

install: all
	cp readline.a readline.lib ../lib
	cp readline.h keymaps.h chardefs.h history.h tilde.h ../include
	cd doc & make install & cd ..
	cp readline.dll h:/bin/dll

bind.obj: bind.c $(HSOURCES1) history.h rldefs.h 
complete.obj: complete.c $(HSOURCES1) rldefs.h 
display.obj: display.c rldefs.h readline.h keymaps.h chardefs.h history.h 
funmap.obj: funmap.c $(HSOURCES1)
history.obj: history.c history.h chardefs.h 
isearch.obj: isearch.c readline.h keymaps.h chardefs.h history.h 
keymaps.obj: keymaps.c emacs_keymap.c vi_keymap.c $(HSOURCES1)
parens.obj: parens.c readline.h keymaps.h chardefs.h 
readline.obj: readline.c $(HSOURCES1) history.h rldefs.h cursor.h
rltty.obj: rltty.c rldefs.h readline.h keymaps.h chardefs.h 
search.obj: search.c readline.h keymaps.h chardefs.h history.h 
setctype.obj: setctype.c cursor.h
signals.obj: signals.c rldefs.h readline.h keymaps.h chardefs.h history.h 
tilde.obj: tilde.c tilde.h chardefs.h 
vi_mode.obj: vi_mode.c rldefs.h readline.h keymaps.h chardefs.h history.h 
xmalloc.obj: xmalloc.c

clean :
	rm -f *.a *.lib *.obj *.dll *.exe
