#############################################################################
# mined text editor makefile	- EMX in window mode; does not work


#############################################################################
# Where and how to install
# installation root, usually empty
root	= $(INSTALLROOT)

# directories for target "make install"
prefix	= $(root)
bindir	= $(prefix)/bin
hlpdir	= $(prefix)/bin
mandir	= $(prefix)/bin

# directories for target "make localinstall"
lprefix	= $(root)
lbindir	= $(lprefix)/bin
lhlpdir	= $(lprefix)/bin
lmandir	= $(lprefix)/bin

INSTALL = install
#INSTALL = /bin/cp -p


#############################################################################
# compilation target options

# terminal handling mode 1: termio
SCREEN	= -DTERMIO
# link termcap functions:
SLIB	= -ltermcap	# usual termcap library
#SLIB	= -L/usr/lib/termcap -ltermcap	# if deprecated (Linux)
#SLIB	= -lcurses	# may work on System V Unix too (Solaris)
#SLIB	= -lncurses	# includes termcap library (Linux)

# terminal handling mode 2: sgtty (old, BSD)
#SCREEN	= -DSGTTY
#SLIB	= -ltermcap

# terminal handling mode 3: curses
# Choose curses only if other options don't work (like for EMX) 
# (see doc/compilation for discussion).
# Use target "make minced" to use UTF-8 enabled ncurses (>= 5.4), 
# or see separate makefile.emx.curses for options with curses for EMX.


# select operating system flavour (define sysV if on System V flavour)
#SYSTEM	= -Dunix -DsysV
#SYSTEM	= -Dunix -DsysV -DFDSET
SYSTEM	= -Dunix

# select operating system environment
DEFS	= -Dunix -Dpc -D__GCC__ -D__pcgcc__ -DFORK -D__EMX__
# use -D__pcgcc__ to disable link() and define file protections as int
# use -DFORK to disable vfork()

# Application mode
#	-Zwin32		windows text mode application
#	-Zrsx32		dual mode (also DOS with DPMI)
#	-lrsxioapp	window application (with -Zwin32)
#MODE	= -Zrsx32
#MODE	= -Zrsx32 -Zsmall-conv -lmalloc1	# with curses
MODE  = -Zwin32 -lrsxioapp	# window mode


# collection of system parameters for compilation
SYSFLAGS	= $(SCREEN) $(SYSTEM) $(DEFS)


#############################################################################
# link options

# link dynamically
LDOPTS=	# -d n links statically
GLDOPTS=	# -static links statically


#############################################################################
# compiler selection and compiler-specific options
# (source warnings, optimisation and debug)

CC=gcc
include mkinclud.cc


#############################################################################
# make actions

# default target:
emx:	minedwin.exe

SCREENOBJ=io.o keyboard.o
MOUSELIB=
KEYMAPSDEP=
KEYMAPS:=
PROTOFLAGS:=
include mkinclud.mak


# Mined modules
WINOBJS:= $(subst mined1,minedwin,$(OBJS))

# Source generation:
minedwin.c:	mined1.c
	sed -e "s,^\(main *(\),rsxio_\1," mined1.c > minedwin.c

# Source compilation:
minedwin.o:	minedwin.c mined.h
	$(CC) $(CFLAGS) $(DHELP) -c minedwin.c

# Windows program file:
minedwin.exe:	$(WINOBJS) $(SCREENOBJ)
	$(CC) $(WINOBJS) $(SCREENOBJ) $(SLIB) $(MODE) $(LINKOPTS) -o minedwin.exe


#############################################################################
# end
