#Module is included unless defined in board to "n"
CONFIG_EXFATPROGS ?= y
modules-$(CONFIG_EXFATPROGS) += exfatprogs

exfatprogs_version := 1.2.1
exfatprogs_dir := exfatprogs-$(exfatprogs_version)
exfatprogs_tar := exfatprogs-$(exfatprogs_version).tar.xz
exfatprogs_url := https://github.com/exfatprogs/exfatprogs/releases/download/$(exfatprogs_version)/$(exfatprogs_tar)
exfatprogs_hash := a6f3b1fb4bd37835c8f8cb421aac4eb75b880a51342b29850c4063973162227b

# For reproducibility reasons we have to override the exec_prefix
# and datarootdir on the configure line so that the Makefiles will
# be generated with the correct paths, but then re-write them when
# we use the install target so that they will be copied to the correct
# location.
exfatprogs_configure := \
	$(CROSS_TOOLS) \
	CFLAGS="-Os"  \
	./configure \
	--host $(MUSL_ARCH)-linux-musl \
	--prefix "" \
	--libexecdir "/bin" \

# Run one build to generate the executables with the pre-defined
# exec_prefix and datarootdir, then a second make to install the binaries
# into our actual target location
exfatprogs_target := $(MAKE_JOBS) \
	&& $(MAKE) -C $(build)/$(exfatprogs_dir) \
		DESTDIR="$(INSTALL)" \
		install

exfatprogs_output := fsck/fsck.exfat mkfs/mkfs.exfat

exfatprogs_depends := $(musl_dep)