#!/usr/bin/make -f

DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

FASM=fasm
# Use this to bootstrap
# FASM=$(CURDIR)/fasm

EXAMPLES=debian/fasm/usr/share/fasm/examples
TOOLS=debian/fasm/usr/share/fasm/tools

%:
	dh $@

override_dh_install:
	(cd source/libc && $(FASM) fasm.asm && gcc $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -m32 fasm.o -o fasm)
	dh_install
	# remove executable bits from files (a change in the 1.73.35 version)
	echo "Listing executable files in usr/share..."
	find $(EXAMPLES) -type f -executable | grep .
	find $(TOOLS) -type f -executable | grep .
	find $(EXAMPLES) -type f -exec chmod -x {} \;
	find $(TOOLS) -type f -exec chmod -x {} \;

override_dh_dwz:
	# do not run dwz

override_dh_clean:
	dh_clean
	rm -f source/libc/fasm source/libc/fasm.o
