CC=gcc
CFLAGS=-g -Wall -Wformat-truncation=0 -Ideps -I/usr/include/SDL2
LDFLAGS=-lSDL2 -lSDL2_image -lSDL2_ttf

all: re tests tests_utf8

recenteditor.o: recenteditor.c re_data.h ext/socklib.h

re_data.o: re_data.c re_data.h

re_plugin_unsaved.o: re_plugin_unsaved.c re_plugin_unsaved.h re_data.h

re_ui.o: re_ui.c re_ui.h hack_regular.h

re_tests.o: re_tests.c re_data.h

re_tests_utf8.o: re_tests_utf8.c re_ui.h

sha3.o: sha3/sha3.c sha3/sha3.h
	$(CC) $(CFLAGS) -Isha3 -c -o sha3.o sha3/sha3.c

hack_regular.c: ttf/Hack-Regular.ttf
	./ttf2h.sh ttf/Hack-Regular.ttf

hack_regular.h: ttf/Hack-Regular.ttf
	./ttf2h.sh ttf/Hack-Regular.ttf

hack_regular.o: hack_regular.c
	$(CC) $(CFLAGS) -c -o hack_regular.o hack_regular.c

socklib.o: ext/socklib.c ext/socklib.h
	$(CC) $(CFLAGS) -Iext -c -o socklib.o ext/socklib.c

re: recenteditor.o re_data.o re_plugin_unsaved.o sha3.o re_ui.o hack_regular.o socklib.o
	$(CC) $(LDFLAGS) -o re recenteditor.o re_data.o re_plugin_unsaved.o sha3.o re_ui.o hack_regular.o socklib.o

tests: re_tests.o re_data.o sha3.o
	$(CC) $(LDFLAGS) -o tests re_tests.o re_data.o sha3.o

tests_utf8: re_tests_utf8.o re_data.o sha3.o
	$(CC) $(LDFLAGS) -o tests_utf8 re_tests_utf8.o re_data.o sha3.o

clean:
	rm -f recenteditor.o re_data.o re_tests.o re_plugin_unsaved.o sha3.o re_ui.o hack_regular.c hack_regular.h hack_regular.o re tests