#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

CONFIGURE_OPTS :=	-DBUILD_SHARED_LIBS=ON \
					-DWITH_OTLP_HTTP=ON \
					-DWITH_OTLP_GRPC=ON \
					-DOPENTELEMETRY_INSTALL=ON \
					-DOTELCPP_PROTO_PATH=/usr/include/

%:
	dh $@

override_dh_auto_configure:
	rm -rf third_party/googletest
	cp -a /usr/src/googletest third_party/googletest
	touch third_party/googletest/.git

	dh_auto_configure -- $(CONFIGURE_OPTS)

override_dh_auto_install:
	dh_auto_install
	rm -rf $(CURDIR)/debian/tmp/usr/include/opentelemetry/proto/

# The test suite has some tests that fail in all the architectures. See
# debian/patches/disable-tests.patch. However, builds in architectures such as
# armhf and i386 end up with even more failing tests.
#
# Some curl-related tests fail when running on multiple CPU cores.
override_dh_auto_test:
ifneq (,$(filter $(DEB_HOST_ARCH), amd64 mips64el ppc64el))
	dh_auto_test --max-parallel=1
else
	dh_auto_test --max-parallel=1 || true
endif
