#!/usr/bin/env make
#
# Generate the Makefile using both qmake and the custom rules we need to add on
# top of it.
#

# Rule to generate the qmake Makefile for building xxdiff.
# Note: To build with Qt5, use QMAKE=qmake5 or QMAKE=qmake.
QMAKE ?= qmake6
MAKEDIR ?= .
QMAKEOPTS =

all: Makefile

OS := $(shell uname -s)
ifeq ($(OS),Darwin)
    # Default is an Xcode project, so force a makefile build
    export QMAKESPEC=macx-clang
endif

Makefile.qmake: $(MAKEDIR)/xxdiff.pro
	$(QMAKE) $(QMAKEOPTS) -o Makefile.qmake $<

Makefile: Makefile.qmake $(MAKEDIR)/Makefile.extra
	echo "MAKEDIR = $(MAKEDIR)" > Makefile
	cat $^ >> Makefile
