#
# File:		makefile.nt
# Author:	Julian Smart
# Created:	1993
# Updated:	
# Copyright:	(c) 1993, AIAI, University of Edinburgh
#
# "%W% %G%"
#
!include <ntwin32.mak>
OS_SPEC=/nologo -DWINNT -DMS_WINDOWS -Dwx_msw
ALLFLAGS= $(OS_SPEC) $(cflags) $(cvars) $(cdebug)
# Makefile : Builds PROLOGIO library

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

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

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

PROLOGLIB = $(PROLOGDIR)\lib\prologio.lib


#---------------------------------------------------------------------
# Not yet tested with NT
#
#!ifndef FINAL
#FINAL=0
#!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=
#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
#
# Not used
#
#LIBS=$(PROLOGLIB) $(WXLIB) oldnames.lib libw llibcew commdlg shell

all:    compact $(PROLOGLIB)

compact:
        -wrun clean

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

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

#
# NT Lib.
#
$(PROLOGLIB): $(OBJECTS)
	-erase $(PROLOGLIB)
	$(implib) @<<
-out:$(PROLOGLIB)
-machine:$(CPU)
$(OBJECTS)
<<

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

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

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

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

y_tab.obj:    y_tab.c lex_yy.c
        $(cc) $(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

#
# Obsol.
#
#test.exe:      $(WXLIB) $(PROLOGLIB) test.obj test.def test.res
#        link $(LINKFLAGS) @<<
#test.obj,
#test,
#NUL,
#$(LIBS),
#test.def
#;
#<<
#        rc -30 -K test.res
#
# NT exe
#
test.exe:      $(WXLIB) $(PROLOGLIB) test.obj test.res
	$(link) @<<
-out:test.exe
-machine:$(CPU)
-subsystem:windows
$(LINKFLAGS)
$(WXDIR)\src\msw\dummy.obj test.obj test.res
$(PROLOGLIB) $(WXLIB)
shell32.lib $(guilibs)
<<


test.obj:      test.cc
        $(cc) @<<
$(ALLFLAGS) $(INC) /c /Tp $*.cc
<<

test.res :      test.rc $(WXDIR)\include\msw\wx.rc
    $(rc) -r /i$(WXDIR)\include\msw -fotest.tmp test.rc
    $(cvtres) -$(CPU) -o test.res test.tmp
    del test.tmp

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

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