PROG        = liqbase
VERS        = 0.1.0
CC          = gcc
LD          = gcc


# xsp is enabled and disabled with this flag -DUSE_MAEMO and -lXsp

OPT_FLAGS   =  -O3
jjjLIBRARIES   = gstreamer-0.10 libpng12 dbus-1 libosso cairo pango glib-2.0 gtk+-2.0 atk
jjjCFLAGS      = -DUSE_MAEMO -Wall `freetype-config --cflags` `pkg-config --cflags  $(LIBRARIES)` -I/usr/include/hildon-1 -I/usr/include/libhildondesktop
jjjLDFLAGS     = -lXsp -lX11 -lXext -lXv -lm `freetype-config --libs` -ljpeg `pkg-config --libs $(LIBRARIES)` -lhildon-1 -lgtk-x11-2.0 

LIBRARIES   = gstreamer-0.10 libpng12 libosso



CFLAGS      = -DUSE_MAEMO -Wall `freetype-config --cflags` `pkg-config --cflags  $(LIBRARIES)`
LDFLAGS     = -lXsp -lX11 -lXext -lXv -lm `freetype-config --libs` -ljpeg `pkg-config --libs $(LIBRARIES)` 
RM          = /bin/rm -f
OBJS        = liqbase_hildon.o liqbase.o liqapp.o liqcanvas_xv.o liqcanvas.o liqfont.o liqdialog.o liqstars.o liqbook.o liqreader.o liqscroll.o liqtextbuffer.o liq_xsurface.o liqbirds.o liqdraw.o liqed.o filebuf.o liqdoc.o liqdrawframe.o liqfloat.o liqfloatpic.o liqgame.o liqspeedtest.o liqtile.o liqgraffiti.o liqcliprect.o liqkeyboard.o liqcamera.o liqimage.o liqtile_easyrun.o liqfloatgallery.o liqmenu.o liqart2.o mk_core.o mk_style.o mksketch.o mkproject.o mkfileselect.o liqbookprogress.o liqintroduction.o liqbase_prefs.o liqmutlitouchtest.o

ETCDIR	    = $(DESTDIR)//etc
PREFIX	    = $(DESTDIR)//usr
SUDODIR	    = $(ETCDIR)/sudoers.d
BINDIR	    = $(PREFIX)/bin
DESKTOPDIR      = $(PREFIX)/share/applications/hildon
SERVICEDIR      = $(PREFIX)/share/dbus-1/services
FONTDIR	    = $(PREFIX)/share/fonts
DOCDIR	    = $(PREFIX)/share/liqbase

.PHONY:     clean distclean
all:        $(PROG)
$(PROG):    $(OBJS)
	      $(LD) $(LDFLAGS) \
                  `echo $$(($$(cat APP_VER_BUILD) + 1)) > APP_VER_BUILD` \
                  -Wl,--defsym,__APP_VER_MAJOR=`cat APP_VER_MAJOR` \
                  -Wl,--defsym,__APP_VER_MINOR=`cat APP_VER_MINOR` \
                  -Wl,--defsym,__APP_VER_REVISION=`cat APP_VER_REVISION` \
                  -Wl,--defsym,__APP_VER_BUILD=`cat APP_VER_BUILD` \
                  -Wl,--defsym,__APP_BUILD_DATE=`date +"0x%Y%m%d"` \
                  -Wl,--defsym,__APP_BUILD_TIME=`date +"0x%H%M%S"` \
                  -o $(PROG) $(OBJS) \
		
.c.o:
	      $(CC) $(OPT_FLAGS) $(CFLAGS) -c $< -o $*.o
clean:
	      $(RM) *~ $(OBJS) $(PROG)
.PHONY:     clean

install: all
	install -d $(BINDIR)
	install -d $(FONTDIR)
	install -d $(DOCDIR)
	install -d $(SUDODIR)
	install -d $(DESKTOPDIR)
	install -d $(SERVICEDIR)

	install -m 0755 liqbase                                                                         $(BINDIR)
	install -m 0755 liqbase_base_fs/usr/bin/liqbase-cpu-ondemand                                    $(BINDIR)
	install -m 0755 liqbase_base_fs/usr/bin/liqbase-cpu-powersave                                   $(BINDIR)
	install -m 0755 liqbase_base_fs/usr/bin/liqbase-cpu-performance                                 $(BINDIR)
	install -m 0755 liqbase_base_fs/usr/bin/liqbase-run                                             $(BINDIR)
	install -m 0755 liqbase_base_fs/etc/sudoers.d/liqbase.sudoers                                   $(SUDODIR)
	install -m 0755 liqbase_base_fs/usr/share/applications/hildon/liqbase.desktop                   $(DESKTOPDIR)
	install -m 0755 liqbase_base_fs/usr/share/dbus-1/services/org.maemo.liqbase.service             $(SERVICEDIR)
	install -m 0755 liqbase_base_fs/usr/share/fonts/lucon.ttf                                       $(FONTDIR)          
	install -m 0644 COPYING                                                                         $(DOCDIR)
	install -m 0644 liqbase_base_fs/usr/share/liqbase/berlin-map-metro-big.png                      $(DOCDIR)
	install -m 0644 liqbase_base_fs/usr/share/liqbase/liqbase-example.txt                           $(DOCDIR)
	install -m 0644 liqbase_base_fs/usr/share/liqbase/menu_back_400_240.jpg                         $(DOCDIR)
	install -m 0644 liqbase_base_fs/usr/share/liqbase/NCI_bacon_alpha_small.png                     $(DOCDIR)
	install -m 0644 liqbase_base_fs/usr/share/liqbase/plane.png                                     $(DOCDIR)
	install -m 0644 liqbase_base_fs/usr/share/liqbase/sun.png                                       $(DOCDIR)
	install -m 0644 liqbase_base_fs/usr/share/liqbase/yuv.png                                       $(DOCDIR)



# BUILD_NUMBER basics from:
# http://www.linuxjournal.com/content/add-auto-incrementing-build-number-your-build-process
#                  -Xlinker --defsym -Xlinker __APP_VER_MAJOR=`cat APP_VER_MAJOR` \
# or http://osdir.com/ml/gcc.cross-compiling/2004-04/msg00059.html
#                  -Wl,--defsym,__APP_VER=`cat APP_VER` \



