ifeq ($(OS),Windows_NT)
all: lsbk.exe
else
all: lsbk img3tool demo_iostream_sink vfp iphoneusb iphoneusb2
endif

iphoneusb2:  iphoneusb2.cpp
	g++ -g -Wall -O0 $^ -I /opt/local/include -I ../../itsutils/common ../../itsutils/common/stringutils.cpp -L/opt/local/lib -liconv -lboost_thread-mt -lcrypto -o $@  -lreadline -lusb-1.0

iphoneusb:  iphoneusb.cpp
	g++ -g -Wall -O0 $^ -I /opt/local/include  -L/opt/local/lib -liconv -lboost_thread-mt -lcrypto -o $@  -lreadline -lusb

img3tool:  img3tool.cpp
	g++ -g -Wall -O0 $^ -I /opt/local/include -I ../../itsutils/common ../../itsutils/common/stringutils.cpp -L/opt/local/lib -liconv -lcrypto -o $@
demo_iostream_sink:  demo_iostream_sink.cpp
	g++ -g -Wall -O0 $^ -I /opt/local/include -I ../../itsutils/common ../../itsutils/common/stringutils.cpp -L/opt/local/lib -liconv -lcrypto -o $@
lsbk.exe: lsbk.cpp PlistParser.h
	cl -nologo -wd4060 -wd4100 -wd4127 -wd4242 -wd4244 -wd4296 -wd4365 -wd4512 -wd4571 -wd4619 -wd4668 -wd4710 -wd4820 -wd4826 -wd4996 -EHsc -DNOMINMAX -D_NO_RAPI -D_NO_WINDOWS -Zi -Wall -Od -I$(BOOST) -I../../itsutils/common  lsbk.cpp ../../itsutils/common/debug.cpp ../../itsutils/common/stringutils.cpp ../../itsutils/common/FileFunctions.cpp
lsbk: lsbk.cpp PlistParser.h
	g++  -D_NO_RAPI -D_NO_WINDOWS -g -Wall -O0 $(filter-out %.h,$^) -I /opt/local/include -I ../../itsutils/common ../../itsutils/common/debug.cpp ../../itsutils/common/FileFunctions.cpp ../../itsutils/common/stringutils.cpp -L/opt/local/lib -liconv -lcrypto -o $@

vfp: vfp.cpp
	g++ -Wall -O3 $^ -o $@ -lcrypto

test: img3tool
	# various os versions:
	./img3tool /Users/itsme-plain/projects/iphone/r7c144-iPhone2/Firmware/all_flash/all_flash.m68ap.production/DeviceTree.m68ap.img3
	./img3tool /Users/itsme-plain/projects/iphone/r7c144-iPhone3G/Firmware/all_flash/all_flash.m68ap.production/DeviceTree.m68ap.img3
	./img3tool /Users/itsme-plain/projects/iphone/r7c144-iPhone3GS/Firmware/all_flash/all_flash.n88ap.production/DeviceTree.n88ap.img3
	# try jb and non jb version of same file
	./img3tool /Users/itsme-plain/projects/iphone/r7c144-jb/Firmware/all_flash/all_flash.n88ap.production/LLB.n88ap.RELEASE.img3
	# try all options on non jb version
	./img3tool /Users/itsme-plain/projects/iphone/r7c144-iPhone3GS/Firmware/all_flash/all_flash.n88ap.production/LLB.n88ap.RELEASE.img3 
	./img3tool /Users/itsme-plain/projects/iphone/r7c144-iPhone3GS/Firmware/all_flash/all_flash.n88ap.production/LLB.n88ap.RELEASE.img3 -iv f6c407732804fde7baa6c18f4e9219b3 -k 23958c7975d357c09d5ae13d5824ecd7ba311d48e66e495cd9482bf541c23e17
	./img3tool /Users/itsme-plain/projects/iphone/r7c144-iPhone3GS/Firmware/all_flash/all_flash.n88ap.production/LLB.n88ap.RELEASE.img3 -o x.x
	./img3tool /Users/itsme-plain/projects/iphone/r7c144-iPhone3GS/Firmware/all_flash/all_flash.n88ap.production/LLB.n88ap.RELEASE.img3 -iv f6c407732804fde7baa6c18f4e9219b3 -k 23958c7975d357c09d5ae13d5824ecd7ba311d48e66e495cd9482bf541c23e17 -o x.x
