# Makefile
#
# 07/29/12

ifeq ($(OSTYPE),cygwin)
eext = .exe
cc = i686-w64-mingw32-gcc
strip = i686-w64-mingw32-strip
cflags = -O3 -Wall -std=c99 -pedantic -finline-functions -include binmode_main.h -static
else
eext =
cc = gcc
strip = strip
cflags = -O3 -Wall -std=c99 -pedantic -finline-functions -static
endif
ifeq ($(DEBUG),1)
debug_opt = -g
strip = true
else
debug_opt = -DNDEBUG
endif

target = nyaruko$(eext)

nyaruko$(eext): nyaruko.c
	$(cc) $(cflags) $(debug_opt) $< -o $@
	$(strip) $@

isaac$(eext): isaac.c
	$(cc) $(cflags) $(debug_opt) $< -o $@
	$(strip) $@

base85$(eext): base85.c
	$(cc) $(cflags) $(debug_opt) $< -o $@

base85_enc$(eext): base85_enc.c
	$(cc) $(cflags) $(debug_opt) $< -o $@

encode_stub$(eext): encode_stub.c
	$(cc) $(cflags) $(debug_opt) $< -o $@

decode_stub$(eext): decode_stub.c
	$(cc) $(cflags) $(debug_opt) $< -o $@

container$(eext): container.c
	$(cc) $(cflags) $(debug_opt) $< -o $@

clean:
	-rm -f $(target) isaac$(eext) base85$(eext) base85_enc$(eext) encode_stub$(eext) decode_stub$(eext) container$(eext)

backup:
	-rm -f backup.tar.xz
	tar cf backup.tar *.c *.pl *.txt *.log *.sh Makefile
	xz -9 backup.tar
