# You should set -march to your CPU architecture. There is an instruction in the SIMD expansions that you want.

all : BLDDcompact BLDDexpand

BLDDcompact : BLDDcompact.c md5.c md5.h
	gcc BLDDcompact.c -o BLDDcompact --std=c99 md5.c -O3 -D_LARGEFILE_64

BLDDcompactstream : BLDDcompactstream.c md5.c md5.h
	gcc BLDDcompactstream.c -o BLDDcompactstream --std=c99 md5.c -O3 -Wall

BLDDexpand : BLDDexpand.c
	gcc BLDDexpand.c md5.c -o BLDDexpand -std=c99

clean :
	rm BLDDcompact BLDDexpand BLDDcompactstream BLDDexpand.exe BLDDcompact.exe

windows: BLDDexpand.c BLDDcompact.c md5.c md5.h
	i586-mingw32msvc-gcc BLDDexpand.c --std=c99 md5.c -o BLDDexpand.exe
	i586-mingw32msvc-gcc BLDDcompact.c --std=c99 md5.c -o BLDDcompact.exe -DWINDOWS

install : BLDDcompact BLDDexpand
	cp BLDDcompact /usr/bin/
	cp BLDDexpand /usr/bin/

test : test.bin BLDDcompact BLDDexpand
	./BLDDcompact test.bin test.bldd
	./BLDDexpand test.bldd test.out -h
	md5sum test.bin test.out
	ls -l test.bin test.bldd test.out

mediumtest : mediumtest.bin BLDDcompact BLDDexpand
	./BLDDcompact mediumtest.bin mediumtest.bldd
	./BLDDexpand mediumtest.bldd mediumtest.out -h
	md5sum mediumtest.bin mediumtest.out
	ls -l mediumtest.*


tinytest : tinytest.bin BLDDcompact BLDDexpand
	./BLDDcompact tinytest.bin tinytest.bldd
	./BLDDexpand tinytest.bldd tinytest.out -h
	md5sum tinytest.bin tinytest.out

bigtest : bigtest.bin BLDDcompact BLDDexpand
	./BLDDcompact bigtest.bin bigtest.bldd
	./BLDDexpand bigtest.bldd bigtest.out -h
	md5sum bigtest.bin bigtest.out

tinytest.bin:
	dd if=/dev/urandom of=tinytest.bin bs=1024 count=1000
	dd if=tinytest.bin of=tinytest.bin conv=notrunc count=128 skip=148

test.bin :
	dd if=/dev/urandom of=test.bin bs=1024 count=1000000
	dd if=test.bin of=test.bin conv=notrunc count=1024 skip=400000
	dd if=test.bin of=test.bin conv=notrunc count=1024 seek=2000 skip=13000
	dd if=test.bin of=test.bin conv=notrunc count=1024 seek=4000 skip=22000
	dd if=test.bin of=test.bin conv=notrunc count=1024 seek=6000 skip=180000
	dd if=test.bin of=test.bin conv=notrunc count=4096 seek=100000 skip=300000

bigtest.bin :
	dd if=/dev/urandom of=bigtest.bin bs=1024 count=100000000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1932 skip=1000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=192 seek=2000 skip=4000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1935 seek=4000 skip=6000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1933 seek=10000 skip=18000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1938 seek=12000 skip=300000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=19320 seek=100000 skip=10000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1920 seek=120000 skip=40000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=19350 seek=12200 skip=60000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=19330 seek=1000000 skip=180000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=19380 seek=1100000 skip=38900000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=9932 seek=1200000 skip=40000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=992 seek=1290000 skip=48000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=9935 seek=20000000 skip=64000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=100000 seek=20100000 skip=50000000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=20000000 seek=20200000 skip=50000000

mediumtest.bin :
	dd if=/dev/urandom of=mediumtest.bin bs=1024 count=10000000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1932 skip=1000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=192 seek=2000 skip=4000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1935 seek=4000 skip=6000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1933 seek=10000 skip=18000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1938 seek=12000 skip=300000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=19320 seek=100000 skip=10000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=1920 seek=120000 skip=40000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=19350 seek=12200 skip=60000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=19330 seek=1000000 skip=180000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=9932 seek=1200000 skip=40000
	dd if=bigtest.bin of=bigtest.bin conv=notrunc count=992 seek=1290000 skip=48000

