
ifndef ASDCPLIB
$(error ASDCPLIB is not set)
endif

ifeq (,$(wildcard $(ASDCPLIB)/src/.libs/libasdcp.dylib))
$(error libasdcp.dylib not found, please build asdcplib before)
endif

ifeq (,$(wildcard $(ASDCPLIB)/src/.libs/libkumu.dylib))
$(error libkumu.dylib not found, please build asdcplib before)
endif

CPP=g++ \
	-g \
	-O2 \
	-Wl,-bind_at_load \
	-DHAVE_OPENSSL=1 

# COMMON
INCLUDES=`pkg-config openssl --cflags`
LIBRARIES=`pkg-config openssl --libs` -lpthread

# ASDCPLIB
INCLUDES_ASDCPLIB=-I$(ASDCPLIB)/src/
LIBRARIES_ASDCPLIB= \
	$(ASDCPLIB)/src/.libs/libasdcp.dylib \
	$(ASDCPLIB)/src/.libs/libkumu.dylib

asdcplib-create-encrypted-mxf:
	$(CPP) \
		-o /tmp/asdcplib-create-encrypted-mxf \
		asdcplib-create-encrypted-mxf.cpp \
		$(INCLUDES) $(LIBRARIES) \
		$(INCLUDES_ASDCPLIB) $(LIBRARIES_ASDCPLIB)

asdcplib-create-encrypted-mxf-exec:
	DYLD_LIBRARY_PATH="$(ASDCPLIB)/src/.libs:${DYLD_LIBRARY_PATH}" \
		/tmp/asdcplib-create-encrypted-mxf

asdcplib-hmac:
	$(CPP) \
		-o /tmp/asdcplib-hmac \
		asdcplib-hmac.cpp \
		$(INCLUDES) $(LIBRARIES) \
		$(INCLUDES_ASDCPLIB) $(LIBRARIES_ASDCPLIB)

asdcplib-hmac-exec:
	DYLD_LIBRARY_PATH="$(ASDCPLIB)/src/.libs:${DYLD_LIBRARY_PATH}" \
		/tmp/asdcplib-hmac

asdcplib-fips-lite:
	$(CPP) \
		-o /tmp/asdcplib-fips-lite \
		asdcplib-fips-lite.cpp \
		$(INCLUDES) $(LIBRARIES)


proto-hmac:
	$(CPP) \
		-o /tmp/proto-hmac \
		proto-hmac.c \
		$(INCLUDES) $(LIBRARIES)
