devkitARM 3DS Makefile error: uname - c

I'm trying to build a .3dsx for 3DS Homebrew, but I get the same error with all of my builds:
It doesn't matter what project I try to make, I always get this error involving uname.
Here's my Makefile:
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := src
DATA := data
INCLUDES := include
APP_TITLE := Savegame Manager
APP_DESCRIPTION := Manage the savegame of your game.\nSD Card Required
APP_AUTHOR := phase
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
#[ -d $# ] || mkdir -p $#
#$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
#echo clean ...
#rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
#echo $(notdir $<)
#$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
#echo $(notdir $<)
#python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
#bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $#
#echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
#echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
#echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
#rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
The C code itself shouldn't matter, since I get this error with every project I try to build.

Related

riscv64-linux-gnu-ld: undefined reference to `fseek'

Recently,I met with this problem under vmware ubuntu 22.04:
riscv64-linux-gnu-ld: loader.c:(.text.naive_uload+0x4c): undefined reference to fseek' riscv64-linux-gnu-ld: loader.c:(.text.naive_uload+0x78): undefined reference to fread'
riscv64-linux-gnu-ld: loader.c:(.text.naive_uload+0xbc): undefined reference to fseek' riscv64-linux-gnu-ld: loader.c:(.text.naive_uload+0xe0): undefined reference to fread'
I was using crossing compiler
My makefile is:
# Makefile for AbstractMachine Kernels and Libraries
### *Get a more readable version of this Makefile* by `make html` (requires python-markdown)
html:
cat Makefile | sed 's/^\([^#]\)/ \1/g' | markdown_py > Makefile.html
.PHONY: html
## 1. Basic Setup and Checks
### Default to create a bare-metal kernel image
ifeq ($(MAKECMDGOALS),)
MAKECMDGOALS = image
.DEFAULT_GOAL = image
endif
### Override checks when `make clean/clean-all/html`
ifeq ($(findstring $(MAKECMDGOALS),clean|clean-all|html),)
### Print build info message
$(info # Building $(NAME)-$(MAKECMDGOALS) [$(ARCH)])
### Check: environment variable `$AM_HOME` looks sane
ifeq ($(wildcard $(AM_HOME)/am/include/am.h),)
$(error $$AM_HOME must be an AbstractMachine repo)
endif
### Check: environment variable `$ARCH` must be in the supported list
ARCHS = $(basename $(notdir $(shell ls $(AM_HOME)/scripts/*.mk)))
ifeq ($(filter $(ARCHS), $(ARCH)), )
$(error Expected $$ARCH in {$(ARCHS)}, Got "$(ARCH)")
endif
### Extract instruction set architecture (`ISA`) and platform from `$ARCH`. Example: `ARCH=x86_64-qemu -> ISA=x86_64; PLATFORM=qemu`
ARCH_SPLIT = $(subst -, ,$(ARCH))
ISA = $(word 1,$(ARCH_SPLIT))
PLATFORM = $(word 2,$(ARCH_SPLIT))
### Check if there is something to build
ifeq ($(flavor SRCS), undefined)
$(error Nothing to build)
endif
### Checks end here
endif
## 2. General Compilation Targets
### Create the destination directory (`build/$ARCH`)
WORK_DIR = $(shell pwd)
DST_DIR = $(WORK_DIR)/build/$(ARCH)
$(shell mkdir -p $(DST_DIR))
### Compilation targets (a binary image or archive)
IMAGE_REL = build/$(NAME)-$(ARCH)
IMAGE = $(abspath $(IMAGE_REL))
ARCHIVE = $(WORK_DIR)/build/$(NAME)-$(ARCH).a
### Collect the files to be linked: object files (`.o`) and libraries (`.a`)
OBJS = $(addprefix $(DST_DIR)/, $(addsuffix .o, $(basename $(SRCS))))
LIBS := $(sort $(LIBS) am klib) # lazy evaluation ("=") causes infinite recursions
LINKAGE = $(OBJS) \
$(addsuffix -$(ARCH).a, $(join \
$(addsuffix /build/, $(addprefix $(AM_HOME)/, $(LIBS))), \
$(LIBS) ))
## 3. General Compilation Flags
### (Cross) compilers, e.g., mips-linux-gnu-g++
AS = $(CROSS_COMPILE)gcc
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
LD = $(CROSS_COMPILE)ld
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
READELF = $(CROSS_COMPILE)readelf
### Compilation flags
INC_PATH += $(WORK_DIR)/include $(addsuffix /include/, $(addprefix $(AM_HOME)/, $(LIBS)))
INCFLAGS += $(addprefix -I, $(INC_PATH))
CFLAGS += -O2 -MMD -Wall -Werror $(INCFLAGS) \
-D__ISA__=\"$(ISA)\" -D__ISA_$(shell echo $(ISA) | tr a-z A-Z)__ \
-D__ARCH__=$(ARCH) -D__ARCH_$(shell echo $(ARCH) | tr a-z A-Z | tr - _) \
-D__PLATFORM__=$(PLATFORM) -D__PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z | tr - _) \
-DARCH_H=\"arch/$(ARCH).h\" \
-fno-asynchronous-unwind-tables -fno-builtin -fno-stack-protector \
-Wno-main -U_FORTIFY_SOURCE
CXXFLAGS += $(CFLAGS) -ffreestanding -fno-rtti -fno-exceptions
ASFLAGS += -MMD $(INCFLAGS)
LDFLAGS += -z noexecstack
## 4. Arch-Specific Configurations
### Paste in arch-specific configurations (e.g., from `scripts/x86_64-qemu.mk`)
-include $(AM_HOME)/scripts/$(ARCH).mk
### Fall back to native gcc/binutils if there is no cross compiler
ifeq ($(wildcard $(shell which $(CC))),)
$(info # $(CC) not found; fall back to default gcc and binutils)
CROSS_COMPILE :=
endif
## 5. Compilation Rules
### Rule (compile): a single `.c` -> `.o` (gcc)
$(DST_DIR)/%.o: %.c
#mkdir -p $(dir $#) && echo + CC $<
#$(CC) -std=gnu11 $(CFLAGS) -c -o $# $(realpath $<)
### Rule (compile): a single `.cc` -> `.o` (g++)
$(DST_DIR)/%.o: %.cc
#mkdir -p $(dir $#) && echo + CXX $<
#$(CXX) -std=c++17 $(CXXFLAGS) -c -o $# $(realpath $<)
### Rule (compile): a single `.cpp` -> `.o` (g++)
$(DST_DIR)/%.o: %.cpp
#mkdir -p $(dir $#) && echo + CXX $<
#$(CXX) -std=c++17 $(CXXFLAGS) -c -o $# $(realpath $<)
### Rule (compile): a single `.S` -> `.o` (gcc, which preprocesses and calls as)
$(DST_DIR)/%.o: %.S
#mkdir -p $(dir $#) && echo + AS $<
#$(AS) $(ASFLAGS) -c -o $# $(realpath $<)
### Rule (recursive make): build a dependent library (am, klib, ...)
$(LIBS): %:
#$(MAKE) -s -C $(AM_HOME)/$* archive
### Rule (link): objects (`*.o`) and libraries (`*.a`) -> `IMAGE.elf`, the final ELF binary to be packed into image (ld)
$(IMAGE).elf: $(OBJS) am $(LIBS)
#echo + LD "->" $(IMAGE_REL).elf
#$(LD) $(LDFLAGS) -o $(IMAGE).elf --start-group $(LINKAGE) --end-group
### Rule (archive): objects (`*.o`) -> `ARCHIVE.a` (ar)
$(ARCHIVE): $(OBJS)
#echo + AR "->" $(shell realpath $# --relative-to .)
#ar rcs $(ARCHIVE) $(OBJS)
### Rule (`#include` dependencies): paste in `.d` files generated by gcc on `-MMD`
-include $(addprefix $(DST_DIR)/, $(addsuffix .d, $(basename $(SRCS))))
## 6. Miscellaneous
### Build order control
image: image-dep
archive: $(ARCHIVE)
image-dep: $(OBJS) am $(LIBS)
#echo \# Creating image [$(ARCH)]
.PHONY: image image-dep archive run $(LIBS)
### Clean a single project (remove `build/`)
clean:
rm -rf Makefile.html $(WORK_DIR)/build/
.PHONY: clean
### Clean all sub-projects within depth 2 (and ignore errors)
CLEAN_ALL = $(dir $(shell find . -mindepth 2 -name Makefile))
clean-all: $(CLEAN_ALL) clean
$(CLEAN_ALL):
-#$(MAKE) -s -C $# clean
.PHONY: clean-all $(CLEAN_ALL)
#HAS_NAVY = 1
RAMDISK_FILE = build/ramdisk.img
NAME = nanos-lite
SRCS = $(shell find -L ./src/ -name "*.c" -o -name "*.cpp" -o -name "*.S")
include $(AM_HOME)/Makefile
ifeq ($(ARCH),native)
ISA = am_native
else
INC_PATH += include $(NAVY_HOME)/libs/libc/include
endif
./src/resources.S: $(RAMDISK_FILE)
#touch $#
ifeq ($(HAS_NAVY),)
files = $(RAMDISK_FILE) src/files.h src/syscall.h
# create an empty file if it does not exist
$(foreach f,$(files),$(if $(wildcard $f),, $(shell touch $f)))
else
ifeq ($(wildcard $(NAVY_HOME)/libs/libos/src/syscall.h),)
$(error $$NAVY_HOME must be a Navy-apps repo)
endif
update:
$(MAKE) -s -C $(NAVY_HOME) ISA=$(ISA) ramdisk
#ln -sf $(NAVY_HOME)/build/ramdisk.img $(RAMDISK_FILE)
#ln -sf $(NAVY_HOME)/build/ramdisk.h src/files.h
#ln -sf $(NAVY_HOME)/libs/libos/src/syscall.h src/syscall.h
.PHONY: update
endif
I was fully unaware of what was happening.Who can help me,please!!!
Solve the cross compile link error

use option -std=c99 or -std=gnu99 to compile your code

I've the following error:
'for' loop initial declarations are only allowed in C99 mode
use option -std=c99 or -std=gnu99 to compile your code.
How can I add this option to my makefile? This is my makefile: (I think that this option should be in the first lines of the makefile)
NATIVE = $(shell uname --machine)
BOARD ?= $(NATIVE)
V2XATK ?= 0
V2XLLC ?= 1
V2XQTI ?= 0
APP = obu-hmi-cohda
# Versioning
APPVERSION := 2.4.0.RC3 (2021-10-19)
# Comment/uncomment the following line to disable/enable debugging
DEBUG := y
ifeq ($(DEBUG),y)
# "-O" is needed to expand inlines
EXTRA_CFLAGS += -O -ggdb -DDEBUG -DDEBUG_PRINT_TIMES
else
EXTRA_CFLAGS += -O2
endif
#Modificato puntamento a librerie compilate per x86 --> per compilazione x86
STACKDIR := $(realpath /home/duser/mk5/stack)
#STACKDIR := $(realpath /home/duser/x86/stack)
SRCDIR := $(realpath $(CURDIR))
OUTDIR := $(realpath $(CURDIR))/$(BOARD)
#############################################################################
# Import board configuration
#############################################################################
-include $(STACKDIR)/boards/$(BOARD).mk
#############################################################################
# Defaults for security libraries
#############################################################################
ifneq ($(NO_VIICSEC),1)
SEC_V2XLIBS := libviicsec.so libviicsec.so.1 libaerolinkPKI.so libaerolinkPKI.so.1 \
libmisbehaviorReport.so libmisbehaviorReport.so.1 \
libssl.so libssl.so.1.1 libcrypto.so libcrypto.so.1.1
SEC_LDLIBS := -Wl,--no-as-needed -ldl -lviicsec -lmisbehaviorReport -lssl -lcrypto
ifeq ($(NO_LIBC2X),0)
SEC_V2XLIBS += libc2x.so libc2x.so.1 libc2x.so.1.0 libc2x-compat.so libc2x-compat.so.1 \
libNxDispatcher.so libNxDispatcher.so.1.9 libNxDispatcher.so.1.9.3
SEC_LDLIBS += -lc2x -lNxDispatcher
endif
ifeq ($(NO_LIBV2XCRYPTO),0)
SEC_V2XLIBS += libv2xCrypto.so libv2xCrypto.so.2.7 libv2xCrypto.so.2.7.1 \
libv2xCryptoPal.so libv2xCryptoPal.so.2.7 libv2xCryptoPal.so.2.7.1 \
libNxDispatcher.so libNxDispatcher.so.1.9 libNxDispatcher.so.1.9.3
SEC_LDLIBS += -lv2xCrypto -lv2xCryptoPal -lNxDispatcher
endif
ifeq ($(NO_AEROLINK_SCMS),0)
SEC_V2XLIBS += libaerolinkSCMS.so
SEC_LDLIBS += -laerolinkSCMS
endif
else
SEC_V2XLIBS :=
SEC_LDLIBS :=
endif
#############################################################################
# BOARD specific setup
# - Folder locations, CROSSCOMPILE, CCOPTS, INSTALLDIR etc.
#############################################################################
# Allow ccache to be disabled for static analysis
CCACHE ?= ccache
ifneq (,$(findstring $(BOARD),mk5 flowradar bach pateo ubxp3))
# MK5 etc.
ARCH := arm
CROSS_COMPILE ?= "$(CCACHE) arm-linux-gnueabihf-"
INSTALLDIR ?= $(STACKDIR)/../bsp/image/rootfs
SEC_V2XLIBS := libviicsec.so libviicsec.so.1 libaerolinkPKI.so libaerolinkPKI.so.1 \
libmisbehaviorReport.so libmisbehaviorReport.so.1 \
libaerolinkSCMS.so libssl.so libssl.so.1.1 libcrypto.so libcrypto.so.1.1 \
libc2x.so libc2x.so.1 libc2x.so.1.0 \
libNxDispatcher.so libNxDispatcher.so.1.9 libNxDispatcher.so.1.9.3
SEC_LDLIBS := -lviicsec -laerolinkSCMS -lssl -lcrypto -lc2x -Wl,--no-as-needed -lNxDispatcher -ldl
else ifneq (,$(findstring $(BOARD),re2l))
ARCH := arm
CROSS_COMPILE ?= ccache arm-poky-linux-gnueabi-
INSTALLDIR ?=
INSTALLDIR ?= $(STACKDIR)/../bsp/image/rootfs
#SDKDIR ?= $(CURDIR)/../../../bsp/atk/craton2-sdk # TODO
CCOPTS += -mfloat-abi=hard -mfpu=neon --sysroot=/opt/imx-v2x/4.1.15-2.1.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi
#CFLAGS += -I$(SDKDIR)/include
CFLAGS += -I/opt/imx-v2x/4.1.15-2.1.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi/usr/include
#LDFLAGS += -L$(SDKDIR)/sdk/local_linux_u/lib/ --sysroot=/opt/poky-craton2/2.2.1/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi
SEC_V2XLIBS := libviicsec.so libviicsec.so.1 libaerolinkPKI.so libaerolinkPKI.so.1 \
libmisbehaviorReport.so libmisbehaviorReport.so.1 \
libaerolinkSCMS.so libssl.so libssl.so.1.1 libcrypto.so libcrypto.so.1.1 \
libc2x.so libc2x.so.1 libc2x.so.1.0 \
libNxDispatcher.so libNxDispatcher.so.1.9 libNxDispatcher.so.1.9.3
SEC_LDLIBS := -lviicsec -laerolinkSCMS -lssl -lcrypto -lc2x -Wl,--no-as-needed -lNxDispatcher -ldl
#/opt/imx-v2x/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc
# SEC_V2XLIBS ?= libviicsec.so libviicsec.so.1 libaerolinkPKI.so libaerolinkPKI.so.1
# SEC_LDLIBS ?= -lviicsec -laerolinkPKI
else ifneq (,$(findstring $(BOARD),mq5))
ARCH := arm
QNX_BASE ?= /opt/qnx660
CROSS_COMPILE := "$(CCACHE) arm-unknown-nto-qnx6.6.0eabi-"
INSTALLDIR ?=
CPPFLAGS += -DNO_SYSINFO
CFLAGS += -fpic
SEC_V2XLIBS :=
SEC_LDLIBS :=
V2XATK := 0
V2XLLC := 1
else ifneq (,$(findstring $(BOARD),craton2))
ARCH := arm
CROSS_COMPILE ?= "$(CCACHE) arm-poky-linux-gnueabi-"
INSTALLDIR ?=
SDKDIR ?= $(CURDIR)/../../../bsp/atk/craton2-sdk
CCOPTS += -mfloat-abi=hard -mthumb -mfpu=neon --sysroot=/opt/poky-craton2/2.2.1/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi
CFLAGS += -I$(SDKDIR)/include
LDFLAGS += -L$(SDKDIR)/sdk/local_linux_u/lib/ --sysroot=/opt/poky-craton2/2.2.1/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi
# SEC_V2XLIBS := libviicsec.so libviicsec.so.1 libaerolinkPKI.so libaerolinkPKI.so.1
# SEC_LDLIBS := -lviicsec -laerolinkPKI
V2XATK := 1
V2XLLC := 0
else ifneq (,$(findstring $(BOARD),dg2))
ifeq (,$(findstring atks,$(CC)))
$(error Setup the cross compilation environment first: 'source /mnt/atks/atks_yocto_sdk/atks_env_setup.sh')
endif
ARCH := arm
CROSS_COMPILE ?= "$(CCACHE) arm-poky-linux-gnueabi-"
INSTALLDIR ?=
SDKDIR ?= $(CURDIR)/../../../bsp/atk/craton2-sdk
CCOPTS += -mfloat-abi=hard -mthumb -mfpu=neon
CPPFLAGS += -DNO_VIICSEC
CFLAGS += -I$(SDKDIR)/include
LDFLAGS += -L$(SDKDIR)/sdk/local_linux_u/lib/
SEC_V2XLIBS := libviicsec.so libviicsec.so.1 \
libaerolinkSCMS.so libssl.so libssl.so.1.1 libcrypto.so libcrypto.so.1.1 libaerolinkPKI.so libaerolinkPKI.so.1
SEC_LDLIBS := -lviicsec \
-laerolinkSCMS -lssl -lcrypto
V2XATK := 1
V2XLLC := 0
else ifneq (,$(findstring $(BOARD),qti))
ARCH := arm64
CROSS_COMPILE ?= "$(CCACHE) aarch64-agl-linux-"
INSTALLDIR ?=
SDKTARGETSYSROOT ?= /opt/poky-agl/3.0.0+snapshot/sysroots/aarch64-agl-linux
CCOPTS += -fPIC --sysroot=$(SDKTARGETSYSROOT)
CPPFLAGS += -DNO_VIICSEC
CFLAGS += -I$(SDKTARGETSYSROOT)/usr/include
LDFLAGS += --sysroot=$(SDKTARGETSYSROOT)
SEC_V2XLIBS :=
SEC_LDLIBS :=
V2XLLC := 0
V2XQTI := 1
CFLAGS += -I$(CURDIR)/../../../bsp/QTI/include
else ifneq (,$(findstring $(BOARD),mk6c))
ARCH := arm64
CROSS_COMPILE ?= "$(CCACHE) aarch64-linux-gnu-"
INSTALLDIR ?= $(STACKDIR)/../bsp/image/rootfs
CCOPTS += -fPIC
CPPFLAGS +=
SEC_V2XLIBS := libviicsec.so libviicsec.so.1 libaerolinkPKI.so libaerolinkPKI.so.1 \
libmisbehaviorReport.so libmisbehaviorReport.so.1 \
libaerolinkSCMS.so \
libv2xCrypto.so libv2xCrypto.so.2.6 libv2xCrypto.so.2.6.0 \
libv2xCryptoPal.so libv2xCryptoPal.so.2.6 libv2xCryptoPal.so.2.6.0 \
libNxDispatcher.so libNxDispatcher.so.1.2 libNxDispatcher.so.1.2.0 \
libssl.so libssl.so.1.1 libcrypto.so libcrypto.so.1.1
SEC_LDLIBS := -Wl,--no-as-needed -ldl \
-lviicsec \
-lmisbehaviorReport \
-laerolinkSCMS \
-lv2xCrypto -lv2xCryptoPal \
-lNxDispatcher \
-lssl -lcrypto
V2XLLC := 0
V2XQTI := 1
CFLAGS += -I$(CURDIR)/../../../bsp/QTI/include
else ifneq (,$(findstring $(BOARD),ir800))
ARCH := x86_64
CROSS_COMPILE ?= "$(CCACHE) "
INSTALLDIR ?=
CFLAGS += -Wall -Wextra #-Werror Rimosso gestione warning as error --> per compilazione x86
CPPFLAGS += -DNO_VIICSEC
SEC_V2XLIBS :=
SEC_LDLIBS :=
else ifneq ($(BOARD),$(NATIVE))
# Generic non-x86
ifneq ($(SDKTARGETSYSROOT),)
CCOPTS += -fPIC --sysroot=$(SDKTARGETSYSROOT)
CFLAGS += -I$(SDKTARGETSYSROOT)/usr/include
LDFLAGS += --sysroot=$(SDKTARGETSYSROOT)
endif
else
# Native (PC)
ARCH ?= $(NATIVE)
CROSS_COMPILE ?= "$(CCACHE) "
INSTALLDIR ?=
CFLAGS += -Wall -Wextra #-Werror Rimosso gestione warning as error --> per compilazione x86
SEC_V2XLIBS := libviicsec.so libviicsec.so.1 libaerolinkPKI.so libaerolinkPKI.so.1 \
libmisbehaviorReport.so libmisbehaviorReport.so.1 \
libcrypto.so libcrypto.so.1.1
SEC_LDLIBS := -lviicsec -laerolinkPKI -lmisbehaviorReport
endif
#############################################################################
# File locations
#############################################################################
# Source directories
SRCDIRS := $(SRCDIR)/src
# Add this list to VPATH, the place $(MAKE) will look for the source files
VPATH := $(SRCDIRS)
# Matching output tree
OUTDIRS := $(subst $(SRCDIR),$(OUTDIR),$(SRCDIRS))
# Include folders
INCDIRS := $(SRCDIRS) \
$(OUTDIR)/include \
$(OUTDIR)/include/asn1 \
$(realpath $(STACKDIR)/../cohda/kernel/include) \
$(realpath $(STACKDIR)/../ieee1609/kernel/include) \
$(SRCDIR)/lib/cjson/arm/include
# Aerolink
ifneq (,$(findstring $(BOARD),$(NATIVE) mk5 mk6c jabiru flowradar bach craton2 pateo re2l ubxp3 ctx0800))
AEROLINK_SRCDIR = $(STACKDIR)/v2x-lib/aerolink
AEROLINK_CONFIG = $(OUTDIR)/aerolink/default
AEROLINK_SCRIPT = $(OUTDIR)/aerolink/rc.aerolink
AEROLINK_TOOLS = \
$(OUTDIR)/aerolink/certadm \
$(OUTDIR)/aerolink/crladm \
$(OUTDIR)/aerolink/acfGenerator \
$(OUTDIR)/aerolink/acfBuilder \
$(OUTDIR)/aerolink/acfInfo \
$(OUTDIR)/aerolink/extractSignerTlmFromEctl \
$(OUTDIR)/aerolink/createEtsiInitRequest \
$(OUTDIR)/aerolink/processEtsiInitResponse
endif
# ffasn1c location/options/etc.
FFASN1DIR = $(STACKDIR)/../tools/ffasn1c
FFASN1C = $(FFASN1DIR)/ffasn1c
FFASN1C_OPTS = -fdefine-int-values
FFASN1PY = $(STACKDIR)/tools/ffasn1.py
FFASN1PREFIX = RAW_
FFASN1DEF = $(SRCDIR)/src/RAW.asn1
FFASN1OUT = $(SRCDIR)/src/raw-asn
#############################################################################
# CPPFLAGS, CFLAGS, LDFLAGS, LDLIBS
#############################################################################
# If using yocto/poky toolchain, use CC in environment
ifeq (,$(TARGET_PREFIX))
CC := $(shell echo $(CROSS_COMPILE)gcc)
endif
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr a-z A-Z)
CFLAGS += -fpic -Wall -Wextra #-Werror Rimosso gestione warning as error --> per compilazione x86
LDFLAGS += -L$(OUTDIR) \
-L$(OUTDIR)/lib \
-L$(SRCDIR)/lib/cjson/arm/lib \
-Wl,--disable-new-dtags -Wl,-rpath,./lib
# Generate the include folders' associated CFLAGS entry by adding '-I' before each include folder
CFLAGS += $(foreach DIR, $(INCDIRS), $(addprefix -I, $(DIR)))
ifneq ($(INSTALLDIR),)
CFLAGS += -I$(INSTALLDIR)/usr/include
LDFLAGS += -L$(INSTALLDIR)/usr/lib
endif
ifneq (,$(LIBCFG_LIB_DIR))
LDFLAGS += -L$(LIBCFG_LIB_DIR)/lib/.libs
endif
ifneq (,$(GPSD_LIB_DIR))
LDFLAGS += -L$(GPSD_LIB_DIR)
endif
ifneq (,$(OPENSSL_LIB_DIR))
LDFLAGS += -L$(OPENSSL_LIB_DIR)
endif
ifneq (,$(DISPATCHER_LIB_DIR))
LDFLAGS += -L$(DISPATCHER_LIB_DIR)
endif
ifneq (,$(LIBV2XCRYPTO_LIB_DIR))
LDFLAGS += -L$(LIBV2XCRYPTO_LIB_DIR)
endif
# Plugins
V2XLIBS += libCANUDP.so
#V2XLIBS += libDNPW.so
V2XLIBS += libEEBL.so
#V2XLIBS += libEVW.so
V2XLIBS += libFCW.so
#V2XLIBS += libGLOSA.so
#V2XLIBS += libGMLAN.so
#V2XLIBS += libHLW.so
#V2XLIBS += libICW.so
#V2XLIBS += libIHW.so
#V2XLIBS += libIVS.so
#V2XLIBS += libLCW.so
#V2XLIBS += libLTA.so
V2XLIBS += libRWW.so
#V2XLIBS += libSVA.so
#V2XLIBS += libSVW.so
#V2XLIBS += libTJA.so
# Cohda libraries (platform, network & facilities layer)
V2XLIBS += libhmi.so libtm.so
LDLIBS += -lhmi -ltm
V2XLIBS += libtc.so libta.so libJudy.a
LDLIBS += -ltc -lta -lJudy
V2XLIBS += libspatmap.so
LDLIBS += -lspatmap
V2XLIBS += libivi.so libldm.so
LDLIBS += -livi -lldm
V2XLIBS += libext.so
LDLIBS += -lext
V2XLIBS += libitsfac.so libitsasn.so libitsnet.so
LDLIBS += -litsfac -litsasn -litsnet
ifneq (,$(findstring $(BOARD),ubxp3))
LDLIBS += -lubxp3
V2XLIBS += libubxp3.so
endif
V2XLIBS += libpos.so libubx.so
LDLIBS += -lpos -lubx
ifneq (,$(findstring $(BOARD),ir800))
V2XLIBS += libplatsv.so libclv.so
LDLIBS += -lplatsv -lclv
else
V2XLIBS += libplat.so libclv.so
LDLIBS += -lplat -lclv
endif
V2XLIBS += libtimechange.so
V2XLIBS += libconfig.a
LDLIBS += -lconfig
V2XLIBS += libgps_static.a libpcap.a
LDLIBS += -lgps_static -lpcap
V2XLIBS += $(SEC_V2XLIBS)
LDLIBS += $(SEC_LDLIBS)
ifeq ($(V2XLLC),1)
CPPFLAGS += -DV2XLLC
V2XLIBS += libLLC.so
LDLIBS += -lLLC
endif
ifeq ($(V2XATK),1)
CPPFLAGS += -DV2XATK
V2XLIBS += libatlklocal_linux_u.a
LDLIBS += -latlklocal_linux_u -ltomcrypt -ltommath
endif
ifeq ($(V2XQTI),1)
CPPFLAGS += -DV2XQTI
V2XLIBS += libv2x_radio.so libcv2x-kinematics.so libv2x_veh.so
V2XLIBS += libQTIVData.so
LDLIBS += -lv2x_radio -lcv2x-kinematics -lv2x_veh
endif
ifeq ($(BOARD),mq5)
LDLIBS += -lsocket -lmq -lc -lm
else
LDLIBS += -lpthread -lrt -ldl -lstdc++ -lm
endif
LDLIBS += -l:libcjson.a
# v2x-libs are installed locally in $(OUTDIR)/lib
V2XLIBS := $(addprefix $(OUTDIR)/lib/, $(V2XLIBS))
#############################################################################
# SRCS, OBJS, DEPS, LIBS etc.
#############################################################################
# Create a list of *.c sources in SRCDIRS
SRCS = $(foreach DIR,$(SRCDIRS),$(wildcard $(DIR)/*.c))
# Define objects for all sources
OBJS = $(subst $(SRCDIR),$(OUTDIR),$(SRCS:.c=.o))
# Define dependency files for all objects
DEPS = $(OBJS:.o=.d)
#############################################################################
# Rule generation function
#############################################################################
define GenerateRules
$(1)/%.o: %.c $(1)/%.d
#mkdir -p $$(#D) # Create the required OUTDIR.. folder
## Generate dependency information as a side-effect of compilation, not instead of compilation.
## -MMD omits system headers from the generated dependencies: if you prefer to preserve system headers as prerequisites, use -MD.
$$(CC) \
-MT $$# -MMD -MP -MF $(1)/$$*.Td \
$$(CCOPTS) $$(CPPFLAGS) $$(CFLAGS) $$(EXTRA_CFLAGS) -c $$< -o $$#
## First rename the generated temporary dependency file to the real dependency file.
## We do this in a separate step so that failures during the compilation won’t leave a corrupted dependency file.
mv -f $(1)/$$*.Td $(1)/$$*.d
## Second touch the object file; it’s been reported that some versions of GCC may leave the object file older than the dependency file, which causes unnecessary rebuilds.
touch $$#
# Create a pattern rule with an empty recipe, so that make won’t fail if the dependency file doesn’t yet exist.
$(1)/%.d: ;
# Mark the dependency files precious to make, so they won’t be automatically deleted as intermediate files.
.PRECIOUS: $(1)/%.d
$(1)/%.gpp: %.c src-gen $(OUTDIR)/include
#mkdir -p $$(#D) # Create the required OUTDIR.. folder
$$(CC) -dD -E $$(CCOPTS) $$(CPPFLAGS) $$(CFLAGS) $$(EXTRA_CFLAGS) -c $$< -o $$#
$(1)/%.lst: %.c src-gen $(OUTDIR)/include
#mkdir -p $$(#D) # Create the required OUTDIR.. folder
$$(CC) -S $$(CCOPTS) $$(CPPFLAGS) $$(CFLAGS) $$(EXTRA_CFLAGS) -c $$< -o $$#
$(1)/%.lint: %.c src-gen $(OUTDIR)/include
#mkdir -p $$(#D) # Create the required OUTDIR.. folder
-splint -shiftimplementation -warnposix -badflag --likelybool $$(CPPFLAGS) $$(CFLAGS) $$< | tee $$#
endef
#############################################################################
# Rules
#############################################################################
all:
env BOARD=$(BOARD) $(MAKE) app
# Generate rules
$(foreach DIR, $(OUTDIRS), $(eval $(call GenerateRules, $(DIR))))
# Include dependencies
-include $(DEPS)
src-gen: asn-gen ## Create all generated code
.PHONY: src-gen
app: version src-gen $(OUTDIR) ## Build $(APP) binary (Append BOARD=? to specify a non-host target)
$(MAKE) $(OUTDIR)/$(APP) aerolink
cpp: $(DEPS:.d=.gpp) ## Preprocess all $(APP) sources (Append BOARD=? to specify a non-host target)
lst: $(DEPS:.d=.lst) ## Generate assembler listings for all $(APP) sources (Append BOARD=? to specify a non-host target)
lint: $(DEPS:.d=.lint) ## Generate assembler listings for all $(APP) sources (Append BOARD=? to specify a non-host target)
.PHONY: all app cpp list lint
# Aerolink rule/targets
aerolink: $(V2XLIBS) $(AEROLINK_SCRIPT) $(AEROLINK_TOOLS) $(AEROLINK_CONFIG)
$(AEROLINK_CONFIG) : $(AEROLINK_SRCDIR)/config
#mkdir -p $#
#rsync -q -av --exclude="*.svn" $</* $#
$(AEROLINK_SCRIPT) : $(OUTDIR)/aerolink/% : $(AEROLINK_SRCDIR)/%
#mkdir -p $(dir $#)
#cp $< $#
$(AEROLINK_TOOLS) : $(OUTDIR)/aerolink/% : $(AEROLINK_SRCDIR)/$(BOARD)/%
#mkdir -p $(dir $#)
#cp $< $#
.PHONY: aerolink
# ffasn1c rules
$(FFASN1DEF):
#ls $(FFASN1DEF) # Nothing to do
$(FFASN1OUT).c: $(OUTDIR) $(FFASN1DEF)
-$(MAKE) --directory $(FFASN1DIR)
$(FFASN1C) $(FFASN1C_OPTS) -fprefix=$(FFASN1PREFIX) -o $(FFASN1OUT).junk $(FFASN1DEF)
$(FFASN1PY) -fprefix=$(FFASN1PREFIX) $(FFASN1OUT).junk $(FFASN1DEF)
# Since we're linking against itsasn, we don't need to create a link to (and complile) the asn.1 codec files
##mkdir -p $(SRCDIR)/src/libffasn1
#ln -sf $(FFASN1DIR)/src/libffasn1/*.[ch] $(SRCDIR)/libffasn1
asn-gen: $(FFASN1OUT).c ## Create all ASN.1 generated code
.PHONY: asn-gen
# v2x-lib targets
$(STACKDIR)/v2x-lib/include $(STACKDIR)/v2x-lib/lib/$(BOARD):
# Build the v2x-libs via the $(STACKDIR)'s makefile
if [ -e $(STACKDIR)/Makefile ]; then \
$(MAKE) -C $(STACKDIR) BOARD=$(BOARD) lib-package; \
fi;
$(subst $(OUTDIR)/lib,$(STACKDIR)/v2x-lib/lib/$(BOARD),$(V2XLIBS)): $(STACKDIR)/v2x-lib/lib/$(BOARD)
$(OUTDIR)/include: $(STACKDIR)/v2x-lib/include $(OUTDIR)
#mkdir -p $#
#cp -ar $</* $#/
$(V2XLIBS): $(OUTDIR)/lib/%: $(STACKDIR)/v2x-lib/lib/$(BOARD)/% $(OUTDIR)
#mkdir -p $(dir $#)
## The referenced lib*.so library may not exist due to licensing constraints
#if [ -e $< ]; then \
cp -a $< $# ;\
fi;
# Build the application
$(OUTDIR)/$(APP): $(OUTDIR)/include $(V2XLIBS) $(OBJS) $(LIBS)
ifeq ($(BOARD),mq5)
# The QNX linker assumes the presence of '-fpic' means we want a shared library rather than an executable
$(CC) $(filter-out -fpic,$(CCOPTS) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) $(LDLIBS)) -o $#
else
$(CC) $(CCOPTS) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) $(LDLIBS) -o $#
endif
$(OUTDIR): # Create a per-target $(OUTDIR)
#mkdir -p $(OUTDIR)
#ln -sf $(SRCDIR)/* $(OUTDIR)/ # Link the contents of $(SRCDIR) en-mass to $(OUTDIR)
#rm -f $(OUTDIR)/$(BOARD) # No circular references allowed
#rm -f $(OUTDIR)/Makefile # A makefile in $(OUTDIR) is just confusing
#rm -f $(OUTDIR)/src && mkdir -p $(OUTDIR)/src # Remove the link to src/ and make our own (for build artefacts)
version: $(OUTDIR)
touch $(OUTDIR)/$#
echo '$(APPVERSION)' > $(OUTDIR)/$#
.PHONY: version
DESTDIR:=$(shell mktemp -d)
# Note the lack of folder prefixes below. TOSHIP files are sourced from $(CURDIR) *and* $(BOARD)
TOSHIP = $(APP) \
rc.$(APP) \
board.conf \
obu.cfg obu.conf \
rsu.cfg rsu.conf \
ui \
lib \
aerolink \
post_install \
version
board.conf:
rm -rf board.conf && ln -s $(BOARD).conf board.conf
tarball: app board.conf ## Create a $(APP) tarball. Use `BOARD`-tarball to generate for other targets (e.g. mk5-tarball)
#rm -f $(APP)-$(BOARD)-*.tgz
#rm -rf $(DESTDIR)
#mkdir -p $(DESTDIR)/$(APP)
#cd $(CURDIR) && rsync -avRL \
--exclude="*src*" --exclude="lib*.a" --ignore-missing-args \
$(TOSHIP) $(DESTDIR)/$(APP) 2>/dev/null || true
#cd $(OUTDIR) && rsync -avRL \
--exclude="*src*" --exclude="lib*.a" --ignore-missing-args \
$(TOSHIP) $(DESTDIR)/$(APP) 2>/dev/null || true
#sudo chown -R root:root $(DESTDIR)
#tar -C $(DESTDIR) \
--exclude-vcs -czf $(CURDIR)/build/$(APP)-$(BOARD)-Exported.tgz ./
#sudo chown $(USER):$(USER) $(CURDIR)/build/$(APP)-$(BOARD)-Exported.tgz
#sudo rm -rf $(DESTDIR)
#echo "== tarball =="
#du -h $(realpath $(CURDIR))/build/$(APP)-$(BOARD)-Exported.tgz
#echo "== installer =="
#base64 $(CURDIR)/build/$(APP)-$(BOARD)-Exported.tgz | cat installer_header.sh - > $(CURDIR)/build/$(APP)-$(BOARD)-installer.sh
#chmod +x $(CURDIR)/build/$(APP)-$(BOARD)-installer.sh
%-tarball:
env BOARD=$* $(MAKE) tarball
.PHONY: tarball,%-tarball
install: $(BOARD)-tarball ## Install $(NATIVE) $(APP) to $(INSTALLDIR)/opt/cohda/application
sudo install -d $(INSTALLDIR)/opt/cohda/application
ifneq (,$(findstring $(BOARD),mq5))
# QNX's buildfile doesn't seem to support globbing so temporarily remove the version number when installing
#mv -f $(CURDIR)/$(APP)-$(BOARD)-Exported.tgz $(CURDIR)/$(APP)-$(BOARD).tgz
sudo install -c $(CURDIR)/$(APP)-$(BOARD).tgz $(INSTALLDIR)/opt/cohda/application
#mv -f $(CURDIR)/$(APP)-$(BOARD).tgz $(CURDIR)/$(APP)-$(BOARD)-Exported.tgz
else
sudo install -c $(CURDIR)/$(APP)-$(BOARD)-Exported.tgz $(INSTALLDIR)/opt/cohda/application
endif
.PHONY: install
# Note the 'clean's
# Use 'clean' to remove locally compiled objects (and associated executables & files)
# Use 'v2xclean' to remove the 'v2x-lib' artefacts too
v2xclean: clean
#if [ -d "$(STACKDIR)/src" ]; then \
echo "Cleaning v2x-lib" ; \
rm -rf $(STACKDIR)/v2x-lib/include ; \
rm -rf $(STACKDIR)/v2x-lib/lib/$(BOARD) ; \
fi
clean: ## Clean up. Use `BOARD`-clean to specify the target (e.g. mk5-clean)
## Generated source(s)
rm -f $(FFASN1OUT)*
## Build tree
sudo rm -rf $(OUTDIR)
## Deployment files & folders
rm -f $(APP)-$(BOARD)-*.tgz
%-clean:
env BOARD=$* $(MAKE) clean
.PHONY: clean,%-clean
help:
#echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
.PHONY: help
#############################################################################
# $(BOARD) specific rules
#############################################################################
$(NATIVE):
env BOARD=$# $(MAKE) app
mk5:
env BOARD=$# $(MAKE) app
mk6c:
env BOARD=$# $(MAKE) app
mq5:
env BOARD=$# $(MAKE) app
.PHONY: $(NATIVE)
.PHONY: mk5
.PHONY: mk6c
.PHONY: mq5
You have a line:
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr a-z A-Z)
You can add it to the end of this line so it reads:
CFLAGS += -DBOARD_$(shell echo $(BOARD) | tr a-z A-Z) -std=c99

dyld: Library not loaded when Linked in makefile

Hi I know there is some other posts with the same title, but they are not in the same context. So: I have a library named mlx and the library file is named libmlx.dylib: when I try to compile it with a simple main using gcc main.c libmlx.dylib it compiles well and the lib is working, but when I try to compile it with my project using my makefile the compilation doesn't throw any error but when I launch the program I get this error message:
dyld: Library not loaded: libmlx.dylib
Referenced from: /Users/leo/Documents/42-cursus/so_long/./so_long
Reason: image not found
[1] 8313 abort ./so_long
Here is my makefile:
SHELL = /bin/sh
NAME = so_long
.SUFFIXES = .c .o .h .dylib
SRCDIR = src
INCDIR = inc
LIBDIR = lib
OBJDIR = .obj
SRC = $(addsuffix $(word 1, $(.SUFFIXES)),\
$(addprefix exception/,\
exception\
bad_alloc\
invalid_arguments\
invalid_map\
runtime_error)\
$(addprefix parsing/,\
get_map)\
$(addprefix rendering/,\
render_map)\
$(addprefix utils/,\
init_image\
make_color)\
$(addprefix cleaning/,\
mlx_clear)\
$(addprefix get_next_line/,\
get_next_line\
get_next_line_utils)\
main)
INC = $(addsuffix $(word 3, $(.SUFFIXES)),\
get_next_line\
mlx\
exception\
so_long)
LIB = mlx\
ft
OBJ = $(SRC:$(word 1, $(.SUFFIXES))=$(word 2, $(.SUFFIXES)))
CC = gcc
CFLAGS = -Wall -Wextra -Werror -I $(INCDIR)
LCFLAGS = $(addprefix -L, $(LIBDIR)) $(addprefix -l, $(lib))
#### COLORS ####
KNRM = \x1B[0m
KRED = \x1B[31m
KGRN = \x1B[32m
KYEL = \x1B[33m
KBLU = \x1B[34m
KMAG = \x1B[35m
KCYN = \x1B[36m
KWHT = \x1B[37m
######################
all: $(OBJDIR) $(NAME)
#printf "$(KGRN)\`$(NAME)\` is up to date.\n$(KNRM)"
$(OBJDIR):
#printf "$(KYEL)➤ "
mkdir -p $#/exception $#/parsing $#/rendering $#/utils $#/cleaning $#/get_next_line
#printf "$(KNRM)"
$(NAME): $(addprefix $(OBJDIR)/, $(OBJ))
#printf "$(KCYN)[ Linking ]\n➤ "
$(CC) $(CFLAGS) $^ -o $# $(LCFLAGS)
#printf "$(KNRM)"
$(OBJDIR)/%$(word 2, $(.SUFFIXES)): $(SRCDIR)/%$(word 1, $(.SUFFIXES)) $(addprefix $(INCDIR)/, $(INC))
#printf "$(KMAG)[ Compiling ]\n➤ "
$(CC) $(CFLAGS) -c $< -o $#
#printf "$(KNRM)"
clean:
#printf "$(KRED)➤ "
rm -rf $(OBJDIR)
#printf "$(KNRM)"
fclean: clean
#printf "$(KRED)➤ "
rm -f $(NAME)
#printf "$(KNRM)"
re: fclean all
I'm linking it with the flags -L $(LIBDIR) -lmlx. What did I do wrong ?
I found that for dynamic libraries you need to have the .dylib in the same directory as your target, I let the post in case some people face the same problem.

Is there any way to link a existed object file in Makefile when compiling?

I want to use the object files already compiled and only link it in Makefile without compiling again.
Then I can put .o file in source folder not .c file.
Is that possible? Thanks in advance!!
I have tried below, but it is not working.
How to create reference to an .o file in Makefile
Actually, I still not sure how it works on my case.
More specific:
Please see my makefile:
obj-$(CONFIG_SH_MMCIF) += sh_mmcif.o
obj-$(CONFIG_SH_SDHI) += sh_sdhi.o
obj-$(CONFIG_STM32_SDMMC2) += stm32_sdmmc2.o
obj-$(CONFIG_MMC_NDS32) += nds32_mmc.o
PREBUILT_O = mysource.o
obj-$(CONFIG_xxx) += $(PREBUILT_O)
obj-$(CONFIG_MMC_MXC) += mxcmmc.o
obj-$(CONFIG_MMC_MXS) += mxsmmc.o
By the way, I can not find "TARGET" in Makefile.
$(TARGET): $(OBJECTS) $(PREBUILT_O)
$(CC) $(OBJECTS) $(PREBUILT_O) $(LIBS) -o $#
I have no idea how "obj-$() += " works for the final TARGET.
It is hard to find the TARGET in the Makefile of upper folder either.
So here are my steps:
Set obj-$(CONFIG_xxx) += mysource.o in Makefile
Compile it, it will generate .o file under out/
Get mysource.o from out/
Remove mysource.c
Modify Makefile => link mysource.o to obj-$(CONFIG_xxx) without compiling
Compile it
=>The compiling error is occurred.
Undefined reference function is still there if other .c file use this obj file.
It seems the compiler still compile mysource.o.
How to link mysource.o to obj-$(CONFIG_xxx) without compile again?
By the way, mysource.c and Makefile is under uboot_xxx/drivers/usb/gadget/
Below is part of Makefile under uboot_xxx/
ifeq ($(KBUILD_SRC),)
# building in the source tree
srctree := .
else
ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
# building in a subdirectory of the source tree
srctree := ..
else
srctree := $(KBUILD_SRC)
endif
endif
objtree := .
src := $(srctree)
obj := $(objtree)
VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
export srctree objtree VPATH
############################################
# set default to nothing for native builds
ifeq ($(HOSTARCH),$(ARCH))
CROSS_COMPILE ?=
endif
KCONFIG_CONFIG ?= .config
export KCONFIG_CONFIG
# SHELL used by kbuild
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
HOSTCC = cc
HOSTCXX = c++
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \
$(if $(CONFIG_TOOLS_DEBUG),-g)
HOSTCXXFLAGS = -O2
ifeq ($(HOSTOS),cygwin)
HOSTCFLAGS += -ansi
endif
# ======================================================================
# Build targets only - this includes vmlinux, arch specific targets, clean
# targets and others. In general all targets except *config targets.
# Additional helpers built in scripts/
# Carefully list dependencies so we do not try to build scripts twice
# in parallel
PHONY += scripts
scripts: scripts_basic include/config/auto.conf
$(Q)$(MAKE) $(build)=$(#)
# Read in dependencies to all Kconfig* files, make sure to run
# oldconfig if changes are detected.
-include include/config/auto.conf.cmd
u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg: include/config.h FORCE
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf $(#)
-include include/autoconf.mk
-include include/autoconf.mk.dep
# If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use
# that (or fail if absent). Otherwise, search for a linker script in a
# standard location.
ifndef LDSCRIPT
#LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds.debug
ifdef CONFIG_SYS_LDSCRIPT
# need to strip off double quotes
LDSCRIPT := $(srctree)/$(CONFIG_SYS_LDSCRIPT:"%"=%)
endif
endif
# If there is no specified link script, we look in a number of places for it
ifndef LDSCRIPT
ifeq ($(wildcard $(LDSCRIPT)),)
LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds
endif
ifeq ($(wildcard $(LDSCRIPT)),)
LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot.lds
endif
ifeq ($(wildcard $(LDSCRIPT)),)
LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot.lds
endif
endif
else
# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
KBUILD_CPPFLAGS += $(KCPPFLAGS)
KBUILD_AFLAGS += $(KAFLAGS)
KBUILD_CFLAGS += $(KCFLAGS)
# Use UBOOTINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
UBOOTINCLUDE := \
-Iinclude \
$(if $(KBUILD_SRC), -I$(srctree)/include) \
$(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
$(if $(CONFIG_HAS_THUMB2),, \
-I$(srctree)/arch/$(ARCH)/thumb1/include),) \
-I$(srctree)/arch/$(ARCH)/include \
-include $(srctree)/include/linux/kconfig.h
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CHECKFLAGS += $(NOSTDINC_FLAGS)
# FIX ME
cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
$(NOSTDINC_FLAGS)
c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
#########################################################################
# U-Boot objects....order is important (i.e. start must be first)
HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
libs-y += lib/
libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
libs-$(CONFIG_OF_EMBED) += dts/
libs-y += fs/
libs-y += net/
libs-y += disk/
libs-y += drivers/
libs-y += drivers/dma/
libs-y += drivers/gpio/
libs-y += drivers/i2c/
libs-y += drivers/mtd/
libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
libs-y += drivers/mtd/onenand/
libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
libs-y += drivers/mtd/spi/
libs-y += drivers/net/
libs-y += drivers/net/phy/
libs-y += drivers/pci/
libs-y += drivers/power/ \
drivers/power/domain/ \
drivers/power/fuel_gauge/ \
drivers/power/mfd/ \
drivers/power/pmic/ \
drivers/power/battery/ \
drivers/power/regulator/
libs-y += drivers/spi/
libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/
libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
libs-$(CONFIG_SYS_FSL_MMDC) += drivers/ddr/fsl/
libs-$(CONFIG_ALTERA_SDRAM) += drivers/ddr/altera/
libs-y += drivers/serial/
libs-y += drivers/usb/cdns3/
libs-y += drivers/usb/dwc3/
libs-y += drivers/usb/common/
libs-y += drivers/usb/emul/
libs-y += drivers/usb/eth/
libs-y += drivers/usb/gadget/
libs-y += drivers/usb/gadget/udc/
libs-y += drivers/usb/host/
libs-y += drivers/usb/musb/
libs-y += drivers/usb/musb-new/
libs-y += drivers/usb/phy/
libs-y += drivers/usb/ulpi/
libs-y += cmd/
libs-y += common/
libs-y += env/
libs-$(CONFIG_API) += api/
libs-$(CONFIG_HAS_POST) += post/
libs-y += test/
libs-y += test/dm/
libs-$(CONFIG_UT_ENV) += test/env/
libs-$(CONFIG_UT_OVERLAY) += test/overlay/
libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
libs-y := $(sort $(libs-y))
u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples
u-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-))))
libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
u-boot-init := $(head-y)
u-boot-main := $(libs-y)
# Add GCC lib
ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
else
PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc
endif
PLATFORM_LIBS += $(PLATFORM_LIBGCC)
export PLATFORM_LIBS
export PLATFORM_LIBGCC
# Special flags for CPP when processing the linker script.
# Pass the version down so we can handle backwards compatibility
# on the fly.
LDPPFLAGS += \
-include $(srctree)/include/u-boot/u-boot.lds.h \
-DCPUDIR=$(CPUDIR) \
$(shell $(LD) --version | \
sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(#F)) -d $< $# \
$(if $(KBUILD_VERBOSE:1=), >$(MKIMAGEOUTPUT))
quiet_cmd_mkfitimage = MKIMAGE $#
cmd_mkfitimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(#F)) -f $(U_BOOT_ITS) -E $# \
$(if $(KBUILD_VERBOSE:1=), >$(MKIMAGEOUTPUT))
quiet_cmd_cat = CAT $#
cmd_cat = cat $(filter-out $(PHONY), $^) > $#
append = cat $(filter-out $< $(PHONY), $^) >> $#
quiet_cmd_pad_cat = CAT $#
cmd_pad_cat = $(cmd_objcopy) && $(append) || rm -f $#
cfg: u-boot.cfg
quiet_cmd_cfgcheck = CFGCHK $2
cmd_cfgcheck = $(srctree)/scripts/check-config.sh $2 \
$(srctree)/scripts/config_whitelist.txt $(srctree)
PHONY += dtbs
dtbs: dts/dt.dtb
#:
dts/dt.dtb: u-boot
$(Q)$(MAKE) $(build)=dts dtbs
quiet_cmd_copy = COPY $#
cmd_copy = cp $< $#
ifeq ($(CONFIG_MULTI_DTB_FIT),y)
fit-dtb.blob: dts/dt.dtb FORCE
$(call if_changed,mkimage)
MKIMAGEFLAGS_fit-dtb.blob = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
-a 0 -e 0 -E \
$(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) -d /dev/null
u-boot-fit-dtb.bin: u-boot-nodtb.bin fit-dtb.blob
$(call if_changed,cat)
u-boot.bin: u-boot-fit-dtb.bin FORCE
$(call if_changed,copy)
else ifeq ($(CONFIG_OF_SEPARATE),y)
u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
$(call if_changed,cat)
u-boot.bin: u-boot-dtb.bin FORCE
$(call if_changed,copy)
else
u-boot.bin: u-boot-nodtb.bin FORCE
$(call if_changed,copy)
endif
%.imx: %.bin
$(Q)$(MAKE) $(build)=arch/arm/mach-imx $#
%.vyb: %.imx
$(Q)$(MAKE) $(build)=arch/arm/cpu/armv7/vf610 $#
quiet_cmd_copy = COPY $#
cmd_copy = cp $< $#
u-boot.dtb: dts/dt.dtb
$(call cmd,copy)
OBJCOPYFLAGS_u-boot.hex := -O ihex
OBJCOPYFLAGS_u-boot.srec := -O srec
u-boot.hex u-boot.srec: u-boot FORCE
$(call if_changed,objcopy)
OBJCOPYFLAGS_u-boot-elf.srec := $(OBJCOPYFLAGS_u-boot.srec)
u-boot-elf.srec: u-boot.elf FORCE
$(call if_changed,objcopy)
OBJCOPYFLAGS_u-boot-spl.srec = $(OBJCOPYFLAGS_u-boot.srec)
spl/u-boot-spl.srec: spl/u-boot-spl FORCE
$(call if_changed,objcopy)
OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \
$(if $(CONFIG_X86_16BIT_INIT),-R .start16 -R .resetvec)
u-boot-nodtb.bin: u-boot FORCE
$(call if_changed,objcopy)
$(call DO_STATIC_RELA,$<,$#,$(CONFIG_SYS_TEXT_BASE))
$(BOARD_SIZE_CHECK)
u-boot.ldr: u-boot
$(CREATE_LDR_ENV)
$(LDR) -T $(CONFIG_CPU) -c $# $< $(LDR_FLAGS)
$(BOARD_SIZE_CHECK)
# binman
# ---------------------------------------------------------------------
quiet_cmd_binman = BINMAN $#
cmd_binman = $(srctree)/tools/binman/binman -d u-boot.dtb -O . \
-I . -I $(srctree)/board/$(BOARDDIR) $<
OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex
OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE
$(call if_changed,objcopy)
#
# U-Boot entry point, needed for booting of full-blown U-Boot
# from the SPL U-Boot version.
#
ifndef CONFIG_SYS_UBOOT_START
CONFIG_SYS_UBOOT_START := 0
endif
# Create a file containing the configuration options the image was built with
quiet_cmd_cpp_cfg = CFG $#
cmd_cpp_cfg = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
-DDO_DEPS_ONLY -D__ASSEMBLY__ -x assembler-with-cpp -P -dM -E -o $# $<
MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)
MKIMAGEFLAGS_u-boot.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
-T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE)
MKIMAGEFLAGS_u-boot-spl.kwb = -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) \
-T kwbimage -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) \
$(if $(KEYDIR),-k $(KEYDIR))
MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
-R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage
u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \
$(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin dts/dt.dtb,u-boot.bin) FORCE
$(call if_changed,mkimage)
u-boot.itb: u-boot-nodtb.bin dts/dt.dtb $(U_BOOT_ITS) FORCE
$(call if_changed,mkfitimage)
$(BOARD_SIZE_CHECK)
u-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
u-boot.sha1: u-boot.bin
tools/ubsha1 u-boot.bin
u-boot.dis: u-boot
$(OBJDUMP) -d $< > $#
ifdef CONFIG_TPL
SPL_PAYLOAD := tpl/u-boot-with-tpl.bin
else
SPL_PAYLOAD := u-boot.bin
endif
OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \
--pad-to=$(CONFIG_SPL_PAD_TO)
u-boot-with-spl.bin: spl/u-boot-spl.bin $(SPL_PAYLOAD) FORCE
$(call if_changed,pad_cat)
MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE)
lpc32xx-spl.img: spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
OBJCOPYFLAGS_lpc32xx-boot-0.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
lpc32xx-boot-0.bin: lpc32xx-spl.img FORCE
$(call if_changed,objcopy)
OBJCOPYFLAGS_lpc32xx-boot-1.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
lpc32xx-boot-1.bin: lpc32xx-spl.img FORCE
$(call if_changed,objcopy)
lpc32xx-full.bin: lpc32xx-boot-0.bin lpc32xx-boot-1.bin u-boot.img FORCE
$(call if_changed,cat)
CLEAN_FILES += lpc32xx-*
OBJCOPYFLAGS_u-boot-with-tpl.bin = -I binary -O binary \
--pad-to=$(CONFIG_TPL_PAD_TO)
tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin FORCE
$(call if_changed,pad_cat)
SPL: spl/u-boot-spl.bin FORCE
$(Q)$(MAKE) $(build)=arch/arm/mach-imx $#
u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL u-boot.bin FORCE
$(Q)$(MAKE) $(build)=arch/arm/mach-imx $#
MKIMAGEFLAGS_u-boot.ubl = -n $(UBL_CONFIG) -T ublimage -e $(CONFIG_SYS_TEXT_BASE)
u-boot.ubl: u-boot-with-spl.bin FORCE
$(call if_changed,mkimage)
MKIMAGEFLAGS_u-boot-spl.ais = -s -n $(if $(CONFIG_AIS_CONFIG_FILE), \
$(srctree)/$(CONFIG_AIS_CONFIG_FILE:"%"=%),"/dev/null") \
-T aisimage -e $(CONFIG_SPL_TEXT_BASE)
spl/u-boot-spl.ais: spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
OBJCOPYFLAGS_u-boot.ais = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO)
u-boot.ais: spl/u-boot-spl.ais u-boot.img FORCE
$(call if_changed,pad_cat)
u-boot-signed.sb: u-boot.bin spl/u-boot-spl.bin
$(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot-signed.sb
u-boot.sb: u-boot.bin spl/u-boot-spl.bin
$(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot.sb
# On x600 (SPEAr600) U-Boot is appended to U-Boot SPL.
# Both images are created using mkimage (crc etc), so that the ROM
# bootloader can check its integrity. Padding needs to be done to the
# SPL image (with mkimage header) and not the binary. Otherwise the resulting image
# which is loaded/copied by the ROM bootloader to SRAM doesn't fit.
# The resulting image containing both U-Boot images is called u-boot.spr
MKIMAGEFLAGS_u-boot-spl.img = -A $(ARCH) -T firmware -C none \
-a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER
spl/u-boot-spl.img: spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
OBJCOPYFLAGS_u-boot.spr = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \
--gap-fill=0xff
u-boot.spr: spl/u-boot-spl.img u-boot.img FORCE
$(call if_changed,pad_cat)
ifneq ($(CONFIG_ARCH_SOCFPGA),)
quiet_cmd_socboot = SOCBOOT $#
cmd_socboot = cat spl/u-boot-spl.sfp spl/u-boot-spl.sfp \
spl/u-boot-spl.sfp spl/u-boot-spl.sfp \
u-boot.img > $# || rm -f $#
u-boot-with-spl.sfp: spl/u-boot-spl.sfp u-boot.img FORCE
$(call if_changed,socboot)
endif
# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including
# reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in
# the middle. This is handled by binman based on an image description in the
# board's device tree.
ifneq ($(CONFIG_X86_RESET_VECTOR),)
rom: u-boot.rom FORCE
refcode.bin: $(srctree)/board/$(BOARDDIR)/refcode.bin FORCE
$(call if_changed,copy)
quiet_cmd_ldr = LD $#
cmd_ldr = $(LD) $(LDFLAGS_$(#F)) \
$(filter-out FORCE,$^) -o $#
u-boot.rom: u-boot-x86-16bit.bin u-boot.bin \
$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
$(if $(CONFIG_HAVE_REFCODE),refcode.bin) FORCE
$(call if_changed,binman)
OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec
u-boot-x86-16bit.bin: u-boot FORCE
$(call if_changed,objcopy)
endif
ifneq ($(CONFIG_ARCH_SUNXI),)
u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb FORCE
$(call if_changed,binman)
endif
ifneq ($(CONFIG_TEGRA),)
ifneq ($(CONFIG_BINMAN),)
u-boot-dtb-tegra.bin u-boot-tegra.bin u-boot-nodtb-tegra.bin: \
spl/u-boot-spl u-boot.bin FORCE
$(call if_changed,binman)
else
OBJCOPYFLAGS_u-boot-nodtb-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)
u-boot-nodtb-tegra.bin: spl/u-boot-spl u-boot-nodtb.bin FORCE
$(call if_changed,pad_cat)
OBJCOPYFLAGS_u-boot-tegra.bin = -O binary --pad-to=$(CONFIG_SYS_TEXT_BASE)
u-boot-tegra.bin: spl/u-boot-spl u-boot.bin FORCE
$(call if_changed,pad_cat)
u-boot-dtb-tegra.bin: u-boot-tegra.bin FORCE
$(call if_changed,copy)
endif # binman
endif
OBJCOPYFLAGS_u-boot-app.efi := $(OBJCOPYFLAGS_EFI)
u-boot-app.efi: u-boot FORCE
$(call if_changed,zobjcopy)
u-boot.bin.o: u-boot.bin FORCE
$(call if_changed,efipayload)
u-boot-payload.lds: $(LDSCRIPT_EFI) FORCE
$(call if_changed_dep,cpp_lds)
# Rule to link the EFI payload which contains a stub and a U-Boot binary
quiet_cmd_u-boot_payload ?= LD $#
cmd_u-boot_payload ?= $(LD) $(LDFLAGS_EFI_PAYLOAD) -o $# \
-T u-boot-payload.lds arch/x86/cpu/call32.o \
lib/efi/efi.o lib/efi/efi_stub.o u-boot.bin.o \
$(addprefix arch/$(ARCH)/lib/,$(EFISTUB))
u-boot-payload: u-boot.bin.o u-boot-payload.lds FORCE
$(call if_changed,u-boot_payload)
OBJCOPYFLAGS_u-boot-payload.efi := $(OBJCOPYFLAGS_EFI)
u-boot-payload.efi: u-boot-payload FORCE
$(call if_changed,zobjcopy)
u-boot-img.bin: spl/u-boot-spl.bin u-boot.img FORCE
$(call if_changed,cat)
#Add a target to create boot binary having SPL binary in PBI format
#concatenated with u-boot binary. It is need by PowerPC SoC having
#internal SRAM <= 512KB.
MKIMAGEFLAGS_u-boot-spl.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \
-R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage \
-A $(ARCH) -a $(CONFIG_SPL_TEXT_BASE)
spl/u-boot-spl.pbl: spl/u-boot-spl.bin FORCE
$(call if_changed,mkimage)
ifeq ($(ARCH),arm)
UBOOT_BINLOAD := u-boot.img
else
UBOOT_BINLOAD := u-boot.bin
endif
OBJCOPYFLAGS_u-boot-with-spl-pbl.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \
--gap-fill=0xff
u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) FORCE
$(call if_changed,pad_cat)
# PPC4xx needs the SPL at the end of the image, since the reset vector
# is located at 0xfffffffc. So we can't use the "u-boot-img.bin" target
# and need to introduce a new build target with the full blown U-Boot
# at the start padded up to the start of the SPL image. And then concat
# the SPL image to the end.
OBJCOPYFLAGS_u-boot-img-spl-at-end.bin := -I binary -O binary \
--pad-to=$(CONFIG_UBOOT_PAD_TO) --gap-fill=0xff
u-boot-img-spl-at-end.bin: u-boot.img spl/u-boot-spl.bin FORCE
$(call if_changed,pad_cat)
# Create a new ELF from a raw binary file.
ifndef PLATFORM_ELFENTRY
PLATFORM_ELFENTRY = "_start"
endif
quiet_cmd_u-boot-elf ?= LD $#
cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $# \
--defsym=$(PLATFORM_ELFENTRY)=$(CONFIG_SYS_TEXT_BASE) \
-Ttext=$(CONFIG_SYS_TEXT_BASE)
u-boot.elf: u-boot.bin
$(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< u-boot-elf.o
$(call if_changed,u-boot-elf)
ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink)
# Rule to link u-boot
# May be overridden by arch/$(ARCH)/config.mk
quiet_cmd_u-boot__ ?= LD $#
cmd_u-boot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_u-boot) -o $# \
-T u-boot.lds $(u-boot-init) \
--start-group $(u-boot-main) --end-group \
$(PLATFORM_LIBS) -Map u-boot.map; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $#, true)
quiet_cmd_smap = GEN common/system_map.o
cmd_smap = \
smap=`$(call SYSTEM_MAP,u-boot) | \
awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \
$(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \
-c $(srctree)/common/system_map.c -o common/system_map.o
u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds FORCE
+$(call if_changed,u-boot__)
ifeq ($(CONFIG_KALLSYMS),y)
$(call cmd,smap)
$(call cmd,u-boot__) common/system_map.o
endif
ifeq ($(CONFIG_RISCV),y)
#tools/prelink-riscv $# 0
endif
quiet_cmd_sym ?= SYM $#
cmd_sym ?= $(OBJDUMP) -t $< > $#
u-boot.sym: u-boot FORCE
$(call if_changed,sym)
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
$(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
# Handle descending into subdirectories listed in $(vmlinux-dirs)
# Preset locale variables to speed up the build process. Limit locale
# tweaks to this spot to avoid wrong language settings when running
# make menuconfig etc.
# Error messages still appears in the original language
PHONY += $(u-boot-dirs)
$(u-boot-dirs): prepare scripts
$(Q)$(MAKE) $(build)=$#
tools: prepare
# The "tools" are needed early
$(filter-out tools, $(u-boot-dirs)): tools
# The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
# is "yes"), so compile examples after U-Boot is compiled.
examples: $(filter-out examples, $(u-boot-dirs))
define filechk_uboot.release
echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
endef
# Store (new) UBOOTRELEASE string in include/config/uboot.release
include/config/uboot.release: include/config/auto.conf FORCE
$(call filechk,uboot.release)
# Things we need to do before we recursively start building the kernel
# or the modules are listed in "prepare".
# A multi level approach is used. prepareN is processed before prepareN-1.
# archprepare is used in arch Makefiles and when processed asm symlink,
# version.h and scripts_basic is processed / created.
# Listed in dependency order
PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
# prepare3 is used to check if we are building in a separate output directory,
# and if so do:
# 1) Check that make has not been executed in the kernel src $(srctree)
prepare3: include/config/uboot.release
ifneq ($(KBUILD_SRC),)
#$(kecho) ' Using $(srctree) as source for U-Boot'
$(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \
echo >&2 " in the '$(srctree)' directory.";\
/bin/false; \
fi;
endif
# prepare2 creates a makefile if using a separate output directory
prepare2: prepare3 outputmakefile
prepare1: prepare2 $(version_h) $(timestamp_h) \
include/config/auto.conf
ifeq ($(wildcard $(LDSCRIPT)),)
#echo >&2 " Could not find linker script."
#/bin/false
endif
archprepare: prepare1 scripts_basic
prepare0: archprepare FORCE
$(Q)$(MAKE) $(build)=.
# All the preparing..
prepare: prepare0
# --------------------------------------------------------------------
quiet_cmd_cpp_lds = LDS $#
cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \
-D__ASSEMBLY__ -x assembler-with-cpp -P -o $# $<
u-boot.lds: $(LDSCRIPT) prepare FORCE
$(call if_changed_dep,cpp_lds)
spl/u-boot-spl.bin: spl/u-boot-spl
#:
spl/u-boot-spl: tools prepare \
$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) \
$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb)
$(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
spl/sunxi-spl.bin: spl/u-boot-spl
#:
spl/sunxi-spl-with-ecc.bin: spl/sunxi-spl.bin
#:
spl/u-boot-spl.sfp: spl/u-boot-spl
#:
spl/boot.bin: spl/u-boot-spl
#:
tpl/u-boot-tpl.bin: tools prepare \
$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb)
$(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.spl all
TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include)
FIND := find
FINDFLAGS := -L
tags ctags:
ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
-name '*.[chS]' -print`
ln -s ctags tags
etags:
etags -a -o etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \
-name '*.[chS]' -print`
cscope:
$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \
cscope.files
cscope -b -q -k
SYSTEM_MAP = \
$(NM) $1 | \
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
LC_ALL=C sort
System.map: u-boot
#$(call SYSTEM_MAP,$<) > $#
# Documentation targets
# ---------------------------------------------------------------------------
%docs: scripts_basic FORCE
$(Q)$(MAKE) $(build)=scripts build_docproc
$(Q)$(MAKE) $(build)=doc/DocBook $#
endif #ifeq ($(config-targets),1)
endif #ifeq ($(mixed-targets),1)
PHONY += checkstack ubootrelease ubootversion
checkstack:
$(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \
$(PERL) $(src)/scripts/checkstack.pl $(ARCH)
ubootrelease:
#echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
ubootversion:
#echo $(UBOOTVERSION)
# Single targets
# --------------------------------------------------------------------
# Single targets are compatible with:
# - build with mixed source and output
# - build with separate output dir 'make O=...'
# - external modules
#
# target-dir => where to store outputfile
# build-dir => directory in kernel source tree to use
ifeq ($(KBUILD_EXTMOD),)
build-dir = $(patsubst %/,%,$(dir $#))
target-dir = $(dir $#)
else
zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $#)))
build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $#))
endif
%.s: %.c prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $#)
%.i: %.c prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $#)
%.o: %.c prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $#)
%.lst: %.c prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $#)
%.s: %.S prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $#)
%.o: %.S prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $#)
%.symtypes: %.c prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $#)

Make error: make (e=2): The system cannot find the file specified

I am trying to compile a c project on a new windows PC, but when I run make I get:
D:\Eclipse_Workspace\project>make
##make -f makefile -C ./ -e cleanobj
process_begin: CreateProcess(NULL, ##make -f makefile -C ./ -e cleanobj, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [all] Fejl 2
On my other PC the project is compiling just fine.
Also "Fejl 2" is danish for "Error 2", have no idea why that is in danish when the rest is english.
EDIT:
Here is the makefile (it's rather long)
PROJECT_NAME := ble_app_hrs_s110_pca10028
export OUTPUT_FILENAME
#MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
MAKEFILE_NAME := $(MAKEFILE_LIST)
MAKEFILE_DIR := $(dir $(MAKEFILE_NAME) )
TEMPLATE_PATH = nrf51_sdk/toolchain/gcc
ifeq ($(OS),Windows_NT)
include $(TEMPLATE_PATH)/Makefile.windows
else
include $(TEMPLATE_PATH)/Makefile.posix
endif
MK := mkdir
RM := rm -rf
#echo suspend
ifeq ("$(VERBOSE)","1")
NO_ECHO :=
else
NO_ECHO := #
endif
# Toolchain commands
CC := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-gcc"
AS := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-as"
AR := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ar" -r
LD := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-ld"
NM := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-nm"
OBJDUMP := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objdump"
OBJCOPY := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-objcopy"
SIZE := "$(GNU_INSTALL_ROOT)/bin/$(GNU_PREFIX)-size"
#function for removing duplicates in a list
remduplicates = $(strip $(if $1,$(firstword $1) $(call remduplicates,$(filter-out $(firstword $1),$1))))
#source common to all targets
C_SOURCE_FILES += \
nrf51_sdk/drivers_nrf/rtc/nrf_drv_rtc.c \
Drivers/NRF51_BLEDriver.c \
(..... a lot more files ....)
#assembly files common to all targets
ASM_SOURCE_FILES = nrf51_sdk/toolchain/gcc/gcc_startup_nrf51.s
#includes common to all targets
INC_PATHS = -I Application/
(..... a lot more include paths.......)
OBJECT_DIRECTORY = _build
LISTING_DIRECTORY =$(OBJECT_DIRECTORY)
OUTPUT_BINARY_DIRECTORY =$(OBJECT_DIRECTORY)
# Sorting removes duplicates
BUILD_DIRECTORIES := $(sort $(OBJECT_DIRECTORY) $(OUTPUT_BINARY_DIRECTORY) $(LISTING_DIRECTORY) )
#flags common to all targets
CFLAGS = -DSOFTDEVICE_PRESENT
CFLAGS += -DNRF51
CFLAGS += -DS110
CFLAGS += -DBOARD_PCA10028
CFLAGS += -DBLE_STACK_SUPPORT_REQD
CFLAGS += -mcpu=cortex-m0
CFLAGS += -mthumb -mabi=aapcs --std=gnu99
CFLAGS += -Wall -O0 -g3
CFLAGS += -mfloat-abi=soft
# keep every function in separate section. This will allow linker to dump unused functions
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
#CFLAGS += -flto -fno-builtin
# keep every function in separate section. This will allow linker to dump unused functions
LDFLAGS += -Xlinker -Map=$(LISTING_DIRECTORY)/$(OUTPUT_FILENAME).map
LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
LDFLAGS += -mcpu=cortex-m0
# let linker to dump unused sections
LDFLAGS += -Wl,--gc-sections
# use newlib in nano version
LDFLAGS += --specs=nano.specs -lc -lnosys
# Assembler flags
ASMFLAGS += -x assembler-with-cpp
ASMFLAGS += -DSOFTDEVICE_PRESENT
ASMFLAGS += -DNRF51
ASMFLAGS += -DS110
ASMFLAGS += -DBOARD_PCA10028
ASMFLAGS += -DBLE_STACK_SUPPORT_REQD
#default target - first one defined
#default: clean nrf51422_xxac_s110
#building all targets
all: #clean
#$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e cleanobj
$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e nrf51422_xxac_s110
#target for printing all targets
help:
#echo following targets are available:
#echo nrf51422_xxac_s110
#echo flash_softdevice
C_SOURCE_FILE_NAMES = $(notdir $(C_SOURCE_FILES))
C_PATHS = $(call remduplicates, $(dir $(C_SOURCE_FILES) ) )
C_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(C_SOURCE_FILE_NAMES:.c=.o) )
ASM_SOURCE_FILE_NAMES = $(notdir $(ASM_SOURCE_FILES))
ASM_PATHS = $(call remduplicates, $(dir $(ASM_SOURCE_FILES) ))
ASM_OBJECTS = $(addprefix $(OBJECT_DIRECTORY)/, $(ASM_SOURCE_FILE_NAMES:.s=.o) )
vpath %.c $(C_PATHS)
vpath %.s $(ASM_PATHS)
OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
nrf51422_xxac_s110: OUTPUT_FILENAME := nrf51422_xxac_s110
nrf51422_xxac_s110: LINKER_SCRIPT=ble_app_hrs_gcc_nrf51.ld
nrf51422_xxac_s110: $(BUILD_DIRECTORIES) $(OBJECTS)
#echo Linking target: $(OUTPUT_FILENAME).out
$(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e finalize
## Create build directories
$(BUILD_DIRECTORIES):
echo $(MAKEFILE_NAME)
$(MK) $#
# Create objects from C SRC files
$(OBJECT_DIRECTORY)/%.o: %.c
#echo Compiling file: $(notdir $<)
#echo arm-none-eabi-gcc $(CFLAGS) $(INC_PATHS) -c -o $# $<
$(NO_ECHO)$(CC) $(CFLAGS) $(INC_PATHS) -c -o $# $<
# Assemble files
$(OBJECT_DIRECTORY)/%.o: %.s
#echo Compiling file: $(notdir $<)
$(NO_ECHO)$(CC) $(ASMFLAGS) $(INC_PATHS) -c -o $# $<
# Link
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out: $(BUILD_DIRECTORIES) $(OBJECTS)
#echo Linking target: $(OUTPUT_FILENAME).out
$(NO_ECHO)$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
## Create binary .bin file from the .out file
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
#echo Preparing: $(OUTPUT_FILENAME).bin
$(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
## Create binary .hex file from the .out file
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex: $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
#echo Preparing: $(OUTPUT_FILENAME).hex
$(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
finalize: genbin genhex echosize
genbin:
#echo Preparing: $(OUTPUT_FILENAME).bin
$(NO_ECHO)$(OBJCOPY) -O binary $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).bin
## Create binary .hex file from the .out file
genhex:
#echo Preparing: $(OUTPUT_FILENAME).hex
$(NO_ECHO)$(OBJCOPY) -O ihex $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).hex
echosize:
-#echo ""
$(NO_ECHO)$(SIZE) $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
-#echo ""
clean:
$(RM) $(BUILD_DIRECTORIES)
cleanobj:
$(RM) $(BUILD_DIRECTORIES)/*.o
flash: $(MAKECMDGOALS)
#echo Flashing: $(OUTPUT_BINARY_DIRECTORY)/$<.hex
nrfjprog --reset --program $(OUTPUT_BINARY_DIRECTORY)/$<.hex)
## Flash softdevice
flash_softdevice:
#echo Flashing: s110_softdevice.hex
nrfjprog --reset --program nrf51_sdk/softdevice/s110/hex/s110_softdevice.hex
In make, every line indented by a TAB character (in a "recipe context") will be passed as a command to the shell. Nothing about such a line will be interpreted by make, except for $.
In particular for you, the # character is not special to make in this context and doesn't introduce a make comment line. So in this rule:
all: #clean
#$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e cleanobj
$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e nrf51422_xxac_s110
the first line is not commented out; it's a command line that begins with a # character and make will ask the system to run that command. Clearly such a command doesn't exist on your system.
If you want to comment out recipe lines in make, you should always put the comment character at the beginning of the line not after the TAB:
all: #clean
# $(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e cleanobj
$(NO_ECHO)$(MAKE) -f $(MAKEFILE_NAME) -C $(MAKEFILE_DIR) -e nrf51422_xxac_s110
Just a comment - I struggled for a very long time until I realised RM was set to rm -f and there was no way that works on Windows. Set it to del and all was fine

Resources