# PLplot:
# This makefile takes care of the overall building process.
# It has the following targets:
# - default:
#      The default make step (links, common, libs)
# - prepare:
#      The default make step without the actual build, useful
#      when you want to adjust the set of drivers manually
# - links:
#      Copies all the source files to the $(PLTMP) directory
# - libs:
#      Target for building the static and dynamic libraries
# - libstat:
#      Build the static library (plplot.lib)
# - libdyn:
#      Build the dynamic library (plplotd.lib, plplotd.dll)
# - common:
#      Writes the plconfig.h and pldevs.h header files
#      (Here the available drivers are selected)
# - install:
#      Installs the built libraries and other files into
#      the directory indicated by $(PLDEST)
#
# Additional drivers should be uncommented from this
# file before running nmake.
#
# Questions/problems, send email to :
#
#       Arjen Markus    arjen.markus@wldelft.nl
#       WL | Delft Hydraulics
#       The Netherlands
#
# Previous maintainer:
#       Olof Svensson   svensson@esrf.fr
#       European Synchrotron Radiation Facility
#       France
#
# Originally written by
#       Paul Casteels   casteels@uia.ua.ac.be
#       University of Antwerp   Dpt. Physics
#       Belgium
#


#
# Location of plplot directories
#
#PLDEST = c:\plplot
PLDEST = c:\plplot
PLDIR = ..\..\..
PLTMP = $(PLDIR)\tmp
PLLIB = $(PLDIR)\lib
PLBIN = $(PLDIR)\bin

#
# Device selection
#
WIN3 = PLD_win3
LJ_HPGL = PLD_lj_hpgl
NULL = PLD_null
PLMETA = PLD_plmeta
PS = PLD_ps
XFIG = PLD_xfig


.IGNORE:
default: links common libs

prepare: links common

links:
#
# Copy the necessary files to the temp dir
#
  @mkdir $(PLTMP)
  @mkdir $(PLTMP)\plplot
  @echo ``
  @echo `Copying source files to $(PLTMP)`
  @echo ``
  @copy $(PLDIR)\src\*.c $(PLTMP)\*.c
  @copy $(PLDIR)\include\*.h $(PLTMP)\*.h
  @copy $(PLDIR)\examples\c\*.c $(PLTMP)\*.c
  @copy $(PLDIR)\examples\c\*.h $(PLTMP)\*.h
  @copy $(PLDIR)\examples\c\lena.pgm $(PLTMP)\lena.pgm
  @copy $(PLDIR)\drivers\*.c $(PLTMP)\*.c
  @copy $(PLDIR)\utils\*.c $(PLTMP)\*.c
  @copy $(PLDIR)\data\*.fnt $(PLTMP)\*.fnt
  @copy $(PLDIR)\data\*.map $(PLTMP)\*.map
  @copy $(PLDIR)\bindings\python\plplotcmodule.i $(PLTMP)\plplotcmodule.i
  @copy $(PLDIR)\bindings\python\plplot_widgetmodule.c $(PLTMP)\plplot_widgetmodule.c
  @copy $(PLDIR)\bindings\python\*.py $(PLTMP)\*.py
#
# Copy the local source files to temp\
#
#  @copy src\*.c $(PLTMP)\*.cpp
  @copy src\win3.cpp $(PLTMP)
  @copy src\plconsole.cpp $(PLTMP)
  @copy src\plstub.cpp $(PLTMP)
  @copy src\resource.h $(PLTMP)
  @copy src\plplot.h $(PLTMP)
  @copy src\plplotd.dep $(PLTMP)
  @copy src\setup.py $(PLTMP)\setup.py
  @copy src\*.rc $(PLTMP)
  @copy src\*.ico $(PLTMP)
  @copy src\*.def $(PLTMP)
#
# Convert from Unix -> Dos
#
#  @echo ``
#  @echo `Converting Unix-2-Dos (add CRs)`
#  @echo ``
#  @crlf -fs $(PLTMP)\*.cpp
#  @crlf -fs $(PLTMP)\*.h
#  @crlf -fs $(PLTMP)\*.rc
#  @crlf -fs $(PLTMP)\*.def

common:
#
# Create plconfig.h file
#
  @echo ``
  @echo `Creating $(PLTMP)\plconfig.h`
  @echo <<$(PLTMP)\plconfig.h
#ifndef __PLCONFIG_H__
#define __PLCONFIG_H__
#define LIB_DIR "$(PLLIB:\=\\)"
#define BIN_DIR "$(PLBIN:\=\\)"
#define DATA_DIR "$(PLLIB:\=\\)"
#define DRV_DIR "$(PLLIB:\=\\)"
#define VERSION "5.6.0"
#define PL_DOUBLE
#endif
<<keep

# Create pldevs.h file
#
  @echo ``
  @echo `Creating $(PLTMP)\pldevs.h`
  @echo <<$(PLTMP)\pldevs.h
!ifdef CGM
#define PLD_cgm
!endif
!ifdef CPS
#define PLD_cps
!endif
!ifdef GIF
#define PLD_gif
!endif
!ifdef HPGL
#define PLD_hp7470
!endif
!ifdef HPGLL
#define PLD_hp7580
!endif
!ifdef JPEG
#define PLD_jpeg
!endif
!ifdef LJII
#define PLD_ljii
!endif
!ifdef LJHPGL
#define PLD_lj_hpgl
!endif
!ifdef MEM
#define PLD_mem
!endif
!ifdef NULL
#define PLD_null
!endif
!ifdef PBM
#define PLD_pbm
!endif
!ifdef PLMETA
#define PLD_plmeta
!endif
!ifdef PNG
#define PLD_png
!endif
!ifdef PS
#define PLD_ps
!endif
!ifdef PSTEX
#define PLD_pstex
!endif
!ifdef XFIG
#define PLD_xfig
!endif
!ifdef WIN3
#define PLD_win3
!endif
<<keep

libs: libstat libdyn

libstat:
    @cd plplib
    @nmake -f plplib.mak
    @cd ..

libdyn:
    @cd plpdll
    @nmake -f plpdll.mak
    @cd ..

install:
    @runinstall.bat $(PLDEST)

