Thanks Nilesh. I have created a new implementation based on your guidelines.
I am still considering whether it would be necessary to include all possible
compilations. Perhaps with only SSE2, AVX2, and AVX512F, it would be sufficient,
or even just SSE2 and AVX2. What do you think, Andreas?
The only change would be in the rules. I'm leaving the code here before uploading
it in case you have any suggestions.
#!/usr/bin/make -f
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS=hardening=+all
include /usr/share/dpkg/
default.mk DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH )
%:
dh $@
override_dh_auto_configure:
ifeq (amd64,$(DEB_HOST_ARCH))
for i in "sse2 SEE2" "sse4_1 SEE4" "avx AVX" "avx2 AVX2" "avx512f AVX512" ; do \
set -- $${i} ; \
dh_auto_configure --builddirectory build_$${1} -- \
-DUSE_NATIVE=OFF -DUSE_SHARED=ON -DUSE_$${2}=ON ; \
done
else
dh_auto_configure -- \
-DUSE_NATIVE=OFF -DUSE_SHARED=ON
endif
override_dh_auto_build:
ifeq (amd64,$(DEB_HOST_ARCH))
printf "#!/bin/sh\n\n" > VeryFastTree
for SIMD in avx512f avx2 avx sse4_1 sse2 ; do \
dh_auto_build --builddirectory build_$${SIMD} && \
cp build_$${SIMD}/VeryFastTree build_$${SIMD}/VeryFastTree-$${SIMD} ; \
printf "if grep -q $${SIMD} /proc/cpuinfo; then\n exec /usr/bin/VeryFastTree-$${SIMD} \"\$$@\"\nfi\n\n" >> VeryFastTree ; \
done
chmod +x VeryFastTree
else
dh_auto_build
endif
override_dh_auto_test:
ifeq (amd64,$(DEB_HOST_ARCH))
dh_auto_test --builddirectory build_SEE2
else
dh_auto_test
endif
override_dh_auto_install:
ifeq (amd64,$(DEB_HOST_ARCH))
dh_install build_*/VeryFastTree-* /usr/bin/
dh_install VeryFastTree /usr/bin/
else
dh_auto_install
endif
override_dh_auto_clean:
dh_auto_clean
rm -Rf build_*
rm -f VeryFastTree
César