#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/dpkg/architecture.mk
-include /usr/share/dpkg/buildtools.mk
PKG_CONFIG ?= pkg-config

CFLAGS += -Wall -g -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
LDFLAGS := -Wl,-z,defs $(LDFLAGS)
CPPFLAGS := $(CPPFLAGS) $(shell $(PKG_CONFIG) --cflags gtk+-x11-2.0)

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
        MAKEFLAGS += -j$(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif

export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
			   --prefix=/usr \
			   --mandir=\$${prefix}/share/man \
			   --infodir=\$${prefix}/share/info \
			   CPPFLAGS='$(CPPFLAGS)' \
			   CFLAGS="$(CFLAGS)" \
			   LDFLAGS="$(LDFLAGS)" \
	|| ( echo configure failed with $$? ; cat config.log ; echo "[end of config.log]" ; exit 1 )

override_dh_auto_install:
	$(MAKE) install DESTDIR=$(CURDIR)/debian/choosewm
	dh_install docs/config /etc/X11/choosewm
