#
# Global setup
PHILIPS = $(TOP)/Philips

DESTDIR = /
prefix  = /opt/dfbsdl

#
# Configuration
CPPFLAGS += -DHAVE_FUSIONDALE -DLINUX_2_6

#
# Compiler flags
CFLAGS += -ffast-math

#
# Take system freetype
INCLUDES += $(shell pkg-config --cflags freetype2)
LIBS     += $(shell pkg-config --libs freetype2)

#
# Take system SDL
INCLUDES += -I/usr/include/SDL
LIBS     += -L/usr/lib -lSDL


#
# Different modules, drivers etc.
OBJECTS = \
	$(SOURCE)/DirectFB/interfaces/IDirectFBFont/idirectfbfont_ft2.o				\
	$(SOURCE)/DirectFB/interfaces/IDirectFBImageProvider/idirectfbimageprovider_gif.o	\
	$(SOURCE)/DirectFB/interfaces/IDirectFBImageProvider/idirectfbimageprovider_jpeg.o	\
	$(SOURCE)/DirectFB/interfaces/IDirectFBImageProvider/idirectfbimageprovider_png.o	\
	$(SOURCE)/DirectFB/inputdrivers/linux_input/linux_input.o				\
	$(SOURCE)/DirectFB/systems/sdl/sdl.o							\
	$(SOURCE)/DirectFB/systems/sdl/primary.o


TOOLS = \
	$(PHILIPS)/Tools/concon		\
	$(PHILIPS)/Tools/df_andi		\
	$(PHILIPS)/Tools/df_cpuload	\
	$(PHILIPS)/Tools/df_dok		\
	$(PHILIPS)/Tools/df_fire		\
	$(PHILIPS)/Tools/df_neo		\
	$(PHILIPS)/Tools/fusion_stream	\
	$(PHILIPS)/Tools/jm_test	\
	$(PHILIPS)/Tools/lock_test	\
	$(PHILIPS)/Tools/slideview		\
	$(PHILIPS)/Tools/stretch_bench	\
	$(PHILIPS)/Tools/stretch_demo	\
	$(PHILIPS)/Tools/sampleSaver	\
	$(PHILIPS)/Tools/ShopFloor		\
	$(PHILIPS)/Tools/window_demo

#
# FusionDale Tools
TOOLS += \
	$(PHILIPS)/Tools/data_test		\
	$(PHILIPS)/Tools/sampleAppMan	\
	$(PHILIPS)/Tools/sampleOSD		\
	$(PHILIPS)/Tools/t2_receiver	\
	$(PHILIPS)/Tools/t2_sender		\
	$(PHILIPS)/Tools/zaps
	
#
# CE apps
TOOLS += \
	$(PHILIPS)/Tools/ce_tune		\
	$(PHILIPS)/Tools/ce_tuner		\
	$(PHILIPS)/Tools/ce_tuning_monitor

#
# Low level Tools (not really needing DirectFB)
TOOLS += \
	$(PHILIPS)/Tools/cpubench		\
	$(PHILIPS)/Tools/cpuload		\
	$(PHILIPS)/Tools/maptest		\
	$(PHILIPS)/Tools/membench


$(PHILIPS)/Tools/%: $(PHILIPS)/Tools/%.o $(TOP)/libdirectfb.so
	$(CC) $(LDFLAGS) -o $@ $< -ldirectfb $(LIBS)

install::
	@(if test -z "$(DESTDIR)"; then echo "**** DESTDIR not set! ****"; exit 1; fi)
	install -d $(DESTDIR)$(datadir)
	install -d $(DESTDIR)$(datadir)/df_neo
	install -d $(DESTDIR)$(datadir)/shopfloor
	install -d $(DESTDIR)$(sysconfdir)
	install -c -m 644 $(PHILIPS)/Tools/data/*.{gif,jpg,png,ttf} $(DESTDIR)$(datadir)/
	install -c -m 644 $(PHILIPS)/Tools/data/df_neo/*.{jpg,png} $(DESTDIR)$(datadir)/df_neo/
	install -c -m 644 $(PHILIPS)/Tools/data/shopfloor/*.{png,sfa} $(DESTDIR)$(datadir)/shopfloor/
	install -c -m 644 $(PHILIPS)/Config/directfbrc* $(DESTDIR)/$(sysconfdir)/
	install -c -m 644 $(PHILIPS)/Config/sawmanrc $(DESTDIR)/$(sysconfdir)/

