# OpenCV should be installed on the system
#   Assuming the system has pkg-config
CFLAGS = `pkg-config --cflags opencv`
LFLAGS = `pkg-config --libs opencv`

target: libcv.dl libhighgui.dl

# for libcv.dl
libcv.dl: cv_chdl.o cv_retstruct_chdl.o cxcore_retstruct_chdl.o cvSetIPLAllocators_chdl.o \
	cvSetMemoryManager_chdl.o cxcore_chdl.o cvaux_chdl.o constcharp2_chdl.o
	ch dllink libcv.dl cv_chdl.o cv_retstruct_chdl.o cxcore_retstruct_chdl.o cvSetIPLAllocators_chdl.o \
	cvSetMemoryManager_chdl.o cxcore_chdl.o cvaux_chdl.o constcharp2_chdl.o  $(LFLAGS) 

cv_chdl.o: cv_chdl.c
	ch dlcomp libcv.dl -cplusplus cv_chdl.c $(CFLAGS)

cxcore_chdl.o: cxcore_chdl.c
	ch dlcomp libcv.dl -cplusplus cxcore_chdl.c $(CFLAGS)

cvaux_chdl.o: cvaux_chdl.c
	ch dlcomp libcv.dl cvaux_chdl.c $(CFLAGS)

cv_retstruct_chdl.o: handmade/cv/cv_retstruct_chdl.c
	ch dlcomp libcv.dl -cplusplus handmade/cv/cv_retstruct_chdl.c $(CFLAGS)

cxcore_retstruct_chdl.o: handmade/cxcore/cxcore_retstruct_chdl.c
	ch dlcomp libcv.dl -cplusplus handmade/cxcore/cxcore_retstruct_chdl.c $(CFLAGS)

cvSetIPLAllocators_chdl.o: handmade/cxcore/cvSetIPLAllocators_chdl.c
	ch dlcomp libcv.dl -cplusplus handmade/cxcore/cvSetIPLAllocators_chdl.c $(CFLAGS)

cvSetMemoryManager_chdl.o: handmade/cxcore/cvSetMemoryManager_chdl.c
	ch dlcomp libcv.dl -cplusplus handmade/cxcore/cvSetMemoryManager_chdl.c $(CFLAGS)

constcharp2_chdl.o: handmade/cxcore/constcharp2_chdl.c
	ch dlcomp libcv.dl -cplusplus handmade/cxcore/constcharp2_chdl.c $(CFLAGS)


# for libhighgui.dl
libhighgui.dl: highgui_chdl.o  cvCreateTrackbar_chdl.o cvSetMouseCallback_chdl.o
	ch dllink libhighgui.dl highgui_chdl.o  cvCreateTrackbar_chdl.o cvSetMouseCallback_chdl.o \
                  $(LFLAGS)

highgui_chdl.o: highgui_chdl.c
	ch dlcomp highgui.dl -cplusplus highgui_chdl.c $(CFLAGS)

cvSetMouseCallback_chdl.o: handmade/highgui/cvSetMouseCallback_chdl.c
	ch dlcomp highgui.dl -cplusplus handmade/highgui/cvSetMouseCallback_chdl.c $(CFLAGS)

cvCreateTrackbar_chdl.o: handmade/highgui/cvCreateTrackbar_chdl.c
	ch dlcomp highgui.dl -cplusplus handmade/highgui/cvCreateTrackbar_chdl.c $(CFLAGS)


clean:
	rm -rf *.o *.obj *.dl *.exp *.lib
