1 # SPDX-License-Identifier: GPL-2.0-only
3 # Sample libpayload Makefile for ARCH_MOCK
4 # ARCH_MOCK is not intended to be used with xcompile
7 ifneq ($(CONFIG_LP_ARCH_MOCK
),y
)
8 $(error This example supports ARCH_MOCK only.
)
14 LIBPAYLOAD_DIR
:= ..
/..
/install/libpayload
15 CFLAGS
:= -fno-builtin
-Wall
-Werror
-Os \
16 -include $(LIBPAYLOAD_DIR
)/include/kconfig.h \
17 -include $(LIBPAYLOAD_DIR
)/include/compiler.h \
18 -I
$(LIBPAYLOAD_DIR
)/include \
19 -I
$(LIBPAYLOAD_DIR
)/include/mock \
22 LDFLAGS
:= -Wl
,--gc-sections
25 OBJS-mock
:= $(TARGET
)_mocks.o
26 LIBPAYLOAD-local
:= libpayload.a
27 mocks
:= console_write
31 $(TARGET
).elf
: $(OBJS
) $(OBJS-mock
) $(LIBPAYLOAD-local
)
32 $(CC
) $(LDFLAGS
) -o
$@
$(OBJS
) $(LIBPAYLOAD-local
) \
33 -Wl
,--exclude-libs
,ALL
-lc
$(OBJS-mock
)
36 $(CC
) $(CFLAGS
) -c
-o
$@
$<
41 # Copy libpayload and weaken all mocked symbols
42 $(LIBPAYLOAD-local
): $(LIBPAYLOAD_DIR
)/lib
/libpayload.a
43 $(OBJCOPY
) $(foreach mock
,$(mocks
),--weaken-symbol
=$(mock
)) $< $@
46 rm -f
$(TARGET
).elf
*.o
$(LIBPAYLOAD-local
)