diff --git a/loadable_apps/loadable.mk b/loadable_apps/loadable.mk index 559403f9a4..2bc71e25e1 100644 --- a/loadable_apps/loadable.mk +++ b/loadable_apps/loadable.mk @@ -33,9 +33,7 @@ OBJCOPY = $(CROSSDEV)objcopy APPDEFINE = ${shell $(TOPDIR)/tools/define.sh "$(CC)" __APP_BUILD__} -SRCS += $(USERSPACE).c - -OBJS = $(SRCS:.c=$(OBJEXT)) +OBJS = $(SRCS:.c=$(OBJEXT)) $(USERSPACE)$(OBJEXT) prebuild: $(call DELFILE, $(USERSPACE)$(OBJEXT)) @@ -43,6 +41,9 @@ prebuild: all: prebuild postbuild .PHONY: prebuild postbuild clean install distclean +$(USERSPACE)$(OBJEXT): + $(Q) $(MAKE) -C $(TOPDIR)/userspace TOPDIR="$(TOPDIR)" APPDEFINE="$(APPDEFINE)" CELFFLAGS="$(CELFFLAGS)" app_obj + $(OBJS): %$(OBJEXT): %.c @echo "CC: $<" $(Q) $(CC) $(APPDEFINE) -c $(CELFFLAGS) $< -o $@ diff --git a/os/Directories.mk b/os/Directories.mk index 387d4dbe8a..5ffac3352d 100644 --- a/os/Directories.mk +++ b/os/Directories.mk @@ -277,3 +277,5 @@ CLEANDIRS += se ifeq ($(CONFIG_NDP120),y) CONTEXTDIRS += drivers endif + +CLEANDIRS += userspace diff --git a/os/Makefile.unix b/os/Makefile.unix index 8f8afbf2d7..59bb28b9d6 100644 --- a/os/Makefile.unix +++ b/os/Makefile.unix @@ -456,7 +456,7 @@ ifeq ($(CONFIG_ELF),y) $(Q) $(LD) -r -o $(OUTBIN_DIR)/$(CONFIG_COMMON_BINARY_NAME) -T $(TOPDIR)/userspace/userspace_apps.ld -L $(LIBRARIES_DIR) --start-group $(USERLIBS) $(LIBGCC) $(LIBSUPXX) --end-group $$(cat $(OUTBIN_DIR)/lib_symbols.txt) else $(Q) $(TOPDIR)/tools/mkldscript.py - $(Q) $(CC) -c $(CFLAGS) -D__COMMON_BINARY__ $(TOPDIR)/userspace/up_userspace.c -o $(TOPDIR)/userspace/up_userspace_common.o + $(Q) $(MAKE) -C userspace CFLAGS="$(CFLAGS)" TOPDIR="$(TOPDIR)" common_obj ifneq ($(CONFIG_XIP_ELF_WARCHIVE), y) $(Q) $(MAKE) -C $(LOADABLE_APPDIR) TOPDIR="$(TOPDIR)" LOADABLEDIR="${LOADABLE_APPDIR}" LIBRARIES_DIR="$(LIBRARIES_DIR)" USERLIBS="$(USERLIBS)" undefsym KERNEL=n $(Q) $(LD) -o $(OUTBIN_DIR)/$(CONFIG_COMMON_BINARY_NAME) -T $(OUTBIN_DIR)/common_0.ld -T $(TOPDIR)/../build/configs/$(CONFIG_ARCH_BOARD)/scripts/xipelf/userspace_all.ld $(TOPDIR)/userspace/up_userspace_common.o -L $(LIBRARIES_DIR) --start-group $(USERLIBS) $(LIBGCC) $(LIBSUPXX) --end-group $$(cat $(OUTBIN_DIR)/lib_symbols.txt) -Map $(OUTBIN_DIR)/$(CONFIG_COMMON_BINARY_NAME).map diff --git a/os/userspace/Makefile b/os/userspace/Makefile new file mode 100644 index 0000000000..ba8d1c56d2 --- /dev/null +++ b/os/userspace/Makefile @@ -0,0 +1,42 @@ +########################################################################### +# +# Copyright 2026 Samsung Electronics All Rights Reserved. +# +# Licensed 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 $(TOPDIR)/Make.defs + +APP_OBJ = up_userspace$(OBJEXT) +COMMON_OBJ = up_userspace_common$(OBJEXT) + +all: app_obj +.PHONY: all app_obj common_obj clean distclean + +app_obj: $(APP_OBJ) + +common_obj: $(COMMON_OBJ) + +$(APP_OBJ): up_userspace.c + $(Q) $(CC) $(APPDEFINE) -c $(CELFFLAGS) $< -o $@ + +$(COMMON_OBJ): up_userspace.c + $(Q) $(CC) -c $(CFLAGS) -D__COMMON_BINARY__ $< -o $@ + +clean: + $(call DELFILE, $(APP_OBJ)) + $(call DELFILE, $(COMMON_OBJ)) + $(call CLEAN) + +distclean: clean