qoa icon indicating copy to clipboard operation
qoa copied to clipboard

A Makefile for the audio samples

Open plstonge opened this issue 2 years ago • 0 comments

While convert_wav.sh does the job of converting all files, I wanted additional features for testing purpose (e.g. make check). Here is my suggested Makefile (which uses the QOA's Makefile) with the script that generates dependencies (gen_deps.sh):

  • Makefile:
-include deps.mk

all: $(QOA_FILES) $(WAV_FILES)

../qoaconv:
	make -C .. conv

md5: qoa.md5 wav.md5

qoa.md5:
	md5sum */qoa/*.qoa > $@

wav.md5:
	md5sum */qoa_wav/*.qoa.wav > $@

check: rebuild_conv all
	md5sum --quiet -c qoa.md5
	md5sum --quiet -c wav.md5

rebuild_conv:
	make -C .. conv

ifndef MAKE_RESTARTS
deps.mk: .UPDATE_DEPS
	./gen_deps.sh > $@

.PHONY: .UPDATE_DEPS
.UPDATE_DEPS:
endif

clean:
	rm -f $(QOA_FILES) $(WAV_FILES)
	make -C .. $@
	rm -f deps.mk
  • gen_deps.sh:
#!/bin/bash

for file_type in QOA,qoa,qoa  WAV,qoa_wav,qoa.wav; do
	PREFIX=$(echo $file_type | cut -d, -f1)
	SUBDIR=$(echo $file_type | cut -d, -f2)
	EXTENS=$(echo $file_type | cut -d, -f3)

	# Create Makefile list of file names
	echo "${PREFIX}_FILES= \\"
	for directory in */; do
		dir_only=$(echo "$directory" | sed 's-/*$--g')

		for wav_orig in "$dir_only"/*.wav; do
			name=$(basename "${wav_orig%.*}")

			# Add file name to the Makefile list
			echo -e "\t$dir_only/$SUBDIR/$name.$EXTENS \\"
		done
	done
	echo  # Empty line
done

QOACONV=../qoaconv

for directory in */; do
	dir_only=$(echo "$directory" | sed 's-/*$--g')

	# Create the subdirectories
	mkdir -p "$dir_only"/qoa
	mkdir -p "$dir_only"/qoa_wav

	# Create Makefile rules
	echo "$dir_only"/qoa/%.qoa: "$dir_only"/%.wav $QOACONV
	echo -e "\t$QOACONV" '$< $@\n'

	echo "$dir_only"/qoa_wav/%.qoa.wav: "$dir_only"/qoa/%.qoa $QOACONV
	echo -e "\t$QOACONV" '$< $@\n'
done

plstonge avatar Oct 10 '23 19:10 plstonge