# trame-gui — GTK3 front-end for Trame

CC      ?= cc
CFLAGS  ?= -O2 -Wall -Wextra
PREFIX  ?= /usr
LOCALEDIR ?= $(PREFIX)/share/locale
DESTDIR ?=
VERSION ?= 1.0

PKGS    = gtk+-3.0
CFLAGS  += $(shell pkg-config --cflags $(PKGS)) -I../tui/src \
           -DLOCALEDIR=\"$(LOCALEDIR)\" -DAPP_VERSION=\"$(VERSION)\"
LDLIBS  += $(shell pkg-config --libs $(PKGS))

# The JSON parser is shared with trame-tui, compiled from tui/src.
SRC = src/trame-gui.c src/window.c src/pages.c src/backend.c src/style.c \
      src/ui.c src/page-wifi.c src/page-sound.c src/page-display.c \
      src/page-power.c src/page-storage.c src/page-users.c \
      src/page-bt.c src/page-lang.c src/page-time.c src/page-help.c \
      ../tui/src/json.c
HDR = src/window.h src/pages.h src/backend.h src/style.h src/ui.h ../tui/src/json.h
BIN = trame-gui

all: $(BIN)

$(BIN): $(SRC) $(HDR)
	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(SRC) $(LDLIBS)

clean:
	rm -f $(BIN)

install: $(BIN)
	install -m 0755 -d $(DESTDIR)$(PREFIX)/bin
	install -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin/$(BIN)
	install -m 0755 -d $(DESTDIR)$(PREFIX)/share/applications
	install -m 0644 data/trame-gui.desktop $(DESTDIR)$(PREFIX)/share/applications
	for d in scalable 22x22 24x24 32x32 48x48 64x64 128x128; do \
		install -m 0755 -d $(DESTDIR)$(PREFIX)/share/icons/hicolor/$$d/apps; \
		install -m 0644 data/icons/hicolor/$$d/apps/trame-gui.* \
			$(DESTDIR)$(PREFIX)/share/icons/hicolor/$$d/apps; \
	done

.PHONY: all clean install
