# To run this makefile, you must provide your system specific EXT and MATLABROOT
# variables on the command line e.g.:
#
# make -f Makefile_unix MATLABROOT="/usr/local/MATLAB/R2011a"  EXT=mexa64 

ifndef MATLABROOT
  $(warning MATLABROOT variable is undefined. Using default MATLABROOT="/usr/local/MATLAB/R2011a" )
  MATLABROOT=/usr/local/MATLAB/R2011a
endif

ifndef EXT
  $(warning EXT variable is undefined. Using default EXT=mexa64 )
  EXT=mexa64
endif

ifndef ARCH
  $(warning ARCH variable is undefined. Using default ARCH=glnxa64 )
  ARCH=glnxa64
endif

include ../../src/ostools.mk

MEXTGT=PolygonClip.$(EXT)
MEXSRC=PolygonClip.c ../GPC/gpc.c
LIBS= -L. -L"$(MATLABROOT)/bin/$(ARCH)" -lmex -lmx -static-libgcc 
INCLUDES= -I"$(MATLABROOT)/extern/include" -I. -I../GPC
CFLAGS=-fPIC -std=c99 -s -O3 -Wall -shared -DMATLAB_MEX_FILE 


all:
	$(CC) $(CFLAGS) $(INCLUDES) $(MEXSRC) $(LIBS) -o $(MEXTGT) 

clean:
	$(RM) $(MEXTGT)

.PHONY: all clean
