#!/usr/bin/make -f
export DH_VERBOSE=1
export DEB_BUILD_OPTIONS += noautodbgsym

export CMAKE_INSTALL_PREFIX=/usr
export CMAKE_BUILD_TYPE=Release

NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))

%:
	dh $@

override_dh_auto_clean:
	rm -Rf usr
	make -C libyui -f Makefile.repo clean
	make -C libyui-qt -f Makefile.repo clean
	make -C libyui-qt-graph -f Makefile.repo clean
	make -C libyui-ncurses -f Makefile.repo clean
	make -C libyui-rest-api -f Makefile.repo clean
	make -C libyui-bindings -f Makefile.repo clean

override_dh_auto_configure:
	make -C libyui -f Makefile.repo configure
	make -C libyui-qt -f Makefile.repo configure
	make -C libyui-qt-graph -f Makefile.repo configure
	make -C libyui-ncurses -f Makefile.repo configure
	CXXFLAGS="-I/usr/include/jsoncpp" make -C libyui-rest-api -f Makefile.repo configure
	make -C libyui-bindings -f Makefile.repo configure

override_dh_auto_build:
	make -C libyui/build -j${NUMJOBS}
	make -C libyui-qt/build -j${NUMJOBS}
	make -C libyui-qt-graph/build -j${NUMJOBS}
	make -C libyui-ncurses/build -j${NUMJOBS}
	make -C libyui-rest-api/build -j${NUMJOBS}
	make -C libyui-bindings/build -j${NUMJOBS}

override_dh_auto_install:
	make -C libyui -f Makefile.repo install DESTDIR=$(CURDIR)
	make -C libyui-qt -f Makefile.repo install DESTDIR=$(CURDIR)
	make -C libyui-qt-graph -f Makefile.repo install DESTDIR=$(CURDIR)
	make -C libyui-ncurses -f Makefile.repo install DESTDIR=$(CURDIR)
	make -C libyui-rest-api -f Makefile.repo install DESTDIR=$(CURDIR)
	make -C libyui-bindings -f Makefile.repo install DESTDIR=$(CURDIR)

override_dh_compress:
	dh_compress -X.cc
