#
# Makefile for VIM on OS/2 using EMX	vim:ts=8:sw=8:tw=78
#
# Created by: Paul Slootman
#

### This Makefile has been succesfully tested on these systems.
### Check the (*) column for remarks, listed below.
### Later code changes may cause small problems, otherwise Vim is supposed to
### compile and run without problems.
### Just to show that this is just like the Unix version!

#system:              configurations:    	     version (*) tested by:
#-------------        ------------------------       -------  -  ----------
#OS/2 Warp HPFS       gcc-2.7.2+emx-0.9b -GUI           4.5      Paul Slootman
#OS/2 FAT             gcc-2.6.3+emx      -GUI           4.5      Karsten Sievert

#>>>>> choose options:

### See feature.h for a list of optionals.
### Any other defines can be included here.

DEFINES = -DUSE_SYSTEM=1

#>>>>> name of the compiler and linker, name of lib directory
CC = gcc

#>>>>> end of choices

### Name of target(s)
TARGET = vim.exe

### Names of the tools that are also made
TOOLS = ctags/ctags.exe xxd/xxd.exe tee/tee.exe

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

INCL = vim.h globals.h option.h keymap.h macros.h ascii.h term.h os_msdos.h structs.h os_os2_cfg.h
CFLAGS = -O2 -fno-strength-reduce -DOS2 -Wall $(DEFINES)

OBJ = \
	buffer.o \
	charset.o \
	digraph.o \
	edit.o \
	eval.o \
	ex_cmds.o \
	ex_docmd.o \
	ex_getln.o \
	fileio.o \
	getchar.o \
	main.o \
	mark.o \
	memfile.o \
	memline.o \
	message.o \
	misc1.o \
	misc2.o \
	normal.o \
	ops.o \
	option.o \
	quickfix.o \
	regexp.o \
	screen.o \
	search.o \
	syntax.o \
	tag.o \
	term.o \
	ui.o \
	undo.o \
	window.o \
	os_unix.o

LIBS = -ltermcap

# Default target is making the executable
all: $(TARGET) $(TOOLS)

# Link the target for normal use
LFLAGS = -s -o $(TARGET) $(LIBS)
$(TARGET): $(OBJ) version.c version.h
	$(CC) $(CFLAGS) version.c $(OBJ) $(LFLAGS)

ctags/ctags.exe:
	cd ctags & $(MAKE) -f Makefile.os2

xxd/xxd.exe: xxd/xxd.c
	cd xxd & $(MAKE) -f Makefile.os2

tee/tee.exe: tee/tee.c
	cd tee & $(MAKE) -f Makefile

clean:
	-del *.o
	-del *.exe
	-del ex_cmds.h
	-del *.~ *~ *.bak
	cd ctags & $(MAKE) -f Makefile.os2 clean
	cd xxd   & $(MAKE) -f Makefile.os2 clean
	cd tee   & $(MAKE) -f Makefile clean

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

os_unix.o:	os_unix.c  $(INCL)
buffer.o:	buffer.c  $(INCL)
charset.o:	charset.c  $(INCL)
digraph.o:	digraph.c  $(INCL)
edit.o:		edit.c  $(INCL)
eval.o:		eval.c  $(INCL)
ex_cmds.o:	ex_cmds.c  $(INCL) ex_cmds.h
ex_docmd.o:	ex_docmd.c  $(INCL) ex_docmd.h ex_cmds.h
ex_getln.o:	ex_getln.c  $(INCL)
fileio.o:	fileio.c  $(INCL)
getchar.o:	getchar.c  $(INCL)
main.o:		main.c  $(INCL)
mark.o:		mark.c  $(INCL)
memfile.o:	memfile.c  $(INCL)
memline.o:	memline.c  $(INCL)
message.o:	message.c  $(INCL)
misc1.o:	misc1.c  $(INCL)
misc2.o:	misc2.c  $(INCL)
normal.o:	normal.c  $(INCL)
ops.o:		ops.c  $(INCL)
option.o:	option.c  $(INCL)
quickfix.o:	quickfix.c  $(INCL)
regexp.o:	regexp.c  $(INCL)
screen.o:	screen.c  $(INCL)
search.o:	search.c  $(INCL)
syntax.o:	syntax.c  $(INCL)
tag.o:		tag.c  $(INCL)
term.o:		term.c  $(INCL)
ui.o:		ui.c  $(INCL)
undo.o:		undo.c  $(INCL)
window.o:	window.c  $(INCL)

ex_cmds.h: ex_docmd.h mkcmdtab.exe
	mkcmdtab ex_docmd.h ex_cmds.h

mkcmdtab.exe:	mkcmdtab.c
	$(CC) $(CFLAGS) -o mkcmdtab.exe mkcmdtab.c
