# Makefile.dll
#
# David Billinghurst
# Comalco Research Centre, Melbourne, Australia
# David.Billinghurst@riotinto.com.au
#
# Use this to build pgplot as a dll using cygwin b20.1 
#
# Based on Mumit Khan's dllhelper-2.5 package.
# See http://www.xraylith.wisc.edu/~khan/software/gnu-win32/dllhelpers.html


AS = as
DLLTOOL = dlltool -v
DLLWRAP = dllwrap -v

DLL_NAME = pgplot.dll
DLL_EXP_LIB = libpgplot.a
DLL_EXP_DEF = pgplot.def
#
#The default entry point defined by dllwrap; the default user callback
# is DllMain, and there is stub in dllinit.c. 
DLL_LDFLAGS = 
# any extra libraries that your DLL may depend on.
DLL_LDLIBS = $(LIBS)

DLL_OBJS =  $(PG_ROUTINES) $(PG_NON_STANDARD) $(GR_ROUTINES) \
	   $(DISPATCH_ROUTINE) $(DRIVERS) $(SYSTEM_ROUTINES)

DLLWRAP_FLAGS = --export-all --output-def $(DLL_EXP_DEF) \
	--implib $(DLL_EXP_LIB) \
	--driver-name $(FCOMPL)

$(DLL_NAME) $(DLL_EXP_DEF) $(DLL_EXP_LIB): $(DLL_OBJS)
	$(DLLWRAP) $(DLLWRAP_FLAGS) -o $(DLL_NAME) \
	    $(DLL_OBJS) $(DLL_LDFLAGS) $(DLL_LDLIBS)


CPG_SOURCE := cpgarro.c cpgask.c cpgaxis.c cpgband.c cpgbbuf.c \
  cpgbeg.c cpgbin.c cpgbox.c cpgcirc.c cpgclos.c cpgconb.c cpgconf.c \
  cpgconl.c cpgcons.c cpgcont.c cpgctab.c cpgcurs.c cpgdraw.c cpgebuf.c \
  cpgend.c cpgenv.c cpgeras.c cpgerr1.c cpgerrb.c cpgerrx.c cpgerry.c \
  cpgetxt.c cpggray.c cpghi2d.c cpghist.c cpgiden.c cpgimag.c cpglab.c \
  cpglcur.c cpgldev.c cpglen.c cpgline.c cpgmove.c cpgmtxt.c cpgncur.c \
  cpgnumb.c cpgolin.c cpgopen.c cpgpage.c cpgpanl.c cpgpap.c cpgpixl.c \
  cpgpnts.c cpgpoly.c cpgpt.c cpgpt1.c cpgptxt.c cpgqah.c \
  cpgqcf.c cpgqch.c cpgqci.c cpgqcir.c cpgqclp.c cpgqcol.c cpgqcr.c \
  cpgqcs.c cpgqdt.c cpgqfs.c cpgqhs.c cpgqid.c cpgqinf.c cpgqitf.c \
  cpgqls.c cpgqlw.c cpgqndt.c cpgqpos.c cpgqtbg.c cpgqtxt.c cpgqvp.c \
  cpgqvsz.c cpgqwin.c cpgrect.c cpgrnd.c cpgrnge.c cpgsah.c cpgsave.c \
  cpgscf.c cpgsch.c cpgsci.c cpgscir.c cpgsclp.c cpgscr.c cpgscrl.c \
  cpgscrn.c cpgsfs.c cpgshls.c cpgshs.c cpgsitf.c cpgslct.c cpgsls.c \
  cpgslw.c cpgstbg.c cpgsubp.c cpgsvp.c cpgswin.c cpgtbox.c cpgtext.c \
  cpgtick.c cpgunsa.c cpgupdt.c cpgvect.c cpgvsiz.c cpgvstd.c cpgwedg.c \
  cpgwnad.c

cpgplot.h: $(PG_SOURCE) pgbind  
	./pgbind $(PGBIND_FLAGS) -h -w $(PG_SOURCE)

CDLL_NAME = cpgplot.dll
CDLL_EXP_LIB = libcpgplot.a
CDLL_EXP_DEF = cpgplot.def
CDLL_OBJS =  $(CPG_SOURCE:.c=.o)
CDLL_LDLIBS = -L. -lpgplot

CDLLWRAP_FLAGS = --export-all --output-def $(CDLL_EXP_DEF) \
	--implib $(CDLL_EXP_LIB) \
	--driver-name $(CCOMPL)

$(CDLL_NAME) $(CDLL_EXP_DEF) $(CDLL_EXP_LIB): $(CDLL_OBJS)
	$(DLLWRAP) $(CDLLWRAP_FLAGS) -o $(CDLL_NAME) \
	    $(CDLL_OBJS) $(DLL_LDFLAGS) $(CDLL_LDLIBS)

%.o: %.c
	$(CCOMPL) -c $(CFLAGC) $(*).c
