# sup2vob — PGS (.sup) -> VobSub (.sub/.idx) converter CLI
#
# Slim CLI: the conversion sources are NOT vendored a second time here —
# they are the framework's ../MP42/Sup2Vob/ files, so the CLI and the app
# always run identical conversion code (the CLI's byte-identical `--full`
# output is the framework converter's verification oracle). Only
# main.swift lives in this directory; see its header for the single
# upstream adaptation. MP42SupConverter.swift (the framework's ObjC
# facade over the same conversion) is deliberately not compiled in.
#
# Build:  make        -> ./sup2vob
# Clean:  make clean

SWIFTC   ?= swiftc
OPTFLAGS ?= -O
TARGET   := sup2vob
PREFIX   ?= /usr/local
CONV     := ../MP42/Sup2Vob
SOURCES  := main.swift $(CONV)/PGS.swift $(CONV)/Convert.swift $(CONV)/VobSub.swift

.PHONY: all clean rebuild install

all: $(TARGET)

$(TARGET): $(SOURCES)
	$(SWIFTC) $(OPTFLAGS) -o $(TARGET) $(SOURCES)

clean:
	rm -f $(TARGET)

rebuild: clean all

# extractsubs (shipped in the Subler app bundle's Resources) resolves
# sup2vob from PATH, so a rebuild only takes effect once installed
# (usually: sudo make install).
install: $(TARGET)
	install -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/$(TARGET)
