######## Follow the simple 3-step procedure below to choose OS platform, options, etc.
######## Then type 'make'
########
######## With the standard build, the following binaries should be created:
######## 	pl
########
######## In order to use ploticus prefabs, the  environment variable PLOTICUS_PREFABS 
######## will need to exist and contain the full path name of the ./prefabs directory.
######## Eg: export PLOTICUS_PREFABS=/home/src/ploticus/prefabs
########
######## PLOTICUS data display engine.  Software, documentation, and examples.  
######## Copyright 1998-2001 Stephen C. Grubb  (scg@jax.org)
######## Covered by GPL; see the file ./Copyright for details. 

# defaults..
CC = gcc
PLATFORM = UNIX
RMCOM = rm -f
XOBJ = x11.o sleep.o interact.o
PLPNG = plpng 



######## Step 1.     Select an OS platform below.
######## Choose one of the following.   All others should be commented out.

#### For Solaris 2.x uncomment the following..
XLIBS = -L/usr/openwin/lib -lX11
XINCLUDEDIR = -I/usr/openwin/include

#### For Linux and FreeBSD uncomment the following..
XLIBS = -L/usr/X11R6/lib -lX11
XINCLUDEDIR = -I/usr/X11R6/include

#### For Cygwin uncomment the following..
# PLATFORM = WIN32
# XLIBS = -L/usr/X11R6/lib -lX11
# XINCLUDEDIR = -I/usr/X11R6/include
# NORLIMFLAG = -DNORLIMIT

#### For Windows/NT compiled using MinGW uncomment the following..
# PLATFORM = WIN32
# RMCOM = del
# XOBJ = 
# NOXFLAG = -DNOX11
# NORLIMFLAG = -DNORLIMIT

#### For AIX 3.2.5, HP-UX 10.20 uncomment the following..
# XLIBS = -L /usr/X11/lib -lX11
# XINCLUDEDIR = -I/usr/X11/include
## ..note for HP-UX it was necessary to do: ln gd_io.h gd16 by hand to get the png compiled

#### For SunOS4, Irix, other BSD uncomment the following..
# XLIBS = -L/usr/lib -lX11
# XINCLUDEDIR = -I/usr/include
## ..note the following additional lines were necessary on the Irix system we used:  CC = cc    FLAGS = -o32

#### For UnixWare uncomment the following..
# XLIBS = -L/usr/X11/lib -lX11
# XINCLUDEDIR = -I/usr/X11/include
# ADDLIBS = -lnsl -lresolv -L/usr/ucblib -lucb
## ..note: the following was necessary on the UnixWare system we used: CC = cc

#### For MPE/iX uncomment the following..
# XLIBS = -L/usr/local/lib -lX11
# XINCLUDEDIR = -I/usr/local/include
# FLAGS = -D_POSIX_SOURCE
# CC = /usr/local/bin/gcc  





######## Step 2.     GD options
######## Ploticus uses the GD library (www.boutell.com/gd) for raster image creation.
######## See the README file for more help, and where to get libs.
########
######## Choose ONE of the following.  All others should be commented out.

#### For pseudo-GIF uncomment the following..  (no libs required)
# ploticus: pl

#### For PNG uncomment the following.. (you must have libpng and zlib)
# ploticus: plpng
# PLPNG = pl 
# GD16LIBS = -lpng -lz
# GD16H = 
# ZFLAG = -DWZ

#### For both pseudo-GIF & PNG uncomment the following..  (you must have libpng and zlib)
# ploticus: pl plpng
# GD16LIBS = -lpng -lz
# GD16H = 

#### For JPEG, WBMP, and PNG using your copy of GD 1.84+ uncomment the following.. 
#### (you must have gd 1.84+, libpng, zlib, libjpeg)
# ploticus: plgd18
# GD18LIBS = -lgd -lpng -lz -ljpeg 
# GD18H = 
# GDFREETYPE = 
# ZFLAG = -DWZ

#### For JPEG, WBMP, and PNG & FreeType2 using your copy of GD 1.84+ uncomment the following..
#### (you must have gd 1.84+, libpng, zlib, libjpeg, libfreetype)
#### Before using set environment var GDFONTPATH to directory containing .ttf files
ploticus: plgd18
PREFABS_DIR = "/usr/share/ploticus"
GD18LIBS = -lgd -lpng -lz -ljpeg -lfreetype
GD18H = 
GDFREETYPE = -DGDFREETYPE
ZFLAG = -DWZ
GDFONTPATH = "/usr/share/fonts/truetype/openoffice:/usr/share/fonts/truetype:/usr/share/fonts/truetype/commercial"

#### To disable GD image support (no GIF, PNG, JPEG, etc) uncomment the following..
# ploticus: plnogd
# NOGDFLAG = -DNOGD



######## Step 3.  
######## Some other things you might want control over..

#### To set a hard-coded directory for prefabs files, uncomment & edit the following.. 
#### If done, users won't be required to have PLOTICUS_PREFABS environment variable defined.
#### This option not available for win32
PREFABS_DIR = "/usr/share/ploticus"

#### For LOCALE support (non-roman alphabets & collation), uncomment the following..
LOCALEOBJ = localef.o
LOCALE_FLAG = -DLOCALE

#### If you want compressed svg (.svgz), and you selected "GIF only", "GIF & PNG", or "disable GD" above, 
#### uncomment the following.  You need to have zlib.  If necessary change -lz to location of zlib.
ZLIB = -lz
ZFLAG = -DWZ

#### To completely remove X11 from any of the above unix builds, uncomment the following..
# NOXFLAG = -DNOX11
# XLIBS = 
# XOBJ =

#### To completely remove safety limits on cpu time & disk space consumption uncomment the following..
# NORLIMFLAG = -DNORLIMIT



######## Done.  Now save this file and type:  make
########
######## You probably won't have to change anything below this point...

#### for basic gd build..
GD13 = grgd13.o devstuff13.o gd13.o 
GD16 = grgd16.o devstuff16.o gd16.o gd_io.o gd_io_dp.o gd_io_file.o gd_png.o 
GD = gdfontg.o gdfontl.o gdfontmb.o gdfonts.o gdfontt.o


LIBS = $(XLIBS) -lm $(ADDLIBS) 

CFLAGS = -DPLOTICUS -D$(PLATFORM) -DTDH_NOREC $(ZFLAG) $(FLAGS) $(LOCALE_FLAG) \
  $(NOGDFLAG) $(NOXFLAG) $(XINCLUDEDIR) $(NORLIMFLAG) -DPREFABS_DIR=\"$(PREFABS_DIR)\"

OBJ = 	proc_annotate.o proc_areadef.o proc_axis.o proc_bars.o proc_rect.o proc_breakaxis.o \
  proc_catslide.o proc_curvefit.o proc_settings.o proc_defineunits.o proc_drawcommands.o \
  proc_getdata.o proc_import.o proc_legend.o proc_legendentry.o proc_line.o proc_lineplot.o \
  proc_page.o proc_pie.o proc_print.o proc_processdata.o proc_rangebar.o proc_rangesweep.o \
  proc_scatterplot.o proc_symbol.o proc_tabulate.o mapfile.o\
  plhead.o execplfile.o lib.o details.o parse.o units.o preliminaries.o \
  plvalue_subst.o process_arg.o do_x_button.o cats.o fieldnames.o autorange.o select.o \
  color.o graphcore.o init.o arrow.o mark.o block.o pcode.o ps.o svg.o stub.o winscale.o lineclip.o \
  condex.o dates.o dbinterface.o err.o functions.o glroutines.o reslimits.o secondaryops.o  \
  shell.o sinterp.o tdhkit.o times.o value.o value_subst.o variable.o custom.o datetime.o \
  $(LOCALEOBJ)


pl: pl.o $(OBJ) $(XOBJ) gdfiles gd13files
	$(CC) pl.o $(FLAGS) $(OBJ) $(GD13) $(GD) $(XOBJ) $(LIBS) $(ZLIB) -o pl

plpng: pl.o $(OBJ) $(XOBJ) gdfiles gd16files
	$(CC) pl.o $(FLAGS) $(OBJ) $(GD16) $(GD) $(XOBJ) $(GD16LIBS) $(LIBS) -o $(PLPNG)

gdfiles: 
	$(CC) -I./gd13 -I./ -c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c
	echo "done with gdfiles" > gdfiles

gd13files: 
	$(CC) -c grgd.c -DGD13 -I./gd13 -o grgd13.o
	$(CC) -c $(CFLAGS) devstuff.c -DGD13 -o devstuff13.o
	$(CC) -c gd13.c -I./gd13 
	echo "done with gd13files" > gd13files

gd16files: 
	$(CC) -c grgd.c -DGD16 -I./ -I./gd16 -o grgd16.o
	$(CC) -c $(CFLAGS) devstuff.c -DGD16 -o devstuff16.o
	$(CC) -c -I./gd16 -I./ $(GD16H) gd16.c gd_io.c gd_io_dp.c gd_io_file.c gd_png.c
	echo "done with gd16files" > gd16files

# GD18: 
plgd18: pl.o $(OBJ) $(XOBJ) gd18files
	$(CC) $(FLAGS) pl.o grgd.o devstuff.o $(OBJ) $(XOBJ) $(GD18LIBS) $(LIBS) -o pl

gd18files:
	$(CC) -c grgd.c devstuff.c -DGD18 $(GDFREETYPE) $(GD18H) $(CFLAGS)


# NOGD: 
plnogd: pl.o $(OBJ) $(XOBJ) nogdfiles
	$(CC) $(FLAGS) pl.o devstuff.o $(OBJ) $(XOBJ) $(LIBS) $(ZLIB) -o pl

nogdfiles:
	$(CC) -c devstuff.c $(CFLAGS)



install:
	mv pl *png ../bin 

clean:
	$(RMCOM) pl.o $(OBJ) $(GD) $(GD13) $(GD16) $(XOBJ) devstuff.o
	$(RMCOM) gdfiles gd13files gd16files
