Linking problems for non explicit interfaces - linker

I am trying to build a model written in F90. I keep having problems with it especially in the linking phase. I tried to compile both with gfortran and with ifort but both of them are complaining about undefined symbols. Here are the errors from ifort (gfortran has very similar ones) after the compilation which works fine
ar rs /Users/manfredo/Desktop/ED2/ED/build//ed_2.1-opt.a allometry.o an_header.o average_utils.o bdf2_solver.o budget_utils.o canopy_air_coms.o canopy_layer_coms.o canopy_radiation_coms.o canopy_struct_dynamics.o c34constants.o charutils.o consts_coms.o dateutils.o decomp_coms.o detailed_coms.o disturbance.o disturb_coms.o edio.o ed_1st.o ed_bigleaf_init.o ed_driver.o ed_filelist.o ed_grid.o ed_init.o ed_init_atm.o ed_init_full_history.o ed_load_namelist.o ed_max_dims.o ed_mem_alloc.o ed_mem_grid_dim_defs.o ed_met_driver.o ed_misc_coms.o ed_model.o ed_mpass_init.o ed_nbg_init.o ed_node_coms.o ed_opspec.o ed_params.o ed_para_coms.o ed_para_init.o ed_print.o ed_read_ed10_20_history.o ed_read_ed21_history.o ed_state_vars.o ed_therm_lib.o ed_type_init.o ed_var_tables.o ed_work_vars.o ed_xml_config.o ename_coms.o euler_driver.o events.o farq_leuning.o fatal_error.o fire.o forestry.o fusion_fission_coms.o fuse_fiss_utils.o great_circle.o grid_coms.o growth_balive.o h5_output.o hdf5_coms.o hdf5_utils.o heun_driver.o hybrid_driver.o hydrology_coms.o hydrology_constants.o init_hydro_sites.o invmondays.o landuse_init.o lapse.o leaf_database.o libxml2f90.f90_pp.o lsm_hyd.o mem_polygons.o met_driver_coms.o mortality.o multiple_scatter.o numutils.o old_twostream_rad.o optimiz_coms.o phenology_aux.o phenology_coms.o phenology_driv.o phenology_startup.o photosyn_driv.o physiology_coms.o pft_coms.o radiate_driver.o radiate_utils.o reproduction.o rk4_coms.o rk4_derivs.o rk4_driver.o rk4_integ_utils.o rk4_misc.o rk4_stepper.o rsys.o soil_coms.o soil_respiration.o stable_cohorts.o structural_growth.o therm_lib.o therm_lib8.o twostream_rad.o update_derived_props.o utils_c.o utils_f.o vegetation_dynamics.o
cp -f /Users/manfredo/Desktop/ED2/ED/src/driver/edmain.F90 edmain.F90
ifort -c -DUSE_INTERF=1 -DUSENC=0 -DMAC_OS_X -DUSE_HDF5=1 -DUSE_COLLECTIVE_MPIO=0 -DUSE_MPIWTIME=0 -O0 -gen-interfaces -I/usr/include/malloc -I/Users/manfredo/Desktop/ED2/ED/src/include -I/usr/local/hdf5_mio/include edmain.F90
rm -f edmain.F90
ifort -o /Users/manfredo/Desktop/ED2/ED/build/ed_2.1-opt edmain.o -I/usr/local/hdf5_mio/include/Users/manfredo/Desktop/ED2/ED/build/ed_2.1-opt.a -lm -lz -L/usr/local/hdf5_mio/lib -lhdf5 -lhdf5_fortran -lhdf5_hl
ifort version 14.0.4
ld: warning: path '/dev/null' following -L not a directory
Undefined symbols for architecture x86_64:
"_decomp_coms_mp_cwd_frac_", referenced from:
_init_decomp_params_ in ed_2.1-opt.a(ed_params.o)
_update_polygon_derived_props_ in ed_2.1-opt.a(update_derived_props.o)
_read_ed_xml_config_ in ed_2.1-opt.a(ed_xml_config.o)
_write_ed_xml_config_ in ed_2.1-opt.a(ed_xml_config.o)
_resp_rh_ in ed_2.1-opt.a(soil_respiration.o)
"_decomp_coms_mp_decay_rate_fsc_", referenced from:
_init_decomp_params_ in ed_2.1-opt.a(ed_params.o)
_read_ed_xml_config_ in ed_2.1-opt.a(ed_xml_config.o)
_write_ed_xml_config_ in ed_2.1-opt.a(ed_xml_config.o)
_resp_rh_ in ed_2.1-opt.a(soil_respiration.o)
_update_c_and_n_pools_ in ed_2.1-opt.a(soil_respiration.o)
another bunch of similar errors
ld: symbol(s) not found for architecture x86_64
make[1]: *** [/Users/manfredo/Desktop/ED2/ED/build//ed_2.1-opt] Error 1
make: *** [all] Error 2
file ed_params.f90 reads
subroutine init_decomp_params()
use decomp_coms , only : n_decomp_lim
decomp_coms.f90 is a module file.
This is the important part of the Makefile
#----- Define path and compilation --------------------------------------------------------#
include paths.mk
include include.mk.$(OPT)
#------------------------------------------------------------------------------------------#
#------------------------------------------------------------------------------------------#
# Double check that the "LOWO" flags have been set. In case they have not, clone the #
# standard options. LOWO stands for LOWer Optimisation, and these flags are used for a #
# subroutines that are taking several hours to compile with ifort-13 (ed_state_vars.f90 #
# and a few others). #
#------------------------------------------------------------------------------------------#
ifeq ($(F_LOWO_OPTS),)
F_LOWO_OPTS = $(F_OPTS)
endif
#------------------------------------------------------------------------------------------#
#----- Compiler commands. -----------------------------------------------------------------#
INCLUDES = $(PAR_INCS) -I$(ED_INCS) $(HDF5_INCS) $(MPI_INCS)
F90_COMMAND = $(F_COMP) -c $(F_OPTS) $(INCLUDES) $(PAR_DEFS)
F90_LOWO_COMMAND = $(F_COMP) -c $(F_LOWO_OPTS) $(INCLUDES) $(PAR_DEFS)
FPP_COMMAND = $(F_COMP) -c -DUSE_INTERF=$(USE_INTERF) -DUSENC=$(USENC) -D$(CMACH) \
-DUSE_HDF5=$(USE_HDF5) -DUSE_COLLECTIVE_MPIO=$(USE_COLLECTIVE_MPIO) \
-DUSE_MPIWTIME=$(USE_MPIWTIME) $(F_OPTS) $(INCLUDES) $(PAR_DEFS)
FPP_LOWO_COMMAND = $(F_COMP) -c -DUSE_INTERF=$(USE_INTERF) -DUSENC=$(USENC) -D$(CMACH) \
-DUSE_HDF5=$(USE_HDF5) -DUSE_COLLECTIVE_MPIO=$(USE_COLLECTIVE_MPIO) \
-DUSE_MPIWTIME=$(USE_MPIWTIME) $(F_LOWO_OPTS) $(INCLUDES) $(PAR_DEFS)
CXX_COMMAND = $(C_COMP) -c $(C_OPTS) -D$(CMACH) $(HDF5_INCS) $(INCLUDES) $(PAR_DEFS)
#------------------------------------------------------------------------------------------#
#----- Define archive and executable names. -----------------------------------------------#
EXE=$(BASE)/ed_$(ED_VERSION)-$(OPT)
LIBMODEL=$(BASE)/ed_$(ED_VERSION)-$(OPT).a
#------------------------------------------------------------------------------------------#
include objects.mk
#----- Define targets. --------------------------------------------------------------------#
all:
make gendep
make $(EXE)
make $(EXE)
make $(EXE)
make $(EXE)
make $(EXE)
gendep:
#echo ""
./generate_deps.sh $(ED_ROOT)
#echo === Finished dependencies ===
$(EXE): $(LIBMODEL) $(MAINOBJ)
#echo ""
$(LOADER) -o $(EXE) edmain.o $(LOADER_OPTS) $(INCLUDES) $(LIBMODEL) $(HDF5_LIBS) \
$(PAR_LIBS) $(NC_LIBS) $(LIBS) $(LOADER_OPTS)
#echo ""
#echo Finished building === $(EXE)
#echo ""
$(MAINOBJ): $(MAIN)
#echo ""
cp -f $< $(<F:.F90=.F90)
$(FPP_COMMAND) $(<F:.F90=.F90)
rm -f $(<F:.F90=.F90)
$(LIBMODEL): $(OBJ_MODEL)
$(ARCHIVE) $(LIBMODEL) $(OBJ_MODEL)
which includes the following file (objects.mk)
#Makefile objects_edofl.mk
# Define main source.
MAIN = $(ED_DRIVER)/edmain.F90
MAINOBJ = edmain.o
# Define objects.
OBJ_MODEL = \
allometry.o \
an_header.o \
average_utils.o \
bdf2_solver.o \
budget_utils.o \
canopy_air_coms.o \
canopy_layer_coms.o \
canopy_radiation_coms.o \
canopy_struct_dynamics.o \
c34constants.o \
charutils.o \
consts_coms.o \
dateutils.o \
decomp_coms.o \
detailed_coms.o \
disturbance.o \
other_objects
and this other file (include.mk.opt.macosx)
MAKE=/usr/bin/make
# libraries.
BASE=$(ED_ROOT)/build/
# Activate appropriate parts below, comment out others.
# HDF 5 Libraries
# ED2 HAS OPTIONAL HDF 5 I/O
# If you wish to use this functionality specify USE_HDF5=1
# and specify the location of the include directory
# library files. Make sure you include the zlib.a location too.
USE_HDF5=1
HDF5_INCS=-I/usr/local/hdf5_mio/include
HDF5_LIBS=-lm -lz -L/usr/local/hdf5_mio/lib -lhdf5 -lhdf5_fortran -lhdf5_hl
#---------------------------------------------------------------
# If you have a version of hdf5 compiled in parallel, then you
# may benefit from collective I/O, then use this flag = 1
# Otherwise, set it to zero.
USE_COLLECTIVE_MPIO=0
#---------------------------------------------------------------
# netCDF libraries ---------------------------------------------
# If you have netCDF set USENC=1 and type the lib folder
# at NC_LIBS, with the leading -L (e.g. -L/usr/local/lib).
# If you don't have it, leave USENC=0 and type a dummy
# folder for NC_LIBS (e.g. -L/dev/null or leave it blank)
USENC=0
NC_LIBS=-L/dev/null
# --------------------------------------------------------------
# interface ----------------------------------------------------
# This should be 1 unless you are running with -gen-interfaces.
# Interfaces usually make the compilation to crash when the
# -gen-interfaces option are on, so this flag bypass all
# interfaces in the code.
USE_INTERF=1
# MPI_Wtime. ---------------------------------------------------
# If USE_MPIWTIME=1, then it will use MPI libraries to compute
# the wall time (the only double-precision intrinsic). In case
# you don't have it, leave USE_MPIWTIME=0, in which case it will
# use a simpler, single-precision function.
USE_MPIWTIME=0
#----------------- MAC_OS_X (Leopard) ---- gfortran/gcc ---------------
CMACH=MAC_OS_X
F_COMP=ifort
C_COMP=icc
LOADER=ifort
MOD_EXT=mod
##################################### COMPILER OPTIONS #####################################
#------------------------------------------------------------------------------------------#
# A. Pickiest - Use this whenever you change arguments on functions and subroutines. #
# This will perform the same tests as B but it will also check whether all #
# arguments match between subroutine declaration and subroutine calls. #
# WARNING: In order to really check all interfaces you must compile with #
# this option twice: #
# 1. Compile (./compile.sh) #
# 2. Prepare second compilation(./2ndcomp.sh) #
# 3. Compile one more time (./compile.sh) #
# If the compilation fails either at step 1 or 3, then your code has inter- #
# face problems. If it successfully compiles, then you can switch to B. #
#------------------------------------------------------------------------------------------#
#USE_INTERF=0
#F_OPTS=-O0 -Wall -ffpe-trap=invalid,zero,overflow,underflow,precision,denormal \
# -ffree-line-length-none
#C_OPTS=-O0 -DUNDERSCORE -DLITTLE
#LOADER_OPTS=-O0 -ffree-line-length-none
#------------------------------------------------------------------------------------------#
# E. Fast - This is all about performance, use only when you are sure that the model has #
# no code problem, and you want results asap. This will not check for any #
# problems, which means that this is an option suitable for end users, not de- #
# velopers. #
#------------------------------------------------------------------------------------------#
USE_INTERF=1
F_OPTS= -O0 -v
C_OPTS= -DLITTLE -v
F_LOWO_OPTS= -O0
LOADER_OPTS= -ffixed-line-length-none
#------------------------------------------------------------------------------------------#
#---------------If using scritps 'mpicc' e 'mpif90'---------------'
MPI_PATH=
PAR_INCS=-I/usr/include/malloc
PAR_LIBS=
PAR_DEFS=
#-----------------------------------------------------------------
# For IBM,HP,SGI,ALPHA,LINUX use these:
ARCHIVE=ar rs
# For NEC SX-6
#ARCHIVE=sxar rs
# For SUN,CONVEX
#ARCHIVE=ar r'
When looking at the source files these errors kind of make sense because most of the subroutines are declared without explicit interfaces, that is without a module and a corresponding use statement.
The problem is that the package encompasses hundreds of files and going through all of them to change the interfaces is not feasible. Moreover the same package can be built on other platforms/compilers.
Thus my question is, is it possible to give the compiler options that enable the correct linking even if most of the subroutines don't have explicit interface.
Thanks for help

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

How to get a loading animation in a Makefile for the time .o files are compiling?

I want to get a little loading animation as long the Makefile compiles my .o files i saw a loading animation which switched between [|], [/], [-], [] and that is what i wanna implement now.
I tried to achieve that by using printf a Make variable and some ifeq and else ifeq conditions but that didn't worked somehow the if conditions are checked just once after the first call of the
$(OBJDIR)/%.o: rule
what i expect is that the stage of the loading box switches every time the $(OBJDIR)/%.o: rule is called or somehow timebased if there is an easy solution but i think its too complicated so i would stick to the first for now
Also its my first time asking here pls be patient and tell me how to improve my questions
that is the makefile
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: pharbst <pharbst#student.42heilbronn.de +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/05/06 09:33:42 by pharbst #+# #+# #
# Updated: 2022/11/29 03:29:26 by pharbst ### ########.fr #
# #
# **************************************************************************** #
SHELL= /bin/bash
Black = $(shell echo -e "\033[0;30m")
FBlack = $(shell echo -e "\033[1;30m")
Red = $(shell echo -e "\033[0;31m")
FRed = $(shell echo -e "\033[1;31m")
Green = $(shell echo -e "\033[0;32m")
FGreen = $(shell echo -e "\033[1;32m")
Brown/Orange = $(shell echo -e "\033[0;33m")
FBrown/Orange = $(shell echo -e "\033[1;33m")
FYellow = $(shell echo -e "\033[1;33m")
Yellow = $(shell echo -e "\033[0;33m")
Blue = $(shell echo -e "\033[0;34m")
FBlue = $(shell echo -e "\033[1;34m")
Purple = $(shell echo -e "\033[0;35m")
FPurple = $(shell echo -e "\033[1;35m")
Cyan = $(shell echo -e "\033[0;36m")
FCyan = $(shell echo -e "\033[1;36m")
FWhite = $(shell echo -e "\033[1;37m")
White = $(shell echo -e "\033[0;37m")
RESET = $(shell echo -e "\033[0m")
TICK = $(shell echo -e "\xE2\x9C\x94")
PRONAME = libftio
NAME = libftio.a
CC = cc
CFLAGS = -Wall -Wextra -Werror -I includes -g
HEADER = ./includes/libftio.h
SRCDIR = ./src
OBJDIR = ./obj
FILES = ft_atoi.c \
ft_bzero.c \
ft_calloc.c \
ft_isalnum.c \
ft_isalpha.c \
ft_isascii.c \
ft_isdigit.c \
ft_isprint.c \
ft_memchr.c \
ft_memcmp.c \
ft_memcpy.c \
ft_memmove.c \
ft_memset.c \
ft_strchr.c \
ft_strlcat.c \
ft_strlcpy.c \
ft_strlen.c \
ft_strncmp.c \
ft_strnstr.c \
ft_strrchr.c \
ft_tolower.c \
ft_toupper.c \
ft_itoa.c \
ft_putchar_fd.c \
ft_putendl_fd.c \
ft_putnbr_fd.c \
ft_putstr_fd.c \
ft_split.c \
ft_strdup.c \
ft_strjoin.c \
ft_strtrim.c \
ft_substr.c \
ft_strmapi.c \
ft_striteri.c \
\
ft_lstnew.c \
ft_lstadd_front.c \
ft_lstsize.c \
ft_lstlast.c \
ft_lstadd_back.c \
ft_lstdelone.c \
ft_lstclear.c \
ft_lstiter.c \
ft_lstmap.c \
\
ft_bufferjoin.c \
ft_buffinit.c \
ft_chartostr.c \
ft_itohex.c \
ft_ptrtohex.c \
ft_strjoinchar.c \
ft_strjoinfree.c \
ft_strlower.c \
ft_strupper.c \
ft_uitoa.c \
ft_printf.c \
ft_printf_helper.c \
get_next_line.c \
ft_strcmp.c \
ft_free_split.c \
OBJS = $(addprefix $(OBJDIR)/, $(FILES:.c=.o))
OBJ_FLAG = 0
all: $(NAME)
$(NAME): header obj_header $(OBJS) linking_header
#ar rcs $(NAME) $(OBJS)
#printf "\b\b\b$(FGreen)[$(TICK)]\n$(RESET)"
$(OBJDIR)/%.o: $(SRCDIR)/*/%.c
#mkdir -p $(OBJDIR)
#$(CC) $(CFLAGS) -o $# -c $<
ifeq ($(OBJ_FLAG), 0)
#printf "\b\b\]"
#OBJ_FLAG=1
else ifeq ($(OBJ_FLAG), 1)
#printf "\b\b|]"
#OBJ_FLAG=2
else ifeq ($(OBJ_FLAG), 2)
#printf "\b\b/]"
#OBJ_FLAG=3
else ifeq ($(OBJ_FLAG), 3)
#printf "\b\b-]"
#OBJ_FLAG=0
endif
clean: header
#echo "$(FRed)Clean $(PRONAME)$(FGreen) [$(TICK)]"
#rm -rf $(OBJS)
#rm -rf $(OBJDIR)
#echo "$(RESET)"
fclean: header
#echo "$(FRed)FCleaning $(PRONAME)$(FGreen) [$(TICK)]"
#rm -rf $(OBJDIR)
#rm -rf $(NAME)
re: fclean all
header:
#echo "$(FBlue)====================$(FYellow)$(PRONAME)$(FBlue)====================$(RESET)"
obj_header:
#printf "$(FBlue)Compiling .o files $(FYellow)[-]"
linking_header:
#printf "\b\b\b$(FGreen)[$(TICK)]\n$(Green)Linking $(PRONAME) $(FYellow)[-]$(RESET)"
git: commit push
commit:
git commit -m "$(msg)"
push:
git push
update:
git pull
.PHONY: all clean fclean re
peter (btw how in the world was this handle not taken prior to 2022?), first off, you really need to go to gnu.org and read the make manual. This is not only recommended but vital if you want to make use of the build language and concepts behind make and its relatives.
Secondly, and this is where I jump ahead of the chapter How make reads a makefile which you should read first, make does not execute the ifeq's in the way you envision: if, ifeq etc. are only used in one first pass when parsing the makefile to decide which parts of the makefile are parsed and which ones are ignored (forever). When make runs over one of its conditionals, it only parses the true-route (if or else branch) and literally throws away all lines from the false-route. This means it is of no use in creating looping constructs or repeated runtime decisions where the various branches are elicited for execution by a dynamic logic predicate. In one word, the ifeq's in your example don't belong to the rule in which they seemingly are embedded but to the file as a whole.
That said, there is one more issue with your perception of make rules: they are executed by calling one extra shell process and therefore a completely fresh set of variables (exceptions: see the manual) per line of a recipe so an assignment like
#OBJ_FLAG=1
is ineffective as the process where this variable exists and has the value 1 lives only for this one line and is deleted immediately afterwards. (See .ONESHELL in the manual for an exemption)
The final upshot of all which I said here is that it is extremely hard to programmatically loop in make in parallel with the recipe execution. This simply never was in the focus of its development which aimed for maximum non-intrusiveness and side-stepping of the make process itself when some recipe process is runnnig. Adorning the build run with interactive elements is left to the user, i.e. to user-supplied programs which also would have to solve the concurrency problems of the 1:n stdout to compilation processes in a parallel make run. Maybe you can draw some inspirations from there: https://unix.stackexchange.com/questions/225179/display-spinner-while-waiting-for-some-process-to-finish

how to fix 'undefined reference to `main' collect2: error: ld returned 1 exit status'

When I am trying to compile the host code using make command. It gave me this error:
`/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [bin/host] Error 1
`
Makefile:
ifeq ($(VERBOSE),1)
ECHO :=
else
ECHO := #
endif
# Where is the Intel(R) FPGA SDK for OpenCL(TM) software?
ifeq ($(wildcard $(INTELFPGAOCLSDKROOT)),)
$(error Set INTELFPGAOCLSDKROOT to the root directory of the Intel(R) FPGA SDK for OpenCL(TM) software installation)
endif
ifeq ($(wildcard $(INTELFPGAOCLSDKROOT)/host/include/CL/opencl.h),)
$(error Set INTELFPGAOCLSDKROOT to the root directory of the Intel(R) FPGA SDK for OpenCL(TM) software installation.)
endif
# OpenCL compile and link flags.
AOCL_COMPILE_CONFIG := $(shell aocl compile-config )
AOCL_LINK_CONFIG := $(shell aocl link-config )
# Compilation flags
ifeq ($(DEBUG),1)
CXXFLAGS += -g
else
CXXFLAGS += -O2
endif
# Compiler
CXX := g++
# Target
TARGET := host
TARGET_DIR := bin
# Directories
INC_DIRS := ../common/inc
LIB_DIRS :=
# Files
INCS := $(wildcard )
SRCS := $(wildcard host/src/*.cpp ../common/src/AOCLUtils/*.cpp)
LIBS := rt pthread
# Make it all!
all : $(TARGET_DIR)/$(TARGET)
# Host executable target.
$(TARGET_DIR)/$(TARGET) : Makefile $(SRCS) $(INCS) $(TARGET_DIR)
$(ECHO)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -fPIC $(foreach D,$(INC_DIRS),-I$D) \
$(AOCL_COMPILE_CONFIG) $(SRCS) $(AOCL_LINK_CONFIG) \
$(foreach D,$(LIB_DIRS),-L$D) \
$(foreach L,$(LIBS),-l$L) \
-o $(TARGET_DIR)/$(TARGET)
$(TARGET_DIR) :
$(ECHO)mkdir $(TARGET_DIR)
# Standard make targets
clean :
$(ECHO)rm -f $(TARGET_DIR)/$(TARGET)
.PHONY : all clean

how to edit Make.Linux_intel64 to get the same performance with IntelĀ® Optimized MP LINPACK Benchmark

My KNL platform is based on Intel(R) Xeon Phi(TM) CPU 7250 # 1.40GHz, 1 node, 68 cores, 96GB memory. I have some problems in linpack benchmark.
When I executed IntelĀ® Optimized MP LINPACK Benchmark following: /opt/intel/compilers_and_libraries_2018.5.274/linux/mkl/benchmarks/mp_linpack
I get the good performance about 1700 gflops ( with N = 40k - compiler: mpirun -np 1 ./xhpl).
But when I download open-source on netlib hpl-2.3 and install it, the performance I got so bad ( about 700gflops, with the same size and compiler). I think my problem is install processing ( edit file Make.Linux_Intel64).
Everybody, please help me fix my problem, or please guide me if you have any idea to get good performance.
Thanks a lot.
SHELL = /bin/sh
#
CD = cd
CP = cp
LN_S = ln -fs
MKDIR = mkdir -p
RM = /bin/rm -f
TOUCH = touch
#
# ----------------------------------------------------------------------
# - Platform identifier ------------------------------------------------
# ----------------------------------------------------------------------
#
#ARCH = Linux_Intel64
ARCH = $(arch)
#
# ----------------------------------------------------------------------
# - HPL Directory Structure / HPL library ------------------------------
# ----------------------------------------------------------------------
#
#TOPdir = $(HOME)/hpl
TOPdir = /home/tuyen1/HPL/hpl-2.3/install_hpl
INCdir = $(TOPdir)/include
BINdir = $(TOPdir)/bin/$(ARCH)
LIBdir = $(TOPdir)/lib/$(ARCH)
#
HPLlib = $(LIBdir)/libhpl.a
#
# ----------------------------------------------------------------------
# - Message Passing library (MPI) --------------------------------------
# ----------------------------------------------------------------------
# MPinc tells the C compiler where to find the Message Passing library
# header files, MPlib is defined to be the name of the library to be
# used. The variable MPdir is only used for defining MPinc and MPlib.
#
# MPdir = /opt/intel/mpi/4.1.0
# MPinc = -I$(MPdir)/include64
# MPlib = $(MPdir)/lib64/libmpi.a
MPdir =/opt/intel/compilers_and_libraries_2018.5.274/linux/mpi
MPinc = -I$(MPdir)/include64
MPlib = $(MPdir)/lib64/libmpi.a
# ----------------------------------------------------------------------
# - Linear Algebra library (BLAS or VSIPL) -----------------------------
# ----------------------------------------------------------------------
# LAinc tells the C compiler where to find the Linear Algebra library
# header files, LAlib is defined to be the name of the library to be
# used. The variable LAdir is only used for defining LAinc and LAlib.
#
LAdir = /opt/intel/compilers_and_libraries_2018.5.274/linux/mkl
ifndef LAinc
LAinc = $(LAdir)/include
endif
ifndef LAlib
LAlib = -L$(LAdir)/lib/intel64 \
-Wl,--start-group \
$(LAdir)/lib/intel64/libmkl_intel_lp64.a \
$(LAdir)/lib/intel64/libmkl_intel_thread.a \
$(LAdir)/lib/intel64/libmkl_core.a \
-Wl,--end-group -lpthread -ldl
endif
#
# ----------------------------------------------------------------------
# - F77 / C interface --------------------------------------------------
# ----------------------------------------------------------------------
# You can skip this section if and only if you are not planning to use
# a BLAS library featuring a Fortran 77 interface. Otherwise, it is
# necessary to fill out the F2CDEFS variable with the appropriate
# options. **One and only one** option should be chosen in **each** of
# the 3 following categories:
#
# 1) name space (How C calls a Fortran 77 routine)
#
# -DAdd_ : all lower case and a suffixed underscore (Suns,
# Intel, ...), [default]
# -DNoChange : all lower case (IBM RS6000),
# -DUpCase : all upper case (Cray),
# -DAdd__ : the FORTRAN compiler in use is f2c.
#
# 2) C and Fortran 77 integer mapping
#
# -DF77_INTEGER=int : Fortran 77 INTEGER is a C int, [default]
# -DF77_INTEGER=long : Fortran 77 INTEGER is a C long,
# -DF77_INTEGER=short : Fortran 77 INTEGER is a C short.
#
# 3) Fortran 77 string handling
#
# -DStringSunStyle : The string address is passed at the string loca-
# tion on the stack, and the string length is then
# passed as an F77_INTEGER after all explicit
# stack arguments, [default]
# -DStringStructPtr : The address of a structure is passed by a
# Fortran 77 string, and the structure is of the
# form: struct {char *cp; F77_INTEGER len;},
# -DStringStructVal : A structure is passed by value for each Fortran
# 77 string, and the structure is of the form:
# struct {char *cp; F77_INTEGER len;},
# -DStringCrayStyle : Special option for Cray machines, which uses
# Cray fcd (fortran character descriptor) for
# interoperation.
#
F2CDEFS = -DAdd__ -DF77_INTEGER=int -DStringSunStyle
#
# ----------------------------------------------------------------------
# - HPL includes / libraries / specifics -------------------------------
# ----------------------------------------------------------------------
#
HPL_INCLUDES = -I$(INCdir) -I$(INCdir)/$(ARCH) -I$(LAinc) $(MPinc)
HPL_LIBS = $(HPLlib) $(LAlib) $(MPlib)
#
# - Compile time options -----------------------------------------------
#
# -DHPL_COPY_L force the copy of the panel L before bcast;
# -DHPL_CALL_CBLAS call the cblas interface;
# -DHPL_CALL_VSIPL call the vsip library;
# -DHPL_DETAILED_TIMING enable detailed timers;
#
# By default HPL will:
# *) not copy L before broadcast,
# *) call the BLAS Fortran 77 interface,
# *) not display detailed timing information.
#
#HPL_OPTS = -DHPL_DETAILED_TIMING -DHPL_PROGRESS_REPORT
HPL_OPTS = -DASYOUGO -DHYBRID
#
# ----------------------------------------------------------------------
#
HPL_DEFS = $(F2CDEFS) $(HPL_OPTS) $(HPL_INCLUDES)
#
# ----------------------------------------------------------------------
# - Compilers / linkers - Optimization flags ---------------------------
# ----------------------------------------------------------------------
#
CC = mpiicc
CCNOOPT = $(HPL_DEFS) -O0 -w -nocompchk
OMP_DEFS = -qopenmp
#CCFLAGS = $(HPL_DEFS) -O3 -w -ansi-alias -i-static -z noexecstack -z relro -z now -nocompchk -Wall
CCFLAGS = $(HPL_DEFS) -O3 -w -ansi-alias -i-static -z noexecstack -z relro -z now -nocompchk
#
#
# On some platforms, it is necessary to use the Fortran linker to find
# the Fortran internals used in the BLAS library.
#
LINKER = $(CC)
LINKFLAGS = $(CCFLAGS) $(OMP_DEFS) -mt_mpi -qopenmp -nocompchk
#
ARCHIVER = ar
ARFLAGS = r
RANLIB = echo

Simulink cross-compilation succeeded, application not working

I am currently trying to compile a Simulink model for a SoC board that is running a Linux OS. I am able to compile and run applications successfully for this board making my own makefiles, which are really very simple.
The cross-compiler I am using is the
environment-setup-cortexa8hf-vfp-neon-poky-linux-gnueabi
Also, generating c code from a Simulink model and applying my makefile works as well. (With very simple simulink models)
The problem is when I try to generate code and also compile the simulink model with the following options:
ert.tcl
toolchain: automatic (GNU)
for: faster builds
This generates a binary that is working but I have to modify the makefile in order to compile the code with my cross-compiler. The cross-compilation works but when I try to run the application in the SoC board I get the following error:
-sh. ./application file not found
Here is the makefile:
###########################################################################
## Makefile generated for Simulink model 'simmod'.
##
## Makefile : simmod.mk
## Generated on : Tue Sep 11 14:57:43 2018
## MATLAB Coder version: 4.0 (R2018a)
##
## Build Info:
##
## Final product: $(RELATIVE_PATH_TO_ANCHOR)/simmod
## Product type : executable
## Build type : Top-Level Standalone Executable
##
###########################################################################
###########################################################################
## MACROS
###########################################################################
# Macro Descriptions:
# PRODUCT_NAME Name of the system to build
# MAKEFILE Name of this makefile
# COMPUTER Computer type. See the MATLAB "computer" command.
PRODUCT_NAME = simmod
MAKEFILE = simmod.mk
COMPUTER = GLNXA64
MATLAB_ROOT = /opt/MATLAB/R2018a
MATLAB_BIN = /opt/MATLAB/R2018a/bin
MATLAB_ARCH_BIN = $(MATLAB_BIN)/glnxa64
MASTER_ANCHOR_DIR =
START_DIR = /home/hector/Documents/Qt/DA_AMiRo/Devices/Reflective_Operator/Matlab_Reflective_Operator/temp
ARCH = glnxa64
SOLVER =
SOLVER_OBJ =
CLASSIC_INTERFACE = 0
TGT_FCN_LIB = ISO_C
MODEL_HAS_DYNAMICALLY_LOADED_SFCNS = 0
MODELREF_LINK_RSPFILE_NAME = simmod_ref.rsp
RELATIVE_PATH_TO_ANCHOR = ..
C_STANDARD_OPTS = -mfloat-abi=hard -std=gnu99 -pedantic -fwrapv #-std=c99
CPP_STANDARD_OPTS = -fwrapv
###########################################################################
## TOOLCHAIN SPECIFICATIONS
###########################################################################
# Toolchain Name: GNU gcc/g++ v4.4.x | gmake (64-bit Linux)
# Supported Version(s): 4.4.x
# ToolchainInfo Version: R2018a
# Specification Revision: 1.0
#
#-------------------------------------------
# Macros assumed to be defined elsewhere
#-------------------------------------------
# C_STANDARD_OPTS
# CPP_STANDARD_OPTS
#-----------
# MACROS
#-----------
WARN_FLAGS = -Wall -W -Wwrite-strings -Winline -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Wcast-align
WARN_FLAGS_MAX = $(WARN_FLAGS) -Wcast-qual -Wshadow
CPP_WARN_FLAGS = -Wall -W -Wwrite-strings -Winline -Wpointer-arith -Wcast-align
CPP_WARN_FLAGS_MAX = $(CPP_WARN_FLAGS) -Wcast-qual -Wshadow
TOOLCHAIN_SRCS =
TOOLCHAIN_INCS =
TOOLCHAIN_LIBS =
#------------------------
# BUILD TOOL COMMANDS
#------------------------
# C Compiler: GNU C Compiler
CC = arm-poky-linux-gnueabi-gcc #gcc
# Linker: GNU Linker
LD = arm-poky-linux-gnueabi-g++ #g++
# C++ Compiler: GNU C++ Compiler
CPP = arm-poky-linux-gnueabi-g++ #g++
# C++ Linker: GNU C++ Linker
CPP_LD = arm-poky-linux-gnueabi-g++ #g++
# Archiver: GNU Archiver
AR = ar
# MEX Tool: MEX Tool
MEX_PATH = $(MATLAB_ARCH_BIN)
MEX = "$(MEX_PATH)/mex"
# Download: Download
DOWNLOAD =
# Execute: Execute
EXECUTE = $(PRODUCT)
# Builder: GMAKE Utility
MAKE_PATH = %MATLAB%/bin/glnxa64
MAKE = "$(MAKE_PATH)/gmake"
#-------------------------
# Directives/Utilities
#-------------------------
CDEBUG = -g
C_OUTPUT_FLAG = -o
LDDEBUG = -g
OUTPUT_FLAG = -o
CPPDEBUG = -g
CPP_OUTPUT_FLAG = -o
CPPLDDEBUG = -g
OUTPUT_FLAG = -o
ARDEBUG =
STATICLIB_OUTPUT_FLAG =
MEX_DEBUG = -g
RM = #rm -f
ECHO = #echo
MV = #mv
RUN =
#----------------------------------------
# "Faster Builds" Build Configuration
#----------------------------------------
ARFLAGS = ruvs
CFLAGS = -c $(C_STANDARD_OPTS) -fPIC \
-O0
CPPFLAGS = -c $(CPP_STANDARD_OPTS) -fPIC \
-O0
CPP_LDFLAGS = -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)"
CPP_SHAREDLIB_LDFLAGS = -shared -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)" -Wl,--no-undefined
DOWNLOAD_FLAGS =
EXECUTE_FLAGS =
LDFLAGS = -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)"
MEX_CPPFLAGS = -R2018a -MATLAB_ARCH=$(ARCH) $(INCLUDES) \
\
CXXOPTIMFLAGS="$(C_STANDARD_OPTS) \
-O0 \
$(DEFINES)" \
\
-silent
MEX_CPPLDFLAGS = LDFLAGS=='$$LDFLAGS'
MEX_CFLAGS = -R2018a -MATLAB_ARCH=$(ARCH) $(INCLUDES) \
\
COPTIMFLAGS="$(C_STANDARD_OPTS) \
-O0 \
$(DEFINES)" \
\
-silent
MEX_LDFLAGS = LDFLAGS=='$$LDFLAGS'
MAKE_FLAGS = -f $(MAKEFILE)
SHAREDLIB_LDFLAGS = -shared -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)" -Wl,--no-undefined
#--------------------
# File extensions
#--------------------
H_EXT = .h
OBJ_EXT = .o
C_EXT = .c
EXE_EXT =
SHAREDLIB_EXT = .so
HPP_EXT = .hpp
OBJ_EXT = .o
CPP_EXT = .cpp
EXE_EXT =
SHAREDLIB_EXT = .so
STATICLIB_EXT = .a
MEX_EXT = .mexa64
MAKE_EXT = .mk
###########################################################################
## OUTPUT INFO
###########################################################################
PRODUCT = $(RELATIVE_PATH_TO_ANCHOR)/simmod
PRODUCT_TYPE = "executable"
BUILD_TYPE = "Top-Level Standalone Executable"
###########################################################################
## INCLUDE PATHS
###########################################################################
INCLUDES_BUILDINFO = -I$(START_DIR) -I$(START_DIR)/simmod_ert_rtw -I$(MATLAB_ROOT)/extern/include -I$(MATLAB_ROOT)/simulink/include -I$(MATLAB_ROOT)/rtw/c/src -I$(MATLAB_ROOT)/rtw/c/src/ext_mode/common -I$(MATLAB_ROOT)/rtw/c/ert
INCLUDES = $(INCLUDES_BUILDINFO)
###########################################################################
## DEFINES
###########################################################################
DEFINES_BUILD_ARGS = -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0
DEFINES_IMPLIED = -DTID01EQ=0
DEFINES_STANDARD = -DMODEL=simmod -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DUNIX
DEFINES = $(DEFINES_BUILD_ARGS) $(DEFINES_IMPLIED) $(DEFINES_STANDARD)
###########################################################################
## SOURCE FILES
###########################################################################
SRCS = $(START_DIR)/simmod_ert_rtw/simmod.c
MAIN_SRC = $(START_DIR)/simmod_ert_rtw/ert_main.c
ALL_SRCS = $(SRCS) $(MAIN_SRC)
###########################################################################
## OBJECTS
###########################################################################
OBJS = simmod.o
MAIN_OBJ = ert_main.o
ALL_OBJS = $(OBJS) $(MAIN_OBJ)
###########################################################################
## PREBUILT OBJECT FILES
###########################################################################
PREBUILT_OBJS =
###########################################################################
## LIBRARIES
###########################################################################
LIBS =
###########################################################################
## SYSTEM LIBRARIES
###########################################################################
SYSTEM_LIBS = -lm
###########################################################################
## ADDITIONAL TOOLCHAIN FLAGS
###########################################################################
#---------------
# C Compiler
#---------------
CFLAGS_BASIC = $(DEFINES) $(INCLUDES)
CFLAGS += $(CFLAGS_BASIC)
#-----------------
# C++ Compiler
#-----------------
CPPFLAGS_BASIC = $(DEFINES) $(INCLUDES)
CPPFLAGS += $(CPPFLAGS_BASIC)
###########################################################################
## INLINED COMMANDS
###########################################################################
###########################################################################
## PHONY TARGETS
###########################################################################
.PHONY : all build buildobj clean info prebuild download execute
all : build
#echo "### Successfully generated all binary outputs."
build : prebuild $(PRODUCT)
buildobj : prebuild $(OBJS) $(PREBUILT_OBJS)
#echo "### Successfully generated all binary outputs."
prebuild :
download : build
execute : download
#echo "### Invoking postbuild tool "Execute" ..."
$(EXECUTE) $(EXECUTE_FLAGS)
#echo "### Done invoking postbuild tool."
###########################################################################
## FINAL TARGET
###########################################################################
#-------------------------------------------
# Create a standalone executable
#-------------------------------------------
$(PRODUCT) : $(OBJS) $(PREBUILT_OBJS) $(MAIN_OBJ)
#echo "### Creating standalone executable "$(PRODUCT)" ..."
$(LD) $(LDFLAGS) -o $(PRODUCT) $(OBJS) $(MAIN_OBJ) $(SYSTEM_LIBS) $(TOOLCHAIN_LIBS)
#echo "### Created: $(PRODUCT)"
###########################################################################
## INTERMEDIATE TARGETS
###########################################################################
#---------------------
# SOURCE-TO-OBJECT
#---------------------
%.o : %.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : %.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : $(RELATIVE_PATH_TO_ANCHOR)/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : $(RELATIVE_PATH_TO_ANCHOR)/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : $(MATLAB_ROOT)/rtw/c/src/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : $(MATLAB_ROOT)/rtw/c/src/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : $(MATLAB_ROOT)/simulink/src/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : $(MATLAB_ROOT)/simulink/src/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : $(START_DIR)/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : $(START_DIR)/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
%.o : $(START_DIR)/simmod_ert_rtw/%.c
$(CC) $(CFLAGS) -o "$#" "$<"
%.o : $(START_DIR)/simmod_ert_rtw/%.cpp
$(CPP) $(CPPFLAGS) -o "$#" "$<"
###########################################################################
## DEPENDENCIES
###########################################################################
$(ALL_OBJS) : $(MAKEFILE) rtw_proj.tmw
###########################################################################
## MISCELLANEOUS TARGETS
###########################################################################
info :
#echo "### PRODUCT = $(PRODUCT)"
#echo "### PRODUCT_TYPE = $(PRODUCT_TYPE)"
#echo "### BUILD_TYPE = $(BUILD_TYPE)"
#echo "### INCLUDES = $(INCLUDES)"
#echo "### DEFINES = $(DEFINES)"
#echo "### ALL_SRCS = $(ALL_SRCS)"
#echo "### ALL_OBJS = $(ALL_OBJS)"
#echo "### LIBS = $(LIBS)"
#echo "### MODELREF_LIBS = $(MODELREF_LIBS)"
#echo "### SYSTEM_LIBS = $(SYSTEM_LIBS)"
#echo "### TOOLCHAIN_LIBS = $(TOOLCHAIN_LIBS)"
#echo "### CFLAGS = $(CFLAGS)"
#echo "### LDFLAGS = $(LDFLAGS)"
#echo "### SHAREDLIB_LDFLAGS = $(SHAREDLIB_LDFLAGS)"
#echo "### CPPFLAGS = $(CPPFLAGS)"
#echo "### CPP_LDFLAGS = $(CPP_LDFLAGS)"
#echo "### CPP_SHAREDLIB_LDFLAGS = $(CPP_SHAREDLIB_LDFLAGS)"
#echo "### ARFLAGS = $(ARFLAGS)"
#echo "### MEX_CFLAGS = $(MEX_CFLAGS)"
#echo "### MEX_CPPFLAGS = $(MEX_CPPFLAGS)"
#echo "### MEX_LDFLAGS = $(MEX_LDFLAGS)"
#echo "### MEX_CPPLDFLAGS = $(MEX_CPPLDFLAGS)"
#echo "### DOWNLOAD_FLAGS = $(DOWNLOAD_FLAGS)"
#echo "### EXECUTE_FLAGS = $(EXECUTE_FLAGS)"
#echo "### MAKE_FLAGS = $(MAKE_FLAGS)"
clean :
$(ECHO) "### Deleting all derived files..."
$(RM) $(PRODUCT)
$(RM) $(ALL_OBJS)
$(ECHO) "### Deleted all derived files."

Resources