Description: Modernize Makefile
 Use pkg-config instead of using hardcoded compilation/link flags and add
 install target to Makefile.
Author: Alexandros Frantzis <alexandros.frantzis@linaro.org>
Last-Update: 2010-06-29
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,23 @@
 SRCS = main.c
-HEAD = 
-FLGS = -g -I/usr/X11R6/include `imlib2-config --cflags`
-LIBS = -L/usr/X11R6/lib -lm -lX11 -lXext -lXrender `imlib2-config --libs`
+FLGS = `pkg-config --cflags imlib2 xrender x11`
+LIBS = `pkg-config --libs imlib2 xrender x11`
+LDFLAGS = -Wl,--as-needed
+DATA_PATH=/usr/share/render-bench/
+DEFINES = -DDATA_PATH=\"$(DATA_PATH)\"
 ####################
 OBJS = $(SRCS:.c=.o)
 
 render_bench: $(OBJS)
 	$(RM) $@
-	$(CC) -o $@ $(OBJS) $(LIBS)
+	$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)
 
 .c.o:
-	$(CC) $(FLGS) -c $< -o $@
+	$(CC) $(DEFINES) $(FLGS) $(CFLAGS) -c $< -o $@
 
 clean::
 	rm -rf render_bench *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut "#"*
+
+install: render_bench
+	install -D render_bench $(DESTDIR)/usr/bin/render_bench
+	install -d $(DESTDIR)$(DATA_PATH)
+	install -m 644 *.png $(DESTDIR)$(DATA_PATH)
