|
18 | 18 | #
|
19 | 19 | ############################################################################
|
20 | 20 |
|
| 21 | +# NuttX is sometimes built as a native target. |
| 22 | +# In that case, the __NuttX__ macro is predefined by the compiler. |
| 23 | +# https://github.com/NuttX/buildroot |
| 24 | +# |
| 25 | +# In other cases, __NuttX__ is an ordinary user-definded macro. |
| 26 | +# It's especially the case for NuttX sim, which is a target to run |
| 27 | +# the entire NuttX as a program on the host OS, which can be Linux, |
| 28 | +# macOS, Windows, etc. |
| 29 | +# https://cwiki.apache.org/confluence/display/NUTTX/NuttX+Simulation |
| 30 | +# In that case, the host OS compiler is used to build NuttX. |
| 31 | +# Thus, eg. NuttX sim on macOS is built with __APPLE__. |
| 32 | +# We #undef predefined macros for those possible host OSes here |
| 33 | +# because the OS APIs this library should use are of NuttX, |
| 34 | +# not the host OS. |
| 35 | + |
| 36 | +ARCHDEFINES += -U_AIX -U_WIN32 -U__APPLE__ -U__FreeBSD__ |
| 37 | +ARCHDEFINES += -U__NetBSD__ -U__linux__ -U__sun__ -U__unix__ |
| 38 | +ARCHDEFINES += -U__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ |
| 39 | + |
21 | 40 | ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
22 | 41 | ARCHOPTIMIZATION = $(CONFIG_DEBUG_SYMBOLS_LEVEL)
|
23 | 42 | endif
|
@@ -58,6 +77,23 @@ ifeq ($(CONFIG_DEBUG_LINK_WHOLE_ARCHIVE),y)
|
58 | 77 | LDFLAGS += --whole-archive
|
59 | 78 | endif
|
60 | 79 |
|
| 80 | +ifeq ($(CONFIG_LIBCXX),y) |
| 81 | + # Linux C++ ABI seems vary. |
| 82 | + # Probably __GLIBCXX__ is the best bet. |
| 83 | + # XXX what to do for windows? |
| 84 | + |
| 85 | + CXXFLAGS += -D__GLIBCXX__ |
| 86 | + |
| 87 | + # Disable availability macros. |
| 88 | + # The availability on Host OS is not likely appropriate for NuttX. |
| 89 | + # |
| 90 | + # Note: When compiling NuttX apps, we undefine __APPLE__. |
| 91 | + # It makes libcxx __availability header unhappy. |
| 92 | + # https://github.com/llvm/llvm-project/blob/2e2999cd44f6ec9a5e396fa0113497ea82582f69/libcxx/include/__availability#L258 |
| 93 | + |
| 94 | + CXXFLAGS += -D_LIBCPP_DISABLE_AVAILABILITY |
| 95 | +endif |
| 96 | + |
61 | 97 | CC = $(CROSSDEV)gcc
|
62 | 98 | CPP = $(CROSSDEV)gcc -E -x c
|
63 | 99 | LD = $(CROSSDEV)ld
|
|
0 commit comments