

all: demo libdemo.so

clean:
	rm -fv *~ *.o demo my-demo-ui.h libdemo.so

# A hacked rule to quickly convert a Glade file to a header file
my-demo-ui.h:my-demo.glade
	quoted=`IFS=""; while read line; do echo -n \"; echo -n $$line | sed -e 's|\\"|\\\"|g'; echo \"; done < my-demo.glade` && \
	echo "const gchar *demo_builder_ui =" $$quoted ";" > $@;

# Building objects
my-demo.o: my-demo.c my-demo.h my-demo-ui.h
	gcc -o $@ -c my-demo.c -Wall -fPIC `pkg-config --cflags gtk+-3.0 gmodule-2.0`

main.o: main.c
	gcc -o $@ -c main.c -Wall `pkg-config --cflags --libs gtk+-3.0 gmodule-2.0`


# Build demo application 
demo: my-demo.o main.o
	gcc -o $@ my-demo.o main.o `pkg-config --libs gtk+-3.0  gmodule-2.0`

# Builde demo library
libdemo.so:my-demo.o
	gcc -o $@ --shared `pkg-config --libs gtk+-3.0 gmodule-2.0` $<
