all: sereg_caller.cpp

DEPS_OPR := $(shell find ../../opr . -name '*.sereg.h')
DEPS_MM := $(shell find ../../opr-mm -name '*.sereg.h')
DEPS_TRT := $(shell find ../../tensorrt -name '*.sereg.h')
DEPS_JIT := $(shell find ../../jit -name '*.sereg.h')

sereg_caller.cpp: $(DEPS_OPR) $(DEPS_MM) $(DEPS_TRT) $(DEPS_JIT) $(DEPS_ANN)
	@echo generate $@
	@( echo '// generated by Makefile'; \
		echo 'namespace mgb{void call_sereg(){}}'; \
		echo '#if MGB_ENABLE_FBS_SERIALIZATION'; \
		echo '#include "flatbuffer_converter.inl"'; \
		echo '#endif'; \
		for i in $(DEPS_OPR); do echo "#include \"$$i\""; done | sort ; \
		echo "#if MGB_ENABLE_OPR_MM"; \
		for i in $(DEPS_MM); do echo "#include \"$$i\""; done | sort ; \
		echo "#endif"; \
		echo "#if MGB_ENABLE_TENSOR_RT"; \
		for i in $(DEPS_TRT); do echo "#include \"$$i\""; done | sort ; \
		echo "#endif"; \
		echo "#if MGB_JIT"; \
		for i in $(DEPS_JIT); do echo "#include \"$$i\""; done | sort ; \
		echo "#endif"; \
		) > $@

.PHONY: all
