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

# Change WXDIR to wherever wxWindows is found
WXDIR = $(WX)
WXLIB = $(WXDIR)\lib\wx.lib
WXINC = $(WXDIR)\include

PROLOGDIR = $(WXDIR)\utils\prologio
PROLOGINC = $(PROLOGDIR)\src
PROLOGLIB = $(PROLOGDIR)\lib\prologio.lib

TOOLBARDIR = $(WXDIR)\utils\toolbar
TOOLBARINC = $(TOOLBARDIR)\src
TOOLBARLIB = $(TOOLBARDIR)\lib\toolbar.lib

TREEDIR = $(WXDIR)\utils\wxtree
TREEINC = $(TREEDIR)\src
TREELIB = $(TREEDIR)\lib\wxtree.lib

DIBDIR = $(WXDIR)\utils\dib
DIBLIB = $(DIBDIR)\dib.lib
DIBINC = $(DIBDIR)

RCDIR = $(WXDIR)\utils\rcparser
RCLIB = $(RCDIR)\lib\rcparser.lib
RCINC = $(RCDIR)\src

FAFALIB = $(WXDIR)\contrib\fafa\fafa.lib

BUILDDIR = $(WXDIR)\utils\wxbuild
THISDIR = $(WXDIR)\utils\wxbuild\src
DOCDIR = $(BUILDDIR)\docs

OBJECTS = wxbuild.obj bapp.obj bmenu.obj bframe.obj bsubwin.obj bgencpp.obj\
  namegen.obj bitem.obj bwin.obj btoolbar.obj bactions.obj btree.obj\
  bgdi.obj shapes.obj rcload.obj

LIBS1=$(WXLIB) $(PROLOGLIB) $(TOOLBARLIB) $(FAFALIB) $(DIBLIB)
LIBS2=$(TREELIB) $(RCLIB) oldnames.lib libw llibcew commdlg ddeml shell ctl3d

!ifndef FINAL
FINAL=0
!endif

INC=/I$(WXDIR)\include\base /I$(WXDIR)\include\msw /I$(PROLOGINC) /I$(TOOLBARINC) /I$(DIBINC) /I$(TREEINC) /I$(RCINC)
PRECOMP=/YuWX.H

!if "$(FINAL)" == "0"
OPT=/Od
CPPFLAGS= /AL /W3 /Zi /G2sw $(OPT) $(PRECOMP) /Dwx_msw $(INC) /Fp$(WXDIR)\src\msw\wx.pch
CFLAGS= /AL /W3 /Zi /G2sw /Od /Dwx_msw
LINKFLAGS=/NOD /CO /ONERROR:NOEXE
!else
OPT=/Ox
CPPFLAGS= /AL /W3 /G2sw $(OPT) $(PRECOMP) /Dwx_msw $(INC) /Fp$(WXDIR)\src\msw\wx.pch
CFLAGS= /AL /W3 /Od /G2sw /Dwx_msw
LINKFLAGS=/NOD /ONERROR:NOEXE
!endif

all:    wx prologio toolbar dib rcparser wxtree wxbuild.exe

compact:
        -wrun clean

prologio:
        cd $(PROLOGDIR)\src
        nmake -f makefile.dos FINAL=$(FINAL) OPT=$(OPT) PRECOMP=$(PRECOMP)
        cd $(THISDIR)

toolbar:
        cd $(TOOLBARDIR)\src
        nmake -f makefile.dos FINAL=$(FINAL) OPT=$(OPT) PRECOMP=$(PRECOMP)
        cd $(THISDIR)

wxtree:
        cd $(TREEDIR)\src
        nmake -f makefile.dos FINAL=$(FINAL) OPT=$(OPT) PRECOMP=$(PRECOMP)
        cd $(THISDIR)

dib:
        cd $(DIBDIR)
        nmake -f makefile.dos FINAL=$(FINAL) OPT=$(OPT) PRECOMP=$(PRECOMP)
        cd $(THISDIR)

rcparser:
        cd $(RCDIR)\src
        nmake -f makefile.dos FINAL=$(FINAL) OPT=$(OPT) PRECOMP=$(PRECOMP)
        cd $(THISDIR)

wx:
        cd $(WXDIR)\src\msw
        nmake -f makefile.dos FINAL=$(FINAL) OPT=$(OPT) PRECOMP=$(PRECOMP)
        cd $(THISDIR)

bwin.h: bactions.h

bapp.obj: bapp.cc bapp.h wxbuild.h bmenu.h bsubwin.h bframe.h namegen.h bwin.h bactions.h btree.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

wxbuild.obj: wxbuild.cc wxbuild.h bapp.h bmenu.h bsubwin.h bframe.h namegen.h bwin.h\
  rcload.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

bmenu.obj: bmenu.cc wxbuild.h bapp.h bmenu.h bframe.h namegen.h bwin.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

bframe.obj: bframe.cc wxbuild.h bapp.h bmenu.h bframe.h bsubwin.h namegen.h bwin.h bactions.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

bsubwin.obj: bsubwin.cc wxbuild.h bapp.h bsubwin.h bframe.h namegen.h bwin.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

bitem.obj: bitem.cc wxbuild.h bapp.h bsubwin.h bframe.h namegen.h bitem.h bwin.h bactions.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

bwin.obj: bwin.cc wxbuild.h bwin.h bactions.h bactions.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

btoolbar.obj: btoolbar.cc wxbuild.h bwin.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

bgencpp.obj: bgencpp.cc wxbuild.h bapp.h bframe.h bgencpp.h namegen.h bwin.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

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

bactions.obj: bactions.cc bactions.h wxbuild.h bwin.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

bgdi.obj: bgdi.cc bgdi.h wxbuild.h bwin.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

btree.obj: btree.cc btree.h bwin.h wxbuild.h bapp.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

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

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

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

wxbuild.exe:      $(WXDIR)\src\msw\dummy.obj $(WXLIB) $(OBJECTS) wxbuild.def wxbuild.res $(PROLOGLIB) $(TOOLBARLIB) $(TREELIB)
        link $(LINKFLAGS) @<<
$(WXDIR)\src\msw\dummy.obj $(OBJECTS)
wxbuild.exe,
nul,
$(LIBS1)+
$(LIBS2),
wxbuild.def
<<
        rc -K wxbuild.res

# Test
noname.obj: noname.cc noname.h
	cl @<<
$(CPPFLAGS) /c /Tp $*.cc
<<

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

noname.exe:      $(WXDIR)\src\msw\dummy.obj noname.obj noname.def noname.res
        link $(LINKFLAGS) @<<
$(WXDIR)\src\msw\dummy.obj noname.obj
noname.exe,
nul,
$(LIBS),
noname.def
<<
        rc -K noname.res


# No PostScript production on the PC: just check it goes through Latex
docs:	dvi hlp xlp htm
dvi:	$(BUILDDIR)/docs/wxbuild.dvi
hlp:	$(BUILDDIR)/docs/wxbuild.hlp
rtf:	$(BUILDDIR)/docs/wxbuild.rtf
xlp:    $(BUILDDIR)/docs/wxbuild.xlp
html:    $(BUILDDIR)/docs/wxbuild.html

$(BUILDDIR)/docs/wxbuild.dvi:	$(BUILDDIR)/docs/wxbuild.tex
	cd $(BUILDDIR)/docs
        latex wxbuild
        latex wxbuild
        makeindx wxbuild
        latex wxbuild
#        dvips -f -r < wxbuild.dvi > wxbuild.ps

$(BUILDDIR)/docs/wxbuild.rtf:       $(DOCDIR)/wxbuild.tex
        cd $(DOCDIR)
        -wx tex2rtf $(DOCDIR)\wxbuild.tex $(DOCDIR)\wxbuild.rtf -twice -winhelp
        cd $(BUILDDIR)/src

$(BUILDDIR)/docs/wxbuild.hlp:       $(DOCDIR)/wxbuild.rtf
        cd $(DOCDIR)
        hc wxbuild
        cd $(BUILDDIR)/src

$(BUILDDIR)/docs/wxbuild.xlp:         $(DOCDIR)/wxbuild.tex
        cd $(DOCDIR)
        -wx tex2rtf $(DOCDIR)\wxbuild.tex $(DOCDIR)\wxbuild.xlp -xlp -twice
        cd $(BUILDDIR)/src

$(BUILDDIR)/docs/wxbuild.html:         $(DOCDIR)/wxbuild.tex
        cd $(DOCDIR)
        -wx tex2rtf $(DOCDIR)\wxbuild.tex $(DOCDIR)\wxbuild.htm -html -twice
        cd $(BUILDDIR)/src

proclean:
        cd $(PROLOGDIR)\src
        nmake -f makefile.dos clean
        cd $(THISDIR)

tbarclean:
        cd $(TOOLBARDIR)\src
        nmake -f makefile.dos clean
        cd $(THISDIR)

treeclean:
        cd $(TREEDIR)\src
        nmake -f makefile.dos clean
        cd $(THISDIR)

clean:
        erase *.obj *.exe *.res

cleanall:	clean
        cd $(PROLOGDIR)\src
        nmake -f makefile.dos clean
        cd $(TOOLBARDIR)\src
        nmake -f makefile.dos clean
        cd $(TREEDIR)\src
        nmake -f makefile.dos clean
        cd $(DIBDIR)
        nmake -f makefile.dos clean
        cd $(RCDIR)\src
        nmake -f makefile.dos clean
        cd $(WXDIR)\src\msw
        nmake -f makefile.dos clean
        cd $(THISDIR)

