# SPDX-License-Identifier: GPL-3.0-or-later
# pomelo-player — Pomelo 影音播放器
PREFIX ?= /usr/local
CFLAGS ?= -Os -pipe -Wall -Wextra -Wno-unused-parameter -Wno-format-truncation
POMELO_CFLAGS ?= $(shell pkg-config --cflags pomelo)
POMELO_LIBS   ?= $(shell pkg-config --libs pomelo)
MEDIA_CFLAGS ?= $(shell pkg-config --cflags libmpg123 sndfile libpulse-simple)
MEDIA_LIBS   ?= $(shell pkg-config --libs libmpg123 sndfile libpulse-simple)

all: pomelo-player pomelo-player.png

pomelo-player: pomelo-player.c engine.c library.c
	$(CC) $(CFLAGS) $(POMELO_CFLAGS) $(MEDIA_CFLAGS) -pthread -o $@ pomelo-player.c $(POMELO_LIBS) $(MEDIA_LIBS) -lm $(LDFLAGS)

pomelo-player.png: pomelo-player
	LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" ./pomelo-player --icon $@

install: all
	install -Dm755 pomelo-player $(DESTDIR)$(PREFIX)/bin/pomelo-player
	install -Dm644 pomelo-player.desktop $(DESTDIR)$(PREFIX)/share/applications/pomelo-player.desktop
	install -Dm644 pomelo-player.png $(DESTDIR)$(PREFIX)/share/icons/hicolor/256x256/apps/pomelo-player.png

clean:
	rm -f pomelo-player pomelo-player.png

.PHONY: all install clean
