apps:modify examples elf compile method

rearrange the elf test directory, make the sub-testcase in separate
directory

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2025-06-18 14:26:57 +08:00 committed by GUIDINGLI
parent 2b0a4a20f5
commit 91f55245eb
31 changed files with 326 additions and 691 deletions

1
examples/elf/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/Kconfig

View file

@ -20,9 +20,5 @@
#
# ##############################################################################
if(CONFIG_EXAMPLES_ELF)
nuttx_add_application(NAME elf SRCS elf_main.c)
# TODO: tests
endif()
nuttx_add_subdirectory()
nuttx_generate_kconfig(MENUDESC "Elf")

View file

@ -20,6 +20,4 @@
#
############################################################################
ifneq ($(CONFIG_EXAMPLES_ELF),)
CONFIGURED_APPS += $(APPDIR)/examples/elf
endif
include $(wildcard $(APPDIR)/examples/elf/*/Make.defs)

View file

@ -20,47 +20,6 @@
#
############################################################################
include $(APPDIR)/Make.defs
MENUDESC = "Elf example"
# ELF Example
ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y)
CSRCS = romfs.c
endif
ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y)
CSRCS = cromfs.c
endif
CSRCS += dirlist.c
CSRCS += symtab.c
tests$(DELIM)symtab.c_CFLAGS = -fno-builtin
tests$(DELIM)symtab.c_CELFFLAGS = -fno-builtin
MAINSRC = elf_main.c
PROGNAME = elf
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_ELF)
DEPPATH := --dep-path tests
# Build targets
VPATH += :tests
ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y)
tests/romfs.c: build
endif
ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y)
tests/cromfs.c: build
endif
tests/dirlist.c: build
tests/symtab.c: build
.PHONY: build
build:
+$(Q) $(MAKE) -C tests TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV)
clean::
+$(Q) $(MAKE) -C tests TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" CROSSDEV=$(CROSSDEV) clean
include $(APPDIR)/Application.mk
include $(APPDIR)/Directory.mk

4
examples/elf/main/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
/elf_romfs.c
/elf_romfs.img
/cromfs.c
/test_symtab.c

View file

@ -0,0 +1,26 @@
# ##############################################################################
# apps/examples/elf/main/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_EXAMPLES_ELF)
nuttx_add_application(NAME elf SRCS elf_main.c)
# TODO: tests
endif()

View file

@ -0,0 +1,23 @@
############################################################################
# apps/examples/elf/main/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifneq ($(CONFIG_EXAMPLES_ELF),)
CONFIGURED_APPS += $(APPDIR)/examples/elf/main
endif

100
examples/elf/main/Makefile Normal file
View file

@ -0,0 +1,100 @@
############################################################################
# apps/examples/elf/main/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
# Module example built-in application info
PROGNAME = elf
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_ELF)
MAINSRC = elf_main.c
SYMTABSRC = test_symtab.c
SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT))
ifneq ($(CONFIG_BUILD_FLAT),y)
PASS1_SYMTAB = $(TOPDIR)/pass1/mod_symtab.c
MODLUE_NAME = tests
endif
$(SYMTABSRC):
$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BINDIR) g_elf >$@.tmp
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
$(SYMTABOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@, -fno-lto -fno-builtin)
ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y)
ROMFSIMG = elf_romfs.img
ROMFSSRC = elf_romfs.c
ROMFSOBJ = $(ROMFSSRC:.c=$(OBJEXT))
$(ROMFSIMG):
$(Q) genromfs -d $(BINDIR) -f $@
$(ROMFSSRC): $(ROMFSIMG)
$(Q) (echo "#include <nuttx/compiler.h>" >$@ && \
xxd -i $(ROMFSIMG) | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@)
$(ROMFSOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@, -fno-lto -fno-builtin)
else ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y)
NXTOOLDIR = $(TOPDIR)/tools
GENCROMFSSRC = gencromfs.c
GENCROMFSEXE = gencromfs$(HOSTEXEEXT)
FSIMG_SRC = cromfs.c
FSIMG_OBJ = $(FSIMG_SRC:.c=$(OBJEXT))
$(NXTOOLDIR)/$(GENCROMFSEXE): $(NXTOOLDIR)/$(GENCROMFSSRC)
$(Q) $(MAKE) -C $(NXTOOLDIR) -f Makefile.host $(GENCROMFSEXE)
# Create the cromfs.c file from the populated cromfs directory
$(FSIMG_SRC):$(NXTOOLDIR)/$(GENCROMFSEXE)
$(Q) $(NXTOOLDIR)/$(GENCROMFSEXE) $(BINDIR) $@.tmp
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
$(FSIMG_OBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@, -fno-lto -fno-builtin)
endif
# Copy the symbol table into the kernel pass1/ build directory
ifneq ($(CONFIG_BUILD_FLAT),y)
$(PASS1_SYMTAB): $(SYMTABSRC)
$(Q) install -m 0644 $(SYMTABSRC) $(PASS1_SYMTAB)
$(Q) mv $(BINDIR)$(DELIM)$(MODLUE_NAME) .
endif
postinstall:: $(ROMFSOBJ) $(SYMTABOBJ) $(FSIMG_OBJ) $(PASS1_SYMTAB)
$(call ARLOCK, $(call CONVERT_PATH,$(BIN)), $^)
distclean::
$(Q) $(call DELFILE, $(SYMTABSRC) $(SYMTABOBJ) $(ROMFSSRC) $(ROMFSIMG) $(ROMFSOBJ) $(MODLUE_NAME))
include $(APPDIR)/Application.mk

View file

@ -1,5 +1,5 @@
/****************************************************************************
* apps/examples/elf/elf_main.c
* apps/examples/elf/main/elf_main.c
*
* SPDX-License-Identifier: Apache-2.0
*
@ -132,8 +132,35 @@ extern const unsigned int elf_romfs_img_len;
# error "No file system selected"
#endif
extern const char *dirlist[];
const char *dirlist[] =
{
"errno",
"hello",
"signal",
"struct",
#ifdef CONFIG_HAVE_CXX
"hello++1",
"hello++2",
# ifdef CONFIG_HAVE_CXXINITIALIZE
"hello++3",
# endif
# ifdef CONFIG_EXAMPLES_ELF_CXX
"hello++4",
"hello++5",
# endif
#endif
#ifdef CONFIG_EXAMPLES_ELF_LONGJMP
"longjmp"
#endif
#ifndef CONFIG_DISABLE_PTHREAD
"mutex",
"pthread",
#endif
#ifndef CONFIG_ARCH_ADDRENV
"task",
#endif
NULL
};
extern const struct symtab_s g_elf_exports[];
extern const int g_elf_nexports;

View file

@ -6,3 +6,4 @@
/dirlist.c
/extfs
/symtab.c
/Kconfig

View file

@ -0,0 +1,39 @@
############################################################################
# apps/examples/elf/tests/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifeq ($(CONFIG_EXAMPLES_ELF),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/errno
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/hello
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/signal
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/struct
ifeq ($(CONFIG_HAVE_CXX),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/helloxx
endif
ifeq ($(CONFIG_EXAMPLES_ELF_LONGJMP),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/longjmp
endif
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/mutex
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/pthread
endif
ifneq ($(CONFIG_ARCH_ADDRENV),y)
CONFIGURED_APPS += $(APPDIR)/examples/elf/tests/task
endif
endif

View file

@ -20,134 +20,6 @@
#
############################################################################
include $(APPDIR)/Make.defs
MENUDESC = "Elf tests example"
ALL_SUBDIRS = errno hello helloxx longjmp mutex pthread signal task struct
BUILD_SUBDIRS = errno hello struct signal
ifeq ($(CONFIG_HAVE_CXX),y)
BUILD_SUBDIRS += helloxx
endif
ifeq ($(CONFIG_EXAMPLES_ELF_LONGJMP),y)
BUILD_SUBDIRS += longjmp
endif
ifneq ($(CONFIG_DISABLE_PTHREAD),y)
BUILD_SUBDIRS += mutex pthread
endif
ifneq ($(CONFIG_ARCH_ADDRENV),y)
BUILD_SUBDIRS += task
endif
ELF_DIR = $(APPDIR)/examples/elf
TESTS_DIR = $(ELF_DIR)/tests
DIRLIST_SRC = $(TESTS_DIR)/dirlist.c
SYMTAB_SRC = $(TESTS_DIR)/symtab.c
ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y)
FSIMG_SUBDIR = romfs
FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR)
ROMFS_IMG = $(TESTS_DIR)/romfs.img
FSIMG_SRC = $(TESTS_DIR)/romfs.c
endif
ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y)
NXTOOLDIR = $(TOPDIR)/tools
GENCROMFSSRC = gencromfs.c
GENCROMFSEXE = gencromfs$(HOSTEXEEXT)
FSIMG_SUBDIR = cromfs
FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR)
FSIMG_SRC = $(TESTS_DIR)/cromfs.c
endif
ifeq ($(CONFIG_EXAMPLES_ELF_EXTERN),y)
FSIMG_SUBDIR = extfs
FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR)
endif
# generate the romfs image in case the fs type is romfs
# the FSIMG_SRC is not actually generated.
ifeq ($(CONFIG_EXAMPLES_ELF_FSTYPE), "romfs")
ROMFS_IMG = $(TESTS_DIR)/romfs.img
FSIMG_SRC = $(TESTS_DIR)/romfs.c
endif
define DIR_template
$(1)_$(2):
+$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" FSIMG_DIR="$(FSIMG_DIR)" CROSSDEV=$(CROSSDEV)
endef
all: $(FSIMG_SRC) $(DIRLIST_SRC) $(SYMTAB_SRC)
.PHONY: all clean install
$(foreach DIR, $(ALL_SUBDIRS), $(eval $(call DIR_template,$(DIR),clean)))
$(foreach DIR, $(BUILD_SUBDIRS), $(eval $(call DIR_template,$(DIR),install)))
# Install each program in the file system image directory
install: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_install)
ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y)
# Create the romfs.img file from the populated romfs directory
$(ROMFS_IMG): install
$(Q) genromfs -f $@.tmp -d $(FSIMG_DIR) -V "ELFTEST"
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
# Create the romfs.c file from the romfs.img file
$(FSIMG_SRC): $(ROMFS_IMG)
$(Q) (cd $(TESTS_DIR) && echo "#include <nuttx/compiler.h>" >$@ && \
xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" | \
sed -e "s/romfs_img/elf_romfs_img/g" >>$@)
endif
ifeq ($(CONFIG_EXAMPLES_ELF_CROMFS),y)
# Make sure that the NuttX gencromfs tool has been built
$(NXTOOLDIR)/$(GENCROMFSEXE): $(NXTOOLDIR)/$(GENCROMFSSRC)
$(Q) $(MAKE) -C $(NXTOOLDIR) -f Makefile.host $(GENCROMFSEXE)
# Create the cromfs.h header file from the populated cromfs directory
$(FSIMG_SRC): install $(NXTOOLDIR)/$(GENCROMFSEXE)
$(Q) $(NXTOOLDIR)/$(GENCROMFSEXE) $(FSIMG_DIR) $@.tmp
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
endif
ifeq ($(CONFIG_EXAMPLES_ELF_FSTYPE),"romfs")
# Create the romfs.img file from the populated romfs directory
$(ROMFS_IMG): install
$(Q) genromfs -f $@.tmp -d $(FSIMG_DIR) -V "ELFTEST"
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
# Create the romfs.c file from the romfs.img file
$(FSIMG_SRC): $(ROMFS_IMG)
endif
# Create the dirlist.h header file from the file system image directory
$(DIRLIST_SRC): install
$(Q) $(TESTS_DIR)/mkdirlist.sh $(FSIMG_DIR) >$@.tmp
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
# Create the exported symbol table
$(SYMTAB_SRC): install
$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(FSIMG_DIR) g_elf >$@.tmp
$(Q) $(call TESTANDREPLACEFILE, $@.tmp, $@)
# Clean each subdirectory
clean: $(foreach DIR, $(ALL_SUBDIRS), $(DIR)_clean)
$(Q) rm -f $(FSIMG_SRC) $(DIRLIST_SRC) $(ROMFS_IMG) $(SYMTAB_SRC)
$(Q) rm -rf $(FSIMG_DIR)
include $(APPDIR)/Directory.mk

View file

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View file

@ -22,49 +22,10 @@
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
else
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
endif
endif
PROGNAME = errno
PRIORITY = 100
STACKSIZE = $(CONFIG_ELF_STACKSIZE)
MODULE = m
MAINSRC = errno.c
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDLIBS += -lc
endif
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDLIBS += -lproxies
endif
BIN = errno
SRCS = $(BIN).c
OBJS = $(SRCS:.c=$(OBJEXT))
all: $(BIN)
.PHONY: all clean install
$(OBJS): %$(OBJEXT): %.c
@echo "CC: $<"
$(Q) $(CC) -c $(CELFFLAGS) $< -o $@
$(BIN): $(OBJS)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(FSIMG_DIR)/$(BIN): $(BIN)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN) $(FSIMG_DIR)/$(BIN)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN)
endif
install: $(FSIMG_DIR)/$(BIN)
clean:
$(call DELFILE, $(BIN))
$(call CLEAN)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View file

@ -22,49 +22,10 @@
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
else
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
endif
endif
PROGNAME = hello
PRIORITY = 100
STACKSIZE = $(CONFIG_ELF_STACKSIZE)
MODULE = m
MAINSRC = hello.c
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDLIBS += -lc
endif
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDLIBS += -lproxies
endif
BIN = hello
SRCS = $(BIN).c
OBJS = $(SRCS:.c=$(OBJEXT))
all: $(BIN)
.PHONY: all clean install
$(OBJS): %$(OBJEXT): %.c
@echo "CC: $<"
$(Q) $(CC) -c $(CELFFLAGS) $< -o $@
$(BIN): $(OBJS)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(FSIMG_DIR)/$(BIN): $(BIN)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN) $(FSIMG_DIR)/$(BIN)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN)
endif
install: $(FSIMG_DIR)/$(BIN)
clean:
$(call DELFILE, $(BIN))
$(call CLEAN)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View file

@ -22,156 +22,19 @@
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
else
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
endif
endif
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDLIBS += -lc
endif
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDLIBS += -lproxies
endif
BIN1 = hello++1
ALL_BIN = $(FSIMG_DIR)/$(BIN1)
BIN2 = hello++2
ALL_BIN += $(FSIMG_DIR)/$(BIN2)
PROGNAME = hello++1 hello++2
PRIORITY = 100
STACKSIZE = $(CONFIG_ELF_STACKSIZE)
MODULE = m
MAINSRC = hello++1.cxx hello++2.cxx
ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
BIN3 = hello++3
ALL_BIN += $(FSIMG_DIR)/$(BIN3)
ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y)
BIN4 = hello++4
ALL_BIN += $(FSIMG_DIR)/$(BIN4)
BIN5 = hello++5
ALL_BIN += $(FSIMG_DIR)/$(BIN5)
endif
endif
SRCS1 = $(BIN1).c
OBJS1 = $(SRCS1:.c=$(OBJEXT))
SRCS2 = $(BIN2).c
OBJS2 = $(SRCS2:.c=$(OBJEXT))
ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
SRCS3 = $(BIN3).c
OBJS3 = $(SRCS3:.c=$(OBJEXT))
ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y)
SRCS4 = $(BIN4).c
OBJS4 = $(SRCS4:.c=$(OBJEXT))
SRCS5 = $(BIN5).c
OBJS5 = $(SRCS5:.c=$(OBJEXT))
endif
endif
SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(SRCS4) $(SRCS5)
OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5)
LDLIBSTDC_STUBS_DIR = $(TOPDIR)/libxx
LDLIBSTDC_STUBS_LIB = $(LDLIBSTDC_STUBS_DIR)/liblibxx.a
all: $(BIN1) $(BIN2) $(BIN3) $(BIN4) $(BIN5)
.PHONY: all clean install
$(OBJS): %$(OBJEXT): %.cxx
@echo "CC: $<"
$(Q) $(CXX) -c $(CXXELFFLAGS) $< -o $@
# This contains libstdc++ stubs to that you can build C++ code
# without actually having libstdc++
$(LDLIBSTDC_STUBS_LIB):
$(Q) $(MAKE) -C $(LDLIBSTDC_STUBS_DIR) TOPDIR=$(TOPDIR)
# BIN1 and BIN2 link just like C code because they contain no
# static constructors. BIN1 is equivalent to a C hello world;
# BIN2 contains a class that implements hello world, but it is
# not statically initialized.
$(BIN1): $(OBJS1)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(BIN2): $(OBJS2)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
# BIN3 is equivalent to BIN2 except that is uses static initializers
ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
$(BIN3): $(OBJS3)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
# BIN4 is similar to BIN3 except that it uses the streams code from libstdc++
# Both BIN4 and BIN5 use exceptions
# NOTE: libstdc++ is not available for NuttX as of this writing
#
ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y)
ifeq ($(CONFIG_CXX_EXCEPTION),y)
$(BIN4): $(OBJS4)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(BIN5): $(OBJS5)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
endif
endif
endif
$(FSIMG_DIR)/$(BIN1): $(BIN1)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN1) $(FSIMG_DIR)/$(BIN1)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN1)
endif
$(FSIMG_DIR)/$(BIN2): $(BIN2)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN2) $(FSIMG_DIR)/$(BIN2)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN2)
endif
ifeq ($(CONFIG_HAVE_CXXINITIALIZE),y)
$(FSIMG_DIR)/$(BIN3): $(BIN3)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN3) $(FSIMG_DIR)/$(BIN3)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN3)
PROGNAME += hello++3
MAINSRC += hello++3.cxx
endif
ifeq ($(CONFIG_EXAMPLES_ELF_CXX),y)
$(FSIMG_DIR)/$(BIN4): $(BIN4)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN4) $(FSIMG_DIR)/$(BIN4)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN4)
PROGNAME += hello++4 hello++5
MAINSRC += hello++4.cxx hello++5.cxx
endif
$(FSIMG_DIR)/$(BIN5): $(BIN5)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN5) $(FSIMG_DIR)/$(BIN5)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN5)
endif
endif
endif
install: $(ALL_BIN)
clean:
$(call DELFILE, $(BIN1))
$(call DELFILE, $(BIN2))
$(call DELFILE, $(BIN3))
$(call DELFILE, $(BIN4))
$(call DELFILE, $(BIN5))
$(call CLEAN)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View file

@ -22,49 +22,10 @@
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
else
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
endif
endif
PROGNAME = longjmp
PRIORITY = 100
STACKSIZE = $(CONFIG_ELF_STACKSIZE)
MODULE = m
MAINSRC = longjmp.c
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDLIBS += -lc
endif
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDLIBS += -lproxies
endif
BIN = longjmp
SRCS = $(BIN).c
OBJS = $(SRCS:.c=$(OBJEXT))
all: $(BIN)
.PHONY: all clean install
$(OBJS): %$(OBJEXT): %.c
@echo "CC: $<"
$(Q) $(CC) -c $(CELFFLAGS) $< -o $@
$(BIN): $(OBJS)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(FSIMG_DIR)/$(BIN): $(BIN)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN) $(FSIMG_DIR)/$(BIN)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN)
endif
install: $(FSIMG_DIR)/$(BIN)
clean:
$(call DELFILE, $(BIN))
$(call CLEAN)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View file

@ -22,49 +22,10 @@
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
else
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
endif
endif
PROGNAME = mutex
PRIORITY = 100
STACKSIZE = $(CONFIG_ELF_STACKSIZE)
MODULE = m
MAINSRC = mutex.c
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDLIBS += -lc
endif
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDLIBS += -lproxies
endif
BIN = mutex
SRCS = $(BIN).c
OBJS = $(SRCS:.c=$(OBJEXT))
all: $(BIN)
.PHONY: all clean install
$(OBJS): %$(OBJEXT): %.c
@echo "CC: $<"
$(Q) $(CC) -c $(CELFFLAGS) $< -o $@
$(BIN): $(OBJS)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(FSIMG_DIR)/$(BIN): $(BIN)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN) $(FSIMG_DIR)/$(BIN)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN)
endif
install: $(FSIMG_DIR)/$(BIN)
clean:
$(call DELFILE, $(BIN))
$(call CLEAN)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View file

@ -22,49 +22,10 @@
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
else
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
endif
endif
PROGNAME = pthread
PRIORITY = 100
STACKSIZE = $(CONFIG_ELF_STACKSIZE)
MODULE = m
MAINSRC = pthread.c
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDLIBS += -lc
endif
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDLIBS += -lproxies
endif
BIN = pthread
SRCS = $(BIN).c
OBJS = $(SRCS:.c=$(OBJEXT))
all: $(BIN)
.PHONY: all clean install
$(OBJS): %$(OBJEXT): %.c
@echo "CC: $<"
$(Q) $(CC) -c $(CELFFLAGS) $< -o $@
$(BIN): $(OBJS)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(FSIMG_DIR)/$(BIN): $(BIN)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN) $(FSIMG_DIR)/$(BIN)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN)
endif
install: $(FSIMG_DIR)/$(BIN)
clean:
$(call DELFILE, $(BIN))
$(call CLEAN)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View file

@ -22,49 +22,10 @@
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
else
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
endif
endif
PROGNAME = signal
PRIORITY = 100
STACKSIZE = $(CONFIG_ELF_STACKSIZE)
MODULE = m
MAINSRC = signal.c
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDLIBS += -lc
endif
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDLIBS += -lproxies
endif
BIN = signal
SRCS = $(BIN).c
OBJS = $(SRCS:.c=$(OBJEXT))
all: $(BIN)
.PHONY: all clean install
$(OBJS): %$(OBJEXT): %.c
@echo "CC: $<"
$(Q) $(CC) -c $(CELFFLAGS) $< -o $@
$(BIN): $(OBJS)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(FSIMG_DIR)/$(BIN): $(BIN)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN) $(FSIMG_DIR)/$(BIN)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN)
endif
install: $(FSIMG_DIR)/$(BIN)
clean:
$(call DELFILE, $(BIN))
$(call CLEAN)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View file

@ -22,48 +22,11 @@
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
else
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
endif
endif
PROGNAME = struct
PRIORITY = 100
STACKSIZE = $(CONFIG_ELF_STACKSIZE)
MODULE = m
CSRCS = struct_dummy.c
MAINSRC = struct_main.c
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDLIBS += -lc
endif
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDLIBS += -lproxies
endif
BIN = struct
SRCS = struct_main.c struct_dummy.c
OBJS = $(SRCS:.c=$(OBJEXT))
all: $(BIN)
.PHONY: all clean install
$(OBJS): %$(OBJEXT): %.c
@echo "CC: $<"
$(Q) $(CC) -c $(CELFFLAGS) $< -o $@
$(BIN): $(OBJS)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(FSIMG_DIR)/$(BIN): $(BIN)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN) $(FSIMG_DIR)/$(BIN)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN)
endif
install: $(FSIMG_DIR)/$(BIN)
clean:
$(call DELFILE, $(BIN))
$(call CLEAN)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,4 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

View file

@ -22,49 +22,10 @@
include $(APPDIR)/Make.defs
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
else
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDELFFLAGS += -Bstatic
LDLIBPATH += -L $(NUTTXLIB)
endif
endif
PROGNAME = task
PRIORITY = 100
STACKSIZE = $(CONFIG_ELF_STACKSIZE)
MODULE = m
MAINSRC = task.c
ifeq ($(CONFIG_EXAMPLES_ELF_LIBC),y)
LDLIBS += -lc
endif
ifeq ($(CONFIG_EXAMPLES_ELF_SYSCALL),y)
LDLIBS += -lproxies
endif
BIN = task
SRCS = $(BIN).c
OBJS = $(SRCS:.c=$(OBJEXT))
all: $(BIN)
.PHONY: all clean install
$(OBJS): %$(OBJEXT): %.c
@echo "CC: $<"
$(Q) $(CC) -c $(CELFFLAGS) $< -o $@
$(BIN): $(OBJS)
@echo "LD: $<"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $@ $(ARCHCRT0OBJ) $^ $(LDLIBS)
$(FSIMG_DIR)/$(BIN): $(BIN)
$(Q) mkdir -p $(FSIMG_DIR)
$(Q) install $(BIN) $(FSIMG_DIR)/$(BIN)
ifneq ($(CONFIG_DEBUG_SYMBOLS),y)
$(Q) $(STRIP) $(FSIMG_DIR)/$(BIN)
endif
install: $(FSIMG_DIR)/$(BIN)
clean:
$(call DELFILE, $(BIN))
$(call CLEAN)
include $(APPDIR)/Application.mk