1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/native/Makefile.include
Marian Buschsieweke f34cd3f7c1
cpu/native: fix build with musl
This changes a bunch of things that allows building with the musl C lib,
provided that `libucontext-dev` and `pkg-config` are installed.

Note that installing libucontext makes absolutely zero sense on C libs
that do natively provide this deprecated System V API, such as glibc.
Hence, it no sane glibc setup is expected to ever have libucontext
installed.

A main pain point was that argv and argc are expected to be passed to
init_fini handlers, but that is actually a glibc extension. This just
parses `/proc/self/cmdline` by hand to populate argv and argc during
startup, unless running on glibc.
2024-05-31 12:18:33 +02:00

29 lines
786 B
Makefile

NATIVEINCLUDES += -I$(RIOTCPU)/native/include/
ifneq (,$(filter periph_can,$(USEMODULE)))
ifeq (,$(filter libsocketcan,$(USEPKG)))
# link system libsocketcan if not using the provided package
LINKFLAGS += -lsocketcan
endif
endif
TOOLCHAINS_SUPPORTED = gnu llvm afl
# Platform triple as used by Rust
ifeq ($(OS) $(OS_ARCH),Linux x86_64)
ifneq (,$(filter arch_32bit,$(FEATURES_USED)))
RUST_TARGET = i686-unknown-linux-gnu
else
RUST_TARGET = x86_64-unknown-linux-gnu
endif
endif
include $(RIOTMAKE)/arch/native.inc.mk
USE_LIBUCONTEXT := $(shell pkg-config libucontext 2> /dev/null && echo 1 || echo 0)
ifeq ($(USE_LIBUCONTEXT),1)
CFLAGS += $(pkg-config libucontext --cflags) -DUSE_LIBUCONTEXT=1
LINKFLAGS += $(shell pkg-config libucontext --libs)
endif