-
Notifications
You must be signed in to change notification settings - Fork 1
/
ert_mac.tmf
executable file
·349 lines (292 loc) · 12.6 KB
/
ert_mac.tmf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# Copyright 1994-2018 The MathWorks, Inc.
#
# File : ert_unix.tmf
#
# Abstract:
# Template makefile for building a MAC-based stand-alone embedded
# real-time version of Simulink model using generated C/C++ code.
#
# This makefile attempts to conform to the guidelines specified in the
# IEEE Std 1003.2-1992 (POSIX) standard. It is designed to be used
# with GNU Make which is located in matlabroot/rtw/bin.
#
# Note that this template is automatically customized by the build
# procedure to create "<model>.mk"
#
# The following defines can be used to modify the behavior of the
# build:
# OPT_OPTS - Optimization options. Default is -O.
# CPP_OPTS - C++ compiler options.
# OPTS - User specific compile options.
# USER_SRCS - Additional user sources, such as files needed by
# S-functions.
# USER_INCLUDES - Additional include paths
# (i.e. USER_INCLUDES="-Iwhere-ever -Iwhere-ever2")
#
# To enable debugging:
# set DEBUG_BUILD = 1 below, which will trigger OPTS=-g and
# LDFLAGS += -g (may vary with compiler version, see compiler doc)
#
# This template makefile is designed to be used with a system target
# file that contains 'rtwgensettings.BuildDirSuffix' see ert.tlc
#------------------------ Macros read by make_rtw ------------------------------
#
# The following macros are read by the build procedure:
#
# MAKECMD - This is the command used to invoke the make utility
# HOST - What platform this template makefile is targeted for
# (i.e. PC or UNIX)
# BUILD - Invoke make from the build procedure (yes/no)?
# SYS_TARGET_FILE - Name of system target file.
MAKECMD = |>MATLAB_BIN<|/|>ARCH<|/gmake
HOST = UNIX
BUILD = yes
SYS_TARGET_FILE = any
# Opt in to simplified format by specifying compatible Toolchain
TOOLCHAIN_NAME = ["Clang v3.1 | gmake (64-bit Mac)", \
"GNU gcc/g++ | gmake (64-bit Linux)"]
#---------------------- Tokens expanded by make_rtw ----------------------------
#
# The following tokens, when wrapped with "|>" and "<|" are expanded by the
# build procedure.
#
# MODEL_NAME - Name of the Simulink block diagram
# MODEL_MODULES - Any additional generated source modules
# MAKEFILE_NAME - Name of makefile created from template makefile <model>.mk
# MATLAB_ROOT - Path to where MATLAB is installed.
# S_FUNCTIONS_LIB - List of S-functions libraries to link.
# NUMST - Number of sample times
# NCSTATES - Number of continuous states
# COMPUTER - Computer type. See the MATLAB computer command.
# BUILDARGS - Options passed in at the command line.
# MULTITASKING - yes (1) or no (0): Is solver mode multitasking
# INTEGER_CODE - yes (1) or no (0): Is generated code purely integer
# MAT_FILE - yes (1) or no (0): Should mat file logging be done,
# if 0, the generated code runs indefinitely
# MULTI_INSTANCE_CODE - Is the generated code multi instantiable (1/0)?
# MODELREFS - List of referenced models
# TGT_FCN_LIB - Target function (code replacement) library to use
# SHRLIBTARGET - Is this build intended for generation of a shared library instead
# of executable (1/0)?
# MAKEFILEBUILDER_TGT - Is this build performed by the MakefileBuilder class
# e.g. to create a PIL executable?
# STANDALONE_SUPPRESS_EXE - Build the standalone target but only create object code modules
# and do not build an executable
MODEL = |>MODEL_NAME<|
MODULES = |>MODEL_MODULES<|
PRODUCT = |>PRODUCT<|
MAKEFILE = |>MAKEFILE_NAME<|
MATLAB_ROOT = |>MATLAB_ROOT<|
ALT_MATLAB_ROOT = |>ALT_MATLAB_ROOT<|
MASTER_ANCHOR_DIR = |>MASTER_ANCHOR_DIR<|
START_DIR = |>START_DIR<|
S_FUNCTIONS_LIB = |>S_FUNCTIONS_LIB<|
NUMST = |>NUMST<|
NCSTATES = |>NCSTATES<|
COMPUTER = |>COMPUTER<|
BUILDARGS = |>BUILDARGS<|
MULTITASKING = |>MULTITASKING<|
INTEGER_CODE = |>INTEGER_CODE<|
MAT_FILE = |>MAT_FILE<|
ALLOCATIONFCN = |>GENERATE_ALLOC_FCN<|
ONESTEPFCN = |>COMBINE_OUTPUT_UPDATE_FCNS<|
TERMFCN = |>INCLUDE_MDL_TERMINATE_FCN<|
ENABLE_SLEXEC_SSBRIDGE = |>ENABLE_SLEXEC_SSBRIDGE<|
MULTI_INSTANCE_CODE = |>MULTI_INSTANCE_CODE<|
CLASSIC_INTERFACE = |>CLASSIC_INTERFACE<|
TGT_FCN_LIB = |>TGT_FCN_LIB<|
MODELREFS = |>MODELREFS<|
GEN_SAMPLE_MAIN = |>GEN_SAMPLE_MAIN<|
TARGET_LANG_EXT = |>TARGET_LANG_EXT<|
SHRLIBTARGET = |>SHRLIBTARGET<|
MAKEFILEBUILDER_TGT = |>MAKEFILEBUILDER_TGT<|
STANDALONE_SUPPRESS_EXE = |>STANDALONE_SUPPRESS_EXE<|
OPTIMIZATION_FLAGS = |>OPTIMIZATION_FLAGS<|
ADDITIONAL_LDFLAGS = |>ADDITIONAL_LDFLAGS<|
INTERLEAVED_COMPLEX_FLAGS = |>INTERLEAVED_COMPLEX_FLAGS<|
DEFINES_CUSTOM = |>DEFINES_CUSTOM<|
SYSTEM_LIBS = |>SYSTEM_LIBS<|
MODEL_HAS_DYNAMICALLY_LOADED_SFCNS = |>MODEL_HAS_DYNAMICALLY_LOADED_SFCNS<|
# To enable debugging:
# set DEBUG_BUILD = 1
DEBUG_BUILD = 0
MODULES := $(filter-out rt_main.c rt_main.cpp, $(MODULES))
#--------------------------- Model and reference models -----------------------
MODELLIB = |>MODELLIB<|
MODELREF_LINK_LIBS = |>MODELREF_LINK_LIBS<|
RELATIVE_PATH_TO_ANCHOR = |>RELATIVE_PATH_TO_ANCHOR<|
# NONE: standalone, SIM: modelref sim, RTW: modelref coder target
MODELREF_TARGET_TYPE = |>MODELREF_TARGET_TYPE<|
ISPROTECTINGMODEL = |>ISPROTECTINGMODEL<|
PROT_CAPIC_SUFFIX = _capi.c
PROT_CAPIO_SUFFIX = _capi_host.o
#-- For gcc, link model reference libraries as a group to resolve circular references ---
# (NOTE: Clang does not recognize these switches but it already resolves circular references)
MODELREF_LINK_LIBS_GROUP = |>MODELREF_LINK_LIBS<|
ifeq ($(COMPUTER),GLNXA64)
MODELREF_LINK_LIBS_GROUP = -Wl,--start-group |>MODELREF_LINK_LIBS<| -Wl,--end-group
endif
#-- In the case when directory name contains space ---
ifneq ($(MATLAB_ROOT),$(ALT_MATLAB_ROOT))
MATLAB_ROOT := $(ALT_MATLAB_ROOT)
endif
#--------------------------- Tool Specifications -------------------------------
include $(MATLAB_ROOT)/rtw/c/tools/unixtools.mk
#------------------------------ Include Path -----------------------------------
# Additional includes
ADD_INCLUDES = \
|>START_EXPAND_INCLUDES<| -I|>EXPAND_DIR_NAME<| \
|>END_EXPAND_INCLUDES<|
INCLUDES = -I. -I$(RELATIVE_PATH_TO_ANCHOR) $(USER_INCLUDES) \
$(INSTRUMENT_INCLUDES) $(ADD_INCLUDES)
#-------------------------------- C Flags --------------------------------------
# Optimization Options
ifndef OPT_OPTS
OPT_OPTS = $(DEFAULT_OPT_OPTS)
endif
# General User Options
ifeq ($(DEBUG_BUILD),0)
DBG_FLAG =
else
# Set OPTS=-g and any additional flags for debugging
DBG_FLAG = -g
LDFLAGS += -g
endif
LDFLAGS += -Wl,-rpath,"$(MATLAB_ROOT)/bin/$(ARCH)" -L"$(MATLAB_ROOT)/bin/$(ARCH)"
# Compiler options, etc:
CPP_REQ_DEFINES1 = -DMODEL=$(MODEL) -DNUMST=$(NUMST) -DNCSTATES=$(NCSTATES) \
-DUNIX -DMAT_FILE=$(MAT_FILE) -DINTEGER_CODE=$(INTEGER_CODE) \
-DONESTEPFCN=$(ONESTEPFCN) -DTERMFCN=$(TERMFCN) \
-DHAVESTDIO -DMULTI_INSTANCE_CODE=$(MULTI_INSTANCE_CODE) \
-DCLASSIC_INTERFACE=$(CLASSIC_INTERFACE) \
-DALLOCATIONFCN=$(ALLOCATIONFCN)
ifneq ($(ENABLE_SLEXEC_SSBRIDGE), 0)
ifeq ($(MODELREF_TARGET_TYPE),SIM)
CPP_REQ_DEFINES1 += -DENABLE_SLEXEC_SSBRIDGE=$(ENABLE_SLEXEC_SSBRIDGE)
endif
endif
CPP_REQ_DEFINES = $(CPP_REQ_DEFINES1)
ifeq ($(MODELREF_TARGET_TYPE),SIM)
CPP_REQ_DEFINES += -DMDL_REF_SIM_TGT=1
else
CPP_REQ_DEFINES += -DMT=$(MULTITASKING)
endif
CPP_REQ_DEFINES += -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=$(MODEL_HAS_DYNAMICALLY_LOADED_SFCNS)
ifneq ($(OPTIMIZATION_FLAGS),)
CC_OPTS = $(OPTS) $(OPTIMIZATION_FLAGS)
else
CC_OPTS = $(OPT_OPTS) $(OPTS)
endif
CFLAGS = $(ANSI_OPTS) $(DBG_FLAG) $(CC_OPTS) $(DEFINES_CUSTOM) $(CPP_REQ_DEFINES) $(INCLUDES)
CPPFLAGS = $(CPP_ANSI_OPTS) $(DBG_FLAG) $(CPP_OPTS) $(CC_OPTS) $(CPP_REQ_DEFINES) $(INCLUDES)
#-------------------------- Additional Libraries ------------------------------
SYSTEM_LIBS += -lm -lpthread
LIBS =
|>START_PRECOMP_LIBRARIES<|
ifeq ($(OPT_OPTS),$(DEFAULT_OPT_OPTS))
ifeq ($(INTEGER_CODE),0)
ifeq ($(MODELREF_TARGET_TYPE),SIM)
LIBS += |>EXPAND_LIBRARY_LOCATION<|/|>EXPAND_LIBRARY_NAME<|_rtwsfcn.a
else
LIBS += |>EXPAND_LIBRARY_LOCATION<|/|>EXPAND_LIBRARY_NAME<|_ert.a
endif
else
LIBS += |>EXPAND_LIBRARY_LOCATION<|/|>EXPAND_LIBRARY_NAME<|_int_ert.a
endif
else
LIBS += |>EXPAND_LIBRARY_NAME<|.a
endif
|>END_PRECOMP_LIBRARIES<| |>START_EXPAND_LIBRARIES<|
LIBS += |>EXPAND_LIBRARY_NAME<|.a |>END_EXPAND_LIBRARIES<|
LIBS += $(S_FUNCTIONS_LIB) $(INSTRUMENT_LIBS)
#----------------------------- Source Files ------------------------------------
ADD_SRCS =
SRCS = $(ADD_SRCS) $(MODULES)
USER_SRCS =
USER_OBJS = $(addsuffix .o, $(basename $(USER_SRCS)))
LOCAL_USER_OBJS = $(notdir $(USER_OBJS))
OBJS = $(addsuffix .o, $(basename $(SRCS))) $(USER_OBJS)
PROT_CAPIC = $(addsuffix $(PROT_CAPIC_SUFFIX), $(MODEL))
PROT_CAPIO = $(addsuffix $(PROT_CAPIO_SUFFIX), $(MODEL))
LINK_OBJS = $(addsuffix .o, $(basename $(SRCS))) $(LOCAL_USER_OBJS)
ADDITIONAL_LDFLAGS += $(ARCH_SPECIFIC_LDFLAGS)
#--------------------------------- Rules ---------------------------------------
BIN_SETTING = $(LD) $(LDFLAGS) $(ADDITIONAL_LDFLAGS) -o $(PRODUCT)
BUILD_PRODUCT_TYPE = "executable"
ifeq ($(MODELREF_TARGET_TYPE),NONE)
ifeq ($(SHRLIBTARGET), 1)
BIN_SETTING = $(LD) $(SHRLIBLDFLAGS)$(MODEL).def -o $(PRODUCT)
BUILD_PRODUCT_TYPE = "shared object"
ifeq ($(GEN_SAMPLE_MAIN), 1)
PRODUCT := $(notdir $(PRODUCT))
$(MODEL) : $(PRODUCT) ert_main.o
$(LD) $(LDFLAGS) $(ADDITIONAL_LDFLAGS) -o $(MODEL) ert_main.o $(PRODUCT) $(SYSTEM_LIBS)
@mv $(PRODUCT) $(RELATIVE_PATH_TO_ANCHOR)/
@mv $(MODEL) $(RELATIVE_PATH_TO_ANCHOR)/
@echo "### Created executable: $@"
endif
endif
ifeq ($(MAKEFILEBUILDER_TGT), 1)
$(PRODUCT) : $(OBJS) $(LIBS) $(MODELLIB) $(MODELREF_LINK_LIBS)
$(BIN_SETTING) $(LINK_OBJS) $(MODELLIB) $(MODELREF_LINK_LIBS_GROUP) $(LIBS) $(SYSTEM_LIBS)
@echo "### Created executable: $@"
else
ifeq ($(STANDALONE_SUPPRESS_EXE), 1)
.PHONY: $(PRODUCT)
$(PRODUCT) : $(OBJS) $(LIBS)
@echo "### Created object modules: $@"
else
$(PRODUCT) : $(OBJS) $(LIBS) $(MODELREF_LINK_LIBS)
$(BIN_SETTING) $(LINK_OBJS) $(MODELREF_LINK_LIBS_GROUP) $(LIBS) $(SYSTEM_LIBS)
@echo "### Created $(BUILD_PRODUCT_TYPE): $@"
endif
endif
else
# Protected model simulation target
ifeq ($(MODELREF_TARGET_TYPE),SIM)
ifeq ($(ISPROTECTINGMODEL),PROTECTING)
all : $(PRODUCT) $(PROT_CAPIO)
$(PROT_CAPIO) : $(PROT_CAPIC)
$(CC) -c -o $(PROT_CAPIO) $(CFLAGS) $(GCC_WALL_FLAG) -DHOST_CAPI_BUILD $(PROT_CAPIC)
endif
endif
$(PRODUCT) : $(OBJS)
@rm -f $(MODELLIB)
$(AR) ruvs $(MODELLIB) $(LINK_OBJS)
@echo "### Created $(MODELLIB)"
@echo "### Created library: $@"
endif
#-------------------------- Support for building modules ----------------------
%.o : %.c
$(CC) -c $(CFLAGS) $(GCC_WALL_FLAG) "$<"
%.o : %.cpp
$(CPP) -c $(CPPFLAGS) $(GCC_WALL_FLAG) "$<"
%.o : $(RELATIVE_PATH_TO_ANCHOR)/%.c
$(CC) -c $(CFLAGS) $(GCC_WALL_FLAG) "$<"
%.o : $(RELATIVE_PATH_TO_ANCHOR)/%.cpp
$(CPP) -c $(CPPFLAGS) $(GCC_WALL_FLAG) "$<"
|>START_EXPAND_RULES<|%.o : |>EXPAND_DIR_NAME<|/%.c
$(CC) -c $(CFLAGS) $(GCC_WALL_FLAG_MAX) "$<"
|>END_EXPAND_RULES<|
|>START_EXPAND_RULES<|%.o : |>EXPAND_DIR_NAME<|/%.cpp
$(CPP) -c $(CPPFLAGS) $(GCC_WALL_FLAG_MAX) "$<"
|>END_EXPAND_RULES<|
#------------------------------- Libraries -------------------------------------
|>START_EXPAND_LIBRARIES<|MODULES_|>EXPAND_LIBRARY_NAME<| = \
|>START_EXPAND_MODULES<| |>EXPAND_MODULE_NAME<|.o \
|>END_EXPAND_MODULES<|
|>EXPAND_LIBRARY_NAME<|.a : $(MAKEFILE) rtw_proj.tmw $(MODULES_|>EXPAND_LIBRARY_NAME<|)
@echo "### Creating $@ "
$(AR) rs $@ $(MODULES_|>EXPAND_LIBRARY_NAME<|)
@echo "### $@ Created "
|>END_EXPAND_LIBRARIES<|
|>START_PRECOMP_LIBRARIES<|MODULES_|>EXPAND_LIBRARY_NAME<| = \
|>START_EXPAND_MODULES<| |>EXPAND_MODULE_NAME<|.o \
|>END_EXPAND_MODULES<|
|>EXPAND_LIBRARY_NAME<|.a : $(MAKEFILE) rtw_proj.tmw $(MODULES_|>EXPAND_LIBRARY_NAME<|)
@echo "### Creating $@ "
$(AR) rs $@ $(MODULES_|>EXPAND_LIBRARY_NAME<|)
@echo "### $@ Created "
|>END_PRECOMP_LIBRARIES<|
#----------------------------- Dependencies ------------------------------------
$(OBJS) : $(MAKEFILE) rtw_proj.tmw