# SPDX-License-Identifier: GPL-3.0-or-later
# pomelo-software
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)

all: pomelo-software pomelo-software.png

pomelo-software: pomelo-software.c
	$(CC) $(CFLAGS) $(POMELO_CFLAGS) -o $@ pomelo-software.c $(POMELO_LIBS) -lm $(LDFLAGS)

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

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

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

.PHONY: all install clean
