#!/usr/bin/make -f

# This is to let dpkg-buildflags do its job with CFLAGS
CMAKEFLAGS = -DCMAKE_BUILD_TYPE=debian -DCMAKE_C_FLAGS_DEBIAN=""

# Fonts
CMAKEFLAGS += -Dfont/freetype=TRUE

# svg2png is required to display country flags
CMAKEFLAGS += -Dsvg2png_scaling=0,8,16,32,48,96 -Dsvg2png_scaling_flag=8,16,32,48,96 -Dsvg2png_scaling_nav=8,16,32,48,96

# Force svg2png conversion using rsvg-convert since it is the most reliable
# ATM
CMAKEFLAGS += -DIMAGE_CONVERTER_SVGZ=rsvg-convert

# Enable GUIs we want
CMAKEFLAGS += -Dgui/gtk=TRUE -Dgui/internal=TRUE -Dgui/qml=FALSE

# Bindings
CMAKEFLAGS += -Dbinding/dbus=TRUE
# Pyrhon binding not available through cmake
#CMAKEFLAGS += -Dbinding/python=FALSE

# Wanted graphic backends
CMAKEFLAGS += -Dgraphics/gtk_drawing_area=TRUE -Dgraphics/qt_qpainter=TRUE -Dgraphics/null=TRUE

# Unwanted graphic backends (yet)
# opengl and sdl backends aren't mature enough
# gd backend segfaults
CMAKEFLAGS += -Dgraphics/android=FALSE -Dgraphics/gd=FALSE -Dgraphics/sdl=FALSE -Dgraphics/opengl=FALSE

# don't build the samplemap - we don't want to download
# stuff while building...
CMAKEFLAGS += -DSAMPLE_MAP=FALSE

# Maps
CMAKEFLAGS += -Dmap/garmin=TRUE -Dmap/mg=TRUE -Dmap/binfile=TRUE -Dmap/csv=TRUE -Dmap/shapefile=TRUE

# Vehicles
CMAKEFLAGS += -Dvehicle/null=TRUE -Dvehicle/demo=TRUE -Dvehicle/gpsd=TRUE
# disable gypsy support as there's no gypsy in Debian
CMAKEFLAGS += -Dvehicle/gypsy=FALSE

# Enable plugin pedestrian
CMAKEFLAGS += -Dplugin/pedestrian=TRUE

# Enable support/shapefile
CMAKEFLAGS += -Dsupport/shapefile=TRUE

# Avoid floating point calculation for armel
ifeq ($(DEB_HOST_ARCH), armel)
  CMAKEFLAGS += -DAVOID_FLOAT=TRUE
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKEFLAGS)

override_dh_install:
	# Generate icon for Debian menu
	mkdir -p $(CURDIR)/debian/tmp/usr/share/pixmaps
	convert $(CURDIR)/navit/xpm/desktop_icons/128x128/navit.png -resize 32x32 $(CURDIR)/debian/tmp/usr/share/pixmaps/navit.xpm

	# Default navit configuration file moved into /etc
	mkdir -p $(CURDIR)/debian/tmp/etc/navit
	mv $(CURDIR)/debian/tmp/usr/share/navit/navit.xml \
	   $(CURDIR)/debian/tmp/etc/navit/

	dh_install
