# ---------------------------------------------------------------
# Makefile to generate XKEYB program file and associated files
#----------------------------------------------------------------
# v0.01 2001/06/25 RQ first version
# v0.1  2001/08/16 ASM: remix with AF's version
#----------------------------------------------------------------
# necessary compiler programs plus shortcuts

TPC=C:\TP\BIN\TPC.EXE
TASM=C:\BORLANDC\BIN\TASM.EXE
BINOBJ=C:\TP\BIN\BINOBJ.EXE

COMPILE=$(TPC) /$G+
ASM=$(TASM)
PACK=C:\TP\UPX --8086

#----------------------------------------------------------------
# Build all the XKEYB program files

all: xkeyb.exe \
     scankbd.exe \
     listxdef.exe \
     keyman.exe

#----------------------------------------------------------------
# Clean all the previous stuff and rebuild all

build: clean all

clean:
     @echo Removing existing binaries...
     @if exist *.exe del *.exe
     @if exist *.obj del *.obj
     @if exist *.tpu del *.tpu


#----------------------------------------------------------------
# the necessary object and unit files....

intr.obj: intr.asm
	$(ASM) intr.asm

callint2.obj: callint2.asm
	$(ASM) callint2.asm

global.tpu: global.pas
	$(COMPILE) global.pas

inter2.tpu: inter2.pas global.tpu intr.obj callint2.obj
	$(COMPILE) inter2.pas

xkeyb_pi.tpu: xkeyb_pi.pas
	$(COMPILE) xkeyb_pi.pas

#----------------------------------------------------------------
# convcopy is a local helper program
convcopy.exe: convcopy.pas
	$(COMPILE) convcopy.pas

#----------------------------------------------------------------
# this creates a binary file for the fast help to be included

xkeybhlp.bin: xkeyb.fhl
	convcopy xkeyb.fhl xkeybhlp.bin

xkeybhlp.obj: convcopy.exe xkeybhlp.bin
        $(BINOBJ) xkeybhlp.bin xkeybhlp.obj Fasthelp

#----------------------------------------------------------------
# and here are finally the rules to build the programs

xkeyb.exe: xkeyb.pas inter2.tpu xkeybhlp.obj
	@echo Compiling XKEYB program...
	$(COMPILE) xkeyb.pas
        $(PACK) xkeyb.exe

scankbd.exe: scankbd.pas
	@echo Compiling ScanKBD keyboard scanner...
	$(COMPILE) scankbd.pas
        $(PACK) scankbd.exe

listxdef.exe: listxdef.pas xkeyb_pi.tpu
	@echo Compiling ListXDef program...
	$(COMPILE) listxdef.pas
        $(PACK) listxdef.exe

keyman.exe: keyman.pas xkeyb_pi.tpu
	@echo Compiling KeyMan macro recorder program...
	$(COMPILE) keyman.pas
        $(PACK) keyman.exe


