# Copyright © 2019-2025 Collabora Ltd.
# SPDX-License-Identifier: MIT

tests = hello-ogg hello-vorbis hello-vorbisenc hello-vorbisfile
all: $(tests)

PKG_CONFIG = $(CROSS_COMPILE)pkg-config
OGG_CFLAGS = $(shell $(PKG_CONFIG) --cflags ogg)
OGG_LIBS = $(shell $(PKG_CONFIG) --libs ogg)
VORBIS_CFLAGS = $(shell $(PKG_CONFIG) --cflags vorbis)
VORBIS_LIBS = $(shell $(PKG_CONFIG) --libs vorbis)
VORBISENC_CFLAGS = $(shell $(PKG_CONFIG) --cflags vorbisenc)
VORBISENC_LIBS = $(shell $(PKG_CONFIG) --libs vorbisenc)
VORBISFILE_CFLAGS = $(shell $(PKG_CONFIG) --cflags vorbisfile)
VORBISFILE_LIBS = $(shell $(PKG_CONFIG) --libs vorbisfile)

hello-ogg: hello-ogg.c
	$(CC) -o$@ $< $(OGG_CFLAGS) $(OGG_LIBS)

hello-vorbis: hello-vorbis.c
	$(CC) -o$@ $< $(VORBIS_CFLAGS) $(VORBIS_LIBS)

hello-vorbisenc: hello-vorbisenc.c
	$(CC) -o$@ $< $(VORBISENC_CFLAGS) $(VORBIS_CFLAGS) $(VORBISENC_LIBS) $(VORBIS_LIBS)

hello-vorbisfile: hello-vorbisfile.c
	$(CC) -o$@ $< $(VORBISFILE_CFLAGS) $(VORBISFILE_LIBS)

check: $(tests)
	./hello-ogg
	./hello-vorbis
	./hello-vorbisenc
	./hello-vorbisfile

clean:
	rm -f $(tests)
