#################################################################
#               PCCURSES                                        #
# Makefile to generate scurses.lib, ccurses.lib, mcurses.lib,   #
# lcurses.lib and hcurses.lib for BorlandC++/TurboC++.          #
#                                                               #
# This makefile will generate subdirectories and call itself    #
# recursively...                                                #
#################################################################
# 1.3:    Release:                    881005                    #
#################################################################

# The following are the directories where your lib and include files
# will be installed. These need to be edited for your system.

CC          = bcc
LIBDIR      = ..

# General definitions:

CFLAGS      = -I..    -m$(MODEL) -c -O -Z -w -a- -f- -G -r -d

COBJS=  attrib.obj   beep.obj     border.obj   boxes.obj     \
        charadd.obj  chardel.obj  charget.obj  charins.obj   \
        charpick.obj clrtobot.obj clrtoeol.obj endwin.obj    \
        initscr.obj  linedel.obj  lineins.obj  longname.obj  \
        move.obj     mvcursor.obj newwin.obj   options.obj   \
        overlay.obj  prntscan.obj refresh.obj  scrreg.obj    \
        setmode.obj  setterm.obj  stradd.obj   strget.obj    \
        tabsize.obj  termmisc.obj unctrl.obj   update.obj    \
        winclear.obj windel.obj   winerase.obj winmove.obj   \
        winscrol.obj wintouch.obj

ASMOBJS=    cursesio.obj

OBJS=        $(COBJS) $(ASMOBJS)

CHMOD=        attrib

#################################################################
# 'all' is all that can (and usually is) done                   #
#################################################################

all:    huge large medium compact small demo.exe demo-pp.exe

#   Compile the demo program
demo.exe:   demo.obj 
        tlink  c0m demo,demo,demo, cm .\mcurses /c
demo-pp.exe:    demo-pp.obj
        tlink  c0m demo-pp,demo-pp,demo-pp, cm .\mcurses /c

demo.obj:   demo.c curses.h makefile
        $(CC) -c -v -mm  demo.c

demo-pp.obj:   demo-pp.cpp curses.h makefile
        $(CC) -c -v -mm  demo-pp.cpp

#################################################################
# The following will create a subdirectory for each memory      #
# model, and initiate the make:ing in each one.                 #
#################################################################

#################################################################
# Create work directory if non-existent, go to it, and          #
# perform the job - small model                                 #
#################################################################

small:        smodel  smodel\farnear.inc smodel\smalhuge.inc
        cd    smodel
        make  -f..\makefile $(MAKEFLAGS) -DMODEL=s $(LIBDIR)\scurses.lib
        cd ..
smodel:
        mkdir    smodel

#################################################################
# Create work directory if non-existent, go to it, and          #
# perform the job - compact model                               #
#################################################################

compact:    cmodel   cmodel\farnear.inc cmodel\smalhuge.inc 
        cd    cmodel
        make  -f..\makefile $(MAKEFLAGS) -DMODEL=c $(LIBDIR)\ccurses.lib
        cd ..

cmodel:
        mkdir    cmodel

#################################################################
# Create work directory if non-existent, go to it, and          #
# perform the job - medium model                                #
#################################################################

medium:        mmodel mmodel\farnear.inc mmodel\smalhuge.inc    
        cd    mmodel
        make  -f..\makefile $(MAKEFLAGS) -DMODEL=m $(LIBDIR)\mcurses.lib
        cd ..

mmodel:
        mkdir    mmodel

#################################################################
# Create work directory if non-existent, go to it, and          #
# perform the job - large model                                 #
#################################################################

large:        lmodel lmodel\farnear.inc lmodel\smalhuge.inc
        cd    lmodel
        make  -f..\makefile $(MAKEFLAGS) -DMODEL=l $(LIBDIR)\lcurses.lib
        cd ..

lmodel:
        mkdir    lmodel

#################################################################
# Create work directory if non-existent, go to it, and          #
# perform the job - large model                                 #
#################################################################

huge:         hmodel hmodel\farnear.inc hmodel\smalhuge.inc
        cd    hmodel
        make  -f..\makefile $(MAKEFLAGS) -DMODEL=h $(LIBDIR)\hcurses.lib
        cd ..

hmodel: 
        mkdir    hmodel

#################################################################
# Put together the library in file tmp.lib, then copy it to     #
# the appropriate name for the memory model in question, and    #
# delete the temporary file                                     #
#################################################################

$(LIBDIR)\$(MODEL)curses.lib:    $(OBJS)
    del    tmp.lib
    tlib /c tmp.lib @..\curses.cmd
    copy   tmp.lib $(LIBDIR)\$(MODEL)curses.lib
    del    tmp.lib

#################################################################
# Commands and dependencies for individual modules              #     
#################################################################

attrib.obj:    ..\attrib.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -oattrib ..\attrib.c

beep.obj:    ..\beep.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -obeep ..\beep.c

border.obj:    ..\border.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -oborder ..\border.c

boxes.obj:    ..\boxes.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -oboxes ..\boxes.c

charadd.obj:    ..\charadd.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ocharadd ..\charadd.c

chardel.obj:    ..\chardel.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ochardel ..\chardel.c

charget.obj:    ..\charget.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ocharget ..\charget.c

charins.obj:    ..\charins.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ocharins ..\charins.c

charpick.obj:    ..\charpick.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ocharpick ..\charpick.c

clrtobot.obj:    ..\clrtobot.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -oclrtobot ..\clrtobot.c

clrtoeol.obj:    ..\clrtoeol.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -oclrtoeol ..\clrtoeol.c

endwin.obj:    ..\endwin.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -oendwin ..\endwin.c

initscr.obj:    ..\initscr.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -oinitscr ..\initscr.c

linedel.obj:    ..\linedel.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -olinedel ..\linedel.c

lineins.obj:    ..\lineins.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -olineins ..\lineins.c

longname.obj:    ..\longname.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -olongname ..\longname.c

move.obj:    ..\move.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -omove ..\move.c

mvcursor.obj:    ..\mvcursor.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -w-par -omvcursor ..\mvcursor.c

newwin.obj:    ..\newwin.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -onewwin ..\newwin.c

options.obj:    ..\options.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ooptions ..\options.c

overlay.obj:    ..\overlay.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ooverlay ..\overlay.c

prntscan.obj:    ..\prntscan.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -N -oprntscan ..\prntscan.c

refresh.obj:    ..\refresh.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -orefresh ..\refresh.c

scrreg.obj:    ..\scrreg.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -oscrreg ..\scrreg.c

setmode.obj:    ..\setmode.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -osetmode ..\setmode.c

setterm.obj:    ..\setterm.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -osetterm ..\setterm.c

stradd.obj:    ..\stradd.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ostradd ..\stradd.c

strget.obj:    ..\strget.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ostrget ..\strget.c

tabsize.obj:    ..\tabsize.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -otabsize ..\tabsize.c

termmisc.obj:    ..\termmisc.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -otermmisc ..\termmisc.c

unctrl.obj:    ..\unctrl.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -ounctrl ..\unctrl.c

update.obj:    ..\update.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -oupdate ..\update.c

winclear.obj:    ..\winclear.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -owinclear ..\winclear.c

windel.obj:    ..\windel.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -owindel ..\windel.c

winerase.obj:    ..\winerase.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -owinerase ..\winerase.c

winmove.obj:    ..\winmove.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -owinmove ..\winmove.c

winscrol.obj:    ..\winscrol.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -owinscrol ..\winscrol.c

wintouch.obj:    ..\wintouch.c ..\curses.h ..\curspriv.h
    $(CC) $(CFLAGS) -owintouch ..\wintouch.c

#################################################################
# You have to choose one of the two following ways to make a    #
# CURSESIO.OBJ - either the 'C' version or the 'ASM' version.    #
# Comment out the one you do not like.                #
#################################################################

#cursesio.obj:    ..\cursesio.c
#    $(CC) $(CFLAGS) -ocursesio ..\cursesio.c

cursesio.obj:    ..\cursesio.asm
     tasm ..\cursesio.asm /mx, cursesio.obj, nul, nul

# include files for cursesio.ams

smodel\farnear.inc:		nearcall.inc
	copy	nearcall.inc	smodel\farnear.inc
smodel\smalhuge.inc:	smaldata.inc
	copy	smaldata.inc	smodel\smalhuge.inc
cmodel\farnear.inc:		nearcall.inc
	copy	nearcall.inc	cmodel\farnear.inc
cmodel\smalhuge.inc:	hugedata.inc
	copy	hugedata.inc	cmodel\smalhuge.inc
mmodel\farnear.inc:		farcall.inc
	copy	farcall.inc	mmodel\farnear.inc
mmodel\smalhuge.inc:	smaldata.inc
	copy	smaldata.inc	mmodel\smalhuge.inc
lmodel\farnear.inc:		farcall.inc
	copy	farcall.inc	lmodel\farnear.inc
lmodel\smalhuge.inc:	hugedata.inc
	copy	hugedata.inc	lmodel\smalhuge.inc
hmodel\farnear.inc:		farcall.inc
	copy	farcall.inc	hmodel\farnear.inc
hmodel\smalhuge.inc:	hugedata.inc
	copy	hugedata.inc	hmodel\smalhuge.inc

#################################################################
# Perform a backup of the files in the directory where the      #
# 'make backup' command was issued - copies all files to the    #
# floppy in drive A:                                            #
#################################################################

backup:
    @echo ***** Backup of PCcurses *****
    @echo Insert backup diskette in drive A: and hit any key!
        rm /r a:\*
    copy *.* a:

#################################################################
# Remove all temporary files and work directories that were     #
# created                                                       #
#################################################################

clean:
    rm /r *.obj smodel cmodel mmodel lmodel hmodel
