CC=gcc
CFLAGS=-g -Wall
LDFLAGS=
CPPFLAGS=-D_GNU_SOURCE
INCLUDES=-Ibogl

COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
LINK = $(CC) $(CFLAGS) $(LDFLAGS)

INSTALL = /usr/bin/install -c
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_PROGRAM = $(INSTALL) -m 755


TARGETS = usplash usplash_write

all: bogl $(TARGETS)


usplash_OBJECTS = usplash.o usplash-testcard.o usplash-testcard-theme.o
usplash_LIBS = bogl/libbogl.a

usplash: $(usplash_OBJECTS) $(usplash_LIBS)
	$(LINK) -o $@ $^ -ldl


usplash_write_OBJECTS = usplash_write.o

usplash_write: $(usplash_write_OBJECTS)
	$(LINK) -o $@ $^


bogl:
	$(MAKE) -C bogl


.c.o:
	$(COMPILE) -o $@ -c $<

.png.c:
	./bogl/pngtobogl $< > $@

.bdf.c:
	./bogl/bdftobogl $< > $@


install:
	$(INSTALL_PROGRAM) usplash $(DESTDIR)/sbin
	$(INSTALL_PROGRAM) usplash_write $(DESTDIR)/sbin

clean:
	-$(MAKE) -C bogl clean
	-rm -f $(TARGETS) $(usplash_OBJECTS) $(usplash_write_OBJECTS)
	-rm -f *~


.PHONY: all bogl install clean
.SUFFIXES: .png .bdf
