# Builds the vendored libogg + libvorbis + vg_codec the way SwiftPM does
# (same sources, same include paths; CVorbis also searches its own folder,
# as Package.swift sets with .headerSearchPath(".")) and runs the round-trip test.
SRC     := ../../Sources
CC      ?= cc
CFLAGS  ?= -O2 -Wall -Wno-unused -Wno-shift-negative-value
INCS    := -I$(SRC)/CVorbis -I$(SRC)/COgg/include -I$(SRC)/CVorbis/include -I$(SRC)/CVoicegramCodec/include
SOURCES := $(wildcard $(SRC)/COgg/*.c) $(wildcard $(SRC)/CVorbis/*.c) $(SRC)/CVoicegramCodec/vg_codec.c codec_test.c

codec_test: $(SOURCES)
	$(CC) $(CFLAGS) $(INCS) -o $@ $(SOURCES) -lm

test: codec_test
	./codec_test codec_test.ogg

clean:
	rm -f codec_test codec_test.ogg

.PHONY: test clean
