samples: demonstrate the use of KBUILD_ZEPHYR_APP

Jira: ZEP-2280
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2017-06-17 13:38:00 -04:00 committed by Anas Nashif
commit 4ad2746088
9 changed files with 97 additions and 0 deletions

View file

@ -0,0 +1,18 @@
#
# Copyright (c) 2017 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
BOARD = qemu_x86
CONF_FILE = prj.conf
KBUILD_ZEPHYR_APP = libmylib.a
SOURCE_DIR = $(CURDIR)
subdir-ccflags-y += -I$(SOURCE_DIR)/mylib/include
obj-y += src/
export obj-y subdir-ccflags-y
export KBUILD_ZEPHYR_APP
include ${ZEPHYR_BASE}/Makefile.inc

View file

@ -0,0 +1,7 @@
libmylib.a:
@echo $(CFLAGS)
@rm -f $(O)/libmylib.a
$(Q)@+$(MAKE) -C $(SOURCE_DIR)/mylib CFLAGS="$(KBUILD_CFLAGS) $(ZEPHYRINCLUDE)"
@cp $(SOURCE_DIR)/mylib/lib/libmylib.a $(O)/libmylib.a

View file

@ -0,0 +1,14 @@
#
# Copyright (c) 2017 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
all:
mkdir -p obj lib
$(CC) -c $(CFLAGS) -Iinclude src/mylib.c -o obj/mylib.o
$(AR) -rcs lib/libmylib.a obj/mylib.o
clean:
rm -rf obj lib

View file

@ -0,0 +1,12 @@
/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _MYLIB_H_
#define _MYLIB_H_
int mylib_hello_world(void);
#endif

View file

@ -0,0 +1,14 @@
/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "mylib.h"
#include <stdio.h>
int mylib_hello_world(void)
{
printf("mylib says: Hello World!\n");
return 0;
}

View file

@ -0,0 +1 @@
CONFIG_STDOUT_CONSOLE=y

View file

@ -0,0 +1,7 @@
#
# Copyright (c) 2017 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
#
obj-y += main.o

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
/* hello world example: calling functions from a static library */
#include <zephyr.h>
#include <stdio.h>
#include <mylib.h>
void main(void)
{
printf("Hello World!\n");
mylib_hello_world();
}

View file

@ -0,0 +1,4 @@
[test]
tags = appdev
build_only = true
platform_whitelist = qemu_x86