# Makefile : Builds graph library and example (DOS).
# Use FINAL=1 argument to nmake to build final version with no debugging
# info

# Set WXDIR for your system
WXDIR = $(WX)
WXLIB = $(WXDIR)\lib\wx.lib $(WXDIR)\contrib\fafa\fafa.lib
GRAPHDIR = $(WXDIR)\utils\wxgraph
GRAPHLIB = $(GRAPHDIR)\lib\wxgraph.lib
DOCDIR = $(GRAPHDIR)\docs
THISDIR = $(GRAPHDIR)\src
LIBS=$(WXLIB) $(GRAPHLIB) oldnames libw llibcew commdlg shell $(WXDIR)\contrib\fafa\fafa.lib
INC=-I$(WXDIR)\include\base -I$(WXDIR)\include\msw
DUMMY=$(WXDIR)\src\msw\dummy.obj

!ifndef FINAL
FINAL=0
!endif

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

HEADERS = wxgraph.h wxgraphp.h
SOURCES = wxgraph.cc
OBJECTS = wxgraph.obj

all:    $(GRAPHLIB)

test:   test.exe

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

wxclean:
        cd $(WXDIR)\src\msw
        nmake -f makefile.dos clean
        cd $(GRAPHDIR)\src

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

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

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

test.obj:      test.h wxgraph.h test.cc $(DUMMY)
        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:   hlp xlp
hlp:   $(DOCDIR)/wxgraph.hlp
xlp:    $(DOCDIR)/wxgraph.xlp
rtf:    $(DOCDIR)/wxgraph.rtf

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

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

$(DOCDIR)/wxgraph.xlp:         $(DOCDIR)/manual.tex $(DOCDIR)/classes.tex
        cd $(DOCDIR)
        -wx tex2rtf $(DOCDIR)\manual.tex $(DOCDIR)\wxgraph.xlp -twice -xlp
        cd $(THISDIR)

clean:
        -erase *.obj $(GRAPHLIB) *.exe *.res *.map *.rws
