SOURCES=$(wildcard *.pas)
TARGET_CPU=$(shell fpc -iTP)
TARGET_OS=$(shell fpc -iTO)
PREFIX=/usr/local
UNITS_DIR=units/${TARGET_CPU}-${TARGET_OS}/gtk3
OPTIONS=\
 -Fi${UNITS_DIR}\
 -Fu${UNITS_DIR}\
 -FU${UNITS_DIR}\
 -FE.\

all:${UNITS_DIR}/gtk3.ppu ${UNITS_DIR}/pangocairo1.ppu

install: all install-binaries install-sources

${UNITS_DIR}/%.ppu:%.pas ${SOURCES}
	mkdir -p ${@D}
	fpc $(OPTIONS) $<

install-binaries:
	install -D -t ${PREFIX}/${UNITS_DIR} ${UNITS_DIR}/*

install-sources:
	install -D -t ${PREFIX}/share/gtk4pas/gtk3 ${SOURCES}

clean:
	${RM} -r units

.PHONY: clean
