#!/usr/bin/make -f

DEB_HOST_ARCH = $(shell dpkg-architecture -qDEB_HOST_ARCH)

FLAGS  = -O3 -ffast-math -fPIC -DPIC -fvisibility=hidden -fdata-sections -ffunction-sections -DNDEBUG
ifeq ($(DEB_HOST_ARCH),armhf)
FLAGS += -march=armv7ve -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4
else ifeq ($(DEB_HOST_ARCH),arm64)
FLAGS += -march=armv8-a -mcpu=cortex-a53
else
FLAGS += -mtune=generic -msse -msse2 -mfpmath=sse
endif

export CFLAGS=$(FLAGS)
export CXXFLAGS=$(FLAGS) -fvisibility-inlines-hidden
export CPPFLAGS=
export LDFLAGS=-Wl,-O1 -Wl,--as-needed -Wl,--no-undefined -Wl,--gc-sections -Wl,--strip-all

override_dh_auto_configure:
	dh_auto_configure -- -Doptimizations=false

override_dh_auto_install:
	dh_auto_install
	install -m 0755 $(CURDIR)/debian/Dexed.sh $(CURDIR)/debian/dexed-lv2/usr/bin/Dexed
	install -m 0755 $(CURDIR)/debian/DrumSynth.sh $(CURDIR)/debian/juced-plugins-lv2/usr/bin/DrumSynth
#	install -m 0755 $(CURDIR)/debian/JuceDemoPlugin.sh $(CURDIR)/debian/distrho-plugin-ports-lv2/usr/bin/JuceDemoPlugin
	install -m 0755 $(CURDIR)/debian/JuceOPL.sh $(CURDIR)/debian/juce-opl-lv2/usr/bin/JuceOPL
	install -m 0755 $(CURDIR)/debian/NoizeMak3r.sh $(CURDIR)/debian/tal-plugins-lv2/usr/bin/NoizeMak3r
	install -m 0755 $(CURDIR)/debian/Obxd.sh $(CURDIR)/debian/obxd-lv2/usr/bin/Obxd
	install -m 0755 $(CURDIR)/debian/Vex.sh $(CURDIR)/debian/distrho-plugin-ports-lv2/usr/bin/Vex
	install -m 0755 $(CURDIR)/debian/Vitalium.sh $(CURDIR)/debian/wolpertinger-lv2/usr/bin/Vitalium
	install -m 0755 $(CURDIR)/debian/Wolpertinger.sh $(CURDIR)/debian/wolpertinger-lv2/usr/bin/Wolpertinger
	ls -laR

override_dh_missing:
	dh_missing --fail-missing

%:
	dh $@ -S meson

override_dh_dwz:
	# court-circuitage
