.PHONY: all clean

all: shell term germ logo

ifdef VERBOSE
Q =
E = @ :
else
Q = @
E = @ echo
endif

clean:
	$(E) CLEAN
	$(Q) rm -f *.[od] shell term germ logo build_fira_mono_tables fira_mono_tables.h

INCLUDE_PATHS = -I. -I/usr/include/libdrm -I/usr/include/freetype2

%.o: %.c
	$(E) "CC  $@"
	$(Q) $(CC) $(CFLAGS) -c -Wall -D_GNU_SOURCE -std=gnu11 -MMD $(INCLUDE_PATHS) $<

germ.c: fira_mono_tables.h
term.c: fira_mono_tables.h

shell: shell.o keymap.o
	$(E) "CC  $@"
	$(Q) $(CC) -o $@ $^ -lsystemd -ldrm -ludev

term: term.o keymap.o
	$(E) "CC  $@"
	$(Q) $(CC) -o $@ $^

germ: germ.o keymap.o
	$(E) "CC  $@"
	$(Q) $(CC) -o $@ $^

logo: logo.o
	$(E) "CC  $@"
	$(Q) $(CC) -o $@ $^

build_fira_mono_tables: build_fira_mono_tables.o
	$(E) "CC  $@"
	$(Q) $(CC) -o $@ $^ -lfreetype

fira_mono_tables.h: build_fira_mono_tables
	$(E) "GEN $@"
	$(Q) ./build_fira_mono_tables >$@

-include *.d