Skip to content

Commit

Permalink
Revert "Squashed commit of the following:"
Browse files Browse the repository at this point in the history
This reverts commit 25b92ed.
  • Loading branch information
gregory-nutt committed Aug 22, 2018
1 parent cd62ab5 commit 2f982e9
Show file tree
Hide file tree
Showing 326 changed files with 569 additions and 561 deletions.
34 changes: 13 additions & 21 deletions Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,6 @@

include $(APPDIR)/Make.defs

ifneq ($(MAINSRC),)
ifneq ($(MODULE),)
ifeq ($(CONFIG_$(MODULE)), m)
BUILD_MODULE = y
endif
endif

ifeq ($(BUILD_MODULE),)
ifeq ($(CONFIG_BUILD_LOADABLE),y)
BUILD_MODULE = y
endif
endif
endif

CXXEXT ?= .cxx

AOBJS = $(ASRCS:.S=$(OBJEXT))
Expand All @@ -66,7 +52,7 @@ endif
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)

ifneq ($(CONFIG_BUILD_LOADABLE),y)
ifneq ($(CONFIG_BUILD_KERNEL),y)
OBJS += $(MAINOBJ)
endif

Expand All @@ -78,10 +64,6 @@ else
INSTALL_DIR = $(BIN_DIR)
endif

ifeq ($(BUILD_MODULE),y)
LDLIBS += $(BIN)
endif

ROOTDEPPATH = --dep-path .

VPATH =
Expand All @@ -107,11 +89,18 @@ $(MAINOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
endif

ifeq ($(LOADABLE),y)
.built: $(OBJS)
$(call ELFLD, $(APPNAME)_main, $(OBJS), $(APPNAME))
$(Q) mkdir -p $(BIN_DIR)
$(Q) install $(APPNAME) $(BIN_DIR)$(DELIM)$(APPNAME)
else
.built: $(OBJS)
$(call ARCHIVE, $(BIN), $(OBJS))
$(Q) touch $@
endif

ifeq ($(BUILD_MODULE), y)
ifeq ($(CONFIG_BUILD_KERNEL),y)
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
@echo "LD: $(PROGNAME)"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
Expand All @@ -129,7 +118,7 @@ ifneq ($(APPNAME),)
ifneq ($(PRIORITY),)
ifneq ($(STACKSIZE),)
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(if $(BUILD_MODULE),,$(APPNAME)_main))
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)

context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
else
Expand All @@ -156,6 +145,9 @@ endif
depend: .depend

clean:
ifeq ($(LOADABLE),y)
$(call DELFILE, $(APPNAME))
endif
$(call DELFILE, .built)
$(call CLEAN)

Expand Down
41 changes: 32 additions & 9 deletions Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,46 @@ DEPCONFIG = $(TOPDIR)$(DELIM).config
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
define REGISTER
$(Q) echo Register: $1
$(Q) echo { "$1", $2, $3, $4 }, > "$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
$(Q) if [ ! -z $4 ]; then \
echo "int $4(int argc, char *argv[]);" > "$(BUILTIN_REGISTRY)$(DELIM)$1.pdat"; \
fi;
$(Q) echo { "$1", $2, $3, $4 }, > "$(BUILTIN_REGISTRY)$(DELIM)$4.bdat"
$(Q) echo int $4(int argc, char *argv[]); > "$(BUILTIN_REGISTRY)$(DELIM)$4.pdat"
$(Q) touch $(BUILTIN_REGISTRY)$(DELIM).updated"
endef
else
define REGISTER
$(Q) echo "Register: $1 $4"
$(Q) echo "{ \"$1\", $2, $3, $4 }," > "$(BUILTIN_REGISTRY)$(DELIM)$1.bdat"
$(Q) if [ ! -z $4 ]; then \
echo "int $4(int argc, char *argv[]);" > "$(BUILTIN_REGISTRY)$(DELIM)$1.pdat"; \
fi;
$(Q) echo "Register: $1"
$(Q) echo "{ \"$1\", $2, $3, $4 }," > "$(BUILTIN_REGISTRY)$(DELIM)$4.bdat"
$(Q) echo "int $4(int argc, char *argv[]);" > "$(BUILTIN_REGISTRY)$(DELIM)$4.pdat"
$(Q) touch "$(BUILTIN_REGISTRY)$(DELIM).updated"
endef
endif

# COMPILE - a macro to compile a loadable app in C

ifeq ($(LOADABLE),y)
define COMPILE
@echo "CC) $1"
$(Q) $(CC) -c $(CELFFLAGS) -DLOADABLE_APP $1 -o $2
endef
endif

# COMPILEXX - a macro to compile a loadable app in C++

ifeq ($(LOADABLE),y)
define COMPILEXX
@echo "CXX: $1"
$(Q) $(CXX) -c $(CXXELFFLAGS) -DLOADABLE_APP $1 -o $2
endef
endif

# ELFLD - a macro to link loadable app
# Example: $(call ELFLD, entry point, in-file(s), out-file)

define ELFLD
@echo "LD: $3"
$(Q) $(LD) $(LDELFFLAGS) $2 -o $3
$(Q) chmod +x $3
endef

# Tools
#
# In a normal build, tools will reside in the nuttx/tools sub-directory and
Expand Down
35 changes: 17 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,21 @@ LIBPATH ?= $(TOPDIR)$(DELIM)staging

# The install path

EXE_DIR = $(APPDIR)$(DELIM)exe
BIN_DIR = $(EXE_DIR)$(DELIM)system$(DELIM)bin
BIN_DIR = $(APPDIR)$(DELIM)bin

# The final build target

BIN = libapps$(LIBEXT)

# Symbol table for loadable apps.

SYMTABSRC = $(EXE_DIR)$(DELIM)symtab_apps.c
SYMTABOBJ = $(SYMTABSRC:.c=$(OBJEXT))
SYMTABSRC = $(APPDIR)$(DELIM)symtab_apps.c
SYMTABOBJ = $(APPDIR)$(DELIM)symtab_apps$(OBJEXT)

# Build targets

all: $(BIN)
.PHONY: import install dirlinks context context_serialize clean_context context_rest .depdirs preconfig depend clean distclean
.PHONY: import symtab install dirlinks context context_serialize clean_context context_rest .depdirs preconfig depend clean distclean
.PRECIOUS: libapps$(LIBEXT)

define MAKE_template
Expand All @@ -103,29 +102,29 @@ $(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),depend))
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))

ifeq ($(CONFIG_BUILD_LOADABLE),)
$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
else
$(SYMTABSRC): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
$(Q) $(MAKE) install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(EXE_DIR)$(DELIM)system $(SYMTABSRC)

$(SYMTABOBJ): %$(OBJEXT): %.c
$(call COMPILE, -fno-lto $<, $@)

$(BIN): $(SYMTABOBJ)
$(call ARCHIVE, $(BIN), $^)
make_symbols:
ifeq ($(CONFIG_SYSTEM_NSH_SYMTAB),y)
mkdir -p $(BIN_DIR)
$(Q) $(APPDIR)$(DELIM)tools$(DELIM)mksymtab.sh $(BIN_DIR) $(SYMTABSRC)
$(call COMPILE, $(SYMTABSRC), $(SYMTABOBJ))
$(call ARCHIVE, $(APPDIR)$(DELIM)$(BIN), $(SYMTABOBJ))
endif

$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all) make_symbols

.install: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_install)

$(BIN_DIR):
$(Q) mkdir -p $(BIN_DIR)
mkdir -p $(BIN_DIR)

install: $(BIN_DIR) .install

.import: $(BIN) install

symtab: $(BIN_DIR)
$(Q) tools/mksymtab.sh $(BIN_DIR) $(APPDIR)$(DELIM)import/symtab.c
$(call MAKE_template,import,symtab)

import:
$(Q) $(MAKE) .import TOPDIR="$(APPDIR)$(DELIM)import"

Expand Down
16 changes: 3 additions & 13 deletions builtin/exec_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,9 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv,

/* Start the built-in */

if (builtin->main)
{
ret = task_spawn(&pid, builtin->name, builtin->main, &file_actions,
&attr, (argv) ? &argv[1] : (FAR char * const *)NULL,
(FAR char * const *)NULL);
}
else
{
ret = posix_spawn(&pid, builtin->name, &file_actions,
&attr, (argv) ? &argv[1] : (FAR char * const *)NULL,
NULL);
}

ret = task_spawn(&pid, builtin->name, builtin->main, &file_actions,
&attr, (argv) ? &argv[1] : (FAR char * const *)NULL,
(FAR char * const *)NULL);
if (ret != 0)
{
serr("ERROR: task_spawn failed: %d\n", ret);
Expand Down
6 changes: 3 additions & 3 deletions examples/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ examples/alarm
Configuration:

CONFIG_EXAMPLES_ALARM - Enable the RTC driver alarm test
CONFIG_EXAMPLES_ALARM_PROGNAME - If CONFIG_BUILD_LOADABLE=y, then this is
CONFIG_EXAMPLES_ALARM_PROGNAME - If CONFIG_BUILD_KERNEL=y, then this is
the name of the program that will be use when the NSH ELF program is
installed.
CONFIG_EXAMPLES_ALARM_PRIORITY - Alarm daemon priority
Expand Down Expand Up @@ -435,7 +435,7 @@ examples/flash_test
* CONFIG_MTD_SMART=y - SMART block driver support
* CONFIG_NSH_BUILTIN_APPS=y - This example can only be built as an NSH
command
* CONFIG_BUILD_PROTECTED=n and CONFIG_BUILD_LOADABLE=n- This test uses
* CONFIG_BUILD_PROTECTED=n and CONFIG_BUILD_KERNEL=n- This test uses
internal OS interfaces and so is not available in the NUTTX kernel
builds

Expand Down Expand Up @@ -1584,7 +1584,7 @@ examples/relays
relies on internal OS interfaces that are not normally available to a
user-space program. As a result, this example cannot be used if a
NuttX is built as a protected, supervisor kernel (CONFIG_BUILD_PROTECTED
or CONFIG_BUILD_LOADABLE).
or CONFIG_BUILD_KERNEL).

examples/rfid_readuid
^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion examples/adc/adc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static void parse_args(FAR struct adc_state_s *adc, int argc, FAR char **argv)
* Name: adc_main
****************************************************************************/

#ifdef CONFIG_BUILD_LOADABLE
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int adc_main(int argc, char *argv[])
Expand Down
2 changes: 1 addition & 1 deletion examples/adxl372_test/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if EXAMPLES_ADXL372_TEST
config EXAMPLES_ADXL372_TEST_PROGNAME
string "Program name"
default "ADXL372_test"
depends on BUILD_LOADABLE
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
Expand Down
2 changes: 1 addition & 1 deletion examples/adxl372_test/adxl372_test_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static int adxl372_test(int is_interactive, FAR char *path)
*
****************************************************************************/

#ifdef CONFIG_BUILD_LOADABLE
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int adxl372_test_main(int argc, FAR char *argv[])
Expand Down
2 changes: 1 addition & 1 deletion examples/ajoystick/ajoy_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static int ajoy_calibrate(int fd)
* ajoy_main
****************************************************************************/

#ifdef CONFIG_BUILD_LOADABLE
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int ajoy_main(int argc, char *argv[])
Expand Down
2 changes: 1 addition & 1 deletion examples/alarm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if EXAMPLES_ALARM
config EXAMPLES_ALARM_PROGNAME
string "Program name"
default "alarm"
depends on BUILD_LOADABLE
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
Expand Down
2 changes: 1 addition & 1 deletion examples/alarm/alarm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void show_usage(FAR const char *progname)
* alarm_main
****************************************************************************/

#ifdef CONFIG_BUILD_LOADABLE
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int alarm_main(int argc, FAR char *argv[])
Expand Down
2 changes: 1 addition & 1 deletion examples/apa102/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if EXAMPLES_APA102
config EXAMPLES_APA102_PROGNAME
string "Program name"
default "apa102"
depends on BUILD_LOADABLE
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
Expand Down
2 changes: 1 addition & 1 deletion examples/apa102/apa102_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static struct apa102_ledstrip_s hsvtorgb(uint16_t h, uint8_t s, uint8_t v)
* apa102_main
****************************************************************************/

#ifdef CONFIG_BUILD_LOADABLE
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int apa102_main(int argc, char *argv[])
Expand Down
2 changes: 1 addition & 1 deletion examples/apds9960/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if EXAMPLES_APDS9960
config EXAMPLES_APDS9960_PROGNAME
string "APDS-9960 Test Program name"
default "apds9960"
depends on BUILD_LOADABLE
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
Expand Down
2 changes: 1 addition & 1 deletion examples/apds9960/apds9960_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
* apds9960_main
****************************************************************************/

#ifdef CONFIG_BUILD_LOADABLE
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int apds9960_main(int argc, char *argv[])
Expand Down
6 changes: 3 additions & 3 deletions examples/bastest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS)

ifneq ($(CONFIG_BUILD_LOADABLE),y)
ifneq ($(CONFIG_BUILD_KERNEL),y)
OBJS += $(MAINOBJ)
endif

Expand Down Expand Up @@ -115,7 +115,7 @@ $(ROMFS_HDR) : $(ROMFS_IMG)

# Link and install the program binary

ifeq ($(CONFIG_BUILD_LOADABLE),y)
ifeq ($(CONFIG_BUILD_KERNEL),y)
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
@echo "LD: $(PROGNAME)"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
Expand All @@ -132,7 +132,7 @@ endif

ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(if $(CONFIG_BUILD_LOADABLE),,$(APPNAME)_main))
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)

context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
else
Expand Down
2 changes: 1 addition & 1 deletion examples/bastest/bastest_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
* bastest_main
****************************************************************************/

#ifdef CONFIG_BUILD_LOADABLE
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int bastest_main(int argc, char *argv[])
Expand Down
2 changes: 1 addition & 1 deletion examples/bmp180/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if EXAMPLES_BMP180
config EXAMPLES_BMP180_PROGNAME
string "Program name"
default "bmp180"
depends on BUILD_LOADABLE
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
Expand Down
2 changes: 1 addition & 1 deletion examples/bmp180/bmp180_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* bmp180_main
****************************************************************************/

#ifdef CONFIG_BUILD_LOADABLE
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int bmp180_main(int argc, char *argv[])
Expand Down
Loading

0 comments on commit 2f982e9

Please sign in to comment.