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

all: pomelo-storage pomelo-automount pomelo-storage.png

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

pomelo-automount: pomelo-automount.c
	$(CC) $(CFLAGS) $(POMELO_CFLAGS) $$(pkg-config --cflags dbus-1) -o $@ pomelo-automount.c $(POMELO_LIBS) $$(pkg-config --libs dbus-1) -lm $(LDFLAGS)

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

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

clean:
	rm -f pomelo-storage pomelo-automount pomelo-storage.png

.PHONY: all install clean
