# Makefile for WAIS Toolkit, libraries and WAISSERV for Windows NT

#NODEBUG = 1

!include <ntwin32.mak>

!IFDEF NODEBUG
ddebug =
!ELSE
ddebug = -DDEBUG
!ENDIF

defines = $(ddebug) -DLITERAL -DHTML -DBOOLEANS -DSOUND

# We don't use inference rules for compiling, because of the need to
# have .obj files with different names from their .c sources.  This
# macro makes it easier to specify the compilation command. 

ccompile = $(cc) $(cdebug) $(cflags) $(cvarsmt) $(ddebug) -Fo$@ $(defines)

!IFNDEF BACKDIR
BACKDIR = g:\chrisa\infeng\freeWAIS
!ENDIF

ZIP=zip

# Main targets

default: config-$(CPU).h
    if not exist bin mkdir bin
    cd ir
    nmake  defines="$(defines)"
    cd ..
    cd waislook
    nmake  ddebug="$(ddebug)"
    cd ..

install:
    copy bin\waisindex-$(CPU).exe $(WINDIR)\system32\waisindex.exe
    copy bin\waislook-$(CPU).exe $(WINDIR)\system32\waislook.exe
    copy bin\waisserv-$(CPU).exe $(WINDIR)\system32\waisserv.exe

backup:
    copy *.c $(BACKDIR)
    copy *.h $(BACKDIR)
    copy Makefile $(BACKDIR)
    cd ir
    nmake BACKDIR=$(BACKDIR) backup
    cd ..
    cd waislook
    nmake BACKDIR=$(BACKDIR) backup
    cd ..
    cd doc
    copy *.doc $(BACKDIR)\doc
    copy read.me $(BACKDIR)\doc
    copy message.txt $(BACKDIR)\doc
    cd ..

clean:
    del *.obj *.bak *.map *.exe
    cd ir
    nmake clean
    cd ..
    cd waislook
    nmake clean
    cd ..

binaryrelease:
    if not exist release mkdir release
    cd release
    copy ..\bin\waisindex-$(CPU).exe waisindx.exe
    copy ..\bin\waislook-$(CPU).exe waislook.exe
    copy ..\bin\waisserv-$(CPU).exe waisserv.exe
    $(ZIP) -m wt$(CPU).zip waisindx.exe waislook.exe waisserv.exe
    $(ZIP) -u -j wt$(CPU).zip ..\doc\waistool.ps ..\doc\waistool.doc ..\doc\waistool.wri ..\doc\read.me
    cd ..

sourcerelease:
    if not exist release mkdir release
    $(ZIP) -u release\wtsource.zip *.c *.h makefile copyright
    $(ZIP) -u release\wtsource.zip ir\*.c ir\*.h ir\makefile
    $(ZIP) -u release\wtsource.zip waislook\*.c waislook\*.h waislook\makefile
    $(ZIP) -u release\wtsource.zip doc\*

# Intermediate targets

config-$(CPU).obj: config.c
    $(ccompile) config.c

config-$(CPU).exe: config-$(CPU).obj
    $(link) $(linkdebug) $(conflags) -out:$*.exe $** $(conlibsmt)

config-$(CPU).h: config-$(CPU).exe
    config-$(CPU) >config-$(CPU).h

