CC=gcc
CFLAGS=-g -Wall -fPIC
LDFLAGS=
INCLUDES=

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

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

all: usplash-theme-hp.so

usplash-theme-hp.so: throbber_back.png.c.o throbber_back_16.png.c.o throbber_fore.png.c.o throbber_fore_16.png.c.o \
						 usplash_hp_1024_768.png.c.o usplash_hp_1365_768_scaled.png.c.o usplash_hp_800_600.png.c.o \
						 usplash_hp_640_400.png.c.o usplash_hp_640_480.png.c.o \
						 usplash_compaq_1024_768.png.c.o usplash_compaq_1365_768_scaled.png.c.o usplash_compaq_800_600.png.c.o \
						 usplash_compaq_640_400.png.c.o usplash_compaq_640_480.png.c.o \
						 usplash-theme-hp.c.o
	$(COMPILE) -shared -o $@ $^

# NOTE that in usplash, all pixmaps must be generated in a 4:3 ratio, even for 16:9 displays (they will be scaled)
usplash_hp_1024_768.png: background_hp_1024x600.png
	convert $< +dither -map background_hp_1024x600.png -geometry 1024x768! gif:- | convert gif:- $@
usplash_hp_1365_768.png: background_hp_1024x600.png
	convert $< +dither -map background_hp_1024x600.png -geometry 1024x768! gif:- | convert gif:- $@
usplash_hp_1365_768_scaled.png: background_hp_1024x600.png
	convert $< +dither -map background_hp_1024x600.png -geometry 1024x768! gif:- | convert gif:- $@
usplash_hp_640_400.png: background_hp_1024x600.png
	convert $< +dither -map background_hp_1024x600.png -geometry 640x400! gif:- | convert gif:- $@
usplash_hp_640_480.png: background_hp_1024x600.png
	convert $< +dither -map background_hp_1024x600.png -geometry 640x480! gif:- | convert gif:- $@
usplash_hp_800_600.png: background_hp_1024x600.png
	convert $< +dither -map background_hp_1024x600.png -geometry 800x600! gif:- | convert gif:- $@
	
usplash_compaq_1024_768.png: background_compaq_1024x600.png
	convert $< +dither -map background_compaq_1024x600.png -geometry 1024x768! gif:- | convert gif:- $@
usplash_compaq_1365_768.png: background_compaq_1024x600.png
	convert $< +dither -map background_compaq_1024x600.png -geometry 1024x768! gif:- | convert gif:- $@
usplash_compaq_1365_768_scaled.png: background_compaq_1024x600.png
	convert $< +dither -map background_compaq_1024x600.png -geometry 1024x768! gif:- | convert gif:- $@
usplash_compaq_640_400.png: background_compaq_1024x600.png
	convert $< +dither -map background_compaq_1024x600.png -geometry 640x400! gif:- | convert gif:- $@
usplash_compaq_640_480.png: background_compaq_1024x600.png
	convert $< +dither -map background_compaq_1024x600.png -geometry 640x480! gif:- | convert gif:- $@
usplash_compaq_800_600.png: background_compaq_1024x600.png
	convert $< +dither -map background_compaq_1024x600.png -geometry 800x600! gif:- | convert gif:- $@
	
throbber_back.png: throbber_back_hp.png
	convert $< +dither -map background_hp_1024x600.png gif:- | convert gif:- $@
throbber_fore.png: throbber_fore_hp.png
	convert $< +dither -map background_hp_1024x600.png gif:- | convert gif:- $@


%.png.c: %.png
	pngtousplash $< > $@

%.bdf.c: %.bdf
	bdftousplash $< > $@

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

install:
	$(INSTALL) -d $(DESTDIR)/usr/lib/usplash
	$(INSTALL_PROGRAM) usplash-theme-hp.so $(DESTDIR)/usr/lib/usplash/usplash-theme-hp.so
clean:
	rm -f *.png.c *.bdf.c *.c.o *.so usplash_*_*.png
	rm -f throbber_fore.png throbber_back.png
