#
# File:		makefile.dos
# Author:	Julian Smart
# Created:	1993
# Updated:	
# Copyright:	(c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
# Makefile : Builds PROLOGIO library

WXDIR = $(WX)
WXLIB = $(WXDIR)\lib\wx.lib $(WXDIR)\contrib\fafa\fafa.lib
WXINC = $(WXDIR)\include

PROLOGDIR = $(WXDIR)\utils\prologio
PROLOGINC = $(PROLOGDIR)\src

DOCDIR = $(PROLOGDIR)\docs
DOCUTILSDIR = $(WXDIR)\utils\tex2rtf\src
THISDIR = $(PROLOGDIR)\src

INC = /I$(WXDIR)\include\base /I$(WXDIR)\include\msw

!ifndef FINAL
FINAL=0
!endif

# Default is to output RTF for WinHelp
!ifndef WINHELP
WINHELP=-winhelp
!endif

!ifndef DLL
DLL=0
!endif

PRECOMP=/YuWX.H

!if "$(FINAL)" == "0"
DEBUG_FLAGS= /Zi
LINK_DEBUG_FLAGS=/CO
OPT = /Od
!else
# /Ox for real FINAL version
DEBUG_FLAGS=/Zi
LINK_DEBUG_FLAGS=
OPT = /Ox
!endif

!if "$(DLL)" == "0"
PCH=$(WXDIR)\src\msw\WX.PCH
CPPFLAGS= $(DEBUG_FLAGS) /AL /W3 /G2sw $(OPT) $(INC) /Dwx_msw
CFLAGS= $(DEBUG_FLAGS) /AL /W3 /G2sw $(OPT) /Dwx_msw
LINKFLAGS=$(LINK_DEBUG_FLAGS) /NOD /ONERROR:NOEXE
PROLOGLIB = $(PROLOGDIR)\lib\prologio.lib
!else
PCH=$(WXDIR)\src\msw\WXDLL.PCH
CPPFLAGS= $(DEBUG_FLAGS) /ALw /W3 /G2sw /GD $(OPT) $(PRECOMP) $(INC) /Fp$(PCH) /Dwx_msw
CFLAGS= $(DEBUG_FLAGS) /ALw /W3 /G2sw /GD $(OPT) /Dwx_msw
LINKFLAGS=$(LINK_DEBUG_FLAGS) /NOD /ONERROR:NOEXE
PROLOGLIB = $(PROLOGDIR)\lib\proiodll.lib
!endif

SOURCES = read.cc prorpc.cc y_tab.c lex.yy.c
HEADERS = read.h expr.h prorpc.h
OBJECTS = read.obj prorpc.obj y_tab.obj
LIBS=$(PROLOGLIB) $(WXLIB) oldnames.lib libw llibcew commdlg shell # ctl3d

all:    compact $(PROLOGLIB)

compact:
        -wrun clean

wx:
        cd $(WXDIR)\src
        nmake -f makefile.dos $(WXLIB) FINAL=$(FINAL)
        cd $(PROLOGDIR)\src

$(PROLOGLIB):      $(OBJECTS)
        erase $(PROLOGLIB)
        lib /PAGESIZE:128 @<<
$(PROLOGLIB)
y
$(OBJECTS)
nul
;
<<

$(OBJECTS):     $(PROLOGINC)\read.h $(PROLOGINC)\expr.h

read.obj: read.cc $(PROLOGINC)\read.h $(PROLOGINC)\expr.h
        cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

prorpc.obj: prorpc.cc $(PROLOGINC)\read.h $(PROLOGINC)\expr.h $(PROLOGINC)\prorpc.h
        cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

#expr.obj: expr.c $(PROLOGINC)\read.h $(PROLOGINC)\expr.h
#        cl $(CFLAGS) /c /Tc $*.c

y_tab.obj:    y_tab.c lex_yy.c
        cl $(CFLAGS) -DYY_USE_PROTOS /c /Tc $*.c

y_tab.c:      parser.y
        yacc parser.y

#lex_yy.c:     lexer.l
#        flex -t -L lexer.l > lex_yy.c

test.exe:      $(WXLIB) $(PROLOGLIB) test.obj test.def test.res
        link $(LINKFLAGS) @<<
test.obj,
test,
NUL,
$(LIBS),
test.def
;
<<
        rc -30 -K test.res

test.obj:      test.cc
        cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

test.res :      test.rc $(WXDIR)\include\msw\wx.rc
    rc -r /dFAFA_LIB /i$(WXDIR)\contrib\fafa /i$(WXDIR)\include\msw test

# Making documents
docs:   $(DOCDIR)/prologio.hlp
rtf:    $(DOCDIR)/prologio.rtf
hlp:    $(DOCDIR)/prologio.hlp

$(DOCDIR)/prologio.hlp:         $(DOCDIR)/prologio.rtf $(DOCDIR)/prologio.hpj
        cd $(DOCDIR)
        -erase prologio.ph
        hc prologio
        cd $(THISDIR)

$(DOCDIR)/prologio.rtf:         $(DOCDIR)/manual.tex $(DOCDIR)/classes.tex
        cd $(DOCDIR)
        -wx tex2rtf $(DOCDIR)\manual.tex $(DOCDIR)\prologio.rtf -twice $(WINHELP)
        cd $(THISDIR)

clean:
        erase *.exe *.obj y_tab.c *.lib $(PROLOGLIB)

cleanall:
        erase *.exe *.obj *.pch y_tab.c $(PROLOGLIB)
