BUILD_DIR=.build

build: prepare
	cd $(BUILD_DIR)/ && make deb

prepare: | submodule
	mkdir -p $(BUILD_DIR)/patches/kernel
	ln -sf $$(readlink -f pve-kernel/debian) $(BUILD_DIR)/
	ln -sf $$(readlink -f pve-kernel/submodules) $(BUILD_DIR)/
	cp -r pve-kernel/patches/kernel/* $(BUILD_DIR)/patches/kernel
	cp -r patches/* $(BUILD_DIR)/patches/kernel
	cp    pve-kernel/* $(BUILD_DIR)/ || true

.PHONY: submodule
submodule:
	git submodule update --init --recursive

.PHONY: clean
clean:
	rm -rf $(BUILD_DIR)