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

2022-11-06 Thread Kang-Che Sung
On Sat, Nov 5, 2022 at 12:55 AM Michael Tokarev  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
 ?
If the system supports macros, we can put this in the Kconfig file and simplify
a lot of things:

config PLATFORM_LINUX
bool
default $(shell, { printf '#ifndef __linux__\n#error \n#endif\n' \
| $(CPP) - -o /dev/null; } >/dev/null 2>&1 && echo y || echo n)
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


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

2022-11-06 Thread Michael Tokarev

07.11.2022 08:25, Kang-Che Sung wrote:

On Sat, Nov 5, 2022 at 12:55 AM Michael Tokarev  wrote:


diff --git a/Makefile b/Makefile



+.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" > $@



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.


That's exactly the goal, - to make linux the default, that's the reason
I changed from ifdef linux to ifndef.  The idea is to bring as few burden
to the main authors as possible, - if this doesn't work, their favorite
platform wont be affected.  See the email I referred to in other message -
http://lists.busybox.net/pipermail/busybox/2011-February/074954.html -
from 11 years ago, - this is when "depends on LINUX" were (mistakenly)
changed to "select LINUX" in the first place, making it effectively
impossible to build busybox on non-linux.


And I'm curious. Does Busybox's kconfig system supports macros as described in
 ?
If the system supports macros, we can put this in the Kconfig file and simplify
a lot of things:

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


No, - busybox's kconfig is much simpler than that, as far as I can see,
it is a fork off a much earlier kconfig language.

Thanks,

/mjt
___
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox