2015-07-10 06:01:56 -07:00
##############################################################################
# Build global options
# NOTE: Can be overridden externally.
#
2019-09-21 14:11:32 -07:00
#
# As of Sep 2019, this is known to compile on Linux
# in my case I had to
# sudo apt-get install gcc-multilib g++-multilib
2024-01-15 16:25:02 -08:00
#
2019-09-21 14:11:32 -07:00
# todo: automatically execute that command same as we automatically fetch submodules?
2024-01-15 16:25:02 -08:00
#
2019-09-21 14:11:32 -07:00
2019-03-20 05:45:15 -07:00
CHIBIOS = ../firmware/ChibiOS
2024-03-16 17:46:25 -07:00
CHIBIOS_CONTRIB = ../firmware/ChibiOS-Contrib
2018-12-22 22:54:14 -08:00
RULESPATH = $( CHIBIOS) /os/common/startup/SIMIA32/compilers/GCC
2024-05-01 16:33:39 -07:00
US_TO_NT_MULTIPLIER = 100
2021-02-08 05:52:31 -08:00
PROJECT_CPU = simulator
2024-03-16 17:46:25 -07:00
i f n e q ( $( BOARD_DIR ) , )
2024-03-18 16:54:49 -07:00
i f n e q ( "$(wildcard ../firmware/$(BOARD_DIR)/default_tune.cpp)" , "" )
BOARDCPPSRC += ../firmware/$( BOARD_DIR) /default_tune.cpp
e n d i f
2024-03-16 17:46:25 -07:00
e n d i f
2024-09-14 10:40:54 -07:00
# OS is a windows-specific environment variable
i f n e q ( $( OS ) , W i n d o w s _ N T )
OS = $( shell uname)
e n d i f
$( info OS is [$ {OS }])
2018-12-22 22:54:14 -08:00
i n c l u d e . . / f i r m w a r e / r u s e f i . m k
2024-03-15 21:46:06 -07:00
i n c l u d e . . / f i r m w a r e / r u s e f i _ r u l e s . m k
2019-12-02 07:26:16 -08:00
2021-07-25 18:23:23 -07:00
# Configure precompiled header
PCH_DIR = $( PROJECT_DIR) /pch
PCHSRC = $( PCH_DIR) /pch.h
2021-11-08 12:52:58 -08:00
PCHSUB = simulator
2021-07-25 18:23:23 -07:00
2020-09-07 09:09:39 -07:00
# used by USE_SMART_BUILD
CONFDIR = .
2018-12-13 18:32:50 -08:00
2021-11-19 22:38:39 -08:00
i f n e q ( $( OS ) , W i n d o w s _ N T )
2022-11-17 22:59:27 -08:00
SANITIZE = yes
2021-11-19 22:38:39 -08:00
e l s e
2022-11-17 22:59:27 -08:00
SANITIZE = no
2021-11-19 22:38:39 -08:00
e n d i f
2018-12-13 18:32:50 -08:00
2023-09-06 20:19:38 -07:00
i f e q ( $( SIMULATOR_DEBUG_LEVEL_OPT ) , )
# If you would like to debug the simulator, swap which of these lines is commented. It's commented because debug info causes a 10-15x increase in binary size.
SIMULATOR_DEBUG_LEVEL_OPT = -O0 -g
e n d i f
2015-07-10 06:01:56 -07:00
# Compiler options here.
i f e q ( $( USE_OPT ) , )
2023-11-25 19:32:08 -08:00
USE_OPT = -Wall -Wno-error= implicit-fallthrough -Wno-error= write-strings -Wno-error= strict-aliasing -Werror= nonnull
2024-05-01 16:33:39 -07:00
USE_OPT += -D US_TO_NT_MULTIPLIER = $( US_TO_NT_MULTIPLIER)
2022-02-01 13:19:46 -08:00
2022-11-17 22:59:27 -08:00
ifeq ( $( OS) ,Windows_NT)
2024-08-03 08:23:49 -07:00
USE_OPT += -DEFI_SIM_IS_WINDOWS= 1 -DIS_WINDOWS_COMPILER= 1
2022-11-17 22:59:27 -08:00
else
2024-08-03 08:23:49 -07:00
USE_OPT += -m32 -DEFI_SIM_IS_WINDOWS= 0 -DIS_WINDOWS_COMPILER= 0
2022-11-17 22:59:27 -08:00
endif
2015-07-10 06:01:56 -07:00
e n d i f
2023-11-25 15:18:59 -08:00
# Pretend we are all different hardware so that all canned engine configs are included
2024-02-24 20:06:42 -08:00
# [CannedTunes]
2023-11-25 15:18:59 -08:00
USE_OPT += -DHW_HELLEN_HYUNDAI= 1
2024-04-14 21:48:03 -07:00
USE_OPT += -DHW_HELLEN_NISSAN= 1
2024-03-06 08:23:10 -08:00
USE_OPT += -DHW_HELLEN_NB1= 1
2024-03-05 21:29:59 -08:00
USE_OPT += -DHW_HELLEN_NB2= 1
USE_OPT += -DHW_HELLEN= 1
2023-11-25 17:41:00 -08:00
USE_OPT += -DHW_PROTEUS= 1
USE_OPT += -DHW_MICRO_RUSEFI= 1
2023-11-25 15:18:59 -08:00
2020-11-11 17:34:39 -08:00
# See explanation in main firmware Makefile for these three defines
2023-09-06 20:19:38 -07:00
USE_OPT += $( SIMULATOR_DEBUG_LEVEL_OPT) $( RUSEFI_OPT) -DEFI_UNIT_TEST= 0 -DEFI_PROD_CODE= 0 -DEFI_SIMULATOR= 1
2019-12-02 07:26:16 -08:00
2021-11-19 22:38:39 -08:00
# Enable address sanitizer, but not on Windows since x86_64-w64-mingw32-g++ doesn't support it.
i f e q ( $( SANITIZE ) , y e s )
2022-11-17 22:59:27 -08:00
USE_OPT += -fsanitize= address
2021-11-19 22:38:39 -08:00
e n d i f
2015-07-10 06:01:56 -07:00
# C specific options here (added to USE_OPT).
i f e q ( $( USE_COPT ) , )
2023-07-06 08:52:17 -07:00
USE_COPT = -std= gnu17
2015-07-10 06:01:56 -07:00
e n d i f
# C++ specific options here (added to USE_OPT).
i f e q ( $( USE_CPPOPT ) , )
2021-11-19 19:19:34 -08:00
USE_CPPOPT = -std= c++2a -Wno-register -fno-rtti
2017-03-23 17:59:14 -07:00
e n d i f
2016-05-30 16:02:00 -07:00
2023-11-01 15:37:00 -07:00
USE_CPPOPT += $( RUSEFI_CPPOPT)
2017-03-29 14:17:39 -07:00
# Enable this if you want the linker to remove unused code and data.
2015-07-10 06:01:56 -07:00
i f e q ( $( USE_LINK_GC ) , )
USE_LINK_GC = yes
e n d i f
2017-03-29 14:17:39 -07:00
# Linker extra options here.
i f e q ( $( USE_LDOPT ) , )
2024-01-15 16:25:02 -08:00
USE_LDOPT =
2017-03-29 14:17:39 -07:00
e n d i f
# Enable this if you want link time optimizations (LTO)
i f e q ( $( USE_LTO ) , )
USE_LTO = no
e n d i f
2015-07-10 06:01:56 -07:00
# Enable this if you want to see the full log while compiling.
i f e q ( $( USE_VERBOSE_COMPILE ) , )
2017-03-29 14:17:39 -07:00
USE_VERBOSE_COMPILE = no
e n d i f
# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
i f e q ( $( USE_SMART_BUILD ) , )
2021-02-24 18:55:51 -08:00
USE_SMART_BUILD = no
2015-07-10 06:01:56 -07:00
e n d i f
#
# Build global options
##############################################################################
##############################################################################
# Architecture or project specific options
#
#
# Architecture or project specific options
##############################################################################
##############################################################################
# Project, sources and paths
#
2017-03-29 14:17:39 -07:00
2017-03-23 17:59:14 -07:00
# Define project name here
2020-07-08 08:10:24 -07:00
i f e q ( $( OS ) , W i n d o w s _ N T )
PROJECT = rusefi_simulator.exe
e l s e
PROJECT = rusefi_simulator
e n d i f
2017-03-23 17:59:14 -07:00
PROJECT_DIR = ../firmware
2017-03-29 14:17:39 -07:00
2015-07-10 06:01:56 -07:00
# Imported source files and paths
2017-03-29 14:17:39 -07:00
2022-07-15 23:22:51 -07:00
# Configure libfirmware Paths/Includes
RUSEFI_LIB = $( PROJECT_DIR) /libfirmware
i n c l u d e $( RUSEFI_LIB ) / u t i l / u t i l . m k
2022-08-08 05:53:08 -07:00
i n c l u d e $( RUSEFI_LIB ) / p t 2 0 0 1 / p t 2 0 0 1 . m k
2022-07-15 23:22:51 -07:00
2021-01-19 12:20:35 -08:00
# Licensing files.
i n c l u d e $( CHIBIOS ) / o s / l i c e n s e / l i c e n s e . m k
2017-03-29 14:17:39 -07:00
# Startup files.
# HAL-OSAL files (optional).
2017-03-23 17:59:14 -07:00
i n c l u d e $( CHIBIOS ) / o s / h a l / h a l . m k
2017-03-29 14:17:39 -07:00
i n c l u d e $( CHIBIOS ) / o s / h a l / b o a r d s / s i m u l a t o r / b o a r d . m k
2021-01-19 12:20:35 -08:00
i n c l u d e $( CHIBIOS ) / o s / h a l / o s a l / r t - n i l / o s a l . m k
2017-03-29 14:17:39 -07:00
# RTOS files (optional).
2017-03-23 17:59:14 -07:00
i n c l u d e $( CHIBIOS ) / o s / r t / r t . m k
2018-01-23 18:17:30 -08:00
i n c l u d e $( CHIBIOS ) / o s / c o m m o n / p o r t s / S I M I A 3 2 / c o m p i l e r s / G C C / p o r t . m k
2017-03-29 14:17:39 -07:00
# Other files (optional).
2021-01-19 12:20:35 -08:00
i n c l u d e $( CHIBIOS ) / o s / h a l / l i b / s t r e a m s / s t r e a m s . m k
#include $(CHIBIOS)/os/various/cpp_wrappers/chcpp.mk
2017-03-23 17:59:14 -07:00
i f e q ( $( OS ) , W i n d o w s _ N T )
include ${ CHIBIOS } /os/hal/ports/simulator/win32/platform.mk
e l s e
2017-03-31 01:36:51 -07:00
include ${ CHIBIOS } /os/hal/ports/simulator/posix/platform.mk
2017-03-23 17:59:14 -07:00
e n d i f
2019-11-19 17:05:12 -08:00
i n c l u d e $( PROJECT_DIR ) / c o n s o l e / b i n a r y / t u n e r s t u d i o . m k
i n c l u d e $( PROJECT_DIR ) / c o n s o l e / c o n s o l e . m k
2022-01-06 16:02:35 -08:00
i n c l u d e $( PROJECT_DIR ) / c o m m o n . m k
2015-07-10 06:01:56 -07:00
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
2021-01-19 12:20:35 -08:00
CSRC = $( ALLCSRC) \
2022-11-18 20:43:43 -08:00
$( RUSEFI_LIB_C)
2015-07-10 06:01:56 -07:00
2022-07-03 05:25:24 -07:00
2015-07-10 06:01:56 -07:00
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
2021-01-19 12:20:35 -08:00
CPPSRC = $( ALLCPPSRC) \
2024-03-18 13:20:56 -07:00
$( BOARDCPPSRC) \
2021-01-19 12:20:35 -08:00
$( CHIBIOS) /os/various/cpp_wrappers/ch.cpp \
2022-11-17 22:59:27 -08:00
$( HW_LAYER_DRIVERS_CPP) \
$( HW_LAYER_DRIVERS_CORE_CPP) \
$( CONSOLE_SRC_CPP) \
2023-03-04 22:50:51 -08:00
$( DEV_SRC_CPP) \
2022-11-17 22:59:27 -08:00
simulator/rusEfiFunctionalTest.cpp \
simulator/can/hal_can_lld.cpp \
simulator/framework.cpp \
2024-01-07 12:39:26 -08:00
simulator/system/signal_executor_sleep.cpp \
2022-11-17 22:59:27 -08:00
simulator/boards.cpp \
$( TEST_SRC_CPP) \
$( RUSEFI_LIB_CPP) \
main.cpp
2017-03-23 17:59:14 -07:00
2015-07-10 06:01:56 -07:00
# List ASM source files here
ASMSRC = $( PORTASM)
2024-05-16 16:37:49 -07:00
i f n e q ( $( BOARD_DIR ) , )
# used by custom board custom live data
INCDIR += $( BOARD_DIR) /firmware
2024-10-06 20:04:28 -07:00
ifneq ( " $( wildcard $( BOARD_DIR) /board_common.mk) " ,"" )
# part common between PROD, simulator and unit tests
include $( BOARD_DIR) /board_common.mk
endif
2024-05-16 16:37:49 -07:00
e n d i f
INCDIR += . \
2022-11-17 22:59:27 -08:00
$( PCH_DIR) \
$( ALLINC) \
$( CHIBIOS) /os/various/cpp_wrappers \
$( PROJECT_DIR) /hw_layer/drivers/can \
${ CHIBIOS } /os/various \
2023-03-04 22:50:51 -08:00
$( PROJECT_DIR) /development/hw_layer \
2022-11-17 22:59:27 -08:00
$( CHIBIOS) /os/hal/lib/streams \
$( RUSEFI_LIB_INC) \
2024-01-07 12:39:26 -08:00
simulator/system \
2022-11-17 22:59:27 -08:00
simulator/can \
simulator
2015-07-10 06:01:56 -07:00
2017-03-29 14:17:39 -07:00
# List ASM source files here
ASMSRC =
ASMXSRC = $( STARTUPASM) $( PORTASM) $( OSALASM)
2015-07-10 06:01:56 -07:00
#
# Project, sources and paths
##############################################################################
##############################################################################
# Compiler settings
#
i f e q ( $( OS ) , W i n d o w s _ N T )
2019-08-26 18:56:10 -07:00
# ChibiOS seem to require 32 bit compiler at least on Windows
2024-01-15 16:25:02 -08:00
# base 32-bit Cygwin is needed with mingw64 32-bit version
2017-03-31 10:28:52 -07:00
# Cygwin64 would not debug if used with mingw64 32-bit version
2019-02-11 21:18:15 -08:00
# 32 bit GDB available at http://www.equation.com/servlet/equation.cmd?fa=gdb
2016-07-04 20:03:06 -07:00
TRGT = i686-w64-mingw32-
2015-07-10 06:01:56 -07:00
e l s e
2024-01-15 16:25:02 -08:00
TRGT =
2015-07-10 06:01:56 -07:00
e n d i f
2023-11-02 11:28:14 -07:00
CC = $( TRGT) gcc
CPPC = $( TRGT) g++
2015-07-10 06:01:56 -07:00
# Enable loading with g++ only if you need C++ runtime support.
# NOTE: You can use C++ even without C++ support if you are careful. C++
# runtime support makes code size explode.
2022-11-18 18:15:13 -08:00
#LD = $(CC)
LD = $( CPPC)
2015-07-10 06:01:56 -07:00
CP = $( TRGT) objcopy
2022-11-18 18:15:13 -08:00
AS = $( CC) -x assembler-with-cpp
2017-03-29 14:17:39 -07:00
AR = $( TRGT) ar
2015-07-10 06:01:56 -07:00
OD = $( TRGT) objdump
2017-03-29 14:17:39 -07:00
SZ = $( TRGT) size
2015-07-10 06:01:56 -07:00
BIN = $( CP) -O binary
2017-03-29 14:17:39 -07:00
COV = gcov
2015-07-10 06:01:56 -07:00
# Define C warning options here
2017-03-29 14:17:39 -07:00
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
2015-07-10 06:01:56 -07:00
# Define C++ warning options here
2017-03-29 14:17:39 -07:00
CPPWARN = -Wall -Wextra -Wundef
2015-07-10 06:01:56 -07:00
#
# Compiler settings
##############################################################################
##############################################################################
# Start of user section
#
# List all user C define here, like -D_DEBUG=1
2017-03-23 17:59:14 -07:00
UDEFS = -DSIMULATOR
2024-03-18 15:59:45 -07:00
DDEFS += -DFIRMWARE_ID= \" simulator\" -DSHORT_BOARD_NAME= $( SHORT_BOARD_NAME)
2022-02-26 21:49:47 -08:00
2015-07-10 06:01:56 -07:00
# Define ASM defines here
UADEFS =
# List all user directories here
UINCDIR =
# List the user directory to look for the libraries here
ULIBDIR =
# List all user libraries here
2017-03-31 01:36:51 -07:00
i f e q ( $( OS ) , W i n d o w s _ N T )
2017-03-31 06:32:47 -07:00
ULIBS = -lws2_32 -static
2017-03-31 01:36:51 -07:00
e l s e
ULIBS =
e n d i f
2015-07-10 06:01:56 -07:00
2021-11-19 22:38:39 -08:00
i f e q ( $( SANITIZE ) , y e s )
ULIBS += -fsanitize= address
e n d i f
2015-07-10 06:01:56 -07:00
#
# End of user defines
##############################################################################
2017-03-29 14:17:39 -07:00
i n c l u d e $( RULESPATH ) / r u l e s . m k
2021-07-25 18:23:23 -07:00
2024-03-12 18:45:21 -07:00
i f n e q ( y e s , $( SUBMAKE ) )
2024-03-12 19:52:07 -07:00
i f e q ( $( SHORT_BOARD_NAME ) , )
SHORT_BOARD_NAME = f407-discovery
e n d i f
i n c l u d e $( PROJECT_DIR ) / r u s e f i _ c o n f i g . m k
2024-03-12 18:45:21 -07:00
e n d i f
2021-07-25 18:23:23 -07:00
# Enable precompiled header
i n c l u d e $( PROJECT_DIR ) / r u s e f i _ p c h . m k
2024-02-06 16:37:06 -08:00
2024-03-23 18:03:55 -07:00
$(OBJS) : .os -sentinel
.os-sentinel : .FORCE
if [ " $$ (cat $@ 2>/dev/null) " != $( OS) ] ; then \
echo $( OS) >$@ ; fi
.FORCE :
2024-03-12 18:46:28 -07:00
.PHONY : CLEAN_RULE_HOOK CLEAN_PCH_HOOK
CLEAN_RULE_HOOK : CLEAN_PCH_HOOK
2024-02-06 16:37:06 -08:00
@echo Cleaning Simulator
rm -rf build
rm -rf .dep
@echo Done Cleaning Simulator