The Makefile is stored in build/Makefile
. By running the make
command, the act is pre-defined to be built.
In MWSDK 2020-04, the .cpp
files in the project folder are automatically detected, so usually there is no need to modify the Makefile
.
Editing is required when source files are placed in subfolders.
In MWSDK 2019-12 and earlier, if there are multiple .cpp
files, editing the Makefile
is necessary.
After copying the project folder from another environment, always delete the build/objs_???
folder. If intermediate files from another environment remain, make
will result in an error.
(From MWSDK 2020-04 onwards) You can avoid errors by running clean
with USE_APPDEPS=0
and then running the make
command again.
make USE_APPDEPS=0 TWELITE=BLUE clean
...
make TWELITE=BLUE
make parameters
TWELITE=
Specify the build target as BLUE or RED. For TWELITE BLUE, specify make TWELITE=BLUE
.
all
Executes the build. Usually omitted, and run like make TWELITE=BLUE
.
clean
Deletes intermediate build files. Run like make TWELITE=BLUE clean
.
cleanall
Deletes all intermediate files. Run like make cleanall
. This is equivalent to deleting all objs_???
folders in the build
folder.
USE_APPDEPS=0 or 1
Setting 1 (default) determines build files based on file dependencies. For example, if a header file changes, related source files will be recompiled.
Setting 0 disables dependency evaluation. If set to 0, make
will not error even if inconsistent intermediate files remain.
Makefile definition
Depending on the size of the act and when defining behaviors, source files are usually split and built.
One of the build files is project_folder_name.cpp
.
If you want to define other files, edit the build/Makefile
in the project folder.
Below is an example Makefile from the sample PAL_AMB-behavior.
##############################################################################
# Copyright (C) 2019 Mono Wireless Inc. All Rights Reserved.
# Released under MW-SLA-*J,*E (MONO WIRELESS SOFTWARE LICENSE
# AGREEMENT).
##############################################################################
# USER PROJECT BUILD DEFINITION.
##############################################################################
#####################################################################
## set TWELITE model
TWELITE ?= BLUE
#TWELITE = RED
#####################################################################
## set application version (MUST SET THIS.)
VERSION_MAIN = 0
VERSION_SUB = 1
VERSION_VAR = 0
#####################################################################
## set an additional source file
## the default file name is dirname.
## for C++ files compiled with g++ (must have .cpp suffix)
APPSRC_CXX += myAppBhvParent.cpp
APPSRC_CXX += myAppBhvParent-handlers.cpp
APPSRC_CXX += myAppBhvChild.cpp
APPSRC_CXX += myAppBhvChild-handlers.cpp
## for C files compiled with gcc (must have .c suffix)
#APPSRC += my_c_file.c
## Additional Src/Include Path
# if set, find source files from given dirs.
#
APP_COMMON_SRC_DIR_ADD1 = ../Parent
APP_COMMON_SRC_DIR_ADD2 = ../Child
#APP_COMMON_SRC_DIR_ADD3 =
#APP_COMMON_SRC_DIR_ADD4 =
#####################################################################
## set misc option for compiler
## C++ flags passed to g++
# e.g. CXXFLAGS += -DMY_DEFS
#CXXFLAGS +=
## C++/C flags passed to g++/gcc
# e.g. CFLAGS += -DMY_DEFS
#CFLAGS +=
## include opts
# e.g. INCFLAGS += -I../my_common_src/
#INCFLAGS +=
## optimize flag (default is -Os, normally no need to change)
#OPTFLAG=-O2
#####################################################################
## must include mwx.mk (the makefile body part.)
MWSDK_PATH?=$(realpath $(MWSDK_ROOT))
include $(MWSDK_PATH)/MkFiles/mwx.mk
#####################################################################
VERSION_???
Specify the version number. It will be reflected in the built file name.
## set application version (MUST SET THIS.)
VERSION_MAIN = 0
VERSION_SUB = 1
VERSION_VAR = 0
During compilation, these are passed as definitions like -DVERSION_MAIN=0
-DVERSION_SUB=1
-DVERSION_VAR=0
.
Adding source files
.c
and .cpp
files in the project folder are added automatically.What is needed when adding source files are APPSRC_CXX
and APP_COMMON_SRC_DIR_ADD?
.
APP_COMMON_SRC_DIR_ADD?
is mandatory.Append the source file names to APPSRC_CXX
. These file names must not include folder names. Even if they are in subfolders, specify them without folder names (i.e., if the same file name exists in multiple subfolders, the build will fail).
APPSRC_CXX += myAppBhvParent.cpp
APPSRC_CXX += myAppBhvParent-handlers.cpp
APPSRC_CXX += myAppBhvChild.cpp
APPSRC_CXX += myAppBhvChild-handlers.cpp
Next, specify the search paths if source files are stored outside the project folder. You can set up to four.
APP_COMMON_SRC_DIR_ADD1 = ../Parent
APP_COMMON_SRC_DIR_ADD2 = ../Child
Folder paths are relative to the Makefile.
Compiler and linker options
You can also pass several other options to the compiler and linker.
Option | Description |
---|---|
CXXFLAGS | Specify compile options for C++ source files. |
CFLAGS | Specify compile options for C/C++ source files. |
INCFLAGS | Specify include paths for header files. |
OPTFLAGS | Define when you want to apply compile options other than the default -Os for special reasons. |
LDFLAGS | Specify linker options. (Although not mentioned in the comments of the above Makefile, you can specify this.) |