.PHONY: help all umk theide install clean distclean
SHELL = /bin/sh
BUILD_METHOD = GCC
OPTIONS=-mbsv
FLAGS=
OUTPUT="$(PWD)/theide"


help:
	@echo "Usage:"
	@echo "  make [theide|umk] [BUILD_METHOD=<file>|BUILD_METHOD=<method>] [OPTIONS=<options>] [FLAGS=<flags>]"
	@echo ""
	@echo "Example:"
	@echo '  make                                        : show this help message'
	@echo '  make theide                                 : build umk then use it to build theide with default parameters'
	@echo "  make theide OPTIONS=-rbsv                   : build umk then use it to build theide as release binary"
	@echo "  make theide BUILD_METHOD=CLANG FLAGS=GUI,MT : build umk then use it to build theide using CLANG and specific FLAGS"
	@echo '  make umk                                    : build umk only'
	@echo "  make umk CXX=g++                            : build umk using g++ (see uppsrc/uMakefile.in for other possible options"

all: umk theide

umk:
	+make -C uppsrc -f uMakefile.in -e OutFile="$(PWD)/umk"

theide: umk

	if [ "$(FLAGS)" != "" ] ; then \
		HOME="$(PWD)/build/" ./umk uppsrc ide $(BUILD_METHOD) "$(OPTIONS)" "$(FLAGS)" "$(OUTPUT)" ; \
	else \
		HOME="$(PWD)/build/" ./umk uppsrc ide $(BUILD_METHOD) "$(OPTIONS)" "$(OUTPUT)" ; \
	fi

install:
	+./doinstall --verbose

uninstall:
	+./douninstall

clean:
	if [ -d "$(PWD)/build" ] ; then \
		rm -fr "$(PWD)/build" ; \
	fi
	if [ -d "$(UPPOUT)" ] ; then \
		rm -fr "$(UPPOUT)" ; \
	else \
		rm -fr uppsrc/_out ; \
	fi
	rm -f uppsrc/build_info.h
	rm -f uppsrc/ide.out
	rm -f uppsrc/umk.out
	rm -f theide
	rm -f umk
	rm -f theide.desktop
