# This line gets the MEX extension for the platform. If the shell
# command 'mexext' is not available on your Matlab installation,
# please execute the 'mexext' command within Matlab, and put the
# answer into the line below (remember to uncomment).
#EXT = $(shell mexext)
#EXT = $(glnx86)

ifndef MATLABROOT
  $(warning MATLABROOT variable is undefined. Using default MATLABROOT="/Applications/MATLAB_R2013a.app/")
  MATLABROOT=/Applications/MATLAB_R2013a.app/
endif

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

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

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

MEXTGT=PolygonClip.$(EXT)
MEXSRC=PolygonClip.c ../GPC/gpc.c
LIBS= -L. -L"$(MATLABROOT)/bin/$(ARCH)" -lmex -lmx 
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
