[PATCH] buildsys: resurrect PLATFORM_LINUX and depend on it for linux-specific applets

Kang-Che Sung explorer09 at gmail.com
Mon Nov 7 05:25:06 UTC 2022


On Sat, Nov 5, 2022 at 12:55 AM Michael Tokarev <mjt at tls.msk.ru> wrote:

> diff --git a/Makefile b/Makefile
> index 503475fe9..ad780c261 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -361,9 +361,16 @@ scripts/basic/%: scripts_basic ;
>
>  # This target generates Kbuild's and Config.in's from *.c files
>  PHONY += gen_build_files
> -gen_build_files: $(wildcard $(srctree)/*/*.c) $(wildcard $(srctree)/*/*/*.c) $(wildcard $(srctree)/embed/*)
> +gen_build_files: $(wildcard $(srctree)/*/*.c) $(wildcard $(srctree)/*/*/*.c) $(wildcard $(srctree)/embed/*) .platform.in
>         $(Q)$(srctree)/scripts/gen_build_files.sh $(srctree) $(objtree)
>
> +.platform.in:
> +       $(Q)printf '#ifndef __linux__\nplatform_is_not_linux\n#endif' \
> +           | $(CPP) - | grep -s platform_is_not_linux \
> +         && linux=n || linux=y; \
> +       printf "config PLATFORM_LINUX\n\tbool\n\tdefault $$linux\n" > $@
> +MRPROPER_FILES += .platform.in
> +
>  # bbox: we have helpers in applets/
>  # we depend on scripts_basic, since scripts/basic/fixdep
>  # must be built before any other host prog

What is the reason for preferring #ifndef check rather than #ifdef?
I mean, that would make PLATFORM_LINUX defaults to y if the compiler fails,
and I would expect n in that case.

And I'm curious. Does Busybox's kconfig system supports macros as described in
<https://www.kernel.org/doc/html/latest/kbuild/kconfig-macro-language.html> ?
If the system supports macros, we can put this in the Kconfig file and simplify
a lot of things:

config PLATFORM_LINUX
<tab>bool
<tab>default $(shell, { printf '#ifndef __linux__\n#error \n#endif\n' \
    | $(CPP) - -o /dev/null; } >/dev/null 2>&1 && echo y || echo n)


More information about the busybox mailing list