GUCHARMAP_CFLAGS = -DMAEMO_CHANGES -I/usr/include/gucharmap-2 -I/usr/include/gconf/2 -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12
GUCHARMAP_LIBS = -lgucharmap -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
HILDON_CFLAGS = -DMAEMO_CHANGES -DMAEMO_GTK -I/usr/include/hildon-1 -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12
HILDON_LIBS = -lhildon-1 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0

CFLAGS = -g -O2 -Wall -Werror \
	$(GUCHARMAP_CFLAGS) \
	$(HILDON_CFLAGS)
LDFLAGS = -Wall \
	$(GUCHARMAP_LIBS) \
	$(HILDON_LIBS)

TARGET = charmap

INSTALL_FILE = install -m 644 -p
INSTALL_PROGRAM = install -m 755 -p -s

####### Build rules

all: build

build: charmap.o maemo-gucharmap-chartable.o
	gcc -o $(TARGET) charmap.o maemo-gucharmap-chartable.o $(LDFLAGS)

charmap.o: charmap.c
	gcc -o charmap.o -c charmap.c $(CFLAGS)

maemo-gucharmap-chartable.o: maemo-gucharmap-chartable.c maemo-gucharmap-chartable.h
	gcc -o maemo-gucharmap-chartable.o -c maemo-gucharmap-chartable.c $(CFLAGS)

clean:
	rm -f $(TARGET) charmap.o maemo-gucharmap-chartable.o

####### Install

install_icon:
	test -d $(INSTALL_ROOT)/usr/share/icons/hicolor/64x64/apps/ || mkdir -p $(INSTALL_ROOT)/usr/share/icons/hicolor/64x64/apps/
	$(INSTALL_FILE) charmap64.png $(INSTALL_ROOT)/usr/share/icons/hicolor/64x64/apps/charmap.png

uninstall_icon:
	rm -f $(INSTALL_ROOT)/usr/share/icons/hicolor/64x64/apps/charmap.png

install_desktopfile:
	test -d $(INSTALL_ROOT)/usr/share/applications/hildon/ || mkdir -p $(INSTALL_ROOT)/usr/share/applications/hildon/
	$(INSTALL_FILE) charmap_fremantle.desktop $(INSTALL_ROOT)/usr/share/applications/hildon/charmap.desktop

uninstall_desktopfile:
	rm -f $(INSTALL_ROOT)/usr/share/applications/hildon/charmap.desktop

install_target:
	test -d $(INSTALL_ROOT)/opt/charmap/bin/ || mkdir -p $(INSTALL_ROOT)/opt/charmap/bin/
	$(INSTALL_PROGRAM) $(TARGET) $(INSTALL_ROOT)/opt/charmap/bin/charmap

uninstall_target:
	rm -f $(INSTALL_ROOT)/opt/charmap/bin/charmap
	rmdir $(INSTALL_ROOT)/opt/charmap/bin/
	rmdir $(INSTALL_ROOT)/opt/charmap/

install: build install_target install_icon install_desktopfile

uninstall: uninstall_desktopfile uninstall_icon uninstall_target
