Adding new files to openwrt sources


TL;DR: I need to add .c and maybe .h files to linux/net and linux/include/net but after make clean they are gone.

I'm sorry if I am asking stupid question or maybe some that was asked previously, but I have been searching in documentation how to solve my problem and I kind of stuck.

For my studies I need to add new packet schedulers to OpenWRT. I tried to simply create .c files in build_dir/target-mips_24kc_musl/linux-ar71xx-mikrotik/linux-4.9.123/net/sched but after call "make clean" in the root of repository, my files are gone. If I understand well, the sources are removed and during "make", are downloaded and ten built. My question is - how to add new files to be sure that they won't be removed during clean? My first idea was to create bash script which will patch the sources with my changes, but this solution is not the best idea.

Best regards,


the openwrt build root use patches to patch the downloaded source code before configuring and compiling.

If you want to add code for all targets, the patches should be placed in target/linux/generic/patchesXXX
and if you want patch only something for ar71xx you should place your patches in target/linux/ar71xx/patchesXXX.

Here is a good documentation for working with paches in the openwrt build system:

PS: You do not have to do make clean after every change.