RESULT ?= bootloader

DEFINES = \
	-DSTM32H563xx \
	-DUSE_HAL_DRIVER \
	-DUSE_STM32H5XX_NUCLEO \
	-D__USE_C99_MATH \
	-D_WINSOCK_H \
	-D__error_t_defined

INCLUDES = \
	-I../src \
	-I../../../../../../third_party/cmsis/include \
	-I../../../../../../third_party/st/devices/stm32h5xx \
	-I../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc \
	-I../../../../../../third_party/st/boards/stm32h5xx_nucleo \
	-I../../../../../../src/common \
	-I../../../../../../src/cyclone_crypto \
	-I../../../../../../src/cyclone_boot \
	-I../../../../../../src/cyclone_boot/bootloader \
	-I../../../../../../src/cyclone_boot/modules

ASM_SOURCES = \
	./startup_stm32h563xx.S

C_SOURCES = \
	../src/system_stm32h5xx.c \
	../src/stm32h5xx_it.c \
	./syscalls.c \
	../src/main.c \
	../src/debug.c \
	../../../../../../src/common/cpu_endian.c \
	../../../../../../src/common/os_port_none.c \
	../../../../../../src/common/date_time.c \
	../../../../../../src/common/str.c \
	../../../../../../src/cyclone_boot/core/crc32.c \
	../../../../../../src/cyclone_boot/core/mailbox.c \
	../../../../../../src/cyclone_boot/drivers/mcu_core/stm32h5xx_mcu_driver.c \
	../../../../../../src/cyclone_boot/drivers/flash/internal/stm32h5xx_flash_driver.c \
	../../../../../../src/cyclone_boot/modules/image/image.c \
	../../../../../../src/cyclone_boot/modules/memory/memory.c \
	../../../../../../src/cyclone_boot/modules/security/cipher.c \
	../../../../../../src/cyclone_boot/bootloader/second_stage/boot.c \
	../../../../../../src/cyclone_boot/bootloader/second_stage/boot_fallback.c \
	../../../../../../src/cyclone_boot/bootloader/second_stage/boot_common.c \
	../../../../../../src/cyclone_crypto/hash/sha256.c \
	../../../../../../src/cyclone_crypto/cipher/aes.c \
	../../../../../../third_party/st/boards/stm32h5xx_nucleo/stm32h5xx_nucleo.c \
	../../../../../../third_party/st/boards/stm32h5xx_nucleo/stm32h5xx_nucleo_usbpd_pwr.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_adc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_adc_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_cec.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_comp.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_cordic.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_cortex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_crc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_crc_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_cryp.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_cryp_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_dac.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_dac_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_dcache.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_dcmi.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_dma.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_dma_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_dts.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_eth.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_eth_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_exti.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_fdcan.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_flash.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_flash_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_fmac.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_gpio.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_gtzc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_hash.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_hcd.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_i2c.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_i2c_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_i2s.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_i2s_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_i3c.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_icache.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_irda.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_iwdg.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_lptim.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_mmc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_mmc_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_nand.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_nor.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_opamp.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_opamp_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_otfdec.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_pcd.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_pcd_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_pka.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_pssi.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_pwr.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_pwr_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_ramcfg.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_rcc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_rcc_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_rng.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_rng_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_rtc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_rtc_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_sai.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_sai_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_sd.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_sdram.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_sd_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_smartcard.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_smartcard_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_smbus.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_smbus_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_spi.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_spi_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_sram.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_tim.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_tim_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_uart.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_uart_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_usart.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_usart_ex.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_wwdg.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_hal_xspi.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_adc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_comp.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_cordic.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_crc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_crs.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_dac.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_dlyb.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_dma.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_exti.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_fmac.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_fmc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_gpio.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_i2c.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_i3c.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_icache.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_lptim.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_lpuart.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_opamp.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_pka.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_pwr.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_rcc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_rng.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_rtc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_sdmmc.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_spi.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_tim.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_ucpd.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_usart.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_usb.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_ll_utils.c \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/src/stm32h5xx_util_i3c.c

HEADERS = \
	../src/os_port_config.h \
	../src/boot_config.h \
	../src/crypto_config.h \
	../src/stm32h5xx_hal_conf.h \
	../src/stm32h5xx_nucleo_conf.h \
	../src/stm32h5xx_it.h \
	../../../../../../src/common/cpu_endian.h \
	../../../../../../src/common/os_port.h \
	../../../../../../src/common/os_port_none.h \
	../../../../../../src/common/date_time.h \
	../../../../../../src/common/str.h \
	../../../../../../src/common/error.h \
	../../../../../../src/common/debug.h \
	../../../../../../src/cyclone_boot/core/cboot_error.h \
	../../../../../../src/cyclone_boot/core/mailbox.h \
	../../../../../../src/cyclone_boot/core/crc32.h \
	../../../../../../src/cyclone_boot/core/flash.h \
	../../../../../../src/cyclone_boot/core/mcu.h \
	../../../../../../src/cyclone_boot/drivers/mcu_core/stm32h5xx_mcu_driver.h \
	../../../../../../src/cyclone_boot/drivers/flash/internal/stm32h5xx_flash_driver.h \
	../../../../../../src/cyclone_boot/modules/image/image.h \
	../../../../../../src/cyclone_boot/modules/memory/memory.h \
	../../../../../../src/cyclone_boot/modules/memory/memory_ex.h \
	../../../../../../src/cyclone_boot/modules/security/cipher.h \
	../../../../../../src/cyclone_boot/bootloader/second_stage/boot.h \
	../../../../../../src/cyclone_boot/bootloader/second_stage/boot_fallback.h \
	../../../../../../src/cyclone_boot/bootloader/second_stage/boot_common.h \
	../../../../../../src/cyclone_crypto/core/crypto.h \
	../../../../../../src/cyclone_crypto/cipher/aes.h \
	../../../../../../src/cyclone_crypto/cipher_modes/cbc.h \
	../../../../../../third_party/st/boards/stm32h5xx_nucleo/stm32h5xx_nucleo.h \
	../../../../../../third_party/st/boards/stm32h5xx_nucleo/stm32h5xx_nucleo_usbpd_pwr.h \
	../../../../../../third_party/st/boards/stm32h5xx_nucleo/stm32h5xx_nucleo_errno.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_adc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_adc_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_cec.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_comp.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_cordic.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_cortex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_crc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_crc_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_cryp.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_cryp_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_dac.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_dac_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_dcache.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_dcmi.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_def.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_dma.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_dma_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_dts.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_eth.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_eth_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_exti.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_fdcan.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_flash.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_flash_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_fmac.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_gpio.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_gpio_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_gtzc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_hash.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_hcd.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_i2c.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_i2c_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_i2s.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_i2s_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_i3c.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_icache.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_irda.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_irda_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_iwdg.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_lptim.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_mmc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_mmc_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_nand.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_nor.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_opamp.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_opamp_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_otfdec.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_pcd.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_pcd_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_pka.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_pssi.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_pwr.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_pwr_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_ramcfg.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_rcc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_rcc_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_rng.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_rng_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_rtc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_rtc_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_sai.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_sai_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_sd.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_sdram.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_sd_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_smartcard.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_smartcard_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_smbus.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_smbus_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_spi.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_spi_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_sram.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_tim.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_tim_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_uart.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_uart_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_usart.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_usart_ex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_wwdg.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_hal_xspi.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_adc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_bus.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_comp.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_cordic.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_cortex.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_crc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_crs.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_dac.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_dcache.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_dlyb.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_dma.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_exti.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_fmac.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_fmc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_gpio.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_i2c.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_i3c.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_icache.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_iwdg.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_lptim.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_lpuart.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_opamp.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_pka.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_pwr.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_rcc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_rng.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_rtc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_sdmmc.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_spi.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_system.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_tim.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_ucpd.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_usart.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_usb.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_utils.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_ll_wwdg.h \
	../../../../../../third_party/st/drivers/stm32h5xx_hal_driver/inc/stm32h5xx_util_i3c.h

ASM_OBJECTS = $(patsubst %.S, %.o, $(ASM_SOURCES))

C_OBJECTS = $(patsubst %.c, %.o, $(C_SOURCES))

OBJ_DIR = obj_build


LINKER_SCRIPT = stm32h563_flash.ld

CFLAGS += -fno-common -Wall -Os -g3
CFLAGS += -mcpu=cortex-m33 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=softfp
CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
CFLAGS += $(DEFINES)
CFLAGS += $(INCLUDES)

CROSS_COMPILE ?= arm-none-eabi-
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size

THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
PYTHON := $(shell command -v python3 || command -v python)
RC = ../../../../../../tools/ResourceCompiler/bin/rc

all:
	$(MAKE) pre-build build size
	$(MAKE) post-build

install:
	$(MAKE) pre-build build size
	$(MAKE) post-build
	$(MAKE) flash

pre-build: ;

post-build:
	$(PYTHON) ../scripts/misc/copy_file.py bootloader.bin ../

build: $(RESULT).elf $(RESULT).lst $(RESULT).bin $(RESULT).hex

$(RESULT).elf: $(ASM_OBJECTS) $(C_OBJECTS) $(HEADERS) $(LINKER_SCRIPT) $(THIS_MAKEFILE)
	$(CC) -Wl,-M=$(RESULT).map -Wl,-T$(LINKER_SCRIPT) $(CFLAGS) $(addprefix $(OBJ_DIR)/, $(notdir $(ASM_OBJECTS))) $(addprefix $(OBJ_DIR)/, $(notdir $(C_OBJECTS))) -o $@

$(ASM_OBJECTS): | $(OBJ_DIR)

$(C_OBJECTS): | $(OBJ_DIR)

$(OBJ_DIR):
	mkdir -p $@

%.o: %.c $(HEADERS) $(THIS_MAKEFILE)
	$(CC) $(CFLAGS) -c $< -o $(addprefix $(OBJ_DIR)/, $(notdir $@))

%.o: %.S $(HEADERS) $(THIS_MAKEFILE)
	$(CC) $(CFLAGS) -c $< -o $(addprefix $(OBJ_DIR)/, $(notdir $@))

%.lst: %.elf
	$(OBJDUMP) -x -S $(RESULT).elf > $@

%.bin: %.elf
	$(OBJCOPY) -O binary $< $@

%.hex: %.elf
	$(OBJCOPY) -O ihex $< $@

size: $(RESULT).elf
	$(SIZE) $(RESULT).elf

flash:
	openocd -f board/st_nucleo_h5.cfg -c "init; reset halt; flash write_image erase $(RESULT).bin 0x08000000; reset run; shutdown"

clean:
	rm -f $(RESULT).elf
	rm -f $(RESULT).bin
	rm -f $(RESULT).map
	rm -f $(RESULT).hex
	rm -f $(RESULT).lst
	rm -f $(OBJ_DIR)/*.o
