Yes, exactly. That is why I said that that solution ws "not one that is easily fielded". The situation would be exactly as it is with Linux. You can't use any toolchain to build Linux, you have to use one with a name like arm-linux-eabi or xxx-linux-elf. It is mandatory for Linux.
And that is where __Linux__ is defined: In the xxx-linux-xxx toolchain. So it is THE standard solution but not one many people who have favorite toolchains would like. On Tue, Feb 22, 2022 at 1:31 PM Piet <m...@mailbox.org.invalid> wrote: > Wouldn‘t the buildroot option require, that all targets needs to be > supported from that single toolchain unless the not supported target > defined __NUTTX__ within their own configs? > > /Piet > > > > > > Am 22.02.2022 um 20:14 schrieb Gregory Nutt <spudan...@gmail.com>: > > > > One option would be to define __NUTTX_ in tools/Config.mk instead of in > > each individual apps/Makefile. That would provide a single point > > definition coordinate all usage. > > > > My favorite solution, but not one that is easily fielded would be to use > > the NuttX buildroot toolchains: > > https://bitbucket.org/nuttx/buildroot/src/master/ . These generate a > > nuttx-eab-gcc (toolchain not a none-eabi toolchain) and they have several > > advantages: (1) they do not use a foreign libc but build directly using > > the NuttX libc. So they will never generate libc header file conflicts. > > and (1) they define __NUTTX__ > > > > The downside is that, as I recall, they don't build the C++ standard > > library. > > > > > >> On Tue, Feb 22, 2022 at 12:50 PM Gregory Nutt <spudan...@gmail.com> > wrote: > >> > >> I have been working on an application for the past several months. Now > >> want to get it running on NuttX. I don't have much experience porting > >> applications to NuttX and have some dumb newbie questions (I mostly > worked > >> on the other side of the application/OS interface). > >> > >> If I have an application that builds and runs on Linux and I want to > port > >> it to NuttX, I would basically just provide the Kconfig files, Make.defs > >> files, and Makefiles as expected by the build system, then just link my > >> application anywhere in the app/ source tree. > >> > >> But how does the code know that it is running on NuttX? There is no > >> CONFIG_NUTTX, there is no OS_managed __NUTTX__ definition. > >> > >> I do see a __NUTTX__ definition defined in some application Makefiles in > >> apps/, but this is a chicken'n'egg problem. They use custom Makefiles > to > >> provide these definitions. But what if you want the same application > build > >> logic to support either platform. I don't see any way to do that. > >> > >> Has anyone thought of way to do this? Or do you all use custom Makefile > >> for the NuttX build? > >> > >> Greg > >> > >> >