# -*- mode: makefile-gmake; -*-
export EEREPO:=$(CURDIR)/ee

BEAR := $(shell command -v bear 2> /dev/null)
ifdef BEAR
	BEAR_MAKE:=bear $(MAKE)
	BEAR_MAKE_APPEND:=bear -a $(MAKE)
else
	BEAR_MAKE:=$(MAKE)
	BEAR_MAKE_APPEND:=$(MAKE)
endif

build :
	(cd ce && $(BEAR_MAKE) -j5 +ee)

rebuild : clean
	$(MAKE) recreate-ee-cdb
	$(MAKE) build

incremental : recreate-ee-cdb
	(cd ce && $(BEAR_MAKE_APPEND) -j5 +ee)

community : clean
	(cd ce && rm -f compile_commands.json && $(BEAR_MAKE) -j5)

clean :
	(cd ce && $(MAKE) -j5 -k cleanbasic)

cleanfull :
	(cd ce && $(MAKE) -j5 -k clean)

recreate-ee-cdb :
	(cd ee && ln -sf "../ce/compile_commands.json" .)

deb :
	(cd ce && $(MAKE) deb+ee)

.PHONY : build rebuild incremental clean community recreate-ee-cdb
