Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Makefile for the audio samples #36

Open
plstonge opened this issue Oct 10, 2023 · 0 comments
Open

A Makefile for the audio samples #36

plstonge opened this issue Oct 10, 2023 · 0 comments

Comments

@plstonge
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant