<commit_before>OUTPUTDIR	?= output

kimage		?= $(CONFIG_IMAGE)
KIMAGE		?= $(if $(kimage),$(kimage),zImage)
KOUTPUT		?= $(OUTPUTDIR)/linux-$(karch)

linux/Makefile:
	@echo "You need to provide your own kernel sources into the $(CURDIR)/$(@D) directory!" >&2
	@echo "Have a look at https://www.kernel.org! or run one of the commands below:" >&2
	@echo "$$ git clone <EMAIL>:torvalds/linux.git $(CURDIR)/$(@D)" >&2
	@echo "or" >&2
	@echo "$$ make $(@D)_download" >&2
	@exit 1

$(KOUTPUT)/.config: linux/Makefile
	@echo "You need to configure your kernel using a defconfig file!" >&2
	@echo "Run one of the commands below:" >&2
	@echo "$$ make -C linux O=$(CURDIR)/$(@D) ARCH=$(karch) menuconfig" >&2
	@echo "or" >&2
	@echo "$$ make -C linux O=$(CURDIR)/$(@D) ARCH=$(karch) tinyconfig" >&2
	@exit 1

ifneq (,$(findstring $(karch),arc arm arm64 c6x h8300 metag microblaze nios2 openrisc powerpc sparc))
%.dtb: $(KOUTPUT)/arch/$(karch)/boot/dts/%.dts
	@echo "Compiling linux ($(@F))..."
	make -C linux O=$(CURDIR)/$(KOUTPUT) $@
	cp $(KOUTPUT)/arch/$(karch)/boot/dts/$@ .

dtbs: linux_dtbs
endif

$(KOUTPUT)/arch/$(karch)/boot/$(KIMAGE): initramfs.cpio $(KOUTPUT)/.config
	@echo "Compiling linux ($(@F))..."
	make -C linux O=$(CURDIR)/$(KOUTPUT) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/$< $(@F)

$(KIMAGE): $(KOUTPUT)/arch/$(karch)/boot/$(KIMAGE)
	cp $< $@

kernel: $(KIMAGE)

kernel_% linux_%:
	make -C linux O=$(CURDIR)/$(KOUTPUT) $*

kernel_menuconfig linux_menuconfig:

kernel_download linux_download:
	wget -qO- https://www.kernel.org/index.html | sed -n '/<td id="latest_link"/,/<\/td>/s,.*<a.*href="\(.*\)">\(.*\)</a>.*,wget -qO- \1 | tar xvJ \&\& ln -sf linux-\2 linux,p' | sh

kernel_configure linux_configure:
	make -f Makefile $(KOUTPUT)/.config

kernel_compile linux_compile:
	make -f Makefile $(KOUTPUT)/arch/$(karch)/boot/$(KIMAGE)

kernel_clean linux_clean:
	make -C linux mrproper<commit_msg>kernel.mk: %.dtb rule does not depend on its %.dts source file.<commit_after>OUTPUTDIR	?= output

kimage		?= $(CONFIG_IMAGE)
KIMAGE		?= $(if $(kimage),$(kimage),zImage)
KOUTPUT		?= $(OUTPUTDIR)/linux-$(karch)

linux/Makefile:
	@echo "You need to provide your own kernel sources into the $(CURDIR)/$(@D) directory!" >&2
	@echo "Have a look at https://www.kernel.org! or run one of the commands below:" >&2
	@echo "$$ git clone git@github.com:torvalds/linux.git $(CURDIR)/$(@D)" >&2
	@echo "or" >&2
	@echo "$$ make $(@D)_download" >&2
	@exit 1

$(KOUTPUT)/.config: linux/Makefile
	@echo "You need to configure your kernel using a defconfig file!" >&2
	@echo "Run one of the commands below:" >&2
	@echo "$$ make -C linux O=$(CURDIR)/$(@D) ARCH=$(karch) menuconfig" >&2
	@echo "or" >&2
	@echo "$$ make -C linux O=$(CURDIR)/$(@D) ARCH=$(karch) tinyconfig" >&2
	@exit 1

ifneq (,$(findstring $(karch),arc arm arm64 c6x h8300 metag microblaze nios2 openrisc powerpc sparc))
$(KOUTPUT)/arch/arm/boot/dts/%.dtb:
	@echo "Compiling linux ($(@F))..."
	make -C linux O=$(CURDIR)/$(KOUTPUT) $(@F)

%.dtb: $(KOUTPUT)/arch/$(karch)/boot/dts/%.dtb
	cp $< .

dtbs: linux_dtbs
endif

$(KOUTPUT)/arch/$(karch)/boot/$(KIMAGE): initramfs.cpio $(KOUTPUT)/.config
	@echo "Compiling linux ($(@F))..."
	make -C linux O=$(CURDIR)/$(KOUTPUT) CONFIG_INITRAMFS_SOURCE=$(CURDIR)/$< $(@F)

$(KIMAGE): $(KOUTPUT)/arch/$(karch)/boot/$(KIMAGE)
	cp $< $@

kernel: $(KIMAGE)

kernel_% linux_%:
	make -C linux O=$(CURDIR)/$(KOUTPUT) $*

kernel_menuconfig linux_menuconfig:

kernel_download linux_download:
	wget -qO- https://www.kernel.org/index.html | sed -n '/<td id="latest_link"/,/<\/td>/s,.*<a.*href="\(.*\)">\(.*\)</a>.*,wget -qO- \1 | tar xvJ \&\& ln -sf linux-\2 linux,p' | sh

kernel_configure linux_configure:
	make -f Makefile $(KOUTPUT)/.config

kernel_compile linux_compile:
	make -f Makefile $(KOUTPUT)/arch/$(karch)/boot/$(KIMAGE)

kernel_clean linux_clean:
	make -C linux mrproper
{'fraction_non_alphanumeric': 0.2167142486374254, 'fraction_numerical': 0.011419672982091877, 'mean_word_length': 4.529411764705882, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 30, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1288549', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1520, 'n_words': 382}